public abstract class UserProfile extends Object implements Serializable, Externalizable
null
(generic profile), it must be defined in subclasses. Additional concepts are the
"remember me" nature of the user profile and the associated roles, permissions and client name.Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
static String |
SEPARATOR |
Constructor and Description |
---|
UserProfile() |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String key,
Object value)
Add an attribute and perform conversion if necessary.
|
void |
addAttributes(Map<String,Object> attributes)
Add attributes.
|
void |
addPermission(String permission)
Add a permission.
|
void |
addPermissions(List<String> permissions)
Add permissions.
|
void |
addPermissions(Set<String> permissions)
Add permissions.
|
void |
addRole(String role)
Add a role.
|
void |
addRoles(List<String> roles)
Add roles.
|
void |
addRoles(Set<String> roles)
Add roles.
|
void |
build(Object id,
Map<String,Object> attributes)
Build a profile from user identifier and attributes.
|
void |
clearSensitiveData() |
boolean |
containsAttribute(String name)
Check to see if profile contains attribute name.
|
Object |
getAttribute(String name)
Return the attribute with name.
|
<T> T |
getAttribute(String name,
Class<T> clazz)
Return the attribute with name.
|
Map<String,Object> |
getAttributes()
Get attributes as immutable map.
|
AttributesDefinition |
getAttributesDefinition()
Return the attributes definition for this user profile.
|
String |
getClientName() |
String |
getId()
Get the user identifier.
|
String |
getOldTypedId()
Deprecated.
|
Set<String> |
getPermissions()
Get the permissions of the user.
|
Set<String> |
getRoles()
Get the roles of the user.
|
String |
getTypedId()
Get the user identifier with a prefix which is the profile type (full class name with package).
|
boolean |
isRemembered()
Is the user remembered?
|
void |
readExternal(ObjectInput in) |
void |
removeAttribute(String key)
Remove an attribute byt its key.
|
void |
setClientName(String clientName) |
void |
setId(Object id)
Set the identifier and convert it if necessary.
|
void |
setRemembered(boolean rme)
Define if this profile is remembered.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
protected final transient org.slf4j.Logger logger
public static final transient String SEPARATOR
public void build(Object id, Map<String,Object> attributes)
id
- user identifierattributes
- user attributespublic AttributesDefinition getAttributesDefinition()
null
for a (generic) user profile.public void addAttribute(String key, Object value)
key
- key of the attributevalue
- value of the attributepublic void addAttributes(Map<String,Object> attributes)
attributes
- use attributespublic void removeAttribute(String key)
key
- the keypublic void setId(Object id)
id
- user identifierpublic String getId()
public String getTypedId()
@Deprecated public String getOldTypedId()
getTypedId()
instead.public Map<String,Object> getAttributes()
public Object getAttribute(String name)
name
- attribute namepublic boolean containsAttribute(String name)
name
- the namepublic <T> T getAttribute(String name, Class<T> clazz)
T
- the type of the attributename
- the attribute nameclazz
- the class of the attributepublic void addRole(String role)
role
- the role to add.public void addPermission(String permission)
permission
- the permission to add.public void addPermissions(List<String> permissions)
permissions
- the permissions to add.public void addPermissions(Set<String> permissions)
permissions
- the permissions to add.public void setRemembered(boolean rme)
rme
- whether the user is remembered.public Set<String> getPermissions()
public boolean isRemembered()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void clearSensitiveData()
public String getClientName()
public void setClientName(String clientName)
Copyright © 2016. All rights reserved.