com.sun.jmx.remote.opt.security
Class JMXPasswordAuthenticator

java.lang.Object
  extended by com.sun.jmx.remote.opt.security.JMXPasswordAuthenticator
All Implemented Interfaces:
JMXAuthenticator

public class JMXPasswordAuthenticator
extends Object
implements JMXAuthenticator

This class represents a username/password based implementation of the JMXAuthenticator interface.

The set of username/password pairs is passed either as a filename which denotes a properties file on disk, or directly as an instance of the Properties class. In both cases, the name of each property represents a username, and the value of the property is the associated password. Thus, any given username either does not exist in the properties or has exactly one password. The same password can be shared by several usernames.

If authentication is successful then an authenticated Subject filled in with a JMXPrincipal is returned. Authorization checks will then be performed based on this Subject.


Constructor Summary
JMXPasswordAuthenticator(Properties pwProps)
          Creates an instance of JMXPasswordAuthenticator and initializes it from the specified properties instance.
JMXPasswordAuthenticator(String pwFile)
          Creates an instance of JMXPasswordAuthenticator and initializes it from the specified properties file.
 
Method Summary
 Subject authenticate(Object credentials)
          Authenticate the MBeanServerConnection client with the given client credentials.
 void refresh()
          Refresh the set of username/password entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXPasswordAuthenticator

public JMXPasswordAuthenticator(String pwFile)
                         throws IOException
Creates an instance of JMXPasswordAuthenticator and initializes it from the specified properties file.

Parameters:
pwFile - name of the file which denotes a properties file on disk containing the username/password entries.
Throws:
IOException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.

JMXPasswordAuthenticator

public JMXPasswordAuthenticator(Properties pwProps)
Creates an instance of JMXPasswordAuthenticator and initializes it from the specified properties instance. This constructor makes a copy of the properties instance using its clone method and it is the copy that is consulted to check the username and password of an incoming connection. The original properties object can be modified without affecting the copy. If the refresh() method is then called, the authenticator will make a new copy of the properties object at that time.

Parameters:
pwProps - properties list containing the username/password entries.
Throws:
IllegalArgumentException - if pwProps is null.
Method Detail

authenticate

public Subject authenticate(Object credentials)
Authenticate the MBeanServerConnection client with the given client credentials.

Specified by:
authenticate in interface JMXAuthenticator
Parameters:
credentials - the user-defined credentials to be passed in to the server in order to authenticate the user before creating the MBeanServerConnection. This parameter must be a two-element String[] containing the client's username and password in that order.
Returns:
the authenticated subject containing a JMXPrincipal(username).
Throws:
SecurityException - if the server cannot authenticate the user with the provided credentials.

refresh

public void refresh()
             throws IOException

Refresh the set of username/password entries.

If this instance was created using the JMXPasswordAuthenticator(String) constructor to specify a file from which the entries are read, the file is re-read.

If this instance was created using the JMXPasswordAuthenticator(Properties) constructor then a new copy of the Properties object is made.

Throws:
IOException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.


Copyright © 2014 Terracotta, Inc.. All rights reserved.