portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r544701 - in /portals/jetspeed-2/trunk: applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/ applications/j2-admin/src/webapp/WEB-INF/ components/portal/src/java/org/apache/jetspeed/administration/ jetspeed-api/src/ja...
Date Wed, 06 Jun 2007 01:27:02 GMT
Author: taylor
Date: Tue Jun  5 18:27:01 2007
New Revision: 544701

URL: http://svn.apache.org/viewvc?view=rev&rev=544701
Log:
https://issues.apache.org/jira/browse/JS2-714

Added:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalConfigurationImpl.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfiguration.java
Modified:
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
Tue Jun  5 18:27:01 2007
@@ -41,6 +41,8 @@
 import javax.security.auth.Subject;
 
 import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.administration.PortalConfiguration;
+import org.apache.jetspeed.administration.PortalConfigurationConstants;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.container.JetspeedPortletContext;
 import org.apache.jetspeed.om.common.UserAttribute;
@@ -49,7 +51,6 @@
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.portlets.security.SecurityResources;
 import org.apache.jetspeed.portlets.security.SecurityUtil;
-import org.apache.jetspeed.portlets.security.users.JetspeedUserBean;
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.PrincipalRule;
 import org.apache.jetspeed.security.Group;
@@ -60,9 +61,9 @@
 import org.apache.jetspeed.security.PasswordCredential;
 import org.apache.jetspeed.security.Role;
 import org.apache.jetspeed.security.RoleManager;
+import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
-import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.UserPrincipal;
 import org.apache.jetspeed.security.om.InternalCredential;
 import org.apache.portals.bridges.beans.TabBean;
@@ -127,6 +128,7 @@
     private String paIdentifier;
     private Collection paUserAttributes;
     private boolean initPrefsAndAttr;
+    private PortalConfiguration configuration;
     
     private LinkedHashMap userTabMap;
     private LinkedHashMap anonymousUserTabMap;
@@ -166,6 +168,12 @@
         {
             throw new PortletException("Failed to find the Page Manager on portlet initialization");
         }
+
+        configuration = (PortalConfiguration)getPortletContext().getAttribute(CommonPortletServices.CPS_PORTAL_CONFIGURATION);
+        if (null == configuration)
+        {
+            throw new PortletException("Failed to find the Portal Configuration on portlet
initialization");
+        }
         
         paIdentifier = ((MutablePortletApplication)((JetspeedPortletContext)config.getPortletContext())
                 .getApplication()).getApplicationIdentifier();
@@ -416,12 +424,31 @@
         {
             if (roles == null)
             {
+                String adminName = configuration.getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN,
"admin");
+                String managerName  = configuration.getString(PortalConfigurationConstants.ROLES_DEFAULT_MANAGER,
"manager");
                 roles = new LinkedList();
                 Iterator fullRoles = roleManager.getRoles("");
                 while (fullRoles.hasNext())
                 {
                     Role role = (Role)fullRoles.next();
-                    roles.add(role.getPrincipal().getName());
+                    String roleName = role.getPrincipal().getName();
+                    // https://issues.apache.org/jira/browse/JS2-714
+                    // Filter roles for delegated security
+                    String username = request.getUserPrincipal().getName();
+                    if (roleName.equals(adminName))                        
+                    {
+                        if (roleManager.isUserInRole(username, adminName))
+                            roles.add(roleName);
+                    }
+                    else if (roleName.equals(managerName))                        
+                    {
+                        if (roleManager.isUserInRole(username, managerName))
+                            roles.add(roleName);
+                    }    
+                    else
+                    {
+                        roles.add(roleName);                        
+                    }
                 }
                 request.getPortletSession().setAttribute(ROLES_CONTROL, roles);
             }

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml
Tue Jun  5 18:27:01 2007
@@ -120,7 +120,6 @@
         <js:service name='GroupManager'/>    
         <js:service name='PageManager'/>    
         <js:service name='PermissionManager'/>        
-        <js:service name='PortalAdministration'/>        
         <js:service name='PortletFactory'/>        
         <js:service name='PortalAdministration'/>
         <js:service name='PortletRegistryComponent'/>
@@ -133,6 +132,7 @@
         <js:service name='DecorationFactory'/> 
         <js:service name='SecurityAccessController'/>  
         <js:service name='PortletTrackingManager'/>     
+        <js:service name='PortalConfiguration'/>
 	</js:services>
 
 </portlet-app>

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalConfigurationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalConfigurationImpl.java?view=auto&rev=544701
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalConfigurationImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalConfigurationImpl.java
Tue Jun  5 18:27:01 2007
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jetspeed.administration;
+
+import java.util.List;
+
+import org.apache.commons.configuration.Configuration;
+
+
+/**
+ * Portal Configuration
+ * 
+ * Retrieve basic data types from the jetspeed.properties configuration
+ * This is a subset of Commons Configuration functionality
+ * Not the best solution wrappering commons configuration, but it does continue 
+ * with the requirements of interface-driven development and zero dependencies in API
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class PortalConfigurationImpl implements PortalConfiguration
+{
+    Configuration configuration;
+    
+    public PortalConfigurationImpl(Configuration configuration)
+    {
+        this.configuration = configuration;
+    }
+    
+    public boolean getBoolean(String key, boolean defaultValue)
+    {
+        return configuration.getBoolean(key, defaultValue);
+    }
+
+    public boolean getBoolean(String key)
+    {
+        return configuration.getBoolean(key);
+    }
+
+    public double getDouble(String key, double defaultValue)
+    {
+        return configuration.getDouble(key, defaultValue);
+    }
+
+    public double getDouble(String key)
+    {
+        return configuration.getDouble(key);
+    }
+
+    public float getFloat(String key, float defaultValue)
+    {
+        return configuration.getFloat(key, defaultValue);
+    }
+
+    public float getFloat(String key)
+    {
+        return configuration.getFloat(key);
+    }
+
+    public int getInt(String key, int defaultValue)
+    {
+        return configuration.getInt(key, defaultValue);        
+    }
+
+    public int getInt(String key)
+    {
+        return configuration.getInt(key);        
+    }
+
+    public List getList(String key)
+    {
+        return configuration.getList(key);
+    }
+
+    public long getLong(String key, long defaultValue)
+    {
+        return configuration.getLong(key, defaultValue);        
+    }
+
+    public long getLong(String key)
+    {
+        return configuration.getLong(key);        
+    }
+
+    public String getString(String key, String defaultValue)
+    {
+        return configuration.getString(key, defaultValue);        
+    }
+
+    public String getString(String key)
+    {
+        return configuration.getString(key);        
+    }
+
+    public String[] getStringArray(String key)
+    {
+        return configuration.getStringArray(key);                
+    }
+}

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
Tue Jun  5 18:27:01 2007
@@ -49,4 +49,5 @@
     public final static String CPS_PASSWORD_ENCODER_COMPONENT = "cps:PasswordEncodingService";
     public final static String CPS_SECURITY_ACCESS_CONTROLLER = "cps:SecurityAccessController";
     public final static String CPS_PORTLET_TRACKING_MANAGER = "cps:PortletTrackingManager";
+    public final static String CPS_PORTAL_CONFIGURATION = "cps:PortalConfiguration";   
 }

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfiguration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfiguration.java?view=auto&rev=544701
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfiguration.java
(added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfiguration.java
Tue Jun  5 18:27:01 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jetspeed.administration;
+
+import java.util.List;
+
+/**
+ * Portal Configuration
+ * 
+ * Retrieve basic data types from the jetspeed.properties configuration
+ * This is a subset of Commons Configuration functionality
+ * Not the best solution wrappering commons configuration, but it does continue 
+ * with the requirements of interface-driven development and zero dependencies in API
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @since 2.1.1
+ * @version $Id: $
+ */
+public interface PortalConfiguration
+{
+    boolean getBoolean(String key);
+    boolean getBoolean(String key, boolean defaultValue);    
+    String getString(String key);
+    String getString(String key, String defaultValue);    
+    double getDouble(String key);
+    double getDouble(String key, double defaultValue);        
+    float getFloat(String key);
+    float getFloat(String key, float defaultValue);        
+    int getInt(String key);
+    int getInt(String key, int defaultValue);        
+    List getList(String key);    
+    long getLong(String key);
+    long getLong(String key, long defaultValue);        
+    String[] getStringArray(String key);    
+}

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
Tue Jun  5 18:27:01 2007
@@ -67,5 +67,10 @@
     
     /** Users */
     static final String USERS_DEFAULT_ADMIN = "default.admin.user";
-    static final String USERS_DEFAULT_GUEST = "default.user.principal";
+    static final String USERS_DEFAULT_GUEST = "default.user.principal";    
+    static final String ROLES_DEFAULT_ADMIN = "default.admin.role";    
+    static final String ROLES_DEFAULT_MANAGER = "default.manager.role";
+    static final String ROLES_DEFAULT_USER = "default.user.role";
+    static final String ROLES_DEFAULT_GUEST = "default.guest.role";
+    
 }

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml Tue Jun  5
18:27:01 2007
@@ -111,6 +111,9 @@
           <entry key ="PortalAuthenticationConfiguration">
           	<ref bean="org.apache.jetspeed.administration.PortalAuthenticationConfiguration"/>
           </entry>
+          <entry key ="PortalConfiguration">
+          	<ref bean="PortalConfiguration"/>
+          </entry>
           
 <!-- first uncomment the below service bean in security-spi-atn.xml
          <entry key="PasswordEncodingService">

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml Tue Jun  5 18:27:01
2007
@@ -25,6 +25,12 @@
         </constructor-arg>
     </bean>
 
+    <bean id="PortalConfiguration" class="org.apache.jetspeed.administration.PortalConfigurationImpl">
+        <constructor-arg>
+            <ref bean="portal_configuration" />        
+        </constructor-arg>
+    </bean>
+
     <!-- ServletConfig -->
     <bean id="javax.servlet.ServletConfig" name="ServletConfig" class="org.apache.jetspeed.components.factorybeans.ServletConfigFactoryBean"
/>
 

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties?view=diff&rev=544701&r1=544700&r2=544701
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties Tue Jun  5 18:27:01
2007
@@ -94,6 +94,10 @@
 # automatically added via HttpRequestContext.setUserPrincpal()
 default.user.principal=guest
 default.admin.user=admin
+default.admin.role=admin
+default.manager.role=manager
+default.user.role=user
+default.guest.role=guest
 
 # -------------------------------------------------------------------
 #  L O G 4 J - L O G G I N G



---------------------------------------------------------------------
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