|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.web.authenticate.OpenNMSTomcatRealm
Implements the interface to allow Tomcat to check our users.xml file to authenticate users.
This class is Tomcat-specific and will not be portable to other servlet containers. It relies on packages supplied with Tomcat.
Field Summary | |
protected org.apache.catalina.Container |
container
The Container with which this Realm is associated. |
protected java.lang.String |
HOME_DIR
The relative path to find the users.xml file |
protected java.lang.String |
info
Descriptive information about this Realm implementation. |
protected org.apache.log4j.Category |
log
The Log4J category for logging web authentication messages. |
protected java.util.Map |
magicRoleMapping
A mapping of special roles to authorized users. |
protected java.io.File |
magicUsersFile
The magic-users.properties file that is read for the list of special users, their passwords, and authorization roles. |
protected long |
magicUsersLastModified
The time (in milliseconds) that the magic-users.properties file was last modified. |
protected static java.lang.String |
name
Descriptive information about this Realm implementation. |
protected java.util.HashMap |
principals
The set of valid Principals for this Realm, keyed by user name. |
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
Convenient support for PropertyChangeEvents. |
Constructor Summary | |
OpenNMSTomcatRealm()
Create a new instance. |
Method Summary | |
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 digest,
java.lang.String nonce,
java.lang.String nc,
java.lang.String cnonce,
java.lang.String qop,
java.lang.String realm,
java.lang.String md5a2)
Not implemented. |
java.security.Principal |
authenticate(java.security.cert.X509Certificate[] certs)
Not implemented. |
org.apache.catalina.Container |
getContainer()
Return the Container with which this Realm has been associated. |
java.lang.String |
getInfo()
Return descriptive information about this Realm implementation and the corresponding version number, in the format <description>/<version> . |
boolean |
hasRole(java.security.Principal principal,
java.lang.String role)
Returns true for any specified user if the role is Authentication.USER_ROLE , and will
additionally return true for the admin user if the role is
Authentication.ADMIN_ROLE . |
protected boolean |
isParseNecessary()
Checks the last modified time of the user and magic users files against the last known last modified time. |
protected void |
parse()
Convenience method for parsing the users.xml file. |
protected java.util.Map[] |
parseMagicUsers()
Parses the magic-users.properties file into two mappings: from magic username to password, and from magic role to authorized users of that role. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component. |
void |
setContainer(org.apache.catalina.Container container)
Set the Container with which this Realm has been associated. |
void |
setHomeDir(java.lang.String homeDir)
Called by tomcat to set the home directory where the app is running from and to handle the userFile attribute in the Realm tag in the server.xml file. |
void |
setUserFile(java.lang.String filename)
Deprecated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String HOME_DIR
protected org.apache.catalina.Container container
protected final java.lang.String info
protected static final java.lang.String name
protected java.util.HashMap principals
protected java.beans.PropertyChangeSupport propertyChangeSupport
protected java.io.File magicUsersFile
protected long magicUsersLastModified
protected org.apache.log4j.Category log
protected java.util.Map magicRoleMapping
List
value of authorized user names.
Constructor Detail |
public OpenNMSTomcatRealm()
Method Detail |
protected void parse()
This method is synchronized so only one thread at a time can parse the
users.xml file and create the principal
instance variable.
public org.apache.catalina.Container getContainer()
getContainer
in interface org.apache.catalina.Realm
public void setContainer(org.apache.catalina.Container container)
setContainer
in interface org.apache.catalina.Realm
container
- The associated Containerpublic java.lang.String getInfo()
<description>/<version>
.
getInfo
in interface org.apache.catalina.Realm
public java.security.Principal authenticate(java.lang.String username, java.lang.String credentials)
null
.
authenticate
in interface org.apache.catalina.Realm
username
- Username of the Principal to look upcredentials
- Password or other credentials to use in authenticating this
usernamepublic java.security.Principal authenticate(java.lang.String username, byte[] credentials)
null
.
authenticate
in interface org.apache.catalina.Realm
username
- Username of the Principal to look upcredentials
- Password or other credentials to use in authenticating this
usernamepublic java.security.Principal authenticate(java.lang.String username, java.lang.String digest, java.lang.String nonce, java.lang.String nc, java.lang.String cnonce, java.lang.String qop, java.lang.String realm, java.lang.String md5a2)
authenticate
in interface org.apache.catalina.Realm
java.lang.IllegalStateException
- because this method is not implemented.public java.security.Principal authenticate(java.security.cert.X509Certificate[] certs)
authenticate
in interface org.apache.catalina.Realm
java.lang.IllegalStateException
- because this method is not implemented.public boolean hasRole(java.security.Principal principal, java.lang.String role)
Authentication.USER_ROLE
, and will
additionally return true for the admin user if the role is
Authentication.ADMIN_ROLE
. Otherwise
this method returns false.
Note that no logging takes place in this method because it is called very frequently. Logging messages here could greatly reduce page-serving performance and would quickly flood the server logs with not very useful information.
hasRole
in interface org.apache.catalina.Realm
principal
- role
- role to be checkedpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface org.apache.catalina.Realm
listener
- The listener to addpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface org.apache.catalina.Realm
listener
- The listener to removepublic void setUserFile(java.lang.String filename)
public void setHomeDir(java.lang.String homeDir)
protected boolean isParseNecessary()
Note that the lastModified
variables are not set here.
This is in case there is a problem parsing either file. If we set the
value here, and then try to parse and fail, then we will not try to parse
again until the file changes again. Instead, when we see the file
changes, we continue parsing attempts until the parsing succeeds.
protected java.util.Map[] parseMagicUsers() throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |