Class AbstractAuthenticationComponent
java.lang.Object
org.alfresco.repo.security.authentication.AbstractAuthenticationComponent
- All Implemented Interfaces:
AuthenticationComponent,AuthenticationContext
- Direct Known Subclasses:
AbstractChainingAuthenticationComponent,AuthenticationComponentImpl,IdentityServiceAuthenticationComponent,JAASAuthenticationComponent,LDAPAuthenticationComponentImpl,SimpleAcceptOrRejectAllAuthenticationComponentImpl
public abstract class AbstractAuthenticationComponent
extends Object
implements AuthenticationComponent
This class abstract the support required to set up and query the Acegi context for security enforcement. There are some simple default method implementations to support simple authentication.
- Author:
- Andy Hind
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.alfresco.repo.security.authentication.AuthenticationComponent
AuthenticationComponent.UserNameValidationMode -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(String userName, char[] password) Authenticateprotected voidauthenticateImpl(String userName, char[] password) Default unsupported authentication implementation - as of 2.1 this is the best way to implement your own authentication component as it will support guest login - prior to this direct over ride for authenticate(String , char[]) was used.voidRemove the current security informationnet.sf.acegisecurity.AuthenticationGet the current authentication contextGet the current user name.Gets a set of user names who for this particular authentication system should be considered administrators by default.Gets a set of user names who for this particular authentication system should be considered guests by default.Get the name of the Guest User note: for MT, will get guest for default domain onlygetGuestUserName(String tenantDomain) Get the name of the guest userintintGet the name of the system user note: for MT, will get system for default domain onlygetSystemUserName(String tenantDomain) Get the name of the system userprotected net.sf.acegisecurity.UserDetailsgetUserDetails(String userName) Default implementation that makes an ACEGI object on the flygetUserDomain(String userName) Extracts the tenant domain name from a user namebooleanTrue if Guest user authentication is allowed, false otherwiseprotected abstract booleanbooleanIs the current user the system user?booleanisGuestUserName(String userName) True if this is a guest user ?booleanisSystemUserName(String userName) Is this the system user ?protected voidprotected voidonFail()voidsetAllowGuestLogin(Boolean allowGuestLogin) Set if guest login is supported.voidsetAuthenticationContext(AuthenticationContext authenticationContext) net.sf.acegisecurity.AuthenticationsetCurrentAuthentication(net.sf.acegisecurity.Authentication authentication) Explicitly set the current suthentication.net.sf.acegisecurity.AuthenticationsetCurrentUser(String userName) Explicitly set the current user to be authenticated.net.sf.acegisecurity.AuthenticationsetCurrentUser(String userName, AuthenticationComponent.UserNameValidationMode validationMode) Explicitly set the current user to be authenticated.voidsetDefaultAdministratorUserNameList(String defaultAdministratorUserNames) Convenience method to allow the administrator user names to be specified as a comma separated listvoidsetDefaultAdministratorUserNames(Set<String> defaultAdministratorUserNames) Sets the user names who for this particular authentication system should be considered administrators by default.voidsetDefaultGuestUserNameList(String defaultGuestUserNames) Convenience method to allow the administrator user names to be specified as a comma separated listvoidsetDefaultGuestUserNames(Set<String> defaultGuestUserNames) Sets the user names who for this particular authentication system should be considered administrators by default.net.sf.acegisecurity.AuthenticationSet the guest user as the current user. note: for MT, will set to default domain onlyvoidsetNodeService(NodeService nodeService) voidsetPersonService(PersonService personService) net.sf.acegisecurity.AuthenticationSet the system user as the current user note: for MT, will set to default domain onlynet.sf.acegisecurity.AuthenticationsetSystemUserAsCurrentUser(String tenantDomain) Set the system user as the current user.voidsetTransactionService(TransactionService transactionService) net.sf.acegisecurity.AuthenticationsetUserDetails(net.sf.acegisecurity.UserDetails ud) Explicitly set the given validated user details to be authenticated.voidsetUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AbstractAuthenticationComponent
public AbstractAuthenticationComponent()
-
-
Method Details
-
setAllowGuestLogin
Set if guest login is supported.- Parameters:
allowGuestLogin- Boolean
-
setAuthenticationContext
-
setPersonService
-
setNodeService
-
setTransactionService
-
setUserRegistrySynchronizer
-
getTransactionService
-
getAllowGuestLogin
-
getNodeService
-
getPersonService
-
authenticate
Description copied from interface:AuthenticationComponentAuthenticate- Specified by:
authenticatein interfaceAuthenticationComponent- Throws:
AuthenticationException
-
authenticateImpl
Default unsupported authentication implementation - as of 2.1 this is the best way to implement your own authentication component as it will support guest login - prior to this direct over ride for authenticate(String , char[]) was used. This will still work.- Parameters:
userName- Stringpassword- char[]
-
setCurrentUser
public net.sf.acegisecurity.Authentication setCurrentUser(String userName) throws AuthenticationException Description copied from interface:AuthenticationComponentExplicitly set the current user to be authenticated.- Specified by:
setCurrentUserin interfaceAuthenticationComponent- Throws:
AuthenticationException
-
setCurrentUser
public net.sf.acegisecurity.Authentication setCurrentUser(String userName, AuthenticationComponent.UserNameValidationMode validationMode) Description copied from interface:AuthenticationComponentExplicitly set the current user to be authenticated. Specify if the userName is to be checked and fixed- Specified by:
setCurrentUserin interfaceAuthenticationComponent
-
getUserDetails
Default implementation that makes an ACEGI object on the fly- Parameters:
userName- String- Returns:
- UserDetails
-
setCurrentAuthentication
public net.sf.acegisecurity.Authentication setCurrentAuthentication(net.sf.acegisecurity.Authentication authentication) Description copied from interface:AuthenticationContextExplicitly set the current suthentication. If the authentication is null the the current authentication iscleared.- Specified by:
setCurrentAuthenticationin interfaceAuthenticationContext- Parameters:
authentication- the current authentication (may be null).- Returns:
- Returns the modified authentication instance or null if it was cleared.
-
getCurrentAuthentication
public net.sf.acegisecurity.Authentication getCurrentAuthentication() throws AuthenticationExceptionGet the current authentication context- Specified by:
getCurrentAuthenticationin interfaceAuthenticationContext- Returns:
- Authentication
- Throws:
AuthenticationException
-
getCurrentUserName
Get the current user name.- Specified by:
getCurrentUserNamein interfaceAuthenticationContext- Returns:
- String
- Throws:
AuthenticationException
-
setSystemUserAsCurrentUser
public net.sf.acegisecurity.Authentication setSystemUserAsCurrentUser()Set the system user as the current user note: for MT, will set to default domain only- Specified by:
setSystemUserAsCurrentUserin interfaceAuthenticationContext- Returns:
- Authentication
-
getSystemUserName
Get the name of the system user note: for MT, will get system for default domain only- Specified by:
getSystemUserNamein interfaceAuthenticationContext- Returns:
- String
-
isSystemUserName
Is this the system user ?- Specified by:
isSystemUserNamein interfaceAuthenticationContext- Returns:
- boolean
-
isCurrentUserTheSystemUser
public boolean isCurrentUserTheSystemUser()Is the current user the system user?- Specified by:
isCurrentUserTheSystemUserin interfaceAuthenticationContext- Returns:
- boolean
-
getGuestUserName
Get the name of the Guest User note: for MT, will get guest for default domain only- Specified by:
getGuestUserNamein interfaceAuthenticationContext- Returns:
- String
-
getGuestUserName
Description copied from interface:AuthenticationContextGet the name of the guest user- Specified by:
getGuestUserNamein interfaceAuthenticationContext
-
setGuestUserAsCurrentUser
public net.sf.acegisecurity.Authentication setGuestUserAsCurrentUser() throws AuthenticationExceptionSet the guest user as the current user. note: for MT, will set to default domain only- Specified by:
setGuestUserAsCurrentUserin interfaceAuthenticationComponent- Throws:
AuthenticationException
-
isGuestUserName
Description copied from interface:AuthenticationContextTrue if this is a guest user ?- Specified by:
isGuestUserNamein interfaceAuthenticationContext
-
implementationAllowsGuestLogin
protected abstract boolean implementationAllowsGuestLogin() -
guestUserAuthenticationAllowed
public boolean guestUserAuthenticationAllowed()Description copied from interface:AuthenticationComponentTrue if Guest user authentication is allowed, false otherwise- Specified by:
guestUserAuthenticationAllowedin interfaceAuthenticationComponent- Returns:
- true if Guest user authentication is allowed, false otherwise
-
clearCurrentSecurityContext
public void clearCurrentSecurityContext()Remove the current security information- Specified by:
clearCurrentSecurityContextin interfaceAuthenticationContext
-
getDefaultAdministratorUserNames
Gets a set of user names who for this particular authentication system should be considered administrators by default. If the security framework is case sensitive these values should be case sensitive user names. If the security framework is not case sensitive these values should be the lower-case user names.- Specified by:
getDefaultAdministratorUserNamesin interfaceAuthenticationComponent- Returns:
- a set of user names
-
setDefaultAdministratorUserNames
Sets the user names who for this particular authentication system should be considered administrators by default.- Parameters:
defaultAdministratorUserNames- a set of user names
-
setDefaultAdministratorUserNameList
Convenience method to allow the administrator user names to be specified as a comma separated list- Parameters:
defaultAdministratorUserNames- String
-
getDefaultGuestUserNames
Description copied from interface:AuthenticationComponentGets a set of user names who for this particular authentication system should be considered guests by default. If the security framework is case sensitive these values should be case sensitive user names. If the security framework is not case sensitive these values should be the lower-case user names.- Specified by:
getDefaultGuestUserNamesin interfaceAuthenticationComponent- Returns:
- a set of user names
-
setDefaultGuestUserNames
Sets the user names who for this particular authentication system should be considered administrators by default.- Parameters:
defaultGuestUserNames- a set of user names
-
setDefaultGuestUserNameList
Convenience method to allow the administrator user names to be specified as a comma separated list- Parameters:
defaultGuestUserNames- String
-
getSystemUserName
Description copied from interface:AuthenticationContextGet the name of the system user- Specified by:
getSystemUserNamein interfaceAuthenticationContext
-
getUserDomain
Description copied from interface:AuthenticationContextExtracts the tenant domain name from a user name- Specified by:
getUserDomainin interfaceAuthenticationContext- Parameters:
userName- a user name- Returns:
- a tenant domain name
-
setSystemUserAsCurrentUser
Description copied from interface:AuthenticationContextSet the system user as the current user.- Specified by:
setSystemUserAsCurrentUserin interfaceAuthenticationContext
-
setUserDetails
public net.sf.acegisecurity.Authentication setUserDetails(net.sf.acegisecurity.UserDetails ud) Description copied from interface:AuthenticationContextExplicitly set the given validated user details to be authenticated.- Specified by:
setUserDetailsin interfaceAuthenticationContext- Parameters:
ud- the User Details- Returns:
- Authentication
-
onAuthenticate
protected void onAuthenticate() -
onFail
protected void onFail() -
getNumberSuccessfulAuthentications
public int getNumberSuccessfulAuthentications() -
getNumberFailedAuthentications
public int getNumberFailedAuthentications()
-