Modularized OSGi Custom Realms in Glassfish v3

The Open Services Gateway Initiative (OSGi) defines an architecture for developing and deploying modular applications and libraries. Since Glassfish v3 is a modular, embeddable and an OSGi compliant  server, custom realms that are built based on the OSGi framework can be easily integrated and configured with GF v3.This facilitates the creation and configuration of a custom realm without any server restart.

 To be recognized as a valid custom realm  OSGi module, in addition to the OSGi mandated structure, the custom realm  should include the following:

i)The Realm class should include the @Service annotation, with the name attribute referring to the name of the custom realm to be configured:

@Service(name="SampleRealm")

where @Service is a hk2-specific annotation.

ii) There should be a file named javax.security.auth.spi.LoginModule  inside META-INF/services directory of the module archive file. The file should specify the fully qualified name of the Custom Login Module class as in:

com.samplerealm.SampleLoginModule

A sample OSGi custom realm module can be downloaded from here. On dropping this file in <GF-HOME>/autodeploy-bundles directory, the module should be loaded. Do make sure   that the <GF-HOME>/<DOMAIN-DIR>/login.conf file has an entry for the jaas-context value, referring to the Module implementation class. This entry can be dynamically added to login.conf(before creating the realm). (This post provides a detailed description on creating a custom realm for GF.)

The realm can now be created from the admin console (name matching the service name specified in the Realm class). This should initialize the realm. No server restart required. On deploying and accessing an application utilizing this realm, the Login module should be initialized as well.This feature works with the latest GF v3 trunk installation.



Comments:

Can you post the source project for your sample module?

Posted by John Leed on November 27, 2009 at 12:32 PM SCT #

The source code for the realm is here : http://blogs.sun.com/nithya/resource/samplerealm.zip

Posted by Nithya Subramanian on August 04, 2010 at 11:49 AM SCT #

On GlassFish v3.1 or v.3.01 "<GF-HOME>/<DOMAIN-DIR>/autodeploy-bundles directory" doesn´t exist. Instead I dropped "mavenrealm.jar" in <GF-HOME>/<DOMAIN-DIR>/autodeploy/bundles but nothing happens. Do I have to do anything else?

Thanks

Posted by Paulo Pérez Prieto on March 22, 2011 at 01:44 PM SCT #

Hi Paulo,
This has to be GF-HOME/modules directory in v3.1.
HTH
Nithya

Posted by Nithya Subramanian on April 10, 2011 at 05:34 AM SCT #

The source code zip provided doesn't include the Service annotation on the SampleRealm class as described in the post. Is this an oversight?

Posted by Ryan on April 15, 2011 at 12:14 PM SCT #

@Ryan

Yes,the @Service annotation is missing in the src code that is attached. The src code originally pointed to a simple custom realm that was not OSGi. Apologies.Please add the @Service annotation to it.

Posted by Nithya Subramanian on April 19, 2011 at 11:19 AM SCT #

@Paulo,

There is a correction . In 3.1, the osgi bundles have to be dropped in <instance-root>/autodeploy/bundles directory to be picked up, or could be installed using ./asadmin deploy --type osgi.

HTH
Nithya

Posted by Nithya Subramanian on April 19, 2011 at 11:21 AM SCT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

nitkal

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks