Hybrid JAAS for Glassfish

The jkniv-jaas-glassfish implements a hybrid realm for authentication and authorization model from JavaTM Authentication and Authorization Service to Glassfish server.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
  <groupId>net.sf.jkniv</groupId>
  <artifactId>jkniv-jaas-glassfish</artifactId>
  <version>0.3.1</version>
</dependency>

Configure Custom Realm for Glassfish

  • Copy the jar file jkniv-jaas-glassfish.jar to domain lib glass-install/glassfish4/glassfish/domains/domain1/lib from glassfish.

  • Edit the file glass-install/glassfish4/glassfish/domains/domain1/config/login.conf to config the hybridRealm. The name hybridRealm must be the same value for jaas-context at Hybrid Realm Properties.

hybridRealm {
  net.sf.jkniv.jaas.gf.HybridLoginModule required;
};
  • Restart glassfish.

  • Enter into glassfish console to config the custom realm and add new realm.

Glassfish realm properties

  • Add the properties conform your database and ldap properties. The realm name must be the same used at <login-config> from web.xml, and class name must be net.sf.jkniv.jaas.gf.HybridRealm.

Glassfish realm properties

  • Sample entry at glass-install/glassfish4/glassfish/domains/domain1/config/domain.xml:

  • Sample web.xml from web application
<login-config>
  <auth-method>FORM</auth-method>
  <realm-name>acme-realm</realm-name>
  <form-login-config>
    <form-login-page>/login.html</form-login-page>
    <form-error-page>/error.html</form-error-page>
  </form-login-config>
</login-config>