【发布时间】:2012-02-23 21:20:44
【问题描述】:
我想安全地访问 EJB。
我正在开发一个eclipse rcp 应用程序,我想连接到一个有一些EJBs 安全的glassfish 3.1.1 服务器,我想使用Java EE 6 security 连接到那个EJBs
我发现了这样的东西:
ProgrammaticLogin pm = new ProgrammaticLogin();
pm.login(usernameText.getText(), passwordText.getText());
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
// optional. Defaults to localhost. Only needed if web server is running on a different host than the appserver
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// optional. Defaults to 3700. Only needed if target orb port is not 3700.
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
try
{
Context ctx = new InitialContext(props);
}
catch (NamingException e)
{
e.printStackTrace();
}
我包含了所有来自 glassfish appclient.jar glassfish3/glassfish/bin/package-appclient的jars
错误示例:
SEVERE: SEC9050: Programmatic login failed
com.sun.enterprise.security.auth.login.common.LoginException: javax.security.auth.login.LoginException: No LoginModules configured for default
at com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:889)
...
您知道如何使用桌面应用程序的任何方法安全地登录EJBs 吗?
我的参考资料:
如果你知道答案..你能不能给我举个例子?
提前谢谢你!
【问题讨论】:
-
我知道它很旧,但你的问题是,代码在
login.conf文件中寻找“默认”,这里可能指定了很多,如果你不指定,代码尝试找到一个条目“默认”如下所示。deafult { com.sun.enterprise.security.auth.login.FileLoginModule required; };但是您的配置没有用于验证用户身份的条目。在独立版中,您还需要添加System.setProperty("java.security.auth.login.config", authFile);以帮助您的代码找到配置文件。
标签: jakarta-ee ejb eclipse-rcp glassfish-3