Package com.oorian.security
Interface UserPrincipal
public interface UserPrincipal
Represents an authenticated user in the Oorian framework.
Applications implement this interface to provide their own user model. The principal
is stored in the OorianSession after a successful login and is
accessible via OorianSession.getPrincipal().
Example:
public class AppUser implements UserPrincipal
{
private final String id;
private final String name;
private final Set<String> roles;
public AppUser(String id, String name, Set<String> roles)
{
this.id = id;
this.name = name;
this.roles = roles;
}
@Override
public String getId() { return id; }
@Override
public String getName() { return name; }
@Override
public Set<String> getRoles() { return roles; }
}
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Details
-
getId
String getId()Returns the unique identifier for this user.This is typically a database primary key, UUID, or username that uniquely identifies the user across the application.
- Returns:
- the user's unique identifier
-
getName
String getName()Returns the display name for this user.- Returns:
- the user's display name
-
getRoles
Returns the set of roles assigned to this user.Roles are used for authorization checks via
hasRole(String). Applications define their own role strings (e.g., "admin", "editor", "viewer").- Returns:
- an unmodifiable set of role names, or an empty set if no roles are assigned
-
hasRole
Checks whether this user has the specified role.- Parameters:
role- the role name to check- Returns:
trueif the user has the role,falseotherwise
-