Hello,
I've started a ejb application with maven and wanted to try the Tomee
container for it but I am having difficulties with the Jaas configuration.
I've override the server.xml file from tomee/conf folder so it will have my
realm like this:
server.xml
....
<Realm appName="CaponeJaas" className="org.apache.catalina.realm.JAASRealm"
roleClassNames="ro.asf.capone.server.jaas.RolePrincipal"
userClassNames="ro.asf.capone.server.jaas.UserPrincipal"/>
....
in a login.conf file i've added the mapping to the java class that located
in the ear
login.conf
....
CaponeJaas {
ro.asf.capone.server.jaas.CustomLoginModule required debug=true;
};
....
The login module is taken from
http://blog.sixthpoint.com/jaas-login-module-in-tomcat-7-example-part-1/
<http://blog.sixthpoint.com/jaas-login-module-in-tomcat-7-example-part-1/>
I've added the MAVEN_OPTS to pickup the login.conf with an absolute path:
export
MAVEN_OPTS="-Djava.security.auth.login.config=/home/daniel.jipa/workspace_agency/agency/agency-ear/src/main/tomee/conf/login.conf
-Xmx1024m -Xms1024m -XX:MaxPermSize=512m
-agentlib:jdwp=transport=dt_socket,address=5577,server=y,suspend=n"
The client side looks like this:
public static void main(String[] args) throws NamingException {
InitialContext ctx = null;
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.SECURITY_PRINCIPAL, "test");
env.put(Context.SECURITY_CREDENTIALS,
"c4ca4238a0b923820dcc509a6f75849b");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
env.put(Context.PROVIDER_URL,
"http://localhost:8080/tomee/ejb");
env.put("openejb.ejbd.authenticate-with-request", "true");
// env.put("openejb.authentication.realmName", "CaponeJaas");
try {
ctx = new InitialContext(env);
System.out.println(ctx);
} catch (NamingException e) {
e.printStackTrace();
}
String jndi =
"global/agency-ear/agency-ejb/AccountControllerBean!ro.asf.capone.server.ejb.account.AccountControllerRemote";
AccountControllerRemote remote = (AccountControllerRemote)
ctx.lookup(jndi);
System.out.println(">remote" + remote);
System.out.println(">>>" + remote.getPersonTypes());
But I get an error on the server side:
SEVERE: Unexpected error
javax.security.auth.login.LoginException: No LoginModules configured for
CaponeJaas
at javax.security.auth.login.LoginContext.init(LoginContext.java:264)
at javax.security.auth.login.LoginContext.<init>(LoginContext.java:512)
FINE: EJB REQUEST: EJBRequest{deploymentId='AccountControllerBean',
type=EJB_OBJECT_BUSINESS_METHOD, Body{ejb=null, orb=null,
methodInstance=public abstract java.util.List
ro.asf.capone.server.ejb.account.AccountController.getPersonTypes(),
interfaceClass=interface
ro.asf.capone.server.ejb.account.AccountControllerRemote,
methodName='getPersonTypes', methodParamTypes=[], methodParameters=[],
primaryKey=null, requestId='null', version=2}} -- RESPONSE:
UNKNOWN_RESPONSE, serverTime=17203376196136ns, containerTime3048702ns :
javax.security.auth.login.CredentialNotFoundException: test
--
View this message in context:
http://tomee-openejb.979440.n4.nabble.com/Jaas-issue-with-Maven-Tomee-plugin-tp4676308.html
Sent from the TomEE Users mailing list archive at Nabble.com.