请教:Jboss jaas 进行安全性验证在ejb3中

最近在研究jaas
我配置了
jboss-web.xml
<jboss-web>
<security-domain>java:/jaas/iOffice</security-domain>
</jboss-web>
login-config.xml
<application-policy name = "iOffice">
<authentication>
<login-module code ="ioffice.pub.auth.loginmodule.iOfficeLoginModule" flag = "required" />
</authentication>
</application-policy>
以及login.config文件
iOffice {
// A properties file LoginModule that supports CallerPrincipal mapping
org.jboss.security.ClientLoginModule required unauthenticatedIdentity=nobody;
};
我在 EJB3中进行测试
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
props.put(Context.PROVIDER_URL, "jnp://localhost:1099");

iOfficeCallbackHandler handler = new iOfficeCallbackHandler(
"admin@ben.ioe.cn", "admin".toCharArray());


LoginContext lc = new LoginContext("iOffice", (CallbackHandler) handler);
lc.login();
InitialContext ctx = new InitialContext(props);

basic = (PublicBasic) ctx.lookup("PublicBasicBean/remote");


在PublicBasicBean中
@Stateless
@Remote(PublicBasic.class)
@SecurityDomain("iOffice")
public class PublicBasicBean implements PublicBasic {
@RolesAllowed({ "BasicUser", "DomainAdministrator", "PowerUser" })
public java.util.Collection getPrivateContacts() {
try {
return xxx....
} catch (Exception e) {

}
}
}
为什么出现
javax.ejb.EJBAccessException: Caller unauthorized
at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:199)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)
at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
希望高手能给解决一下,并给讲讲jaas
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值