continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcconn...@apache.org
Subject svn commit: r482512 - in /maven/continuum/trunk: continuum-security/src/main/java/org/apache/maven/continuum/security/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/c...
Date Tue, 05 Dec 2006 06:04:00 GMT
Author: jmcconnell
Date: Mon Dec  4 22:03:55 2006
New Revision: 482512

URL: http://svn.apache.org/viewvc?view=rev&rev=482512
Log:
continuum-1016 a rename will work on restart now, still trying to iron out the details for
getting this to work correctly on a rename automatically, think I found a potential caching
issue in p-sec but need to confirm.  but this allows for recovery from a group project rename
without have to resort to digging into the database

Modified:
    maven/continuum/trunk/continuum-security/src/main/java/org/apache/maven/continuum/security/ContinuumRoleProfileManager.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/checks/security/RoleProfileEnvironmentCheck.java

Modified: maven/continuum/trunk/continuum-security/src/main/java/org/apache/maven/continuum/security/ContinuumRoleProfileManager.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-security/src/main/java/org/apache/maven/continuum/security/ContinuumRoleProfileManager.java?view=diff&rev=482512&r1=482511&r2=482512
==============================================================================
--- maven/continuum/trunk/continuum-security/src/main/java/org/apache/maven/continuum/security/ContinuumRoleProfileManager.java
(original)
+++ maven/continuum/trunk/continuum-security/src/main/java/org/apache/maven/continuum/security/ContinuumRoleProfileManager.java
Mon Dec  4 22:03:55 2006
@@ -1,10 +1,10 @@
 package org.apache.maven.continuum.security;
 
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.rbac.profile.DefaultRoleProfileManager;
-import org.codehaus.plexus.rbac.profile.RoleProfileException;
 import org.codehaus.plexus.rbac.profile.DynamicRoleProfile;
+import org.codehaus.plexus.rbac.profile.RoleProfileException;
 import org.codehaus.plexus.security.rbac.Role;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 /*
  * Copyright 2006 The Apache Software Foundation.
  *
@@ -42,27 +42,25 @@
         getRole( "continuum-group-administrator" );
         getRole( "registered-user" );
 
-
+        // this should not be additive in the database, and will make sure they are in synced
on updates
         mergeRoleProfiles( "system-administrator", "continuum-system-administrator" );
         mergeRoleProfiles( "user-administrator", "continuum-user-administrator" );
         mergeRoleProfiles( "guest", "continuum-guest" );
 
-
-
-        setInitialized( true ); //todo remove the initialization idea from profile managers
+        setInitialized( true );
     }
 
 
     public Role getDynamicRole( String roleHint, String resource )
         throws RoleProfileException
     {
-        if ( !initialized )
+        if ( !isInitialized() )
         {
             initialize();
         }
 
         try
-        {
+        {            
             DynamicRoleProfile roleProfile =  (DynamicRoleProfile)container.lookup( DynamicRoleProfile.ROLE,
roleHint );
 
             return roleProfile.getRole( resource ); 
@@ -73,3 +71,4 @@
         }
     }
 }
+

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?view=diff&rev=482512&r1=482511&r2=482512
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Mon Dec  4 22:03:55 2006
@@ -16,18 +16,10 @@
  * limitations under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.web.bean.ProjectGroupUserBean;
-import org.apache.maven.continuum.ContinuumException;
 import org.codehaus.plexus.security.rbac.RBACManager;
 import org.codehaus.plexus.security.rbac.RbacManagerException;
 import org.codehaus.plexus.security.rbac.RbacObjectNotFoundException;
@@ -35,6 +27,16 @@
 import org.codehaus.plexus.security.user.User;
 import org.codehaus.plexus.security.user.UserManager;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.rbac.profile.RoleProfileManager;
+import org.codehaus.plexus.rbac.profile.RoleProfileException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * ProjectGroupAction:
@@ -67,6 +69,11 @@
      */
     private RBACManager rbac;
 
+    /**
+     * @plexus.requirement role-hint="continuum"
+     */
+    private RoleProfileManager roleManager;
+
     private int projectGroupId;
 
     private ProjectGroup projectGroup;
@@ -181,7 +188,23 @@
     {
         projectGroup = getContinuum().getProjectGroupWithProjects( projectGroupId );
 
-        projectGroup.setName( name );
+        // need to administer roles since they are based off of this
+        // todo convert everything like to work off of string keys
+        if ( !name.equals( projectGroup.getName() ) )
+        {
+            try
+            {
+                roleManager.renameDynamicRole( "continuum-group-developer", projectGroup.getName(),
name );
+                roleManager.renameDynamicRole( "continuum-group-user", projectGroup.getName(),
name );
+
+                projectGroup.setName( name );
+            }
+            catch ( RoleProfileException e )
+            {
+                throw new ContinuumException( "unable to rename the project group", e );
+            }
+
+        }
 
         projectGroup.setDescription( description );
 

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/checks/security/RoleProfileEnvironmentCheck.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/checks/security/RoleProfileEnvironmentCheck.java?view=diff&rev=482512&r1=482511&r2=482512
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/checks/security/RoleProfileEnvironmentCheck.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/checks/security/RoleProfileEnvironmentCheck.java
Mon Dec  4 22:03:55 2006
@@ -20,8 +20,12 @@
 import org.codehaus.plexus.rbac.profile.RoleProfileManager;
 import org.codehaus.plexus.rbac.profile.RoleProfileException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.Continuum;
 
 import java.util.List;
+import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * RoleProfileEnvironmentCheck:
@@ -42,6 +46,11 @@
      */
     private RoleProfileManager continuumRoleManager;
 
+    /**
+     * @plexus.requirement
+     */
+    private Continuum continuum;
+
     public void validateEnvironment( List list )
     {
         try
@@ -50,6 +59,19 @@
             {
                 continuumRoleManager.initialize();
             }
+
+            Collection projectGroups = continuum.getAllProjectGroups();
+
+            for ( Iterator i = projectGroups.iterator(); i.hasNext(); )
+            {
+                ProjectGroup group = (ProjectGroup) i.next();
+
+                // gets the role, making it if it doesn't exist
+                continuumRoleManager.getDynamicRole( "continuum-group-user", group.getName()
);
+                continuumRoleManager.getDynamicRole( "continuum-group-developer", group.getName()
);
+
+            }
+
         }
         catch ( RoleProfileException rpe )
         {



Mime
View raw message