2012-12-13 29 views
3

我试图连接到JBoss MBean,但由于身份验证失败而被阻止。远程连接到JBoss 4.2.3的身份验证

 Hashtable<String, String> env = new Hashtable<String, String>(); 
     env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); 
     env.put(Context.PROVIDER_URL, "jnp://"+testIP+":"+testPort); 
     env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); 

     env.put(Context.SECURITY_PRINCIPAL, "admin"); 
     env.put(Context.SECURITY_CREDENTIALS, "admin"); 

     InitialContext ic = new InitialContext(env); 
     RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor"); 
     // Get the MBeanInfo for the JNDIView MBean 
     ObjectName name = new ObjectName("my.service:service=MyBean"); 
     MBeanInfo info = server.getMBeanInfo(name);   

一切似乎都在连接,直到最后一行的方面表现得很好,当我得到:

java.lang.SecurityException: Failed to authenticate principal=null, securityDomain=jmx-console 
at org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:97) 
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) 
at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:179) 
: 
: 

的安全域配置为使用JAAS(在JMX-调用-service.xml中) :

<interceptor code="org.jboss.jmx.connector.invoker.AuthenticationInterceptor" 
       securityDomain="java:/jaas/jmx-console"/> 

并且用户在jmx-console-users.properties中正确定义。

在我看来,校长根本没有被正确阅读。 JBoss是否使用Context.SECURITY_PRINCIPAL/CREDENTIALS以外的内容?它从Their Naming Documentation出现,他们没有,但为什么这是失败呢?

非常感谢,

-C

回答

1

尝试设置你喜欢这个初始上下文工厂:

env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory"); 
+1

感谢尼古拉。这是我需要的暗示。不幸的是,使用该上下文工厂在客户端需要一些额外的配置文件。在试图找出需要什么的时候,我发现另一个上下文工厂插入并且似乎按照期望行事:'org.jboss.security.jndi.JndiLoginInitialContextFactory' – cneller

+0

我正要建议下一个... :) – Nicholas