我使用JConsole的訪問正在運行一個MBean。繞過用戶名/密碼JConsole的需求 - 使用JAAS自定義登錄模塊時使用JMX處理授權和認證
的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;
};
然後用戶將通過登錄通過訪問此正在運行的進程h命令行中的JConsole。
jconsole -debug //or just jconsole
用戶選擇「遠程連接」,具有RemoteProcess「本地主機:1234」
登錄模塊處理基於當前登錄到Windows用戶,這是用於將用戶驗證和主體的設定查詢單獨的授權邏輯以確定訪問級別。
我想什麼發生:
- 用戶enteres JConsole的進入CMD
- JConsole窗口中打開。
- 用戶輸入過程的地址例如「本地主機:1234」
- 用戶不輸入用戶名或密碼(因爲這不是必需的授權由自定義JAAS登錄模塊處理)。
- 模塊確定用戶是否具有讀寫,只讀或無訪問。打開
- 過程JConsole的窗口,或登錄失敗。
的問題:
要訪問JMX過程在JConsole窗口我必須輸入一個虛擬用戶名和密碼,例如U:一,P:一,否則我得到以下錯誤:
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中創建一個條件,其中用戶名和密碼字段必須在該字段中打開。
如果設置爲false,登錄模塊不會被調用。
是否有可能無需設置任何延長JConsole的功能的特定情況下,應用配置設置,或啓用JAAS登錄模塊:
-Dcom.sun.management.jmxremote.authenticate=true
爲了防止進入的必要性在以下領域的用戶名和密碼,下面重點介紹:
我在尋找一個類似的解決方案證明here。但不需要用戶輸入用戶名或密碼字段。
編輯:此外,爲了澄清,這將需要完成而無需修改客戶端JCONSOLE,所以通過純粹使用服務器端的更改和設置。
謝謝你,但是,我的問題是專門關於修改用戶的JConsole的需要關於要求的輸入。案例研究重點關注JaasLoginModule和客戶端代碼。 – Loco234
請不要鏈接只有鏈接可能會中斷的答案。 – NathanOliver
Re:編輯。 我很好奇是否有更直接的方法來解決這個問題,因爲使用Jaas登錄模塊是相當常見的需求。使用Jconsole中的字段限制用戶和密碼憑證輸入似乎很奇怪。 我的直接想法是在設置com.sun.management.jmxremote.authenticate = false時指向jaas配置文件。 上下文生成由在loginmodule中調用的單獨腳本處理,有效地繞過了需要檢查用戶憑據的需求,因爲它們將基於當前登錄的用戶。 – Loco234