8 Replies Latest reply on May 25, 2009 12:59 AM by mabimal

    HTTP Status 500 - No authenticated user while accessing /por

      Hello All,

      I have pointed portal's db to oracle.I am trying to point my own DB just for login credentials. and for it i created 3 tables in my DB. I have not used encryption for password in DB.

      The changes i made in jboss portal are

      login-config.xml

      <login-module code = "org.jboss.portal.identity.auth.DBIdentityLoginModule" flag="sufficient">
       <module-option name="dsJndiName">java:/HEUSERDS</module-option>
       <module-option name="principalsQuery">SELECT user_password FROM portal_users WHERE user_uname=?</module-option>
       <module-option name="rolesQuery">SELECT portal_roles.role_name, 'Roles' FROM portal_roles_membership INNER JOIN portal_roles ON portal_roles_membership.role_rid = portal_roles.role_rid INNER JOIN portal_users ON portal_roles_membership.user_uid = portal_users.user_uid WHERE portal_users.user_uname=?</module-option>
       <module-option name="additionalRole">Authenticated</module-option>
       </login-module>
       <login-module code="org.jboss.security.ClientLoginModule" flag="required"></login-module>

      inside authentication tag.

      The dsJndiName here used is to point my DB(Just for login).

      i have not changed
      <resource-ref>
       <res-ref-name>jdbc/PortalDS</res-ref-name>
       <jndi-name>java:PortalDS</jndi-name>
       </resource-ref>

      in jboss-web.xml of portal-server.war/WEB-INF

      Should i mention jdbc/HEUSERDS here?

      I have added
      <servlet>
       <servlet-name>LoginServlet</servlet-name>
       <servlet-class>org.bimal.tryout.LoginServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>LoginServlet</servlet-name>
       <url-pattern>/LoginServlet</url-pattern>
       </servlet-mapping>

      in web.xml of portal-server.war/WEB-INF

      and this LoginServlet have been used as the action of login.jsp of portal-server

      The code of LoginServlet.java is as follows

      protected void doPost(HttpServletRequest req, HttpServletResponse resp)
       throws ServletException, IOException {
       String user = req.getParameter("j_username");
       String pass = req.getParameter("j_password");
       String baseURL = "/portal/auth/dashboard";
      
       String referer = null;
       System.out.println(user);
      
       WebAuthentication webA = new WebAuthentication();
      
       if(webA.login(user, pass)){
       System.out.println(user);
       System.out.println(pass);
      
       System.out.println("Logged in successfully");
       System.out.println(req.getRemoteUser() +"\n"+ req.getUserPrincipal());
       referer = req.getHeader("Referer");
       System.out.println(referer);
       System.out.println(req.getRemoteUser());
       System.out.println(req.getUserPrincipal());
       resp.sendRedirect(baseURL);
       } else {
       referer = req.getHeader("Referer");
       System.out.println(referer);
       resp.sendRedirect(baseURL);
       }
       }


      Here in this code, req.getRemoteUser() and req.getUserPrincipal() are not null and they are returning user. but still i am getting

      HTTP Status 500 - No authenticated user while accessing /portal/auth/dashboard when LoginServlet redirects to /portal/auth/dashboard.

      If i point to /portal it shows user logged in, but dashboard link is not present.
      If the user is with admin role then Admin links appear and it's fully functional too.

      But what is going on with Dashboard.
      The Dashboard, Configure Dashboard links dont appear.

      One thing to mention is I am using JBoss Portal 2.7.2 bundled edition, which has JBoss AS 4.2.3.

      What might be the solution of it.






        • 1. Re: HTTP Status 500 - No authenticated user while accessing
          mathewa

          Hi mabimal,

          1) your conf/login-config.xml looks okay, and I assume works because your login servlet works?
          2) dont change portal-server.war/WEB-INF/jboss-web.xml, instead change the ...ds-xml file in deploy
          3) remove your login servlet - that's not the way to do it... if you want to customise your login module then do this:
          4) create a new class extending the org.jboss.portal.identity.auth.DBIdentityLoginModule, and in the overridden commit method you will be given a Subject which has .getPrincipals() method that returns not just the current user but also their roles ("Authenticated" should be in there because it's specified in the following line in the login-config.xml file

          <module-option name="additionalRole">Authenticated</module-option>

          That role is specified in the portal-server.war/WEB-INF/web.xml here:
           <security-constraint>
           <web-resource-collection>
           <web-resource-name>Authenticated</web-resource-name>
           <description></description>
           <url-pattern>/auth/*</url-pattern>
           </web-resource-collection>
           <auth-constraint>
           <role-name>Authenticated</role-name>
           </auth-constraint>
           </security-constraint>
          

          which basically says anything down the address http://server/portal/auth/... (which includes the dashboard) will require this "Authenticated" UserPrincipal in the Subject.getPrincipals() list.

          If you login this way then you can investigate the Subject to find out what roles you have. I suspect you dont have the "Authenticated" UserPrincipal in the Subject and therefore cannot view anything down the .../auth/...address path.

          btw, youll have to put your jar with the new YourDBIdentityLoginModule into the portal sar (or any other deployed sar) so it's on the class path for portal to see it, and change your line in login-config.xml from
          <login-module code = "org.jboss.portal.identity.auth.DBIdentityLoginModule" flag="sufficient">

          to:

          <login-module code = "xxx.xxx.xxx.YourDBIdentityLoginModule" flag="sufficient">
          


          Hope this helps,
          mat

          • 2. Re: HTTP Status 500 - No authenticated user while accessing

            Thank you matthew, Thank you for your time in solving my problem.

            A little confusion still existing is i m not getting, the overridden method commit in my code. I have extended that DBLoginIdentityModule, but not getting any overridden method.

            So please can you provide a little more detail on




            and in the overridden commit method you will be given a Subject which has .getPrincipals() method


            • 3. Re: HTTP Status 500 - No authenticated user while accessing

              Hello mathewa,

              Further more i would like to request you one thing that, Actually i m getting everything, except dashboard URL and configure dashboard URL, plus dashboard functionality. Infact I am under /portal/auth and there if i login as admin then admin appears and it's fully functional.

              So any solution for it please.

              Regards,
              Mabimal

              • 4. Re: HTTP Status 500 - No authenticated user while accessing
                mathewa

                ah sorry... extend the IdentityLoginModule. this does give you a commit method to override and also uses config to authenticate the user via the database.

                • 5. Re: HTTP Status 500 - No authenticated user while accessing

                  Hello mathewa,

                  I am still unable to do it, can you please provide some example code.

                  Regards,
                  Mabimal

                  • 6. Re: HTTP Status 500 - No authenticated user while accessing

                    Ah sorry matallen i will try out this code and let u know..

                    • 7. Re: HTTP Status 500 - No authenticated user while accessing

                      Hello matalle,

                      I just checked and

                      Map<String, ?> arg2, Map<String, ?>

                      was error, and i just changed to
                      Map sharedState, Map options

                      was compiled successful here .

                      I changed in the login-config.xml file too, but when i attempt to login, it succeeds and land on http://server:8080/portal/auth/dashboard, with HTTP:500 No Authenticated User, but in the console, there is the output,

                      Admin,
                      Authenticated

                      when logged in as admin,

                      and
                      User
                      Authenticated

                      when logged in as user.

                      Is there anything missing?

                      Regards,
                      Mabimal




                      • 8. Re: HTTP Status 500 - No authenticated user while accessing

                        Hello Mattallen,

                        I have tried that JIRA 2178 too, but no result yet.
                        Whenever i point to JBoss Portal's Schema in Oracle , it shows dashboard and all fully functional, but i m in the situation to have my own Schema where i will have same relationship maintained by JBoss Portal as in JBP_User, JBP_Role and JBP_Role_Membership.

                        Everything works under JBoss Portal's Schema, without any modifications.
                        But when i point to my own Schema, then login succeeds but only dashboard not coming.

                        Thanks and Regards
                        Mabimal