users@glassfish.java.net

Custom Authentication Realm Login Module Not Found

From: <glassfish_at_javadesktop.org>
Date: Fri, 15 Feb 2008 10:10:44 PST

Trying to create a custom authentication realm on glassfish-v2ur1-b09d. Although much of the documentation available is either wrong or contradictory, I have:

1. Created a LoginModule, com.swstrings.jaas.SWSPasswordLoginModule which extends com.sun.appserv.security.AppservPasswordLoginModule.
2. Created a Realm, com.swstrings.jaas.SWSRealm which extends com.sun.appserv.security.AppservRealm.
3. Put the jar with relevant class files in <glassfish_home>/lib.
4. Created a custom realm, swsRealm with classname com.swstrings.jaas.SWSRealm and properties auth-type=swsRealm, jaas-context=swsRealm.
5. Added the entry:
swsRealm {
        com.swstrings.jaas.SWSPasswordLoginModule required;
};
to login.conf.
6. Added sun-application.xml with:
<realm>swsRealm</realm>
to my web application.
7. Restarted the app server.

I see the appserver load the realm:
[#|2008-02-15T10:07:18.454-0700|FINE|sun-appserver9.1|javax.enterprise.system.core.security|_ThreadID=10;_ThreadName=main;ClassName=com.sun.enterprise.security.RealmConfig;MethodName=createRealms;_RequestID=6d3ff829-d3c6-4a6a-9e0b-c84cd2007af4;|Configured realm: swsRealm|#]

but when authentication is attempted I get:

[#|2008-02-15T10:33:47.477-0700|FINE|sun-appserver9.1|javax.enterprise.system.core.security|_ThreadID=19;_ThreadName=httpSSLWorkerThread-443-1;ClassName=com.sun.enterprise.security.auth.LoginContextDriver;MethodName=doPasswordLogin;_RequestID=a20bc7e6-0886-4929-9587-b630fa0ef612;|Logging in user [tommytest] into realm: swsRealm using JAAS module: null|#]


and

[#|2008-02-15T10:33:47.478-0700|FINEST|sun-appserver9.1|javax.enterprise.system.core.security|_ThreadID=19;_ThreadName=httpSSLWorkerThread-443-1;ClassName=com.sun.enterprise.security.auth.LoginContextDriver;MethodName=doPasswordLogin;_RequestID=a20bc7e6-0886-4929-9587-b630fa0ef612;|doPasswordLogin fails
javax.security.auth.login.LoginException: Invalid null input: name
        at javax.security.auth.login.LoginContext.init(LoginContext.java:229)
        at javax.security.auth.login.LoginContext.<init>(LoginContext.java:367)
        at javax.security.auth.login.LoginContext.<init>(LoginContext.java:444)
        at com.sun.enterprise.security.auth.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:294)
        at com.sun.enterprise.security.auth.LoginContextDriver.login(LoginContextDriver.java:170)
        at com.sun.enterprise.security.auth.LoginContextDriver.login(LoginContextDriver.java:123)
        at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:479)
        at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:419)
        at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:253)
        at org.apache.catalina.authenticator.AuthenticatorBase.processSecurityCheck(AuthenticatorBase.java:1011)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:622)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:609)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.process(SSLReadTask.java:440)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLReadTask.doTask(SSLReadTask.java:228)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
|#]



which seems to indicate that the LoginModule is not being found or the login.conf file is not correct. Any ideas on why this might be happening? I already set jvm-option:

<jvm-options>-Djava.security.debug=logincontext</jvm-options>

and have security logging at FINEST but this is the must info I get.

Thanks,

TB
[Message sent by forum member 'travbow' (travbow)]

http://forums.java.net/jive/thread.jspa?messageID=259243