ClientLoginServlet JBoss example - does it work ?
pdhar Oct 31, 2002 12:51 AMHi,
I am using jboss-3.0.2_tomcat-4.0.4. and implemented a
unsecured servlet which will call a secured Stateless Session Bean. Also I have the similar secured servlet using JAAS Authentication-FormLogin calling the EJB. The secured servlet using the FormLogin can call the secured EJB and works while the unsecured servlet using LoginContext.login() is not able to execute the session bean methods.
I am using the ClientLoginServlet.java example from the Jboss source code.
private LoginContext doLogin(String username, String password)
throws LoginException {
UsernamePasswordHandler handler =
new UsernamePasswordHandler(username, password.toCharArray());
LoginContext lc = new LoginContext("IDSCONF-REALM", handler);
lc.login();
return lc;
}
UNSECURED -
try {
lc = doLogin("admin", "admin22");
log.info("Login Successful");
InstanceConfigSvcDelegate ic = new InstanceConfigSvcDelegate(); // calls the remote interface using delegate
String[] ins = ic.getAllInstances();
for (int i = 0; i < ins.length; i++) {
out.println(ins + "");
}
} catch (LoginException e) {
e.printStackTrace(out);
} catch (InstanceConfigException e) {
e.printStackTrace(out);
} finally {
if (lc != null) {
try {
lc.logout();
} catch (LoginException e) {
}
}
}
The problem I am getting is shown below although I have users.properties/roles.properties in WEB-INF/classes directory which work well with a secured servlet calling a secured session bean.
22:36:13,947 INFO [idsconfServlet] Login Successful
22:36:13,968 ERROR [UsersRolesLoginModule] Failed to load users/passwords/role files
java.io.IOException: Properties file users.properties not found
at org.jboss.security.auth.spi.UsersRolesLoginModule.loadProperties(UsersRolesLoginModule.java:212)
at org.jboss.security.auth.spi.UsersRolesLoginModule.loadUsers(UsersRolesLoginModule.java:193)
at org.jboss.security.auth.spi.UsersRolesLoginModule.initialize(UsersRolesLoginModule.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
I would like to know if anyone has come across this situation and know any workarounds.
Thanks,
Pranab