|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.servicemix.jbi.jmx.PasswordAuthenticator
public class PasswordAuthenticator
Implementation of the JMXAuthenticator interface to be used on server side to
secure access to
JMXConnectorServers.
Usage:
JMXAuthenticator authenticator = new PasswordAuthenticator(new File("users.properties"));
Map environment = new HashMap();
environment.put(JMXConnectorServer.AUTHENTICATOR, authenticator);
JMXServiceURL address = new JMXServiceURL("rmi", "localhost", 0);
MBeanServer server = ...;
JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(address, environment, server);
The format of the users.properties file is that of a standard properties
file: java -cp mx4j-remote.jar mx4j.tools.remote.PasswordAuthenticatorand following the instructions printed on the console. The output will be a string that should be copy/pasted as the password into the properties file.
MessageDigest algorithm, and then by
Base64-encoding the resulting bytes.
String[] credentials = new String[2];
// The user will travel as clear text
credentials[0] = "user";
// You may send the password in clear text, but it's better to obfuscate it
credentials[1] = PasswordAuthenticator.obfuscatePassword("password");
Map environment = new HashMap();
environment.put(JMXConnector.CREDENTIALS, credentials);
JMXServiceURL address = ...;
JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
Note that
obfuscating the
passwords only works if the server side has been setup with the
PasswordAuthenticator. However, the PasswordAuthenticator can be used with
other JSR 160 implementations, such as Sun's reference implementation.
| Constructor Summary | |
|---|---|
PasswordAuthenticator(File passwordFile)
Creates a new PasswordAuthenticator that reads user/password pairs from the specified properties file. |
|
PasswordAuthenticator(InputStream is)
Creates a new PasswordAuthenticator that reads user/password pairs from the specified InputStream. |
|
| Method Summary | |
|---|---|
Subject |
authenticate(Object credentials)
|
static void |
main(String[] args)
Runs this class as main class to obfuscate passwords. |
static String |
obfuscatePassword(String password)
Obfuscates the given password using MD5 as digest algorithm |
static String |
obfuscatePassword(String password,
String algorithm)
Obfuscates the given password using the given digest algorithm. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PasswordAuthenticator(File passwordFile)
throws IOException
IOExceptionobfuscatePassword(java.lang.String)
public PasswordAuthenticator(InputStream is)
throws IOException
IOExceptionobfuscatePassword(java.lang.String)| Method Detail |
|---|
public static void main(String[] args)
throws Exception
ExceptionobfuscatePassword(java.lang.String,java.lang.String)public static String obfuscatePassword(String password)
obfuscatePassword(java.lang.String,java.lang.String)
public static String obfuscatePassword(String password,
String algorithm)
digested using the specified
algorithm, then the resulting bytes are Base64-encoded.
public Subject authenticate(Object credentials)
throws SecurityException
authenticate in interface JMXAuthenticatorSecurityException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||