portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r552664 - in /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed: layout/impl/PortletActionSecurityConstraintsBehavior.java login/filter/PortalFilter.java
Date Tue, 03 Jul 2007 04:35:39 GMT
Author: taylor
Date: Mon Jul  2 21:35:38 2007
New Revision: 552664

URL: http://svn.apache.org/viewvc?view=rev&rev=552664
Log:
bug fix on PortalFilter, was not correctly creating Subject + roles, credentials on very first
login

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java?view=diff&rev=552664&r1=552663&r2=552664
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
Mon Jul  2 21:35:38 2007
@@ -47,7 +47,6 @@
         if (config != null)
         {
             guest = config.getString("default.user.principal");
-            System.out.println("pas.guest=" + guest);
         }
     }
 

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java?view=diff&rev=552664&r1=552663&r2=552664
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java
Mon Jul  2 21:35:38 2007
@@ -36,10 +36,14 @@
 import org.apache.jetspeed.administration.PortalAuthenticationConfiguration;
 import org.apache.jetspeed.administration.PortalConfiguration;
 import org.apache.jetspeed.login.LoginConstants;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.SecurityHelper;
+import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.UserPrincipal;
 import org.apache.jetspeed.security.impl.PrincipalsSet;
+import org.apache.jetspeed.security.impl.UserPrincipalImpl;
 import org.apache.jetspeed.security.impl.UserSubjectPrincipalImpl;
 
 public class PortalFilter implements Filter
@@ -74,11 +78,29 @@
                     {
                         request.getSession().invalidate();
                     }
-                    Set principals = new PrincipalsSet();
-                    Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
-                    UserPrincipal userPrincipal = new UserSubjectPrincipalImpl(username,
subject);
-                    principals.add(userPrincipal);
-                    sRequest = wrapperRequest(request, subject, userPrincipal);
+                    Subject subject = null;
+                    try
+                    {
+                        // load the user principals (roles, groups, credentials)
+                        User user = userManager.getUser(username);
+                        if ( user != null )
+                        {
+                            subject = user.getSubject();
+                        }
+                    }
+                    catch (SecurityException sex)
+                    {
+                        subject = null;
+                    }       
+                    if (subject == null)
+                    {
+                        Set principals = new PrincipalsSet();
+                        subject = new Subject(true, principals, new HashSet(), new HashSet());
+                        UserPrincipal userPrincipal = new UserSubjectPrincipalImpl(username,
subject);
+                        principals.add(userPrincipal);
+                    }
+                    Principal principal = SecurityHelper.getPrincipal(subject, UserPrincipal.class);
+                    sRequest = wrapperRequest(request, subject, principal);
                     request.getSession().removeAttribute(LoginConstants.ERRORCODE);
                     HttpSession session = request.getSession(true);
                     session.setAttribute(PortalReservedParameters.SESSION_KEY_SUBJECT, subject);
@@ -115,7 +137,7 @@
             filterChain.doFilter(sRequest, sResponse);
         }
     }
-
+    
     private ServletRequest wrapperRequest(HttpServletRequest request, Subject subject, Principal
principal)
     {
         PortalRequestWrapper wrapper = new PortalRequestWrapper(request, subject, principal);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message