public class GenericPrincipal extends java.lang.Object implements TomcatPrincipal, java.io.Serializable
Realm
implementations.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
attributes
The additional attributes associated with this Principal.
|
protected org.ietf.jgss.GSSCredential |
gssCredential
The user's delegated credentials.
|
protected javax.security.auth.login.LoginContext |
loginContext
The JAAS LoginContext, if any, used to authenticate this Principal.
|
protected java.lang.String |
name
The username of the user represented by this Principal.
|
protected java.lang.String |
password
The authentication credentials for the user represented by this Principal.
|
protected java.lang.String[] |
roles
The set of roles associated with this user.
|
protected java.security.Principal |
userPrincipal
The authenticated Principal to be exposed to applications.
|
| Constructor and Description |
|---|
GenericPrincipal(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.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(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles,
java.security.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(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles,
java.security.Principal userPrincipal,
javax.security.auth.login.LoginContext loginContext)
Construct a new Principal, associated with the specified Realm, for the specified username and password, with the
specified role names (as Strings).
|
GenericPrincipal(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles,
java.security.Principal userPrincipal,
javax.security.auth.login.LoginContext loginContext,
org.ietf.jgss.GSSCredential gssCredential,
java.util.Map<java.lang.String,java.lang.Object> attributes)
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 |
|---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the named attribute as an
Object, or
null if no attribute of the given name exists, or if
null has been specified as the attribute's name. |
java.util.Enumeration<java.lang.String> |
getAttributeNames()
Returns an
Enumeration containing the names of the
attributes available to this Principal. |
org.ietf.jgss.GSSCredential |
getGssCredential() |
java.lang.String |
getName() |
java.lang.String |
getPassword() |
java.lang.String[] |
getRoles() |
java.security.Principal |
getUserPrincipal() |
boolean |
hasRole(java.lang.String role)
Does the user represented by this Principal possess the specified role?
|
void |
logout()
Calls logout, if necessary, on any associated JAASLoginContext and/or
GSSContext.
|
protected void |
setGssCredential(org.ietf.jgss.GSSCredential gssCredential) |
java.lang.String |
toString()
Return a String representation of this object, which exposes only information that should be public.
|
protected final java.lang.String name
protected final java.lang.String password
protected final java.lang.String[] roles
protected final java.security.Principal userPrincipal
protected final transient javax.security.auth.login.LoginContext loginContext
protected transient org.ietf.jgss.GSSCredential gssCredential
protected final java.util.Map<java.lang.String,java.lang.Object> attributes
public GenericPrincipal(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles)
name - 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(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles,
java.security.Principal userPrincipal)
name - 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(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles,
java.security.Principal userPrincipal,
javax.security.auth.login.LoginContext loginContext)
name - 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 GenericPrincipal(java.lang.String name,
java.lang.String password,
java.util.List<java.lang.String> roles,
java.security.Principal userPrincipal,
javax.security.auth.login.LoginContext loginContext,
org.ietf.jgss.GSSCredential gssCredential,
java.util.Map<java.lang.String,java.lang.Object> attributes)
name - 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 timegssCredential - - If provided, the user's delegated credentialsattributes - - If provided, additional attributes associated with this Principalpublic java.lang.String getName()
getName in interface java.security.Principalpublic java.lang.String getPassword()
public java.lang.String[] getRoles()
public java.security.Principal getUserPrincipal()
getUserPrincipal in interface TomcatPrincipalpublic org.ietf.jgss.GSSCredential getGssCredential()
getGssCredential in interface TomcatPrincipalprotected void setGssCredential(org.ietf.jgss.GSSCredential gssCredential)
public boolean hasRole(java.lang.String role)
role - Role to be testedtrue if this Principal has been assigned the given role, otherwise falsepublic java.lang.String toString()
toString in interface java.security.PrincipaltoString in class java.lang.Objectpublic void logout()
throws java.lang.Exception
TomcatPrincipallogout in interface TomcatPrincipaljava.lang.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 LoginContextpublic java.lang.Object getAttribute(java.lang.String name)
TomcatPrincipalObject, or
null if no attribute of the given name exists, or if
null has been specified as the attribute's name.
Only the servlet container may set attributes to make available custom information about a Principal or the user it represents.
The purpose of the method is to implement read only access to attributes
which may be stored in the Realm implementation's backend
due to its inherent design.
As using this method from application code will make it non portable to
other EE compliant containers, it is advised this should never be used
as an object storage facility tied to the Principal, but
rather as simple extra additional metadata. It is recommended that a
container level object is used to further process the attributes that
may be associated with the Principal.
Realm implementations that are provided by Tomcat will
not provide complex type mapping, but will in most cases always
return a result as a String object which may need custom
decoding.
Realm implementations that are provided by Tomcat will
not provide an implementation for this facility unless it is inherent
to the storage backend of the Realm itself and metadata
is available without additional user intervention or configuration.
getAttribute in interface TomcatPrincipalname - a String specifying the name of the attributeObject containing the value of the attribute, or
null if the attribute does not exist, or if
null has been specified as the attribute's namepublic java.util.Enumeration<java.lang.String> getAttributeNames()
TomcatPrincipalEnumeration containing the names of the
attributes available to this Principal. This method returns an empty
Enumeration if the Principal has no attributes available to
it.getAttributeNames in interface TomcatPrincipalEnumeration of strings containing the names of
the Principal's attributesCopyright © 2000-2024 Apache Software Foundation.
Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo are either registered trademarks or trademarks of the Apache Software Foundation.