14 Replies Latest reply on Dec 11, 2007 8:51 AM by bvogt

    Redirect to a specific portal after login

    ameo

      Hello,

      I would like to know, how to redirect to a desired portal instance after a user logs in.

      We have more than one portal instances. After users log in by username and passwort using the default jboss portal login form, is it possible to have them automatically redirect to a specific portal (the one that was assigned to them) ?

      Can you tell me, how to use the default login mechanism, maybe how to change it ?

      Greetings,
      ameo

        • 1. Re: Redirect to a specific portal after login
          ameo

          addition: do I have to write my own login portlet ?

          Isn't it possible to chage the default login mechanism to redirekt to antother portal (redirect to a desired portal page) after logging in ?

          greetings,
          ameo

          • 2. Re: Redirect to a specific portal after login
            ameo


            Is there nobod in the world who knows how ?

            • 3. Re: Redirect to a specific portal after login
              bvogt

               

              Isn't it possible to chage the default login mechanism to redirekt to antother portal (redirect to a desired portal page) after logging in ?


              Do you need to "redirect" to a different portal or page within a portal?

              Have you thought about using portal permissions for hiding pages, I mean do you really need more than one portal?

              I can imagine, that defining a custom PortalCommandFactory (to handle your selection logic) shall work.

              • 4. Re: Redirect to a specific portal after login
                johnnythehun

                I have the exact same question:

                We have two portals:
                Administrative portal
                and
                Public portal

                We want to use one url

                We want to redirect any admin to the admin portal whenever he logs in.

                Admins are able to see the public portal too, which is already cluttered with tabs, so we don't want to put any more pages there

                • 5. Re: Redirect to a specific portal after login
                  ameo

                   

                  "bvogt" wrote:

                  Do you need to "redirect" to a different portal or page within a portal?

                  Have you thought about using portal permissions for hiding pages, I mean do you really need more than one portal?


                  Our users have the possibility to create portal pages. They can close and open portal pages and work with them. The portal page can be only seen by the user which was created from. The user can create any number of pages and the number of pages could be very large, if we only use one portal for all users. Think there could be performance problems for the portal, to read all page objects and to decide to show or hide them.

                  Instead I had the idea to create for every user this own portal. The permission handling is easier und the pages are less than the other solution. Therefore I need the redirection to redirect after a login to the user portal.

                  Another solution could be to use the dashboard as userportal. Maybe the better solution. Here I have the problem, to update the dashboard, see please post at http://www.jboss.com/index.html?module=bb&op=viewtopic&t=124909


                  "bvogt" wrote:

                  I can imagine, that defining a custom PortalCommandFactory (to handle your selection logic) shall work.


                  Can you tell me please where I can find more info about a custom PortalCommandFactory ?

                  I think that I need something that acts between the login and the redirection.

                  thanks for answers,
                  ameo

                  • 6. Re: Redirect to a specific portal after login
                    bvogt

                    First, I don't know, if there's a better approach for your scenario, because you need the selection just after login - the PortalCommandFactory is called frequently...
                    I extended:

                    org.jboss.portal.core.model.portal.DefaultPortalCommandFactory


                    for translating symbolic page names into real page names (information hiding) e.g. for news letter links to jump directly onto a portal page.

                    An example of how to use the different Commands (ViewPortalCommand, ViewPageCommand, ...) is given in:

                    org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor


                    • 7. Re: Redirect to a specific portal after login
                      ameo

                       

                      "bvogt" wrote:
                      .. you need the selection just after login - the PortalCommandFactory is called frequently...


                      thanks for answers..

                      but, how I have to use it ? Can I write my own commands and the PortalCommandFactory executes them ?

                      Do you have an example or some more info about that ?

                      greetings,
                      ameo

                      • 8. Re: Redirect to a specific portal after login
                        bvogt

                        In your PortalCommandFactory you have to implement the method:

                        public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation, String host, String contextPath, String requestPath)
                        

                        it returns instances of org.jboss.portal.core.controller.ControllerCommand

                        Existing ControllerCommands are e.g. ViewPortalCommand and ViewPageCommand.

                        An example for switching to another portal is given in the org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor, the 'admin' link is generated by:
                        PortalObjectPermission perm = new PortalObjectPermission(adminPortalId, PortalObjectPermission.VIEW_MASK);
                        try
                        {
                         if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
                         {
                         ViewPageCommand showadmin = new ViewPageCommand(adminPortalId);
                         rd.setAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL", new PortalURLImpl(showadmin, controllerCtx, null, null));
                         }
                        }
                        catch (PortalSecurityException e)
                        {
                         log.error("", e);
                        }


                        I would assume, that returning the above mentioned 'showadmin' instance in your doMapping() method shall do the portal switch. In addition you have to think about the page of the target portal that is to be displayed...

                        • 9. Re: Redirect to a specific portal after login
                          ameo

                          Hello,

                          so I hope for one more, but last question.

                          Do I have to register my own PortalCommandFactory in the
                          jboss-service.xml ? If so, then I have to deploy my application as *.sar and create my own jboss-servicel.xml file and register the Factory (like the DefaultPortalCommandFactory in the jboss-portal.sar\META-INF\jboss-service.xml File ). Right ?

                          tanks a lot bvogt,
                          greetings,
                          ameo



                          • 10. Re: Redirect to a specific portal after login
                            bvogt

                            yes, yes, yes ;-)

                            • 11. Re: Redirect to a specific portal after login
                              ameo

                              Sorry for annoying, but I had no luck since yet )-:

                              here's what I have done:

                              testportal.sar/META-INF/jboss-service.xml
                              
                              <server>
                               <mbean code="de.ameo.TestPortalCommandFactory"
                               name="portal:commandFactory=SomeTestPortal" xmbean-dd=""
                               xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
                               <xmbean />
                               <depends optional-attribute-name="Container"
                               proxy-type="attribute">
                               portal:container=PortalObject
                               </depends>
                               </mbean>
                              
                              </server>
                              


                              The factory:
                              public class TestPortalCommandFactory extends AbstractCommandFactory {
                              
                              
                               private PortalObjectContainer container;
                              
                               public PortalObjectContainer getContainer()
                               {
                               return container;
                               }
                              
                               public void setContainer(PortalObjectContainer container)
                               {
                               this.container = container;
                               }
                              
                               public ControllerCommand doMapping(ControllerContext controllerContext,
                               ServerInvocation invocation, String host, String contextPath,
                               String requestPath) {
                              
                               Portal portal = (Portal) container.getContext().getPortal("testportal");
                              
                               if (portal == null) {
                               throw new IllegalStateException("Default portal does not exist");
                               }
                               Page page = portal.getPage("startpage");
                               if (page == null) {
                               throw new IllegalStateException("Default page does not exist");
                               }
                               PortalObjectId id = page.getId();
                               return new ViewPageCommand(id);
                              
                               }
                              }
                              


                              Nothing happens. The factory is not invoked after login. During debugging I cannot see some invokation of DefaultCommandPortalFactory, which should call my TestPortalCommandFactory. Although in the JMX console I can see that the factory is registerd. What I'm doing wrong ?

                              greetings,
                              ameo

                              • 12. Re: Redirect to a specific portal after login
                                bvogt

                                jboss-portal.sar/META-INF/jboss-service.xml:
                                change:

                                ...
                                 <depends
                                 optional-attribute-name="CommandFactory"
                                 proxy-type="attribute">portal:commandFactory=DefaultPortal</depends>
                                ...

                                to:
                                 <depends
                                 optional-attribute-name="CommandFactory"
                                 proxy-type="attribute">portal:commandFactory=SomeTestPortal</depends>
                                


                                In addition I would suggest to extend DefaultPortalCommandFactory instead of AbstractCommandFactory.
                                This allows to invoke the default behaviour in case that your interception doesn't lead to a valid ControllerCommand

                                • 13. Re: Redirect to a specific portal after login
                                  ameo

                                  Hello,

                                  the PortalCommandFactory works now ! Thanks for your answers !

                                  Sadly I have one effect with this solution. Starting position:

                                  DefaultPortal -> Login -> CommandFacorty switches to DesiredPortal [ok]

                                  After login the "DesiredPortal" displays on the screen, but the URL of the browser don't chage to DesiredPortal. So I have some side effects, like after refreshing the browser the portal turns back to the default portal.

                                  How Can I change the url or how to tell the server to switch the url, too ?

                                  greetings,
                                  ameo




                                  • 14. Re: Redirect to a specific portal after login
                                    bvogt

                                    as far as I have seen, the PortalCommandFactory intercepts each request, may be it's just a matter of remembering the "desired portal" decision?

                                    If not, which part of the url changes (server name?)?