|
Apache Tomcat 6.0.45 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.catalina.realm.RealmBase
public abstract class RealmBase
Simple implementation of Realm that reads an XML file to configure the valid users, passwords, and roles. The file format (and default file location) are identical to those currently supported by Tomcat 3.X.
| Nested Class Summary | |
|---|---|
protected static class |
RealmBase.AllRolesMode
|
| Field Summary | |
|---|---|
protected RealmBase.AllRolesMode |
allRolesMode
The all role mode. |
protected Container |
container
The Container with which this Realm is associated. |
protected Log |
containerLog
Container log |
protected javax.management.ObjectName |
controller
|
protected java.lang.String |
digest
Digest algorithm used in storing passwords in a non-plaintext format. |
protected java.lang.String |
digestEncoding
The encoding charset for the digest. |
protected java.lang.String |
domain
|
protected java.lang.String |
host
|
protected static java.lang.String |
info
Descriptive information about this Realm implementation. |
protected boolean |
initialized
|
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component. |
protected java.security.MessageDigest |
md
The MessageDigest object for digesting user credentials (passwords). |
protected static MD5Encoder |
md5Encoder
The MD5 helper object for this class. |
protected static java.security.MessageDigest |
md5Helper
MD5 message digest provider. |
protected javax.management.MBeanServer |
mserver
|
protected javax.management.ObjectName |
oname
|
protected java.lang.String |
path
|
protected java.lang.String |
realmPath
|
protected static StringManager |
sm
The string manager for this package. |
protected boolean |
started
Has this component been started? |
protected java.beans.PropertyChangeSupport |
support
The property change support for this component. |
protected java.lang.String |
type
|
protected boolean |
validate
Should we validate client certificate chains when they are presented? |
protected X509UsernameRetriever |
x509UsernameRetriever
The object that will extract user names from X509 client certificates. |
protected java.lang.String |
x509UsernameRetrieverClassName
The name of the class to use for retrieving user names from X509 certificates. |
| Fields inherited from interface org.apache.catalina.Lifecycle |
|---|
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT |
| Constructor Summary | |
|---|---|
RealmBase()
|
|
| Method Summary | |
|---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component. |
java.security.Principal |
authenticate(java.lang.String username,
byte[] credentials)
Return the Principal associated with the specified username and credentials, if there is one; otherwise return null. |
java.security.Principal |
authenticate(java.lang.String username,
java.lang.String credentials)
Return the Principal associated with the specified username and credentials, if there is one; otherwise return null. |
java.security.Principal |
authenticate(java.lang.String username,
java.lang.String clientDigest,
java.lang.String nonce,
java.lang.String nc,
java.lang.String cnonce,
java.lang.String qop,
java.lang.String realm,
java.lang.String md5a2)
Return the Principal associated with the specified username, which matches the digest calculated using the given parameters using the method described in RFC 2069; otherwise return null. |
java.security.Principal |
authenticate(java.security.cert.X509Certificate[] certs)
Return the Principal associated with the specified chain of X509 client certificates. |
void |
backgroundProcess()
Execute a periodic task, such as reloading, etc. |
void |
destroy()
|
protected java.lang.String |
digest(java.lang.String credentials)
Digest the password using the specified algorithm and convert the result to a corresponding hexadecimal string. |
static java.lang.String |
Digest(java.lang.String credentials,
java.lang.String algorithm,
java.lang.String encoding)
Digest password using the algorithm specified and convert the result to a corresponding hex string. |
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. |
SecurityConstraint[] |
findSecurityConstraints(Request request,
Context context)
Return the SecurityConstraints configured to guard the request URI for this request, or null if there is no such constraint. |
java.lang.String |
getAllRolesMode()
Return the all roles mode. |
Container |
getContainer()
Return the Container with which this Realm has been associated. |
javax.management.ObjectName |
getController()
|
java.lang.String |
getDigest()
Return the digest algorithm used for storing credentials. |
protected java.lang.String |
getDigest(java.lang.String username,
java.lang.String realmName)
Return the digest associated with given principal's user name. |
java.lang.String |
getDigestEncoding()
Returns the digest encoding charset. |
java.lang.String |
getDomain()
|
java.lang.String |
getInfo()
Return descriptive information about this Realm implementation and the corresponding version number, in the format <description>/<version>. |
protected abstract java.lang.String |
getName()
Return a short name for this Realm implementation, for use in log messages. |
javax.management.ObjectName |
getObjectName()
|
protected abstract java.lang.String |
getPassword(java.lang.String username)
Return the password associated with the given principal's user name. |
protected abstract java.security.Principal |
getPrincipal(java.lang.String username)
Return the Principal associated with the given user name. |
protected java.security.Principal |
getPrincipal(java.security.cert.X509Certificate usercert)
Return the Principal associated with the given certificate. |
java.lang.String |
getRealmPath()
|
protected java.lang.String |
getRealmSuffix()
|
java.lang.String |
getType()
|
boolean |
getValidate()
Return the "validate certificate chains" flag. |
java.lang.String |
getX509UsernameRetrieverClassName()
Gets the name of the class that will be used to extract user names from X509 client certificates. |
protected boolean |
hasMessageDigest()
|
boolean |
hasResourcePermission(Request request,
Response response,
SecurityConstraint[] constraints,
Context context)
Perform access control based on the specified authorization constraint. |
boolean |
hasRole(java.security.Principal principal,
java.lang.String role)
Return true if the specified Principal has the specified
security role, within the context of this Realm; otherwise return
false. |
boolean |
hasUserDataPermission(Request request,
Response response,
SecurityConstraint[] constraints)
Enforce any user data constraint required by the security constraint guarding this request URI. |
void |
init()
|
static void |
main(java.lang.String[] args)
Digest password using the algorithm specified and convert the result to a corresponding hex string. |
void |
postDeregister()
|
void |
postRegister(java.lang.Boolean registrationDone)
|
void |
preDeregister()
|
javax.management.ObjectName |
preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
|
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component. |
void |
setAllRolesMode(java.lang.String allRolesMode)
Set the all roles mode. |
void |
setContainer(Container container)
Set the Container with which this Realm has been associated. |
void |
setController(javax.management.ObjectName controller)
|
void |
setDigest(java.lang.String digest)
Set the digest algorithm used for storing credentials. |
void |
setDigestEncoding(java.lang.String charset)
Sets the digest encoding charset. |
void |
setRealmPath(java.lang.String theRealmPath)
|
void |
setValidate(boolean validate)
Set the "validate certificate chains" flag. |
void |
setX509UsernameRetrieverClassName(java.lang.String className)
Sets the name of the class that will be used to extract user names from X509 client certificates. |
void |
start()
Prepare for the beginning of active use of the public methods of this component. |
void |
stop()
Gracefully terminate the active use of the public methods of this component. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Container container
protected Log containerLog
protected java.lang.String digest
null if no digesting should
be performed.
protected java.lang.String digestEncoding
protected static final java.lang.String info
protected LifecycleSupport lifecycle
protected java.security.MessageDigest md
protected static final MD5Encoder md5Encoder
protected static java.security.MessageDigest md5Helper
protected static StringManager sm
protected boolean started
protected java.beans.PropertyChangeSupport support
protected boolean validate
protected java.lang.String x509UsernameRetrieverClassName
protected X509UsernameRetriever x509UsernameRetriever
protected RealmBase.AllRolesMode allRolesMode
protected java.lang.String type
protected java.lang.String domain
protected java.lang.String host
protected java.lang.String path
protected java.lang.String realmPath
protected javax.management.ObjectName oname
protected javax.management.ObjectName controller
protected javax.management.MBeanServer mserver
protected boolean initialized
| Constructor Detail |
|---|
public RealmBase()
| Method Detail |
|---|
public Container getContainer()
getContainer in interface Realmpublic void setContainer(Container container)
setContainer in interface Realmcontainer - The associated Containerpublic java.lang.String getAllRolesMode()
public void setAllRolesMode(java.lang.String allRolesMode)
public java.lang.String getDigest()
public void setDigest(java.lang.String digest)
digest - The new digest algorithmpublic java.lang.String getDigestEncoding()
public void setDigestEncoding(java.lang.String charset)
charset - The charset (null for platform default)public java.lang.String getInfo()
<description>/<version>.
getInfo in interface Realmpublic boolean getValidate()
public void setValidate(boolean validate)
validate - The new validate certificate chains flagpublic java.lang.String getX509UsernameRetrieverClassName()
public void setX509UsernameRetrieverClassName(java.lang.String className)
className - The name of the class that will be used to extract user names
from X509 client certificates.X509UsernameRetrieverpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface Realmlistener - The listener to add
public java.security.Principal authenticate(java.lang.String username,
java.lang.String credentials)
null.
authenticate in interface Realmusername - Username of the Principal to look upcredentials - Password or other credentials to use in
authenticating this username
public java.security.Principal authenticate(java.lang.String username,
byte[] credentials)
null.
authenticate in interface Realmusername - Username of the Principal to look upcredentials - Password or other credentials to use in
authenticating this username
public java.security.Principal authenticate(java.lang.String username,
java.lang.String clientDigest,
java.lang.String nonce,
java.lang.String nc,
java.lang.String cnonce,
java.lang.String qop,
java.lang.String realm,
java.lang.String md5a2)
null.
authenticate in interface Realmusername - Username of the Principal to look upclientDigest - Digest which has been submitted by the clientnonce - Unique (or supposedly unique) token which has been used
for this requestrealm - Realm namemd5a2 - Second MD5 digest used to calculate the digest :
MD5(Method + ":" + uri)public java.security.Principal authenticate(java.security.cert.X509Certificate[] certs)
null.
authenticate in interface Realmcerts - Array of client certificates, with the first one in
the array being the certificate of the client itself.public void backgroundProcess()
backgroundProcess in interface Realm
public SecurityConstraint[] findSecurityConstraints(Request request,
Context context)
null if there is no such constraint.
findSecurityConstraints in interface Realmrequest - Request we are processingcontext - Context the Request is mapped to
public boolean hasResourcePermission(Request request,
Response response,
SecurityConstraint[] constraints,
Context context)
throws java.io.IOException
true if this constraint is satisfied and processing
should continue, or false otherwise.
hasResourcePermission in interface Realmrequest - Request we are processingresponse - Response we are creatingconstraints - Security constraint we are enforcingcontext - The Context to which client of this class is attached.
java.io.IOException - if an input/output error occurs
public boolean hasRole(java.security.Principal principal,
java.lang.String role)
true if the specified Principal has the specified
security role, within the context of this Realm; otherwise return
false. This method can be overridden by Realm
implementations, but the default is adequate when an instance of
GenericPrincipal is used to represent authenticated
Principals from this Realm.
hasRole in interface Realmprincipal - Principal for whom the role is to be checkedrole - Security role to be checked
public boolean hasUserDataPermission(Request request,
Response response,
SecurityConstraint[] constraints)
throws java.io.IOException
true if this constraint
was not violated and processing should continue, or false
if we have created a response already.
hasUserDataPermission in interface Realmrequest - Request we are processingresponse - Response we are creatingconstraints - Security constraint being checked
java.io.IOException - if an input/output error occurspublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface Realmlistener - The listener to removepublic void addLifecycleListener(LifecycleListener listener)
addLifecycleListener in interface Lifecyclelistener - The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners in interface Lifecyclepublic void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener in interface Lifecyclelistener - The listener to remove
public void start()
throws LifecycleException
start in interface LifecycleLifecycleException - if this component detects a fatal error
that prevents this component from being used
public void stop()
throws LifecycleException
stop in interface LifecycleLifecycleException - if this component detects a fatal error
that needs to be reportedpublic void destroy()
protected java.lang.String digest(java.lang.String credentials)
credentials - Password or other credentials to use in
authenticating this usernameprotected boolean hasMessageDigest()
protected java.lang.String getDigest(java.lang.String username,
java.lang.String realmName)
protected abstract java.lang.String getName()
protected abstract java.lang.String getPassword(java.lang.String username)
protected java.security.Principal getPrincipal(java.security.cert.X509Certificate usercert)
protected abstract java.security.Principal getPrincipal(java.lang.String username)
public static final java.lang.String Digest(java.lang.String credentials,
java.lang.String algorithm,
java.lang.String encoding)
credentials - Password or other credentials to use in
authenticating this usernamealgorithm - Algorithm used to do the digestencoding - Character encoding of the string to digestpublic static void main(java.lang.String[] args)
public javax.management.ObjectName getController()
public void setController(javax.management.ObjectName controller)
public javax.management.ObjectName getObjectName()
public java.lang.String getDomain()
public java.lang.String getType()
public java.lang.String getRealmPath()
public void setRealmPath(java.lang.String theRealmPath)
public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
throws java.lang.Exception
preRegister in interface javax.management.MBeanRegistrationjava.lang.Exceptionpublic void postRegister(java.lang.Boolean registrationDone)
postRegister in interface javax.management.MBeanRegistration
public void preDeregister()
throws java.lang.Exception
preDeregister in interface javax.management.MBeanRegistrationjava.lang.Exceptionpublic void postDeregister()
postDeregister in interface javax.management.MBeanRegistrationpublic void init()
protected java.lang.String getRealmSuffix()
|
Apache Tomcat 6.0.45 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||