Package org.apereo.cas.authentication
Class PolicyBasedAuthenticationManager
- java.lang.Object
-
- org.apereo.cas.authentication.PolicyBasedAuthenticationManager
-
- All Implemented Interfaces:
org.apereo.cas.authentication.AuthenticationManager
public class PolicyBasedAuthenticationManager extends java.lang.Object implements org.apereo.cas.authentication.AuthenticationManagerThis isPolicyBasedAuthenticationManager, which provides common operations around an authentication manager implementation.- Since:
- 5.0.0
-
-
Constructor Summary
Constructors Constructor Description PolicyBasedAuthenticationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAuthenticationMethodAttribute(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.Authentication authentication)Add authentication method attribute.org.apereo.cas.authentication.Authenticationauthenticate(org.apereo.cas.authentication.AuthenticationTransaction transaction)protected voidauthenticateAndResolvePrincipal(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.Credential credential, org.apereo.cas.authentication.principal.PrincipalResolver resolver, org.apereo.cas.authentication.AuthenticationHandler handler)Authenticate and resolve principal.protected org.apereo.cas.authentication.AuthenticationBuilderauthenticateInternal(org.apereo.cas.authentication.AuthenticationTransaction transaction)Authenticate internal authentication builder.protected org.apache.commons.lang3.tuple.Pair<java.lang.Boolean,java.util.Set<java.lang.Throwable>>evaluateAuthenticationPolicies(org.apereo.cas.authentication.Authentication authentication, org.apereo.cas.authentication.AuthenticationTransaction transaction)Evaluate authentication policies.protected voidevaluateFinalAuthentication(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)Evaluate produced authentication context.protected java.util.Set<org.apereo.cas.authentication.AuthenticationHandler>getAuthenticationHandlersForThisTransaction(org.apereo.cas.authentication.AuthenticationTransaction transaction)Gets authentication handlers for this transaction.protected java.util.Collection<org.apereo.cas.authentication.AuthenticationMetaDataPopulator>getAuthenticationMetadataPopulatorsForTransaction(org.apereo.cas.authentication.AuthenticationTransaction transaction)Gets authentication metadata populators for transaction.protected org.apereo.cas.authentication.principal.PrincipalResolvergetPrincipalResolverLinkedToHandlerIfAny(org.apereo.cas.authentication.AuthenticationHandler handler, org.apereo.cas.authentication.AuthenticationTransaction transaction)Gets principal resolver linked to the handler if any.protected voidhandleAuthenticationException(java.lang.Throwable ex, java.lang.String name, org.apereo.cas.authentication.AuthenticationBuilder builder)Handle authentication exception.protected voidinvokeAuthenticationPostProcessors(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)Populate authentication metadata attributes.protected booleaninvokeAuthenticationPreProcessors(org.apereo.cas.authentication.AuthenticationTransaction transaction)Invoke authentication pre processors.protected voidpopulateAuthenticationMetadataAttributes(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)Populate authentication metadata attributes.protected voidpublishEvent(org.springframework.context.ApplicationEvent event)Publish event.protected org.apereo.cas.authentication.principal.PrincipalresolvePrincipal(org.apereo.cas.authentication.AuthenticationHandler handler, org.apereo.cas.authentication.principal.PrincipalResolver resolver, org.apereo.cas.authentication.Credential credential, org.apereo.cas.authentication.principal.Principal principal)Resolve principal.
-
-
-
Method Detail
-
invokeAuthenticationPostProcessors
protected void invokeAuthenticationPostProcessors(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)Populate authentication metadata attributes.- Parameters:
builder- the buildertransaction- the transaction
-
populateAuthenticationMetadataAttributes
protected void populateAuthenticationMetadataAttributes(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)Populate authentication metadata attributes.- Parameters:
builder- the buildertransaction- the transaction
-
addAuthenticationMethodAttribute
protected void addAuthenticationMethodAttribute(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.Authentication authentication)Add authentication method attribute.- Parameters:
builder- the builderauthentication- the authentication
-
resolvePrincipal
protected org.apereo.cas.authentication.principal.Principal resolvePrincipal(org.apereo.cas.authentication.AuthenticationHandler handler, org.apereo.cas.authentication.principal.PrincipalResolver resolver, org.apereo.cas.authentication.Credential credential, org.apereo.cas.authentication.principal.Principal principal)Resolve principal.- Parameters:
handler- the handler nameresolver- the resolvercredential- the credentialprincipal- the current authenticated principal from a handler, if any.- Returns:
- the principal
-
authenticate
public org.apereo.cas.authentication.Authentication authenticate(org.apereo.cas.authentication.AuthenticationTransaction transaction) throws org.apereo.cas.authentication.AuthenticationException- Specified by:
authenticatein interfaceorg.apereo.cas.authentication.AuthenticationManager- Throws:
org.apereo.cas.authentication.AuthenticationException
-
invokeAuthenticationPreProcessors
protected boolean invokeAuthenticationPreProcessors(org.apereo.cas.authentication.AuthenticationTransaction transaction)
Invoke authentication pre processors.- Parameters:
transaction- the transaction- Returns:
- the boolean
-
authenticateAndResolvePrincipal
protected void authenticateAndResolvePrincipal(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.Credential credential, org.apereo.cas.authentication.principal.PrincipalResolver resolver, org.apereo.cas.authentication.AuthenticationHandler handler) throws java.security.GeneralSecurityException, org.apereo.cas.authentication.PreventedExceptionAuthenticate and resolve principal.- Parameters:
builder- the buildercredential- the credentialresolver- the resolverhandler- the handler- Throws:
java.security.GeneralSecurityException- the general security exceptionorg.apereo.cas.authentication.PreventedException- the prevented exception
-
getAuthenticationHandlersForThisTransaction
protected java.util.Set<org.apereo.cas.authentication.AuthenticationHandler> getAuthenticationHandlersForThisTransaction(org.apereo.cas.authentication.AuthenticationTransaction transaction)
Gets authentication handlers for this transaction.- Parameters:
transaction- the transaction- Returns:
- the authentication handlers for this transaction
-
getPrincipalResolverLinkedToHandlerIfAny
protected org.apereo.cas.authentication.principal.PrincipalResolver getPrincipalResolverLinkedToHandlerIfAny(org.apereo.cas.authentication.AuthenticationHandler handler, org.apereo.cas.authentication.AuthenticationTransaction transaction)Gets principal resolver linked to the handler if any.- Parameters:
handler- the handlertransaction- the transaction- Returns:
- the principal resolver linked to handler if any, or null.
-
getAuthenticationMetadataPopulatorsForTransaction
protected java.util.Collection<org.apereo.cas.authentication.AuthenticationMetaDataPopulator> getAuthenticationMetadataPopulatorsForTransaction(org.apereo.cas.authentication.AuthenticationTransaction transaction)
Gets authentication metadata populators for transaction.- Parameters:
transaction- the transaction- Returns:
- the authentication metadata populators for transaction
-
publishEvent
protected void publishEvent(org.springframework.context.ApplicationEvent event)
Publish event.- Parameters:
event- the event
-
authenticateInternal
protected org.apereo.cas.authentication.AuthenticationBuilder authenticateInternal(org.apereo.cas.authentication.AuthenticationTransaction transaction) throws org.apereo.cas.authentication.AuthenticationExceptionAuthenticate internal authentication builder.- Parameters:
transaction- the transaction- Returns:
- the authentication builder
- Throws:
org.apereo.cas.authentication.AuthenticationException- the authentication exception
-
evaluateFinalAuthentication
protected void evaluateFinalAuthentication(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction) throws org.apereo.cas.authentication.AuthenticationExceptionEvaluate produced authentication context. We apply an implicit security policy of at least one successful authentication. Then, we apply the configured security policy.- Parameters:
builder- the buildertransaction- the transaction- Throws:
org.apereo.cas.authentication.AuthenticationException- the authentication exception
-
evaluateAuthenticationPolicies
protected org.apache.commons.lang3.tuple.Pair<java.lang.Boolean,java.util.Set<java.lang.Throwable>> evaluateAuthenticationPolicies(org.apereo.cas.authentication.Authentication authentication, org.apereo.cas.authentication.AuthenticationTransaction transaction)Evaluate authentication policies.- Parameters:
authentication- the authenticationtransaction- the transaction- Returns:
- true /false
-
handleAuthenticationException
protected void handleAuthenticationException(java.lang.Throwable ex, java.lang.String name, org.apereo.cas.authentication.AuthenticationBuilder builder)Handle authentication exception.- Parameters:
ex- the exceptionname- the namebuilder- the builder
-
-