public class SAMLAuthenticationProvider extends Object implements org.springframework.security.authentication.AuthenticationProvider, org.springframework.beans.factory.InitializingBean
Modifier and Type | Field and Description |
---|---|
protected WebSSOProfileConsumer |
consumer |
protected WebSSOProfileConsumer |
hokConsumer |
protected SAMLLogger |
samlLogger |
protected SAMLUserDetailsService |
userDetails |
Constructor and Description |
---|
SAMLAuthenticationProvider() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Verifies that required entities were autowired or set.
|
org.springframework.security.core.Authentication |
authenticate(org.springframework.security.core.Authentication authentication)
Attempts to perform authentication of an Authentication object.
|
protected Collection<? extends org.springframework.security.core.GrantedAuthority> |
getEntitlements(SAMLCredential credential,
Object userDetail)
Method is responsible for returning collection of users entitlements.
|
protected Date |
getExpirationDate(SAMLCredential credential)
Parses the SAMLCredential for expiration time.
|
protected Object |
getPrincipal(SAMLCredential credential,
Object userDetail)
Method determines what will be stored as principal of the created Authentication object.
|
SAMLUserDetailsService |
getUserDetails()
Returns saml user details service used to load information about logged user from SAML data.
|
protected Object |
getUserDetails(SAMLCredential credential)
Populates user data from SAMLCredential into UserDetails object.
|
boolean |
isExcludeCredential() |
boolean |
isForcePrincipalAsString() |
void |
setConsumer(WebSSOProfileConsumer consumer)
Profile for consumption of processed messages, must be set.
|
void |
setExcludeCredential(boolean excludeCredential)
When false (default) the resulting Authentication object will include instance of SAMLCredential
as a credential value.
|
void |
setForcePrincipalAsString(boolean forcePrincipalAsString)
By default principal in the returned Authentication object is the NameID included in the
authenticated Assertion.
|
void |
setHokConsumer(WebSSOProfileConsumer hokConsumer)
Profile for consumption of processed messages using the Holder-of-Key profile, must be set.
|
void |
setSamlLogger(SAMLLogger samlLogger)
Logger for SAML events, cannot be null, must be set.
|
void |
setUserDetails(SAMLUserDetailsService userDetails)
The user details can be optionally set and is automatically called while user SAML assertion
is validated.
|
boolean |
supports(Class aClass)
SAMLAuthenticationToken is the only supported token.
|
protected WebSSOProfileConsumer consumer
protected WebSSOProfileConsumer hokConsumer
protected SAMLLogger samlLogger
protected SAMLUserDetailsService userDetails
public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationException
authenticate
in interface org.springframework.security.authentication.AuthenticationProvider
authentication
- SAMLAuthenticationToken to verifyorg.springframework.security.core.AuthenticationException
- user can't be authenticated due to an errorprotected Object getUserDetails(SAMLCredential credential)
If no SAMLUserDetailsService is specified null is returned.
credential
- credential to load user fromprotected Object getPrincipal(SAMLCredential credential, Object userDetail)
credential
- credential used to authenticate useruserDetail
- loaded user details, can be nullprotected Collection<? extends org.springframework.security.core.GrantedAuthority> getEntitlements(SAMLCredential credential, Object userDetail)
In case object of other type is found empty list is returned. Users are supposed to override this method to provide custom parsing is such case.
credential
- credential used to authenticate user during SSOuserDetail
- user detail object returned from getUserDetails callprotected Date getExpirationDate(SAMLCredential credential)
credential
- credential to use for expiration parsing.public SAMLUserDetailsService getUserDetails()
public boolean supports(Class aClass)
supports
in interface org.springframework.security.authentication.AuthenticationProvider
aClass
- class to check for support@Autowired(required=false) public void setUserDetails(SAMLUserDetailsService userDetails)
userDetails
- user details@Autowired public void setSamlLogger(SAMLLogger samlLogger)
samlLogger
- logger@Autowired @Qualifier(value="webSSOprofileConsumer") public void setConsumer(WebSSOProfileConsumer consumer)
consumer
- consumer@Autowired @Qualifier(value="hokWebSSOprofileConsumer") public void setHokConsumer(WebSSOProfileConsumer hokConsumer)
hokConsumer
- holder-of-key consumerpublic boolean isForcePrincipalAsString()
public void setForcePrincipalAsString(boolean forcePrincipalAsString)
forcePrincipalAsString
- true to force principal to be a Stringpublic boolean isExcludeCredential()
public void setExcludeCredential(boolean excludeCredential)
excludeCredential
- false to include credential in the Authentication object, true to exclude itpublic void afterPropertiesSet() throws ServletException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
ServletException