AXIOM jar Conflict in Glassfish 2.1.1
Today I found the reason why my ear/web application did not work in Glassfish V 2.1.1. (it works in V 2.1.0) The app deploys but when I try to open the Web context URL I see the following exception in glassfish server.log:
Exception
sending context initialized event to listener instance of class
com.sun.faces.config.ConfigureListener
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! This
parser does not support specification "null" version "null" at
com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:215)
After some searching I think that the problem was forced by some additional libraries which I provided in my web module.
So after I removed my axiom-api dependency (maven 1.2.7) and I removed xercesImpl-2.6.2 the app works fine again.
Posted at 12:10PM Mrz 10, 2010
Posted by: Ralph
Category: General
RichFaces on Glassfish
Today I run into a deployment problem during I tried to install my RichFaces Application on Glassfish. The situation was realy crazy. At the first look everything works well. But when I tried to add the rich:tree component into one of my pages the page causes an error on my glassfish server.
Even when I select a Node of my Tree Component I got an
NoClassDefFoundError: org/apache/xerces/xni/parser/XMLConfigurationException
First I tried to add the newest xerces version into my web app. But this generates more and more problems as the xerces lib conflicts with the xerces parser provided by glassfish.
After playing arround with the richfaces config params in the web.xml I found that the nikohtml library was the problem why glassfish did not run the application properply
I have had used the following additional richfaces configuration in my web.mxl (I did no know why)
<context-param>
<param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
<param-value>NEKO, TIDY</param-value>
</context-param>
And this leads into a problem with the xerces parser included into glassfish.
The solution easy. I simply replaced the NEKO with TIDY
So now I use the following configuration in my web.xml
<context-param>
<param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
<param-value>TIDY</param-value>
</context-param>
And now the tree component works perfect !
An usefull link will also be this blog:
http://www.javaplex.com/blog/optimizing-jsf-richfaces-applications/
Posted at 01:05PM Feb 20, 2010
Posted by: Ralph
Category: General
Glassfish & OpenID - JSR-196 with OpenID4Java
Today I implemented a new ServerAuthModule based on JSR-196 using the OpenID4Java library. OpenID4Java is a open source library supporting the Client side authentication process to login a user with an OpenID.
OpenID is an open standard that allows a User to sign into web sites through a single URL (a single digital identity). This URL can be a personal home page, a blog or a web service (e.g from a OpenID Provider like myopenid, Google or yahoo.com) that the user is already using. In any case the user must register only once with his OpenID service provider and therefore he need only one password. Another advantage of using OpenID in your web application is the exemption of hosting and managing user accounts and password informations. You can read more about the details on openid.net.
Using JSR-196 and OpenID
There are different
solutions available to enable a Web Application to login users with
there OpenID account. One of the most auspicious mechanisms to integrate
OpenID in JEE Applications is the jsr-196.
This authentication service allows web containers to use different
login modules - like an external openid provider. JSR-196 is part of Glassfish Server
so a Login Mechanism based on the jsr-196 is very easy to use in a JEE
or Web application. Ron Monzillo who is the specification lead gives a
good overview about the jsr-192 on his blog "concepts behind JRS-196".
How to Install the OpenID4JavaAuthModule
The OpenID4JavaAuthModule I have written is easy to install. To enable your JEE Web application for OpenID you need a Server plattform supporting JSR-196. The following section will describe the installation steps for a Glassfish Application Server. Glassfish supports JSR-196. But there may be also other web containers supporting JSR-196.
To install the OpenID4Java AuthModule you first need to download the following parts:
- imixs-openid-0.0.2-SNAPSHOT
Includes my new JSR-196 ServerAuthModule implementation based on the openid4java library. - openid4java-0.9.5.jar
Includes the official openid4java library and additional tools provided by the OpenID4Java Group.
Copy the imixs-openid-0.0.2-SNAPSHOT.jar into the Glassfish Lib folder
[GLASSFISHHOME]/lib/
Extract the the openid4java zip archive and copy the following jars into your Glassfish Domain lib/ext/ folder.
- openid4java-0.9.5.jar
- commons-codec-1.3.jar
- commons-httpclient-3.0.1.jar
- commons-logging-1.03.jar
The glassfish domain specific /lib folder is located on the following path:
[GLASSFISHHOME]/domains/domain1/lib/ext/
where domain1 is your prefered domain (domain1 is the default domain typical used).
Notice: The tree commons-* libraries are appache utilities which are used by openid4java.
Configuration of the OpenID4JavaAuthModule
Now you can configure the OpenID4JavaAuthModule using the GlassFish Admin Console following the next steps:
- Make sure the GlassFish Application Server is running. If it is not already running, you can start it using the
following command:
<GF_HOME>bin/asadmin start-domain domain1
where <GF_HOME> is the directory where you installed GlassFish
- Open the GlassFish Admin Console by pointing your browser to the URL:
http://localhost:4848/. - Login to the Admin Console by entering your ID and password.
- Expand the Configuration node at the bottom of the left-hand pane.
- Navigate to the Security node, expand it, and click MessageSecurity.

- Under Message Security Configurations, either open the HttpServlet layer if it already exists, or create it if it doesn't exist by clicking the New button. Clicking the button opens the New Message Security Configuration window.
- Set the following in the New Message Security Configuration window:
Provider Type: server
Provider ID:OpenIDProvider
Class Name:org.imixs.openid.openid4java.OpenID4JavaAuthModuleDo not check the Default Provider: Enabled check box.
- Click the OK button. This saves the settings and opens the Message Security Configurations window.
- Click on HttpServlet in the Authentication Layer column.
- Select the Providers tab. This opens the Provider Configuration window.
- Select OpenIDProvider in the Provider ID column you just created. This opens the Edit Provider Configuration window.
- Click the Save button to complete the configuration of the provider.
- Open the HttpServlet layer by selecting it in the Message Security Configurations window.
- Select the Providers tab to open the Provider Configuration window.

- Click the New button to open the New Provider Configuration window.
- In the Provider Configuration area of the window, set the following:
Provider Type: server
Provider ID:OpenIDProvider
Class Name:org.imixs.openid.openid4java.OpenID4JavaAuthModuleDo not check the Default Provider: Enabled check box.
If you can not see the HttpServlet node you need to create the layer:
Click the "New" button and you can than start to configure the new provider in one step. To do that:
If the HttpServlet layer already exists, you open first the provider list and add a new Provider:
For the first configuration this is a little bit confusing as you
need to create the HttpServlet Layer. But in general the hole
configuration is very simple.
Also note that the provider configuration utility also provides a dialog box that you can use to configure additional properties. We will use this properties to configure out OpenIDProvider for our applications.
Configure additional Properties
After adding the new OpenIDProvider like described before you can start using the provider in your web application. But there a also a few additional properties which can be configured for each provider instance. You can add these properties by using the box "additional properties at the end of you configuration page:

The different properties and there usage are described below:
assign.groups
This property is the most important one. It defines which group will be assigned to a user how has logged on with his OpenID. Typical this is a
default group used in your web application.
This property allows you define different debug stages. So you can
follow the different phases during the logon process on the server log.
Remove this property to turn the debug modus off to switch off debugging.
loginpage
Per default the login module will prompt the user with a simple login page where he can enter his OpenID. You can replace this default page with a individual page supported by your web application (similar to a form based authentication). I will discus this later.
(The other params - verfiymode and debug - shown in the screenshot are deprecated and can be left)
Configuration of your Web Application
Now I will explain how you can configure your web application to use openid as a login mechanism. If you have installed the OpenID Login module like described before this step is quiet easy.
web.xml & sun-web.xml
The first thing what you should do is remove existing tag login-config like basic or form-based authentification configuration from the web.xml if available. Using JSR-196 you now only need the security-constraint configuration.
This is an example of the security-constraint seciton in my web.xml
....
<security-constraint>
<display-name>Access Manager Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>AUTHENTICATED_RESOURCE
</web-resource-name>
<url-pattern>/pages/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS
</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS
</role-name>
</security-role>
.....
Next you need to link your openid provider configured on glassfish admin client with you web application in the sun-web.xml.
Therefor you need to add the attriubte "httpservlet-security-provider" with the name of your openid provider. The the following example of my sun-web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="" httpservlet-security-provider="OpenIDProvider">
<context-root>/openidtestclient</context-root>
<security-role-mapping>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS</role-name>
<group-name>Author</group-name>
</security-role-mapping>
<class-loader delegate="true" />
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class java
code.</description>
</property>
</jsp-config>
</sun-web-app>
That's it!
Now You will see a default login page if you try to login to your web application:
Role Mapping
Notice that we mapped also our default group "Author" to a application specific role name. The group "Author" was configured in the OpenIDProvider property "assign.groups". So each user how have successful authenticated against his OpenID Provider will default to this group and the role "org.imixs.ACCESSLEVEL.AUTHORACCESS". You can change this settings to the requirements of your application.
Login Form
If you did not specific a login form with the additional property "loginpage" the OpenID Login Module will answer an unautenticated request with an simple login form as shown above.
You can implement you own login form if you like and use this form as the default form for your openidProvider module.
There for add the property "loginpage" to your provider configuration and support a valid Page inside your application or a simple HTTP page located on a web server.
This is a simple example for a individual login form based on JSF :
<form method="get"
action="#{facesContext.externalContext.requestContextPath}/openid_login">
<f:facet name="header">
<h:outputLabel value="#{global.login_title} " />
</f:facet>
<h:panelGrid columns="2">
<h:outputLabel value="#{global.username}:" />
<h:inputText id="openid_identifier" />
<h:inputHidden id="return_to"
value="#{loginMB.serverURI}#{facesContext.externalContext.requestContextPath}/pages/notes.jsf" />
</h:panelGrid>
<input type="submit" value="#{global.login}" />
<!-- BEGIN ID SELECTOR -->
<script type="text/javascript" id="__openidselector"
src="https://www.idselector.com/selector/e0ed3a269b77fa785de90aeaa20fa0f985746767"
charset="utf-8"></script>
<!-- END ID SELECTOR -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3469303-6");
pageTracker._trackPageview();
</script>
</form>
Your form need to care about three things:
- The form action method need to point to the method path "/openid_login". This path indicates the OpenIDLogin Module to start an OpenID Login process.
- The users Input field to enter his OpenID URL should be named "openid_identifier". Make sure that the "name" and "ID" attribute are set to "openid_identifier"
- The form must support a hidden field "return_to" with points to a page where the user is redirected after login process succeed.
The ID Selector Script is just a funny script provided by http://www.idselector.com to support the user with a nice widget to simplify using openid.
Conclusion
You can see that using JSR-196 and OpenID4Java is a very comfortable way to support a new and easy to use login mechanism for web applications. For Internet applications openid opens you web site to millions of users. It is easy to use and you don't have to handle all the stuff with managing userids and passwords.
If you have any suggestions or comments let me know.
You can download the source file of my Implementation also from here.
I also want to thank the OpenID4Java Team for there work.
Please note that I have started a little project site on googlecode to publish the sources and provide a platform to discuss and exchange experience. You are welcome to join this project.
http://code.google.com/p/openid4java-jsr196/
Posted at 09:52AM Jan 17, 2010
Posted by: Ralph
Category: General
Glassfis: Using saxon XSL Processor instat of xerces
Glassfish Application server provides an Xerces XSL Processor. This processor did only support XSL 1.0 but no XSL 2.0 which comes with a lot of additional functions.
So in a Web Application which is doing some XML/XSL transformation the xerces processor will be used per default. To change this behavior you can simply copy the saxon processor into the /lib folder of your web module.
Or if you are using maven add the following dependency into your pom.xml
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
<version>8.7</version>
</dependency>
Thats it. Now your web module will run with saxon xml/xsl and you can work with all the cool XSL 2.0 functions.
Posted at 01:35PM Dez 08, 2009
Posted by: Ralph
Category: General
AWStats and Glassfish
AWStats is a free powerful tool that generates graphically web server statistics. This log analyzer works also in combination with the Glassfish Application Server.
To get the web statistic out form the glassfish server there are a few things to be payed attention for after you have installed AWStats successfully on your server.
First off all you need to activate the Access Log in Glassfish. The Access Log is switched off per default.
Also it maks sense to use a new feature from glassfish which allows to generate a kind of standard log file format called Apache combined log format. This Log format gets out much more informations from a web server statistic. See Jan Luehe's Blog for details.
You can activate the Access Log in Glassfish using the Glassfish Console.
Next it is also necessary to tell AWStats how to access the daily logfiles generated by glassfish server and which log file format (Apache combined log format) should be used by AWStats. Therefor it is necessary to edit the awstats.config file of your webdomain (on linux the config files are located in /etc/awstats/).
Edit the config File and change two important properties to optimize AWSats to work with glassfish:
LogFile
This property defines the location of the AccessLog files. These files are typical stored in the logs/access folder form the glassfish domain. Set these property like this:
LogFile="/usr/glassfish/domains/domain1/logs/access/server_access_log.%YYYY-0-%MM-0-%DD-0.txt"
where /usr/glassfish/ should point to your glassfish install directory.
LogFormat
The second property is the LogFormat. This property has a default setting of "4" which indicates to use the Apache common log format. Change this Property to "1" to indicate to use the Apache combined log format.
After this changes the Web statistic of your glassfish server should look cool and gives you all the informations you are looking for.
Posted at 08:03PM Okt 06, 2009
Posted by: Ralph
Category: General
Eclipse Galileo and the Glassfish Server Plugin
For some reasons it is not possible to install and add the Glassfish Server Adapter in Eclipse Galileo with the Buildin Wizard form the "New Server" Wizzard (Function - "Download additional server")
But you can add the Glassfish Server Adapter easily with the "Help->Install new Software" Dialog, using this additional Download URL:
https://ajax.dev.java.net/eclipse
Posted at 12:37PM Aug 13, 2009
Posted by: Ralph
Category: General
Glassfish TimerService - Expunging timer after failed deliveries
On my glassfish installation I am running different TimerServices. In one I saw the problem that the TimerService stopped unexpected after running more than 20 hours.
In this situations a exeption is logged by the server like this one:
[#|2009-07-09T03:10:56.375+0200|INFO|sun-appserver2.1|javax.enterprise.system.container.ejb|_ThreadID=15;_ThreadName=p: thread-pool-1; w: 4;'1@@1247059844937@@server@@domain1' 'TimedObject = ScheduledWorkflowServiceImplementation' 'Application = myapp.ear-1.3.4' 'BEING_DELIVERED' 'PERIODIC' 'Container ID = 81721584505847814' 'Wed Jul 08 15:30:44 CEST 2009' '600000' ;2;|EJB5119:Expunging timer ['1@@1247059844937@@server@@domain1' 'TimedObject = ScheduledWorkflowServiceImplementation' 'Application = myapp.ear-1.3.4' 'BEING_DELIVERED' 'PERIODIC' 'Container ID = 81721584505847814' 'Wed Jul 08 15:30:44 CEST 2009' '600000' ] after [2] failed deliveries|#]
There is a Bugreport concerning this issue:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=4634
and also this discussion thread:
http://forums.java.net/jive/thread.jspa?messageID=219367
arround this toppic.
Now I will test if changing the TimerService settings in the EJB Containterconfiguration will solve the problem.
First I will change the following Params
- "Maximum Redeliveries" from "1" -> "16"
- "Redelivery Interval" from 5000 -> 30000
not sure if this will help....
Posted at 06:24AM Jul 09, 2009
Posted by: Ralph
Category: General
Error deploying EAR on Glassfish - error expanding jar
Today I was faced again with a deployment problem on glassish. When I tried to deploy my EAR application on glassfish I got some strange errors telling me that Glassfish was not able to expand some jars in my ear. In other cases an error can be that glassfish is did not find a jar in ear.
The problem occurs only when I build my EAR with Maven inside Eclipse Ganymed on a Windows Mashine. The Reason is the missing version tag in the ear pom file
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>5</version>
<modules>
.....
I often did not use the version tag in the configuration of my maven-ear-plugin. But if you do so in Eclipse ganymede running on a windows machine the Eclipse/Maven Plugins will generate a EAR 1.3 Module! So the build process will add a wrong application.xml file into the ear.
This is strange as using eclipse on linux did not run into this configuration conflict.
anyway - do not miss the version tag in your ear pom! And if you run in the situation described here also clear your maven projects befor you run a new install. otherwise the old applicaiton.xml fill will stay in you target folder!
Posted at 07:45AM Mai 21, 2009
Posted by: Ralph
Category: General
Escape Problem downloading Files form a Web / JSF Application
Today I stumbled into a problem with my JSF Web Application supporting File Upload/Download Functionality.
Everything works fine until some user uploaded files with "blank" in the filename e.g. "my fantastic long filename.doc" or files with german characters like "große datei mit wörtern.doc"
The Upload of sees files is no problem for my JSF up. But if a user tries to download such a file an error 404 occurs.
My JSF Implementation supports a typical form to download the files from a file list. It looks like this:
<h2>Download</h2>
<c:forEach var="attachment" items="#{workitemLobBean.files}">
<h:outputLink target="_blank"
value="#{facesContext.externalContext.requestContextPath}/Service/$file/#{attachment}">
<h:outputText value="#{attachment}" />
</h:outputLink>
<br />
</c:forEach>
So the filenames will be escaped into something like :
"my+fantastic+long+filename.doc"
which leads into the error 404. To avoid this escaping I used the following trick (not very nice but it works)
<h2>Download</h2>
<c:forEach var="attachment" items="#{workitemLobBean.files}">
<h:outputText escape="false" value="<a target='_balnk' href='" />
<h:outputText escape="false" value="#{facesContext.externalContext.requestContextPath}/Service/$file/#{attachment}" />
<h:outputText escape="false" value="'>#{attachment}</a>" />
<br />
</c:forEach>
If you find a better solution to escape filenems in JSF output let me know.
Posted at 09:42AM Mai 19, 2009
Posted by: Ralph
Category: General
Using @runas in EJB 3.0
Today I implemented a EJB where I used the @runas annotation the first time.
This annotation allows you to skip over the security settings in your EJB module. I use the Imixs IX JEE Workflow so I have to deal with the workflow IX Workflow roles. My new EJB should create a new workflow task triggered by a not authenticated user (anonymous). So my EJB need the workflow role "org.imixs.ACCESSLEVEL.AUTHORACCESS" to get access to the workflow model and the grant to create a new workitem. This can be decleared by the @runas annotation in the EJB implemenation
package org.imixs.business;
....
@Stateless
@DeclareRoles( { "org.imixs.ACCESSLEVEL.AUTHORACCESS" })
@RunAs("org.imixs.ACCESSLEVEL.AUTHORACCESS")
public class ContactServiceBean implements ContactService {
// Workflow Manager
@EJB
org.imixs.workflow.jee.ejb.WorkflowManager wm;
ItemCollection workItem = null;
/**
* This method creates a new Contact worktiem.
*/
public ItemCollection create() throws Exception {
// create emtpy workitem
workItem = wm.createWorkItem(INITIAL_PROCESS);
workItem.replaceItemValue("type", "contact");
return workItem;
}
.....
}
Next it is necessary (I am running on Glassfish server) to add a User Principal to the sun-ejb-jar.xml and also declare the pricipal:
sun-ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<security-role-mapping>
<role-name>org.imixs.ACCESSLEVEL.READERACCESS</role-name>
<principal-name>org.imixs.ACCESSLEVEL.READERACCESS</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS</role-name>
<principal-name>org.imixs.ACCESSLEVEL.AUTHORACCESS</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>org.imixs.ACCESSLEVEL.EDITORACCESS</role-name>
<principal-name>org.imixs.ACCESSLEVEL.EDITORACCESS</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>org.imixs.ACCESSLEVEL.MANAGERACCESS</role-name>
<group-name>IMIXS-WORKFLOW-Manager</group-name>
<principal-name>WorkflowScheduler</principal-name>
</security-role-mapping>
<enterprise-beans>
<ejb>
<ejb-name>ContactServiceBean</ejb-name>
<jndi-name>ejb/ShareyourworkContactServiceBean</jndi-name>
<principal><name>WorkflowScheduler</name></principal>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
Now the principal "WorkflowScheduler" is named as a principal in my EJB declaration and is mapped to the role "org.imixs.ACCESSLEVEL.MANAGERACCESS" this user will be able to call my EJB methods. As this role is declared as a @runas role in my contactEJB the principal "WorkflowScheduler" will be used by the EJB container to run the methods in my ejb.
Posted at 11:51AM Apr 15, 2009
Posted by: Ralph
Category: General
OpenID for JEE Applications - Part III
- Part I - The JSR-196, a general overview
- Part II - How to install a OpenID Module on Glassfish
- Part III - Using OpenID in your Web Application
Now I will explain how you can configure your web application to use openid for login mechanism. If you have installed the OpenID Login module like described in part II. this step is quiet easy.
web.xml & sun-web.xml
The first thing what you should do is remove existing tag login-config like basic or form-based authentification configuration from the web.xml if available. You now only need the security-constraint configuration.
This is an example of the security-constraint seciton in my web.xml
....
<security-constraint>
<display-name>Access Manager Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>AUTHENTICATED_RESOURCE
</web-resource-name>
<url-pattern>/pages/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS
</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS
</role-name>
</security-role>
.....
Next you need to specify your openid provider configured on glassfish admin client in the sun-web.xml.
Therefor you need to add the attriubte "httpservlet-security-provider" with the name of your openid provider
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="" httpservlet-security-provider="OpenIDProvider">
<context-root>/openidtestclient</context-root>
<security-role-mapping>
<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS</role-name>
<group-name>Author</group-name>
</security-role-mapping>
<class-loader delegate="true" />
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class java
code.</description>
</property>
</jsp-config>
</sun-web-app>
Thats it!
Now you application supports OpenID.
Role Mapping
Notice that we mapped also our default group "Author" to a application specific Rolename. The Group "Author" was configured in the OpenIDProvider property "assign.groups". So each user how have successfull authtenticated against his OpenID Proivder will default to this group and the role "org.imixs.ACCESSLEVEL.AUTHORACCESS". You can change this settings to the requriements of your application.
Login Form
If you did not specific a login form with the additional property "loginpage" the OpenID Login Module will answer an unautenticated reqeust with an simple login form as shown above.
You can implement you own login form if you like and use this form as the default form for you openidProvider module.
There for add the property "loginpage" to your provider configuration and support a valid Page inside your application or a simple HTTP page located on a web server.
This is a simple example for a individual login form based on JSF :
<form method="get"
action="#{facesContext.externalContext.requestContextPath}/openid_login">
<f:facet name="header">
<h:outputLabel value="#{global.login_title} " />
</f:facet>
<h:panelGrid columns="2">
<h:outputLabel value="#{global.username}:" />
<h:inputText id="openid_identifier" />
<h:inputHidden id="return_to"
value="#{loginMB.serverURI}#{facesContext.externalContext.requestContextPath}/pages/notes.jsf" />
</h:panelGrid>
<input type="submit" value="#{global.login}" />
<!-- BEGIN ID SELECTOR -->
<script type="text/javascript" id="__openidselector"
src="https://www.idselector.com/selector/e0ed3a269b77fa785de90aeaa20fa0f985746767"
charset="utf-8"></script>
<!-- END ID SELECTOR -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3469303-6");
pageTracker._trackPageview();
</script>
</form>
Your form need to care about three things:
- The form action method need to point to the method path "/openid_login". This path indicates the OpenIDLogin Module to start an OpenID Login process.
- The users Input field to enter his OpenID URL should be named "openid_identifier". Make sure that the "name" and "ID" attriubte are set to "openid_identifier"
- The form must support a hidden field "return_to" with points to a page where the user is redirected after login process succeed.
The ID Selector Script is just a funny script provided by http://www.idselector.com to support the user with a nice widget to simplify using openid.
Single Sign On (SSO)
OpenID supports single sing on. This means if your application knows the users OpenID you can easily logon the user to different pages from different web applications on the same server. To use this feature you only need to redirect the authenticated user to a new site providing his identity and the return url in the QueryString.
For example:
http://myhost/mynewapplication?openid.identity=[http://usersopenid]&openid.return_to=[http://myhost/mynewapplication]
The login process now depends on the users openid provider settings. Some providers like myid.net give the user a convenient way to control his personal settings for different pages and applications using openid
Conclusion
You can see that using JSR-196 and OpenID is a very comfortable way to support a new and easy to use login mechansim for web applications. For internet applications openid opens you web site to millions of users. It is easy to use and you dont have to handle all the stuff with managing userids and passwords.
As OpenID servers are also available als OpenSource JSR-196 and OpenID can be a competitive way for enterprises to implement a single sign on (SSO) architecture in an intranet or extranet.
If you have any suggestions or comments let me know.
Posted at 07:15AM Apr 05, 2009
Posted by: Ralph
Category: General
OpenID for JEE Applications - Part II
- Part I - The JSR-196, a general overview
- Part II - How to install a OpenID Module on Glassfish
- Part III - Using OpenID in your Web Application
In Part I. I described the general concepts behind the JSR 196 and the OpenID integration in Glassfish. Now I would like to explain how you can configure a OpenLogin Provider in Glassfish.
To configure a OpenID Provider in glassfish you need first the libary containg the OpenID Login Module. You can download the latest version of the library containing this OpenID Login Module from here: (sam.openid-0.0.1-SNAPSHOT.jar).
Next you can put the jar file simply into the <GF_HOME>/lib folder of your Glassfish installation.
Configuration of a OpenID Login Provider
You can configure the OpenID Login Provider using the GlassFish Admin Console following the next steps:
- Make sure the GlassFish Application Server is running. If it is not already running, you can start it using the
following command:
<GF_HOME>bin/asadmin start-domain domain1
where <GF_HOME> is the directory where you installed GlassFish
- Open the GlassFish Admin Console by pointing your browser to the URL:
http://localhost:4848/. - Login to the Admin Console by entering your ID and password.
- Expand the Configuration node at the bottom of the left-hand pane.
- Navigate to the Security node, expand it, and click MessageSecurity.

- Under Message Security Configurations, either open the HttpServlet layer if it already exists, or create it if it doesn't exist by clicking the New button. Clicking the button opens the New Message Security Configuration window.
- Set the following in the New Message Security Configuration window:
Provider Type: server
Provider ID:OpenIDProvider
Class Name: SAM, that is,com.sun.security.sam.openid2.OpenIDServerAuthModuleDo not check the Default Provider: Enabled check box.
- Click the OK button. This saves the settings and opens the Message Security Configurations window.
- Click on HttpServlet in the Authentication Layer column.
- Select the Providers tab. This opens the Provider Configuration window.
- Select OpenIDProvider in the Provider ID column you just created. This opens the Edit Provider Configuration window.
- Click the Save button to complete the configuration of the provider.
- Open the HttpServlet layer by selecting it in the Message Security Configurations window.
- Select the Providers tab to open the Provider Configuration window.

- Click the New button to open the New Provider Configuration window.
- In the Provider Configuration area of the window, set the following:
Provider Type: server
Provider ID:OpenIDProvider
Class Name: SAM, that is,com.sun.security.sam.openid2.OpenIDServerAuthModuleDo not check the Default Provider: Enabled check box.
If you can not see the HttpServlet node you need to create the layer:
Click the "New" button and you can than start to configure the new provider in one step. To do that:
If the HttpServlet layer already exists, you open first the provider list and add a new Provider:
For the first configuration this is a little bit confusing as you need to create the HttpServlet Layer. But in general the hole configuration is very simple.
Also note that the provider configuration utility also provides a dialog box that you can use to configure additional properties. We will use this properties to configure out OpenIDProvider for our applications.
Configure additional Properties
After adding the new OpenIDProvider like described before you can start using the provider in your web application. But there a also a few additional properties which can be configured for each provicer instance. You cann add these properties by using the box "additional properties at the end of you confiugration page:

The different properties and there usage are described below:
assign.groups
This property is the most important one. It defines which group will be assigend to a user how has loged on with its OpenID. Typical this is a default group used in your web application.
debug
Defines is login module will print debug messages on the console file. Remove this property to turn debug modus off.
debug.stages
This property allows you define different debug stages. So you can follow the different phases during the logon process on the server log. Remove this property to turn the debug modus off.
loginpage
Per default the login module will promt the user with a simpel login page where he can enter his OpenID url. You can replace this default page with a individueal page supported by your web application (simmilar to a form based authentification). We will descuss this later.
verifymode
This property can be set to "once" or "allways". If the property is set to "once" the login module will verify the OpenID Token only first time the user enters a restricted page. If set to "allways" (default) the token will be verified for every request of a restricted ressource.
Posted at 11:28AM Apr 04, 2009
Posted by: Ralph
Category: General
OpenID for JEE Applications - Part I
Please note that I have written a new (maybe better) implementation based on OpenID4Java. See my latest blog entry....
A few months ago I started to work on a Internet Web Application using OpenID as the primary login mechanism. In the following I will explain how you can use OpenID in your JEE Application.
- Part I - The JSR-196, a general overview
- Part II - How to install a OpenID Module on Glassfish
- Part III - Using OpenID in your Web Application
OpenID is an open standard that allows a User to sign into web sites through a single URL (a single digital identity). This URL can be a personal home page, a blog or a web service (e.g from a OpenID Provider like myopenid or yahoo.com) that the user is already using. In any case the user must register only once with his OpenID service provider and therefore he need only one password. You can read more about the details on openid.net.
Using OpenID in a Web Application
There are different solutions available to enable a Web Application to login users with there OpenID url. One of the most auspicious mechanisms to integrate OpenID in JEE Applications is the jsr-196. This authentication service allows web containers to use different login modules - like an external openid provider. JSR-196 is part of Glassfish Server so a Login Mechanism based on the jsr-196 is very easy to use in a JEE or Web application. Ron Monzillo who is the specification lead gives a good overview about the jsr-192 on his blog "concepts behind JRS-196".
The OpenSSO extension jsr196
As a subproject of the OpenSSO Project Ron has published a first implementation of a OpenID Login Module based on the OpneID Standard 1.0. in june 2008. I joined this project and started the work with Ron on this implementation. There is an Issue List available where you can see topics of the current work. And also the sources can be downloaded frome here: https://opensso.dev.java.net/source/browse/opensso/extensions/jsr196/
We implemented a new parser to optimize the handshake between the login module and the openid provider and in 2009 I added different enhancements. Finally I implemented a new version of the Login Module which now supports also OpenID 2.0 Providers like yahoo.com. This new login module is located in the package com.sun.security.sam.openid2 and is called OpenIDServerAuthModule.
You can download the latest version of the library containing this OpenID Login Module from here: (sam.openid-0.0.1-SNAPSHOT.jar).
In the next part I will explain how you install the login module and which configuration on glassfish server is necessary.
In Part III. I will show how you enable your web application to logon users with an openID.
If you have any comments or suggestions let me know
Posted at 10:26AM Apr 04, 2009
Posted by: Ralph
Category: General
Using JNDI and JavaMail with SMTP auth
Today I stumbled into a problem configuring a SMTP Mail session in Glassfish to be used out from my EJB.
My SMTP Host requires an authentification with a username and a special password.
Using the javax.mail.api the following params are responsible for a authenticated connection.
mail.smtp.host
mail.smtp.user
mail.smtp.password
The problem is that these params can not be read - or better will not be provided to the configured mail session in glassfish.
Here is a bugreport which explains the problem and show how the params need to be named:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=4515
also there is a useful thread which a general descussion how to establish a authenticated smtp session:
http://forums.sun.com/thread.jspa?threadID=615393&start=0&tstart=0
So the smtp params in glassfish need to be renamed as followed:
mail-smtp.host
mail-smtp.user
mail-smtp.password
Posted at 02:18PM Mrz 04, 2009
Posted by: Ralph
Category: General
Ubuntu - MySQL - Glassfish
To install MySQL on Ubuntu to be used in a Glassfish JEE App is very easy.
You can download and install MySQL Server using the Synaptic Tool in Ubuntu. During Setup you will be asked for a root password. this is a password for the user "root" inside the mySQL Server. So its not your Linux root password.
After intalling mysql server you can easily start and stop it with
> sudo /etc/init.d/mysql start
> sudo /etc/init.d/mysql stop
To get into the mysql console use
>mysql -u root -p
There you will be ask for the mysql root password.
To create a new database use the following command form the mysql console:
mysql> create database my_database;
Now you can setup the JDBC Pool inside Glassfish server.
First download the JDBC Driver form mysql download page and put the 'mysql-connecto-java-5.1.x.jar' into glassfish/domains/domain1/lib/ext
use the following Class Name to configure you JDBC Pool: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Use the additional params:
- databaseName : [you_database_name]
- user: root
- password : [you mysql admin password]
Posted at 07:33AM Nov 17, 2008
Posted by: Ralph
Category: General