Package org.pac4j.core.profile
Class ProfileHelper
- java.lang.Object
-
- org.pac4j.core.profile.ProfileHelper
-
public final class ProfileHelper extends Object
This class is an helper for profiles.- Since:
- 1.1.0
- Author:
- Jerome Leleu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CommonProfile
buildUserProfileByClassCompleteName(String completeName)
Build a profile by its class name.static <U extends UserProfile>
List<U>flatIntoAProfileList(Map<String,U> profiles)
Flat the map of profiles into a list of profiles.static <U extends UserProfile>
Optional<U>flatIntoOneProfile(Collection<U> profiles)
Flat the list of profiles into a single optional profile (skip any anonymous profile unless it's the only one).static boolean
isTypedIdOf(String id, Class<? extends CommonProfile> clazz)
Indicate if the user identifier matches this kind of profile.static CommonProfile
restoreOrBuildProfile(ProfileDefinition<? extends CommonProfile> profileDefinition, String typedId, Map<String,Object> profileAttributes, Map<String,Object> authenticationAttributes, Object... parameters)
Restore or build a profile.static String
sanitizeIdentifier(BasicUserProfile profile, Object id)
Sanitize into a string identifier.
-
-
-
Method Detail
-
isTypedIdOf
public static boolean isTypedIdOf(String id, Class<? extends CommonProfile> clazz)
Indicate if the user identifier matches this kind of profile.- Parameters:
id
- user identifierclazz
- profile class- Returns:
- if the user identifier matches this kind of profile
-
restoreOrBuildProfile
public static CommonProfile restoreOrBuildProfile(ProfileDefinition<? extends CommonProfile> profileDefinition, String typedId, Map<String,Object> profileAttributes, Map<String,Object> authenticationAttributes, Object... parameters)
Restore or build a profile.- Parameters:
profileDefinition
- the profile definitiontypedId
- the typed identifierprofileAttributes
- The profile attributes. May benull
.authenticationAttributes
- The authentication attributes. May benull
.parameters
- additional parameters for the profile definition- Returns:
- the restored or built profile
-
buildUserProfileByClassCompleteName
public static CommonProfile buildUserProfileByClassCompleteName(String completeName)
Build a profile by its class name.- Parameters:
completeName
- the class name- Returns:
- the built user profile
-
flatIntoOneProfile
public static <U extends UserProfile> Optional<U> flatIntoOneProfile(Collection<U> profiles)
Flat the list of profiles into a single optional profile (skip any anonymous profile unless it's the only one).- Type Parameters:
U
- the kind of profile- Parameters:
profiles
- the list of profiles- Returns:
- the (optional) profile
-
flatIntoAProfileList
public static <U extends UserProfile> List<U> flatIntoAProfileList(Map<String,U> profiles)
Flat the map of profiles into a list of profiles.- Type Parameters:
U
- the kind of profile- Parameters:
profiles
- the map of profiles- Returns:
- the list of profiles
-
sanitizeIdentifier
public static String sanitizeIdentifier(BasicUserProfile profile, Object id)
Sanitize into a string identifier.- Parameters:
profile
- the user profileid
- the identifier object- Returns:
- the sanitized identifier
-
-