I want to access EJBs with security..
I am developing an eclipse rcp application and I want to connect to a glassfish 3.1.1 server that has some EJBs secured and I want to connect to that EJBs using Java EE 6 security
I found something like this:
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();
}
I included all jars from glassfish appclient.jar glassfish3/glassfish/bin/package-appclient
Example errors:
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)
...
Do you know how to securely login to EJBs using any method for a desktop application?
My references:
If you know the answer.. can you, please, provide me examples?
Thank you in advance!
You might try making the pm.login call after context initialization.
I know this question is old, but I stumbled across it after encountering the same error, and would have appreciated a solution.
I had code comparable to the following:
Simply re-ordering it as below solved the problem:
The idea being, at least as I understand my case, that the server/my connection to the server hadn’t yet been initialized, and thus was unable to handle the login.