String user = "XX";
String pwd = "XXX";
CustomCallbackHandler handler = new CustomCallbackHandler(user, pwd.toCharArray());
System.setProperty("java.security.auth.login.config", new File("/JAAS-login-modules.conf").getAbsolutePath() ); -->> in this file org.jboss.security.ClientLoginModule is configured in wildfly
LoginContext lc = new LoginContext("ClientLoginModule", new Subject(), handler);
lc.login(); -->> at this stage server call is happening in weblogic but not in wildfly.
Because of this following issues we are facing:
1. LoginContext.login() always return success irrespective of right or wrong credentials
2. Subject does not contains right roles
3. Subject.doAs(lc.getSubject(), previlegedAction); is always invoked, ideally this should only invoked if login is success.
we found some guide here, but ejb-security-jaas throws 404.
Looking for help ASAP.
Thanks,
Pankaj K.
AuthenticationConfiguration superUser = AuthenticationConfiguration.empty()
.setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("PLAIN")).useName(user)
.usePassword(pwd);
final AuthenticationContext authCtx = AuthenticationContext.empty().with(MatchRule.ALL, superUser);
AuthenticationContext.getContextManager().setThreadDefault(authCtx);
final Hashtable<String, String> jndiProperties = new Hashtable<>();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
jndiProperties.put(Context.PROVIDER_URL, "remote+http://localhost:8080");
try {
final Context context = new InitialContext(jndiProperties);
SecuredEJBRemote reference = (SecuredEJBRemote) context.lookup("ejb:test-ear/secured-ejb/SecuredEjb!"
+ SecuredEJBRemote.class.getName());
System.out.println("\n\n\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
System.out.println("Successfully called, caller principal " + reference.getSecurityInfo());
System.out.println("\nPrincipal has guest permission: " + reference.userMethod());
System.out.println("\nPrincipal has admin permission: " + reference.administrativeMethod());
} catch (Exception e) {
e.printStackTrace();
}