I am trying to create a custom realm and login module for Glassfish 4.
I followed the procedure outlined in The glassfish 4 Application Development Guide p. 4-6, "Creating a Custom Realm".
I also followed the steps in this article.
I created a loginModule that extends com.sun.appserv.security.AppservPasswordLoginModule.
I created a realm (SaltRealm) that extends com.sun.appserv.security.AppservRealm.
I compile to a jar, and placed the jar in glassfish4\glassfish\domains\domain1\lib.
I added this to \glassfish4\glassfish\domains\domain1\config\login.conf:
saltRealm {
com.example.LoginModule required;
};
I added to \glassfish4\glassfish\domains\domain1\config\domain.xml:
<auth-realm classname="com.example.SaltRealm" name="saltRealm">
<property name="jaas-context" value="saltRealm"></property>
</auth-realm>
And I added a section in web.xml to use saltRealm.
<login-config>
<auth-method>FORM</auth-method>
<realm-name>saltRealm</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/error.xhtml</form-error-page>
</form-login-config>
</login-config>
It looks like the saltRealm class is found (I can tell that the constructor runs).
However, it seems that the login module is not found. I get this warning:
WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Invalid null input: name
I'm not sure what I'm missing here.