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
ConstructorDescriptionSaml2UserDetails
(Collection<UserAttribute> attributes, String primaryAttribute, String authnContextUri, Instant authnInstant, String subjectIpAddress) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Gets 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.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
.int
hashCode()
boolean
Always returnstrue
.boolean
Always returnstrue
.boolean
Always returnstrue
.boolean
Always returnstrue
.boolean
Predicate telling whether the IdP displayed a SignMessage for the user.void
setAuthenticatingAuthority
(String authenticatingAuthority) Assigns the authenticating authority.void
setSignMessageDisplayed
(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:
getUsername
in 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
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
null
if not set
-
setAuthenticatingAuthority
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
-
isSignMessageDisplayed
public boolean isSignMessageDisplayed()Predicate telling whether the IdP displayed a SignMessage for the user.- Returns:
true
if a SignMessage was displayed andfalse
otherwise
-
setSignMessageDisplayed
public void setSignMessageDisplayed(boolean signMessageDisplayed) Tells whether the IdP displayed a SignMessage for the user.- Parameters:
signMessageDisplayed
-true
if a SignMessage was displayed andfalse
otherwise
-
getAuthorities
Will always return en empty collection.- Specified by:
getAuthorities
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
getPassword
Always returns the empty string.- Specified by:
getPassword
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isAccountNonExpired
public boolean isAccountNonExpired()Always returnstrue
.- Specified by:
isAccountNonExpired
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isAccountNonLocked
public boolean isAccountNonLocked()Always returnstrue
.- Specified by:
isAccountNonLocked
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()Always returnstrue
.- Specified by:
isCredentialsNonExpired
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isEnabled
public boolean isEnabled()Always returnstrue
.- Specified by:
isEnabled
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
hashCode
public int hashCode() -
equals
-