public class UserIdentifier
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
UserIdentifier.Type
Definitions for user types.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
IDENTIFIER_SPLITTER |
static java.lang.String |
ROLE_SPLITTER |
Constructor and Description |
---|
UserIdentifier(UserIdentifier.Type type,
java.lang.String identifier)
Creates a new
UserIdentifier with the given type and identifier. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
static UserIdentifier |
getAnonymous() |
java.lang.String |
getIdentifier() |
static UserIdentifier |
getProducer() |
UserIdentifier.Type |
getType() |
static UserIdentifier |
getWithProducerRole() |
int |
hashCode() |
static <T> java.util.Collection<T> |
mapMultiRoleIdentifier(java.lang.String identifier,
java.util.function.Function<java.lang.String,T> mapper)
Utility method for splitting multi-role identifier to Strings
and mapping them to wanted type.
|
static UserIdentifier |
parse(java.lang.String identifierString)
Parses a user identifier string and creates a
UserIdentifier instance. |
java.lang.String |
toString() |
public static final java.lang.String ROLE_SPLITTER
public static final java.lang.String IDENTIFIER_SPLITTER
public UserIdentifier(UserIdentifier.Type type, java.lang.String identifier)
UserIdentifier
with the given type and identifier.
Usually objects are instantiated using parse(String)
for creating objects.type
- Role typeidentifier
- Identifier (user name or role name)public static UserIdentifier parse(java.lang.String identifierString)
UserIdentifier
instance.
user identifier string is in format <type>:<identifier> e.g. user:admin or role:ROLE_ADMINidentifierString
- User identifier string to parsepublic static <T> java.util.Collection<T> mapMultiRoleIdentifier(java.lang.String identifier, java.util.function.Function<java.lang.String,T> mapper)
T
- Type to which the roles are mapped toidentifier
- Identifier without typemapper
- Mapper function for String -> role type mappingpublic static UserIdentifier getAnonymous()
public static UserIdentifier getProducer()
public static UserIdentifier getWithProducerRole()
public UserIdentifier.Type getType()
public java.lang.String getIdentifier()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object