public class GenericPrincipal extends Object implements Principal
Realm
implementations.Modifier and Type | Field and Description |
---|---|
protected LoginContext |
loginContext
The JAAS LoginContext, if any, used to authenticate this Principal.
|
protected String |
name
The username of the user represented by this Principal.
|
protected String |
password
The authentication credentials for the user represented by
this Principal.
|
protected Realm |
realm
The Realm with which this Principal is associated.
|
protected String[] |
roles
The set of roles associated with this user.
|
protected Principal |
userPrincipal
The authenticated Principal to be exposed to applications.
|
Constructor and Description |
---|
GenericPrincipal(Realm realm,
String name,
String password)
Construct a new Principal, associated with the specified Realm, for the
specified username and password.
|
GenericPrincipal(Realm realm,
String name,
String password,
List<String> roles)
Construct a new Principal, associated with the specified Realm, for the
specified username and password, with the specified role names
(as Strings).
|
GenericPrincipal(Realm realm,
String name,
String password,
List<String> roles,
Principal userPrincipal)
Construct a new Principal, associated with the specified Realm, for the
specified username and password, with the specified role names
(as Strings).
|
GenericPrincipal(Realm realm,
String name,
String password,
List<String> roles,
Principal userPrincipal,
LoginContext loginContext)
Construct a new Principal, associated with the specified Realm, for the
specified username and password, with the specified role names
(as Strings).
|
Modifier and Type | Method and Description |
---|---|
String |
getName() |
String |
getPassword() |
Realm |
getRealm() |
String[] |
getRoles() |
Principal |
getUserPrincipal() |
boolean |
hasRole(String role)
Does the user represented by this Principal possess the specified role?
|
void |
logout()
Calls logout, if necessary, on any associated JAASLoginContext.
|
String |
toString()
Return a String representation of this object, which exposes only
information that should be public.
|
protected String name
protected String password
protected Realm realm
protected String[] roles
protected Principal userPrincipal
protected LoginContext loginContext
public GenericPrincipal(Realm realm, String name, String password)
realm
- The Realm that owns this Principalname
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userpublic GenericPrincipal(Realm realm, String name, String password, List<String> roles)
realm
- The Realm that owns this principalname
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userroles
- List of roles (must be Strings) possessed by this userpublic GenericPrincipal(Realm realm, String name, String password, List<String> roles, Principal userPrincipal)
realm
- The Realm that owns this principalname
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userroles
- List of roles (must be Strings) possessed by this useruserPrincipal
- - the principal to be returned from the request
getUserPrincipal call if not null; if null, this will be returnedpublic GenericPrincipal(Realm realm, String name, String password, List<String> roles, Principal userPrincipal, LoginContext loginContext)
realm
- The Realm that owns this principalname
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userroles
- List of roles (must be Strings) possessed by this useruserPrincipal
- - the principal to be returned from the request
getUserPrincipal call if not null; if null, this will be returnedloginContext
- - If provided, this will be used to log out the user
at the appropriate timepublic String getPassword()
public Realm getRealm()
public String[] getRoles()
public Principal getUserPrincipal()
public boolean hasRole(String role)
role
- Role to be testedpublic void logout() throws Exception
Exception
- If something goes wrong with the logout. Uses Exception
to allow for future expansion of this method to cover
other logout mechanisms that might throw a different
exception to LoginContextCopyright © 2018 JBoss by Red Hat. All rights reserved.