[英]Bypassing JConsole requirement for username/password - when using a Jaas custom login module with JMX to handle authorization and authentication
我正在使用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的用戶處理用戶驗證和主體設置,用於查詢單獨的授權邏輯以確定訪問級別。
我想要發生什么:
問題:
要在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)
題
要運行Jaas登錄模塊,我需要以下設置:
-Dcom.sun.management.jmxremote.authenticate=true
但是,這也會在JConsole中創建一個條件,其中必須在字段中打開用戶名和passowrd字段。
如果將其設置為false,則永遠不會調用loginmodule。
是否可以擴展特定實例的Jconsole功能,應用配置設置或啟用jaas登錄模塊而無需設置:
-Dcom.sun.management.jmxremote.authenticate=true
為了防止在以下突出顯示的以下字段中輸入用戶名和密碼的必要性:
我正在尋找類似於此處演示的解決方案。 但無需用戶輸入用戶名或密碼字段。
編輯:此外,澄清一下,這需要在不修改客戶端JCONSOLE的情況下完成,因此純粹使用服務器端更改和設置。
瀏覽此鏈接 。 特別參見案例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 /服務器
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.