Merge of BRANCHES/DEV/4.2_ENT_DEV/ADMIN_CONSOLE - Admin Console 46247-46672

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@46677 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2013-02-15 11:44:53 +00:00
parent dc60a53187
commit a625d87120
27 changed files with 930 additions and 51 deletions

View File

@@ -22,6 +22,8 @@ import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
import org.alfresco.repo.management.subsystems.ActivateableBean;
import net.sf.acegisecurity.Authentication;
/**
@@ -40,6 +42,13 @@ public abstract class AbstractChainingAuthenticationComponent extends AbstractAu
{
super();
}
/**
* Get the authentication component with the specified name
* @param name
* @return the authentication component or null if it does not exist
*/
protected abstract AuthenticationComponent getAuthenticationComponent(String name);
/**
* Gets the authentication components across which methods will chain.
@@ -55,6 +64,8 @@ public abstract class AbstractChainingAuthenticationComponent extends AbstractAu
* the user name
* @param password
* the password
*
* @throws AuthenticationException
*/
@Override
protected void authenticateImpl(String userName, char[] password)
@@ -73,6 +84,44 @@ public abstract class AbstractChainingAuthenticationComponent extends AbstractAu
}
throw new AuthenticationException("Failed to authenticate");
}
/**
* Test authenticate with a specific authenticator and user name and password.
*
* @param authenticatorName
* the name of the authenticator to use
* @param userName
* the user name
* @param password
* the password
* @throws AuthenticationException including diagnostic information about the failure
*/
public void testAuthenticate(String authenticatorName, String userName, char[] password)
{
AuthenticationComponent authenticationComponent = getAuthenticationComponent(authenticatorName);
if(authenticationComponent != null)
{
if (authenticationComponent instanceof ActivateableBean)
{
if(!((ActivateableBean) authenticationComponent).isActive())
{
AuthenticationDiagnostic diagnostic = new AuthenticationDiagnostic();
Object[] args = {authenticatorName};
diagnostic.addStep(AuthenticationDiagnostic.STEP_KEY_VALIDATION_AUTHENTICATOR_NOT_ACTIVE, false, args);
throw new AuthenticationException("authentication.err.validation.authenticator.notactive", args , diagnostic);
}
}
authenticationComponent.authenticate(userName, password);
return;
}
AuthenticationDiagnostic diagnostic = new AuthenticationDiagnostic();
Object[] args = {authenticatorName};
diagnostic.addStep(AuthenticationDiagnostic.STEP_KEY_VALIDATION_AUTHENTICATOR_NOT_FOUND, false, args);
throw new AuthenticationException("authentication.err.validation.authenticator.notfound", args , diagnostic);
}
/**
* If any implementation supports guest then guest is allowed.