如何Java的LoginContext.login()工作? [英] How does java LoginContext.login() work?

查看:1530
本文介绍了如何Java的LoginContext.login()工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code创建一个Java客户端的配置连接到JBoss应用服务器:

I have this code to create a configuration of a java client to connect to a JBoss application server:

System.setProperty( "java.security.auth.login.config", "auth.conf" );
LoginContext auth = new LoginContext( "myAuth", 
    new LoginCallbackHandler( username, password ) );
auth.login();

文件 auth.conf 包含以下行:

myAuth {
    org.jboss.security.ClientLoginModule required;
};

现在,在code别的地方(LoginContext的 AUTH 不知道那里)我有一个做一个EJB 的InitialContext .lookup(jndiName)窄()到JBoss应用服务器上访问一个Bean。这仅在第一步的登录信息是正确的成功。

Now, somewhere else in the code (the LoginContext auth isn't known there) I have an EJB that does a initialContext.lookup( jndiName ) and a narrow() to access a Bean on the JBoss application server. This narrow only succeeds if the login information of the first step was correct.

如何将登录信息从 LoginContext的传播到窄()?我看不出这两个地方之间的任何连接。

How does the login information propagate from the LoginContext to the narrow()? I don't see any connection between these two places.

和进一步的,我怎么可以做一个客户端内两个或两个以上不同的登录?

And further, how could I do two or more different logins inside of one client?

推荐答案

我发现在的 JBoss文档(章8.4.1)

登录()通话只绑定到客户端的JBoss的EJB层的名称和密码。所有后续的EJB调用将使用这些凭据并将其传递给调用的EJB方法。

The login() call only binds the name and password to the JBoss EJB layer of the client. All subsequent EJB calls will use these credentials and pass them to the called EJB method.

这篇关于如何Java的LoginContext.login()工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆