In-memory representation of an individual user, to which specific roles
may be assigned directly, or indirectly by virtue of membership in one
or more groups. This class exhibits the following JavaBeans properties:
Method from org.apache.tomcat.security.file.FileRealmUser Detail: |
public void addGroup(FileRealmGroup group) {
group.addUser(this);
groups.put(group.getName(), group);
}
Add this user as a member of the specified group. |
public void addRole(String role) {
database.addRole(role);
roles.put(role, role);
}
Add the explicit assignment of the specified role to this user. |
public boolean authenticate(String password) {
return (MessageDigest.isEqual(this.password, encrypt(password)));
}
Can this user be authenticated with the specified password? |
public void destroy() {
database.remove(this);
}
Remove this user from the database to which it belongs. |
public Enumeration getGroups() {
return (groups.elements());
}
Return an enumeration of the groups to which this user belongs.
If this user is a member of no groups, an empty enumeration is
returned. Each element in the enumeration is an instance of
FileRealmGroup. |
public String getName() {
return (name);
}
Return the username of this user. |
public byte[] getPassword() {
return (password);
}
Return the encrypted version of the password. |
public Enumeration getRoles() {
return (roles.keys());
}
Return an enumeration of the roles explicitly assigned to this user.
If there are no assigned roles, an empty enumeration is returned. |
public boolean hasGroup(FileRealmGroup group) {
return (groups.get(group.getName()) != null);
}
Is this user a member of the specified group? |
public boolean hasRole(String role) {
return (roles.get(role) != null);
}
Has this user been explicitly assigned the specified role? |
public void remove(FileRealmGroup group) {
groups.remove(group.getName());
group.remove(this);
}
Remove this user from membership in the specified group. |
public void remove(String role) {
roles.remove(role);
}
Remove the specified explicitly assigned role from this user. |
public void setPassword(byte[] password) {
this.password = new byte[password.length];
for (int i = 0; i < this.password.length; i++)
this.password[i] = password[i];
}
Set the password associated with this user. |
public void setPassword(String password) {
this.password = encrypt(password);
}
Set the password associated with this user. This cleartext value
will be immediately encrypted for storage. |