我正在使用JConsole访问正在运行的MBean .
MBean使用自定义Jaas登录模块,并使用以下命令运行:
java -classpath UserLGUGroupHandlingApplication.jar;MBeanSecure.jar
-com.sun.management.jmxremote.login.config=management.properties
-Djava.security.auth.login.config=./sample_jaas.config
com.test.running.RunningImplementation
management.properties文件看起来像这样:
com.sun.management.jmxremote.access.file=jmxremote.access
com.sun.management.jmxremote=true
com.sun.management.jmxremote.authenticate=true
com.sun.management.jmxremote.port=1234
com.sun.management.jmxremote.login.config=Sample
com.sun.management.jmxremote.ssl=false
com.sun.management.jmxremote.ssl.need.client.auth=false
和sample_jaas.config:
Sample {
test.module.AETTLoginModule required debug=true;
};
然后,用户将通过命令行中的JConsole登录来访问此运行进程 .
jconsole -debug //or just jconsole
用户选择“远程连接”,使用RemoteProcess'localhost:1234'
loginmodule根据当前登录到Windows的用户处理用户验证和主体设置,用于查询单独的授权逻辑以确定访问级别 .
What I want to happen:
-
用户将jconsole输入cmd
-
jconsole窗口打开 .
-
用户输入过程的地址,例如"localhost:1234"
-
用户不输入用户名或密码(因为授权由自定义jaas登录模块处理,因此不需要) .
-
Module确定用户是否具有readwrite,readonly或no access .
-
进程的Jconsole窗口打开,或登录失败 .
The Issue:
要在jconsole窗口中访问jmx进程,我必须输入一个虚拟用户名和密码,例如U:a,P:a,否则我收到以下错误:
java.lang.SecurityException: Authentication failed! Credentials required
at com.sun.jmx.remote.security.JMXPluggableAuthenticator.authenticationFailure(JMXPluggableAuthenticator.java:193)
at com.sun.jmx.remote.security.JMXPluggableAuthenticator.authenticate(JMXPluggableAuthenticator.java:145)
at sun.management.jmxremote.ConnectorBootstrap$AccessFileCheckerAuthenticator.authenticate(ConnectorBootstrap.java:201)
at javax.management.remote.rmi.RMIServerImpl.doNewClient(RMIServerImpl.java:213)
at javax.management.remote.rmi.RMIServerImpl.newClient(RMIServerImpl.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:303)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2327)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:277)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:225)
at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:334)
at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:296)
at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:280)
Question
要运行Jaas登录模块,我需要以下设置:
-Dcom.sun.management.jmxremote.authenticate=true
但是,这也会在JConsole中创建一个条件,其中必须在字段中打开用户名和passowrd字段 .
如果将其设置为false,则永远不会调用loginmodule .
是否可以扩展特定实例的Jconsole功能,应用配置设置或启用jaas登录模块而无需设置:
-Dcom.sun.management.jmxremote.authenticate=true
为了防止在以下突出显示的以下字段中输入用户名和密码的必要性:
我正在寻找类似于here的解决方案 . 但无需用户输入用户名或密码字段 .
编辑:此外,澄清一下,这需要在不修改客户端JCONSOLE的情况下完成,因此纯粹使用服务器端更改和设置 .
3 回答
仔细阅读link . 特别参见案例3,它可能会对您有所帮助 .
对问题进行更多澄清后更多更新************
基本上你想要实现的是绕过(JAAS提供的)特定客户端连接的安全性,在你的情况下是JCONSOLE ....我建议: - 1)为JMX服务器提供两个端口:安全和非安全 . ..使用JCONSOLE的非安全端口,或
2)如果您正在编写自己的自定义JAAS模块,请尝试编写以在login()方法中跳过特定客户端的连接 - 我不确定这是否可行,因为您如何知道请求客户端的上下文...
试试这个 :
https://blogs.oracle.com/alanb/entry/one_password_to_rule_them假设以下不是您想要的(基于@ ag112的回答)
-J-Djmx.remote.x.password.file = / path / to / file / jmx.password然后将你的用户名/凭证和空格放在那里 .
我必须在下面的笔记中添加另一个答案:
导航到要远程连接的服务器实例(无用户ID /密码) . 导航服务器实例'server.xml' . 寻找标签,你可能会发现如下
如果在服务器实例中配置了它,则可以在不进行任何访问的情况下监视它:
使用以下连接字符串访问远程进程的Jconsole .
服务:JMX:RMI://10.10.10.11:8082 / JNDI / RMI://10.10.10.11:8081 /服务器