如何Java的LoginContext.login()工作? [英] How does java LoginContext.login() work?
问题描述
我有这样的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屋!