Package io.buji.pac4j.subject
Class Pac4jPrincipal
- java.lang.Object
-
- io.buji.pac4j.subject.Pac4jPrincipal
-
- All Implemented Interfaces:
Serializable,Principal
public class Pac4jPrincipal extends Object implements Principal, Serializable
A principal created by Pac4JRealm that wraps a CommonProfile.- Since:
- 2.0.0
- Author:
- Jerome Leleu
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Pac4jPrincipal(List<org.pac4j.core.profile.UserProfile> profiles)Construct a Pac4jPrincipal.Pac4jPrincipal(List<org.pac4j.core.profile.UserProfile> profiles, String principalNameAttribute)Construct a Pac4jPrincipal and specify which attribute in the CommonProfile should be used for the principal name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)StringgetName()Returns a name for the principal based upon one of the attributes of the main CommonProfile.org.pac4j.core.profile.UserProfilegetProfile()Get the main profile of the authenticated user.List<org.pac4j.core.profile.UserProfile>getProfiles()Get all the profiles of the authenticated user.inthashCode()StringtoString()
-
-
-
Constructor Detail
-
Pac4jPrincipal
public Pac4jPrincipal(List<org.pac4j.core.profile.UserProfile> profiles)
Construct a Pac4jPrincipal. The principal name returned will be CommonProfile.getId().- Parameters:
profiles- A list containing all of the CommonProfiles created by Pac4j authorization.
-
Pac4jPrincipal
public Pac4jPrincipal(List<org.pac4j.core.profile.UserProfile> profiles, String principalNameAttribute)
Construct a Pac4jPrincipal and specify which attribute in the CommonProfile should be used for the principal name.- Parameters:
profiles- A list containing all of the CommonProfiles created by Pac4j authorization.principalNameAttribute- The attribute name in the CommonProfile that holds the principal name. A null or blank value means that CommonProfile.getId() should be used as the principal name.
-
-
Method Detail
-
getProfile
public org.pac4j.core.profile.UserProfile getProfile()
Get the main profile of the authenticated user.- Returns:
- the main profile
-
getProfiles
public List<org.pac4j.core.profile.UserProfile> getProfiles()
Get all the profiles of the authenticated user.- Returns:
- the list of profiles
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
toString
public String toString()
-
getName
public String getName()
Returns a name for the principal based upon one of the attributes of the main CommonProfile. The attribute name used to query the CommonProfile is specified in the constructor.
-
-