Class Saml2UserDetails
java.lang.Object
se.swedenconnect.spring.saml.idp.authentication.Saml2UserDetails
- All Implemented Interfaces:
Serializable,org.springframework.security.core.userdetails.UserDetails
public class Saml2UserDetails
extends Object
implements org.springframework.security.core.userdetails.UserDetails
Representation of a user authenticated using SAML2.
- Author:
- Martin Lindström
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSaml2UserDetails(Collection<UserAttribute> attributes, String primaryAttribute, String authnContextUri, Instant authnInstant, String subjectIpAddress) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets an unmodifiable collection of all user attributes.If the authentication was performed by another provider and the current IdP acts as a proxy, this field holds the ID of the authenticating authority or authorities that was/were used.Deprecated.Gets the authentication context URI under which the authentication was made.Gets the authentication instant.Collection<? extends org.springframework.security.core.GrantedAuthority> Will always return en empty collection.Always returns the empty string.Gets the ID of the primary attribute (that must appear among the attributes).Gets the subject locality, an IP-address.Returns the attribute value for theprimaryAttribute.inthashCode()booleanAlways returnstrue.booleanAlways returnstrue.booleanAlways returnstrue.booleanAlways returnstrue.booleanPredicate telling whether the IdP displayed a SignMessage for the user.voidsetAuthenticatingAuthorities(List<String> authenticatingAuthorities) Assigns the authenticating authority.voidsetAuthenticatingAuthority(String authenticatingAuthority) Deprecated.voidsetSignMessageDisplayed(boolean signMessageDisplayed) Tells whether the IdP displayed a SignMessage for the user.
-
Constructor Details
-
Saml2UserDetails
public Saml2UserDetails(Collection<UserAttribute> attributes, String primaryAttribute, String authnContextUri, Instant authnInstant, String subjectIpAddress) Constructor.- Parameters:
attributes- the user identity attributesprimaryAttribute- the ID of the primary attribute (that must appear among the attributes)authnContextUri- the authentication context URI under which the authentication was madeauthnInstant- the authentication instant
-
-
Method Details
-
getUsername
Returns the attribute value for theprimaryAttribute.- Specified by:
getUsernamein interfaceorg.springframework.security.core.userdetails.UserDetails
-
getAttributes
Gets an unmodifiable collection of all user attributes.- Returns:
- the user attributes
-
getPrimaryAttribute
Gets the ID of the primary attribute (that must appear among the attributes).- Returns:
- the primary attribute ID
-
getAuthnContextUri
Gets the authentication context URI under which the authentication was made.- Returns:
- the authn context URI
-
getAuthnInstant
Gets the authentication instant.- Returns:
- the authentication instant
-
getSubjectIpAddress
Gets the subject locality, an IP-address.- Returns:
- the subject locality
-
getAuthenticatingAuthority
Deprecated.If the authentication was performed by another provider and the current IdP acts as a proxy, this field holds the ID of the authenticating authority.- Returns:
- the authenticating authority, or
nullif not set
-
getAuthenticatingAuthorities
If the authentication was performed by another provider and the current IdP acts as a proxy, this field holds the ID of the authenticating authority or authorities that was/were used.- Returns:
- a (potentially empty) list of authenticating authorities
-
setAuthenticatingAuthority
Deprecated.Assigns the authenticating authority. If the authentication was performed by another provider and the current IdP acts as a proxy, this field holds the ID of the authenticating authority.- Parameters:
authenticatingAuthority- the authenticating authority
-
setAuthenticatingAuthorities
Assigns the authenticating authority. If the authentication was performed by another provider and the current IdP acts as a proxy, this field holds the ID of the authenticating authority.- Parameters:
authenticatingAuthorities- the authenticating authorities
-
isSignMessageDisplayed
public boolean isSignMessageDisplayed()Predicate telling whether the IdP displayed a SignMessage for the user.- Returns:
trueif a SignMessage was displayed andfalseotherwise
-
setSignMessageDisplayed
public void setSignMessageDisplayed(boolean signMessageDisplayed) Tells whether the IdP displayed a SignMessage for the user.- Parameters:
signMessageDisplayed-trueif a SignMessage was displayed andfalseotherwise
-
getAuthorities
Will always return en empty collection.- Specified by:
getAuthoritiesin interfaceorg.springframework.security.core.userdetails.UserDetails
-
getPassword
Always returns the empty string.- Specified by:
getPasswordin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isAccountNonExpired
public boolean isAccountNonExpired()Always returnstrue.- Specified by:
isAccountNonExpiredin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isAccountNonLocked
public boolean isAccountNonLocked()Always returnstrue.- Specified by:
isAccountNonLockedin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()Always returnstrue.- Specified by:
isCredentialsNonExpiredin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isEnabled
public boolean isEnabled()Always returnstrue.- Specified by:
isEnabledin interfaceorg.springframework.security.core.userdetails.UserDetails
-
hashCode
public int hashCode() -
equals
-
getAuthenticatingAuthorities()