2 Replies Latest reply on Apr 19, 2011 10:21 PM by claudio4j

    Forwad authentication to external application

      Hi,
      We are using GateIn VS3.0 for our intranet.
      Our GateIn is branched to a LDAP. We have other external applications branched on this LDAP but we don't have any SSO. We want to tranfer/forward authentication (credentials) from GateIn to external applications.
      We developped a http servlet filter mapped on "/login" url pattern. The filter catch the username and the password with succes. With them, we get a ticket from our external application. We want to make this ticket available for each portlet instance they need it during all the session.
      In this servlet filter, we tried to set the ticket in the session like that:
         --------------------------------------------
         HttpServletRequest httpRequest = (HttpServletRequest) request;
         HttpSession session = httpRequest.getSession(false);
         if (null != session){
           session.setAttribute("myTicket", myTicket);
          System.out.println("Session ID in filter"+session.getId());
         }
         --------------------------------------------
      But we didn't find how to retrieve the ticket in the managed bean of the JSFPortlet. We tried that:

       

         --------------------------------------------
         PortletSession session =  (PortletSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
         System.out.println("Session ID in managed bean (JSFPortlet)"+session.getId()); //display the same id as in the servlet filter
         System.out.println("myTicket (portlet_scope): "+session.getAttribute("myTicket"));   //display: null
         System.out.println("myTicket (app_scope): "+session.getAttribute("myTicket", PortletSession.APPLICATION_SCOPE));    //display: null
         --------------------------------------------
      We also explored the possibility to create our own TokenService (as a filter, like the "Remember me" filter) without succes. We did not find much documentation.
      Please, could you help us?
      Thank you in advance.

      Gabriel

        • 1. Re: Forwad authentication to external application

          Hi,

          I found a solution to retrieve HttpSession from my managed bean.

           

               PortalRequestContext portalContext = org.exoplatform.portal.webui.util.Util.getPortalRequestContext();
               HttpSession httpSession = portalContext.getRequest().getSession(false);


          Now, it works! May be it can help someone in the future.

           

          I'm still interested by a documentation on how to create my own TokenService as a filter.   

           

          Best Regards,

           

          Gabriel

          • 2. Re: Forwad authentication to external application
            claudio4j

            I had the same request, from a portlet to get a value set by the servlet filter.

             

            Glad you posted the results.

             

            Thanks

             

            Claudio