Package org.jenkinsci.plugins.cas.spring
Class CasEventListener
java.lang.Object
org.jenkinsci.plugins.cas.spring.CasEventListener
- All Implemented Interfaces:
EventListener,org.springframework.context.ApplicationListener<org.springframework.security.authentication.event.AuthenticationSuccessEvent>
public class CasEventListener
extends Object
implements org.springframework.context.ApplicationListener<org.springframework.security.authentication.event.AuthenticationSuccessEvent>
Listener for successful CAS authentication events, that syncs attributes
with the corresponding Jenkins User.
- Author:
- Fabien Crespel
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetAttributeValue(org.springframework.security.cas.authentication.CasAuthenticationToken authToken, String attributeName) Retrieve an attribute's value from a CAS authentication token.Get the email address attribute name.Get the full name attribute name.voidonApplicationEvent(org.springframework.security.authentication.event.AuthenticationSuccessEvent event) Handle an application event.voidonSuccessfulAuthentication(org.springframework.security.core.Authentication authentication) Successful authentication event handler.protected StringparseAttributeTemplate(org.springframework.security.cas.authentication.CasAuthenticationToken authToken, String attributeTemplate) Replace placeholders in an attribute template string.voidsetEmailAttribute(String emailAttribute) Set the email address attribute name.voidsetFullNameAttribute(String fullNameAttribute) Set the full name attribute name.protected voidsyncUserAttributes(org.springframework.security.cas.authentication.CasAuthenticationToken casToken) Sync user attributes with a CAS authentication token.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Field Details
-
DEFAULT_FULL_NAME_ATTRIBUTE
- See Also:
-
DEFAULT_EMAIL_ATTRIBUTE
- See Also:
-
-
Constructor Details
-
CasEventListener
public CasEventListener()
-
-
Method Details
-
onApplicationEvent
public void onApplicationEvent(org.springframework.security.authentication.event.AuthenticationSuccessEvent event) Handle an application event.- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.security.authentication.event.AuthenticationSuccessEvent>- Parameters:
event- the event to respond to
-
onSuccessfulAuthentication
public void onSuccessfulAuthentication(org.springframework.security.core.Authentication authentication) Successful authentication event handler. This event is fired immediately after authentication, before filter chain is invoked and before Spring security context is updated.- Parameters:
authentication- the successful authentication object
-
syncUserAttributes
protected void syncUserAttributes(org.springframework.security.cas.authentication.CasAuthenticationToken casToken) throws IOException Sync user attributes with a CAS authentication token.- Parameters:
casToken- CAS authentication token- Throws:
IOException- I/O error when persisting user
-
parseAttributeTemplate
protected String parseAttributeTemplate(org.springframework.security.cas.authentication.CasAuthenticationToken authToken, String attributeTemplate) Replace placeholders in an attribute template string.- Parameters:
authToken- CAS authentication tokenattributeTemplate- attribute template containing '{{placeholder}}' or plain attribute name- Returns:
- attribute value or null if not found
-
getAttributeValue
protected String getAttributeValue(org.springframework.security.cas.authentication.CasAuthenticationToken authToken, String attributeName) Retrieve an attribute's value from a CAS authentication token.- Parameters:
authToken- CAS authentication tokenattributeName- attribute name- Returns:
- attribute value or null if not found
-
getFullNameAttribute
Get the full name attribute name.- Returns:
- full name attribute name.
-
setFullNameAttribute
Set the full name attribute name.- Parameters:
fullNameAttribute- full name attribute name.
-
getEmailAttribute
Get the email address attribute name.- Returns:
- email address attribute name.
-
setEmailAttribute
Set the email address attribute name.- Parameters:
emailAttribute- email address attribute name.
-