users@glassfish.java.net

[gf-users] Custom realm in Glassfish 4: login module not found

From: Tomaz Majerhold <tomaz.majerhold_at_arnes.si>
Date: Sun, 11 Dec 2016 12:12:08 +0100

1) I create OSGI Bundle:
- MyRealm extends AppservRealm:
    ...
     @Override
     public String getJAASContext() {
             return "portalRealm ";
     }

- MyLoginModule extends AppservPasswordLoginModule

2) I deployed as osgi & and try also copy to modules as jar(same not
working result)

> asadmin deploy --type osgi MyAuth.jar
> Application deployed with name MyAuth.
> Command deploy executed successfully.

3) In web admin console I define myAppRealm with class MyRealmand in LOG
is see:
Fine: Initializing MyRealm
Info: Realm [myAppRealm ] of classtype
[si.arnes.glassfish.auth.MyRealm ] successfully created.
Info: MyRealm:init:JAAS_CONTEXT_PARAM=jaas-context
Info: MyRealm:init:jaasCtxName=portalRealm
Fine: A new com.sun.enterprise.config.serverbeans.AuthRealm was added
: GlassFishConfigBean.com.sun.enterprise.config.serverbeans.AuthRealm

4) In myDomain/config in file login.conf I define
portalRealm {
     si.arnes.glassfish.auth.MyLoginModule required;
};

5) When using myAppRealm in LOG see this:
Fine: Logging in user [darkot_at_os-sladki-vrh.si] into realm: myAppRealm
using JAAS module: portalRealm
Finest: doPasswordLogin fails
javax.security.auth.login.LoginException: No LoginModules configured for
portalRealm
...
Info: PortalArisAuth:getJAASContext=portalRealm


What is wrong, I see override method is called(getJAASContext) and
return what is defined in login.conf, but MyLoginModule is NEVER called.

Regards, Tomaz