Skip to main content

glassfish 4.0 custom security realm

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
4 replies [Last post]
Belbin, Peter Guest
Offline
Joined: 2012-03-22

Where will I find an example (or, complete documentation) as to how to build a custom security realm for Glassfish 4.0 ?

It appears that there are some changes since 3.1.2.2, or, that the required artefacts have been relocated, or, perhaps not exposed yet via maven?

Please advise.

Regards,
Peter

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kithouna
Offline
Joined: 2011-03-28

You can also look at JASPIC. This is the Java EE standard way to create a custom realm. GlassFish has very good support for this.

See http://arjan-tijms.blogspot.com/2012/11/implementing-container-authentic...

christBe
Offline
Joined: 2013-09-17

Found a working GF4 example
https://github.com/martijnblankestijn/glassfish-jdbc-realm

thanks Martijn

Also need help on this
I have used
https://blogs.oracle.com/nithya/entry/modularized_osgi_custom_realms_in
https://blogs.oracle.com/nithya/entry/groups_in_custom_realms

The Realm seems to work but at logon i get error below. Seems Realm is not passed because LoginModule in not used

WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Invalid null input: name
FINE: Exception
com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Invalid null input: name
at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:395)
at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:241)
at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:154)
at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:695)
at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:636)
at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:166)
at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1524)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:585)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:702)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:724)
Caused by: javax.security.auth.login.LoginException: Invalid null input: name
at javax.security.auth.login.LoginContext.init(LoginContext.java:246)
at javax.security.auth.login.LoginContext.(LoginContext.java:382)
at javax.security.auth.login.LoginContext.(LoginContext.java:459)
at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:382)
... 31 more

jaques.claudino
Offline
Joined: 2014-01-07

Hi,

To fix this problem: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Invalid null input: name...

I've added a jaas-context property on my auth-realm in domain.xml:

domain.xml (spaced tags):
< auth-realm name="my-realm" classname="eu.lucubratory.myrealm.MyRealm">
< property name="jaas-context" value="myRealm">< /property>
< /auth-realm>

login.conf:
myRealm {
eu.lucubratory.myrealm.LoginModule required;
};

After that, my example is working fine on Glassfish 4.0 using this tutorial: http://www.lucubratory.eu/custom-jaas-realm-for-glassfish-3

Regards,
Jaques

lberteau
Offline
Joined: 2013-08-01

Hello,

I have the same issue trying to create a custom LoginModule : documentation refers to inheriting com.sun.appserv.security.AppservPasswordLoginModule but this class is no more in security.jar

In which artifact can it be found ?

Edit: Found it in artifact glassfish-ee-api.jar

Regards,
Laurent