EJB3的安全机制在JBOSS5中的改变,默认安全域other
@org.jboss.security.annotation.SecurityDomain was for AS-4.x. That annotation has been moved to @org.jboss.ejb3.annotation.SecurityDomain in AS-5.x and later.
JBOSS4 SecurityDomain -->@org.jboss.security.annotation.SecurityDomain
JBOSS5 SecurityDomain -->@org.jboss.ejb3.annotation.SecurityDomain
在Client端
prop.setProperty(Context.PROVIDER_URL, "192.168.1.118:1099"); prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); prop.setProperty(Context.SECURITY_PRINCIPAL, "name"); prop.setProperty(Context.SECURITY_CREDENTIALS, "pwd"); InitialContext ctx = new InitialContext(prop);
prop.setProperty(Context.PROVIDER_URL, "192.168.1.118:1099"); prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); SecurityClient securityClient = SecurityClientFactory.getSecurityClient(); securityClient.setSimple("name", "pwd"); securityClient.login(); InitialContext ctx = new InitialContext(prop);
由于手上找的资料都是JBOSS4的,今天在JBOSS5中按照4的方法去配置,发现怎么都不会成功
会报一个Caller unauthorized的异常,最后终于在老外的一些论坛中找到了原因,抓狂了一个下午
参考地址