cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r321116 - in /cocoon: blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/ blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/ blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ blocks/portal/trunk/java/o...
Date Fri, 14 Oct 2005 13:37:56 GMT
Author: cziegeler
Date: Fri Oct 14 06:37:43 2005
New Revision: 321116

URL: http://svn.apache.org/viewcvs?rev=321116&view=rev
Log:
Support for PortletRequest.USER_INFO

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
      - copied, changed from r321063, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
Removed:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUser.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
    cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java?rev=321116&r1=321115&r2=321116&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java Fri
Oct 14 06:37:43 2005
@@ -19,7 +19,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.portal.profile.PortalUser;
-import org.apache.cocoon.portal.profile.impl.UserInfo;
+import org.apache.cocoon.portal.profile.impl.AbstractPortalUser;
 import org.apache.cocoon.portal.PortalException;
 import org.apache.cocoon.webapps.authentication.AuthenticationManager;
 import org.apache.cocoon.webapps.authentication.user.RequestState;
@@ -31,7 +31,7 @@
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  * @version $Id$
  */
-public class User extends UserInfo { 
+public class User extends AbstractPortalUser { 
 
     protected final UserHandler handler;
 
@@ -56,7 +56,7 @@
             final RequestState state = authManager.getState();
             final UserHandler handler = state.getHandler();
 
-            final UserInfo info = new User(handler);
+            final AbstractPortalUser info = new User(handler);
 
             info.setUserName(handler.getUserId());
             try {

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java?rev=321116&r1=321115&r2=321116&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/adapter/PortletAdapter.java
Fri Oct 14 06:37:43 2005
@@ -19,6 +19,7 @@
 import java.util.Properties;
 
 import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
 import javax.portlet.WindowState;
 import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
@@ -346,6 +347,10 @@
         final Map objectModel = ContextHelper.getObjectModel(this.context);
         final ServletRequestImpl req = new ServletRequestImpl((HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT),
event);
         final HttpServletResponse res = new ServletResponseImpl((HttpServletResponse) objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT));
+        if ( !service.getComponentManager().getProfileManager().getUser().isAnonymous() )
{
+            req.setAttribute(PortletRequest.USER_INFO,
+                             service.getComponentManager().getProfileManager().getUser().getUserInfos());
+        }
         objectModel.put("portlet-response",  res);
         objectModel.put("portlet-request", req);        
 
@@ -404,6 +409,10 @@
             objectModel.put("portlet-response",  new ServletResponseImpl(res));
             final ServletRequestImpl req = new ServletRequestImpl((HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT),
null);
             objectModel.put("portlet-request",  req);
+            if ( !service.getComponentManager().getProfileManager().getUser().isAnonymous()
) {
+                req.setAttribute(PortletRequest.USER_INFO,
+                                 service.getComponentManager().getProfileManager().getUser().getUserInfos());
+            }
         }
     }
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUser.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUser.java?rev=321116&r1=321115&r2=321116&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUser.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUser.java Fri Oct
14 06:37:43 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.portal.profile;
 
+import java.util.Map;
+
 /**
  * Information about the current portal user.
  * This object decouples the portal from the used authentication method.
@@ -25,6 +27,11 @@
 public interface PortalUser {
 
     /**
+     * Is this user an anonymous user?
+     */
+    boolean isAnonymous();
+
+    /**
      * @return Returns the group.
      */
     String getGroup();
@@ -35,4 +42,8 @@
     String getUserName();
 
     boolean isUserInRole(String role);
+
+    Object getUserInfo(String key);
+
+    Map getUserInfos();
 }

Copied: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
(from r321063, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java)
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java?p2=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java&p1=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java&r1=321063&r2=321116&rev=321116&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
Fri Oct 14 06:37:43 2005
@@ -16,6 +16,8 @@
 package org.apache.cocoon.portal.profile.impl;
 
 import java.io.Serializable;
+import java.util.Collections;
+import java.util.Map;
 
 import org.apache.cocoon.portal.profile.PortalUser;
 
@@ -27,17 +29,35 @@
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @version $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
  */
-public abstract class UserInfo implements PortalUser, Serializable {
+public abstract class AbstractPortalUser
+    implements PortalUser, Serializable {
 
+    /** The unique name of the user. */
     protected String userName;
 
     protected String group;
 
-    public UserInfo() {
+    protected Map userInfo = Collections.EMPTY_MAP;
+
+    /** Is this an anonymous user. */
+    protected boolean anonymous;
+
+    public AbstractPortalUser() {
         // nothing to do
     }
 
     /**
+     * @see org.apache.cocoon.portal.profile.PortalUser#isAnonymous()
+     */
+    public boolean isAnonymous() {
+        return this.anonymous;
+    }
+
+    public void setAnonymous(boolean anonymous) {
+        this.anonymous = anonymous;
+    }
+
+    /**
      * @return Returns the group.
      */
     public String getGroup() {
@@ -63,5 +83,27 @@
      */
     public void setUserName(String userName) {
         this.userName = userName;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.profile.PortalUser#getUserInfo(java.lang.String)
+     */
+    public Object getUserInfo(String key) {
+        return this.userInfo.get(key);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.profile.PortalUser#getUserInfos()
+     */
+    public Map getUserInfos() {
+        return this.userInfo;
+    }
+
+    public void setUserInfos(Map infos) {
+        if ( infos == null ) {
+            this.userInfo = Collections.EMPTY_MAP;
+        } else {
+            this.userInfo = Collections.unmodifiableMap(infos);
+        }
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java?rev=321116&r1=321115&r2=321116&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
Fri Oct 14 06:37:43 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.portal.profile.impl;
 
-import java.io.Serializable;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -533,27 +532,13 @@
         return new User(state);
     }
 
-    protected static final class User implements PortalUser, Serializable {
+    protected static final class User extends AbstractPortalUser {
 
         protected final RequestState state;
 
         public User(RequestState state) {
-            this.state = state;    
-        }
-
-        /**
-         * @see org.apache.cocoon.portal.profile.PortalUser#getGroup()
-         */
-        public String getGroup() {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        /**
-         * @see org.apache.cocoon.portal.profile.PortalUser#getUserName()
-         */
-        public String getUserName() {
-            return this.state.getHandler().getUserId();
+            this.state = state;
+            this.setUserName(state.getHandler().getUserId());
         }
 
         /**

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?rev=321116&r1=321115&r2=321116&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Fri Oct 14 06:37:43 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.portal.profile.impl;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -345,20 +344,11 @@
         return this.portalUser;
     }
 
-    protected static final class StaticPortalUser implements PortalUser, Serializable {
+    protected static final class StaticPortalUser extends AbstractPortalUser {
 
-        /**
-         * @see org.apache.cocoon.portal.profile.PortalUser#getGroup()
-         */
-        public String getGroup() {
-            return null;
-        }
-
-        /**
-         * @see org.apache.cocoon.portal.profile.PortalUser#getUserName()
-         */
-        public String getUserName() {
-            return "static";
+        public StaticPortalUser() {
+            this.setUserName("static");
+            this.setAnonymous(true);
         }
 
         /**

Modified: cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar?rev=321116&r1=321115&r2=321116&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message