Version 2

    Authors

    Overview

    This Gadget uses GWT and access the Organization service to display some information about a user.

    Description

    Portlets by default allow for a wide range of access to useful information about the user and the portal environment its running in. With GateIn, a portlet also has easy access to a Portlet or Portal RequestContext to access GateIn specific services.

     

    A gadget on the other hand has a bit more difficultly accessing this information. It doesn't have the same access to kind of information that a portlet usually does, and it doesn't have access to the Portlet or Portal RequestContext.

     

    Since a gadget is normally run as javascript inside the browser of a client, we need to have a server side component to access the portal environment information. A GWT gadget using an RPC component will allow for us to easily have this server side component.

     

    For information on how to get started using GWT and Google Gadgets please see http://code.google.com/p/gwt-google-apis/wiki/GadgetsGettingStarted

     

    Attached to this wiki article is a simple gwt gadget example that will show a welcome message with the users first name and the last time they logged into the server. The example has a simple client interface that will access this information from a servlet using RPC.

    Getting Portal Information from a Servlet

    Its easy enough to get most of the GateIn services from a servlet if its running on the same server. Most of these services are available directly from the eXoKernel or from a factory's getInstance method.

     

    In our example we get an instance of the PortalContainer and then use the PortalContainer to get access to the OrganizationService (internally via the eXoKernel):

     

    PortalContainer portalContainer = PortalContainer.getInstance();
    OrganizationService orgService = portalContainer.getComponentInstanceOfType(OrganizationService.class);
    

     

    Once we have access to the OrganizationService we can get access to a User object which will contain information about a user:

     

    orgService.getUserHandler().findUserByName(remoteUser);
    

     

    The problem is getting access to the username. This information is coming from a servlet via ajax and is not being run inside the portal environment. In order to get the username we can have the servlet use the same realm as GateIn and enable the SingleSignOn valve so that they will share login details.

     

    In the servlet's web.xml set up the same realm as GateIn:

     

    <login-config>
     <auth-method>BASIC</auth-method>
     <realm-name>gatein-domain</realm-name>
    </login-config>
    

     

    In the servlet's jboss-web.xml setup the same realm as GateIn:

     

    <jboss-web>
      <security-domain>java:/jaas/gatein-domain</security-domain>
    </jboss-web>
    

     

    Once we have this setup, within our servlet we can use the remote user name from the GWT threadRequest:

     

    this.perThreadRequest.get().getRemoteUser();
    

     

    Installation procedure

    Build system: Maven

    Source location: Attached file

    Compatibility list (please add to this list if you have tested a new version of GateIn):

    TesterVersion of the exampleVersion of GateInResultComment