Many thanks for the detailed response! What is the type for the variable registry?
Many thanks for the detailed response! What is the type for the variable registry?
could not find a spring suitable class so:
and :Code:public interface AuthenticationRegistry { Authentication register(String key, Authentication authentication); Authentication remove(String key); }
Code:private Map<String,Authentication> registry = Collections.synchronizedMap(new HashMap<String,Authentication>()); public Authentication register(String key, Authentication authentication) { if(key == null){ key = authentication.getName(); } return registry.put(key, authentication); } public Authentication remove(String key) { return registry.remove(key); }
Confirming that the solution posted by wims.tijd involving spring-aop worked like a charm! Thank you wims.tijd you are a lifesaver.
Hi,
I am, trying to implement authentication for JMX accsess via Jconsole using JMXMP protocol.
I followed exactly the procedure and implemented a custom JMXAuthenticatorImpl.
My application did call the custom authenticator, but the argument 'credentials has only the URL.
They do not contain the username and password that was entered on the JConsole GUI.
What am I missing?
thanks
Srini
Hi Farrukh najim
Thanks for the reply.
The solution posted is using RMI protocol (JMX RMI).
p:serviceUrl="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/cycle"
But I am trying to use JMXMP protocol.
service:jmx:jmxmp://localhost:9998
When I followed the procedure suggested by wims.tijd by chaning protocol url, I am seeing some issues.
First, I do see that my custom JMXAuthenticatorImpl is geting called. But the credential object it is geting does not
contain user name or password. It contains only one element in the array, that is the URL.
Application started.
May 26, 2011 12:47:43 PM SocketConnectionServer accept
FINER: Waiting a new connection...
May 26, 2011 12:47:51 PM SocketConnection Constructor
FINER: Creating with a socket Socket[addr=/10.40.141.40,port=2412,localport=9998]
May 26, 2011 12:47:51 PM GenericConnectorServer Receiver.run
FINER: received connection request.
May 26, 2011 12:47:51 PM GenericConnectorServer Receiver.run
FINER: waiting for connection.
May 26, 2011 12:47:51 PM SynchroMessageConnectionServerImpl accept
FINER: Waiting a coming client...
May 26, 2011 12:47:51 PM SocketConnectionServer accept
FINER: Waiting a new connection...
May 26, 2011 12:47:51 PM SocketConnection connect
FINER: First time to connect to the server.
May 26, 2011 12:47:51 PM AdminServer connectionOpen
FINER: >>>>> Handshake Begin <<<<<
May 26, 2011 12:47:51 PM AdminServer connectionOpen
FINER: Server Supported Profiles [ null ]
May 26, 2011 12:47:51 PM AdminServer connectionOpen
FINER: Server JMXMP Version [ 1.0 ]
May 26, 2011 12:47:51 PM SocketConnection writeMessage
FINEST: Write a message ...
May 26, 2011 12:47:51 PM SocketConnection readMessage
FINEST: Read a message ...
May 26, 2011 12:47:51 PM AdminServer connectionOpen
FINER: >>>>> Handshake End <<<<<
May 26, 2011 12:47:51 PM AdminServer connectionOpen
FINER: Client Context Object [ [Ljava.lang.String;@109ea96 ]
*******Inside JMXAuthenticatorImpl******************
CLass Of credential obj=[Ljava.lang.Object;
Elements in the cred array=2
CLass Of credential obj=java.lang.String
name=jmxmp://lchi069094.prod.ad.merc.chicago.cme.com:2412 539419
password=null
When I looked at the source code of the implementation of com.sun.jmx.remote.opt.security.AdminServer that is calling my JMXAuthenticatorImpl
I see it is using something called connectionId to create credential object. AS anyone tried the authentication with JMXMP protocol?
thanks
Srini
Code:<bean id="jmx.client.connector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean" p:serviceUrl="service:jmx:rmi://localhost/jndi/rmi://localhost:1098/stock" p:environmentMap-ref="jmx.remote.environment.map" p:connectOnStartup="false" /> <util:map id="jmx.remote.environment.map"> <entry key-ref="jmx.remote.credentials" value="willem:willem"/> </util:map> <util:constant id="jmx.remote.credentials" static-field="javax.management.remote.JMXConnector.CREDENTIALS"/>
In this article I present guide how to obligate a simple MBean which allows users to alter the aim of a Log4j logger at runtime without the essential to preserve the effort.
The Spring design has transformed only slightly from my previous article to serve testing; the nub remains the identical tho'.
Pontiac Power Steering Gear Box
Working configuration:
Code:<util:map id="jmx.environment"> <entry key="com.sun.management.jmxremote.authenticate" value="true"/> <entry key="jmx.remote.x.password.file" value="[Absolute path to file with 600 permissions] "/> </util:map> <bean depends-on="mbeanServer" id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" p:objectName="connector:name=slpRMIConnector" p:serviceUrl="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myConnector" p:environmentMap-ref="jmx.environment" />
jmx.remote.x.password.file property is used in javax.management.remote.rmi.RMIServerImpl.doNewCli ent() method as follows:
Code:RMIConnection doNewClient(Object credentials) throws IOException { ... Subject subject = null; JMXAuthenticator authenticator = (JMXAuthenticator) env.get(JMXConnectorServer.AUTHENTICATOR); if (authenticator == null) { /* * Create the JAAS-based authenticator only if authentication * has been enabled */ if (env.get("jmx.remote.x.password.file") != null || env.get("jmx.remote.x.login.config") != null) { authenticator = new JMXPluggableAuthenticator(env); } } if (authenticator != null) { if (tracing) logger.trace("newClient","got authenticator: " + authenticator.getClass().getName()); try { subject = authenticator.authenticate(credentials); } catch (SecurityException e) { logger.trace("newClient", "Authentication failed: " + e); throw e; } } ... }
Regards,
Maciej