mx4j.tools.remote
public class PasswordAuthenticator extends Object implements JMXAuthenticator
javax.management.remote.JMXConnectorServer JMXConnectorServer
s. 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.
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.
Version: $Revision: 1.3 $
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. Obfuscation consists of 2 steps: first the clear text password is java.security.MessageDigest#digest digested
using the specified algorithm, then the resulting bytes are Base64-encoded.For example, the obfuscated version of the password "password" is "OBF(MD5):X03MO1qnZdYdgyfeuILPmQ==" or "OBF(SHA-1):W6ph5Mm5Pz8GgiULbPgzG37mj9g=". |
See Also: PasswordAuthenticator
See Also: PasswordAuthenticator
See Also: PasswordAuthenticator
See Also: PasswordAuthenticator
java.security.MessageDigest#digest digested
using the specified algorithm, then the resulting bytes are Base64-encoded.