cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r149059 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile: . impl
Date Sat, 29 Jan 2005 19:05:23 GMT
Author: cziegeler
Date: Sat Jan 29 11:05:22 2005
New Revision: 149059

URL: http://svn.apache.org/viewcvs?view=rev&rev=149059
Log:
Add portal user
Added:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/PortalUser.java
  (contents, props changed)
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/PortalUser.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/PortalUser.java?view=auto&rev=149059
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/PortalUser.java
Sat Jan 29 11:05:22 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile;
+
+/**
+ * Information about the current portal user.
+ * This object decouples the portal from the used authentication method.
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @version SVN $Id$
+ */
+public interface PortalUser {
+    
+    /**
+     * @return Returns the group.
+     */
+    String getGroup();
+
+    /**
+     * @return Returns the userName.
+     */
+    String getUserName();
+    
+    boolean isUserInRole(String role);
+}

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java?view=diff&rev=149059&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java&r1=149058&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java&r2=149059
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileManager.java
Sat Jan 29 11:05:22 2005
@@ -125,4 +125,9 @@
      * one.
      */
     void storeProfile(Layout rootLayout, String layoutKey);
+    
+    /**
+     * Get current user information
+     */
+    PortalUser getUser();
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java?view=diff&rev=149059&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java&r1=149058&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java&r2=149059
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
Sat Jan 29 11:05:22 2005
@@ -32,6 +32,7 @@
 import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.layout.LayoutFactory;
+import org.apache.cocoon.portal.profile.PortalUser;
 import org.apache.cocoon.portal.profile.ProfileLS;
 import org.apache.cocoon.portal.util.DeltaApplicableReferencesAdjustable;
 import org.apache.cocoon.portal.util.ProfileException;
@@ -537,4 +538,44 @@
        	}
     }
 
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getUser()
+     */
+    public PortalUser getUser() {
+        final RequestState state = this.getRequestState();
+        return new User(state);
+    }
+    
+    protected static final class User implements PortalUser {
+        
+        protected final RequestState state;
+        
+        public User(RequestState state) {
+            this.state = state;    
+        }
+        
+        /* (non-Javadoc)
+         * @see org.apache.cocoon.portal.profile.PortalUser#getGroup()
+         */
+        public String getGroup() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+        
+        /* (non-Javadoc)
+         * @see org.apache.cocoon.portal.profile.PortalUser#getUserName()
+         */
+        public String getUserName() {
+            return this.state.getHandler().getUserId();
+        }
+        
+        /* (non-Javadoc)
+         * @see org.apache.cocoon.portal.profile.PortalUser#isUserInRole(java.lang.String)
+         */
+        public boolean isUserInRole(String role) {
+            return this.state.getHandler().isUserInRole(role);
+        }
+    }
+    
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?view=diff&rev=149059&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java&r1=149058&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java&r2=149059
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
Sat Jan 29 11:05:22 2005
@@ -41,6 +41,7 @@
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
 import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.profile.PortalUser;
 import org.apache.cocoon.portal.profile.ProfileLS;
 import org.apache.cocoon.util.ClassUtils;
 import org.apache.commons.collections.map.LinkedMap;
@@ -617,5 +618,23 @@
         } finally {
             this.manager.release(service);
         }
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getUser()
+     */
+    public PortalUser getUser() {
+        PortalService service = null;
+        try {
+            service = (PortalService) this.manager.lookup(PortalService.ROLE);
+            final String layoutKey = service.getDefaultLayoutKey();
+            final UserInfo info = this.provider.getUserInfo(service.getPortalName(), layoutKey);
+            return info;
+        } catch (Exception ce) {
+            throw new CascadingRuntimeException("Exception during getUser().", ce);
+        } finally {
+            this.manager.release(service);
+        }            
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?view=diff&rev=149059&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java&r1=149058&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java&r2=149059
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Sat Jan 29 11:05:22 2005
@@ -34,6 +34,7 @@
 import org.apache.cocoon.portal.layout.Item;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.layout.LayoutFactory;
+import org.apache.cocoon.portal.profile.PortalUser;
 import org.apache.cocoon.portal.profile.ProfileLS;
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.collections.map.StaticBucketMap;
@@ -58,6 +59,8 @@
 
     protected static final String LAYOUTKEY_PREFIX = StaticProfileManager.class.getName()
+ "/Layout/";
 
+    protected PortalUser portalUser = new StaticPortalUser();
+    
     /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(String, String)
      */
@@ -372,4 +375,35 @@
     public void storeProfile(Layout rootLayout, String layoutKey) {
         throw new RuntimeException("The static profile manager does not support the storeProfile()
method.");
     }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getUser()
+     */
+    public PortalUser getUser() {
+        return this.portalUser;
+    }
+    
+    protected static final class StaticPortalUser implements PortalUser {
+        
+        /* (non-Javadoc)
+         * @see org.apache.cocoon.portal.profile.PortalUser#getGroup()
+         */
+        public String getGroup() {
+            return null;
+        }
+        
+        /* (non-Javadoc)
+         * @see org.apache.cocoon.portal.profile.PortalUser#getUserName()
+         */
+        public String getUserName() {
+            return "static";
+        }
+
+        /* (non-Javadoc)
+         * @see org.apache.cocoon.portal.profile.PortalUser#isUserInRole(java.lang.String)
+         */
+        public boolean isUserInRole(String role) {
+            return false;
+        }
+}
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java?view=diff&rev=149059&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java&r1=149058&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java&r2=149059
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
Sat Jan 29 11:05:22 2005
@@ -17,6 +17,8 @@
 
 import java.util.Map;
 
+import org.apache.cocoon.portal.profile.PortalUser;
+
 /**
  * Information about the current user.
  * This data object is used for loading the profile. It decouples the
@@ -25,7 +27,7 @@
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
  */
-public class UserInfo {
+public class UserInfo implements PortalUser {
     
     protected String userName;
     
@@ -96,5 +98,13 @@
      */
     public String getPortalName() {
         return portalName;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.PortalUser#isUserInRole(java.lang.String)
+     */
+    public boolean isUserInRole(String role) {
+        // TODO Auto-generated method stub
+        return false;
     }
 }

Mime
View raw message