Hi,

I append a small patch, including the necessary features to support basic
and digest authentication for the mx4j JMX http connector.

The way the http adaptor is initialized in JkMX.java today gives no
possibility to restrict access to it. Since the JMX console is very
powerful
I included code n JkMx.java to parse 3 additional configuration options
from jk2.properties to the connector:

mx.authMode
mx.authUser
mx.authPassword

The patch is very local and simple. It is based on the newest version of
JkMX.java. Thank for considering.

Rainer Jung

% diff -w -c JkMX.java.orig JkMX.java
*** JkMX.java.orig      Thu Jun 17 21:03:20 2004
--- JkMX.java   Sun Aug 29 14:16:35 2004
***************
*** 39,44 ****
--- 39,47 ----
      private boolean enabled=false;
      private int httpport=-1;
      private String httphost="localhost";
+     private String authmode="none";
+     private String authuser=null;
+     private String authpassword=null;
      private int jrmpport=-1;
      private String jrmphost="localhost";
      private boolean useXSLTProcessor = true;
***************
*** 86,91 ****
--- 89,118 ----
          return httphost;
      }
  
+     public void setAuthMode(String mode) {
+         authmode=mode;
+     }
+ 
+     public String getAuthMode() {
+         return authmode;
+     }
+ 
+     public void setAuthUser(String user) {
+         authuser=user;
+     }
+ 
+     public String getAuthUser() {
+         return authuser;
+     }
+ 
+     public void setAuthPassword(String password) {
+         authpassword=password;
+     }
+ 
+     public String getAuthPassword() {
+         return authpassword;
+     }
+ 
      /** Enable the MX4J JRMP internal adapter
       */
      public void setJrmpPort( int i ) {
***************
*** 162,167 ****
--- 189,205 ----
                      mserver.setAttribute(httpServerName, new Attribute("Host", 
httphost));
                  mserver.setAttribute(httpServerName, new Attribute("Port", new 
Integer(httpport)));
  
+                 if( authmode!=null  && ( "none".equals(authmode) || 
"basic".equals(authmode) || "digest".equals(authmode) ) )
+                     mserver.setAttribute(httpServerName, new 
Attribute("AuthenticationMethod", authmode));
+ 
+                 if( authuser!=null && authpassword!=null )
+                     mserver.invoke(httpServerName, "addAuthorization",
+                         new Object[] {
+                             authuser,
+                             authpassword},
+                         new String[] { "java.lang.String", "java.lang.String" });
+ 
+ 
                  if(useXSLTProcessor) {
                      ObjectName processorName = 
registerObject("mx4j.tools.adaptor.http.XSLTProcessor",
                                                            "Http:name=XSLTProcessor");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to