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 Details

  • Constructor Details

    • CasEventListener

      public CasEventListener()
  • Method Details

    • onApplicationEvent

      public void onApplicationEvent(org.springframework.security.authentication.event.AuthenticationSuccessEvent event)
      Handle an application event.
      Specified by:
      onApplicationEvent in interface org.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 token
      attributeTemplate - 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 token
      attributeName - attribute name
      Returns:
      attribute value or null if not found
    • getFullNameAttribute

      public String getFullNameAttribute()
      Get the full name attribute name.
      Returns:
      full name attribute name.
    • setFullNameAttribute

      public void setFullNameAttribute(String fullNameAttribute)
      Set the full name attribute name.
      Parameters:
      fullNameAttribute - full name attribute name.
    • getEmailAttribute

      public String getEmailAttribute()
      Get the email address attribute name.
      Returns:
      email address attribute name.
    • setEmailAttribute

      public void setEmailAttribute(String emailAttribute)
      Set the email address attribute name.
      Parameters:
      emailAttribute - email address attribute name.