continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r471829 - in /maven/continuum/branches/continuum-acegi: ./ continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/security/ continuum-core/src/main/java/org/apache/maven/continuum/ con...
Date Mon, 06 Nov 2006 19:05:14 GMT
Author: carlos
Date: Mon Nov  6 11:05:11 2006
New Revision: 471829

URL: http://svn.apache.org/viewvc?view=rev&rev=471829
Log:
Align with trunk reducing coupling with maven-user

Removed:
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
    maven/continuum/branches/continuum-acegi/continuum-model/src/main/java/org/apache/maven/continuum/model/system/ContinuumUser.java
    maven/continuum/branches/continuum-acegi/continuum-model/src/main/java/org/apache/maven/continuum/model/system/Permission.java
    maven/continuum/branches/continuum-acegi/continuum-model/src/main/java/org/apache/maven/continuum/model/system/UserGroup.java
    maven/continuum/branches/continuum-acegi/continuum-model/src/main/resources/
Modified:
    maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/security/ContinuumSecurity.java
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/DefaultContinuumSecurity.java
    maven/continuum/branches/continuum-acegi/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/security/DefaultContinuumSecurityTest.java
    maven/continuum/branches/continuum-acegi/continuum-model/pom.xml
    maven/continuum/branches/continuum-acegi/continuum-model/src/main/mdo/continuum.xml
    maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
    maven/continuum/branches/continuum-acegi/pom.xml

Modified: maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Mon Nov  6 11:05:11 2006
@@ -348,30 +348,54 @@
     // Security
     // ----------------------------------------------------------------------
 
+    /**
+     * @deprecated use Security framework instead
+     */
     ContinuumSecurity getSecurity();
 
     // ----------------------------------------------------------------------
     // User
     // ----------------------------------------------------------------------
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void addUser( ContinuumUser user )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void addUser( Map configuration )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void updateUser( ContinuumUser user )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void updateUser( int userId, Map configuration )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     List getUsers()
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     ContinuumUser getUser( int userId )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void removeUser( int userId )
         throws ContinuumException;
 
@@ -379,23 +403,44 @@
     // User Group
     // ----------------------------------------------------------------------
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void addUserGroup( UserGroup userGroup );
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void addUserGroup( Map configuration )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void updateUserGroup( UserGroup userGroup )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void updateUserGroup( int userGroupId, Map configuration )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     List getUserGroups()
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     UserGroup getUserGroup( int userGroupId )
         throws ContinuumException;
 
+    /**
+     * @deprecated use Security framework instead
+     */
     void removeUserGroup( int userGroupId )
         throws ContinuumException;
 

Modified: maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/security/ContinuumSecurity.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/security/ContinuumSecurity.java?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/security/ContinuumSecurity.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-api/src/main/java/org/apache/maven/continuum/security/ContinuumSecurity.java
Mon Nov  6 11:05:11 2006
@@ -22,6 +22,8 @@
 import java.util.List;
 
 /**
+ * @deprecated use Security framework instead
+ * 
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Nov  6 11:05:11 2006
@@ -52,8 +52,6 @@
 import org.apache.maven.continuum.utils.ProjectSorter;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
-import org.apache.maven.user.model.PasswordRuleViolationException;
-import org.apache.maven.user.model.UserManager;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.action.Action;
@@ -109,11 +107,6 @@
      * @plexus.requirement
      */
     private ContinuumStore store;
-    
-    /**
-     * @plexus.requirement
-     */
-    private UserManager userManager;
 
     /**
      * @plexus.requirement
@@ -1040,6 +1033,8 @@
 
                 int projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext
);
 
+
+
                 projectGroup = store.getProjectGroupWithProjects( projectGroupId );
             }
 
@@ -1101,7 +1096,6 @@
 
     // This whole section needs a scrub but will need to be dealt with generally
     // when we add schedules and profiles to the mix.
-
     public ProjectNotifier getNotifier( int projectId, int notifierId )
         throws ContinuumException
     {
@@ -1785,40 +1779,38 @@
     // User
     // ----------------------------------------------------------------------
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public List getUsers()
         throws ContinuumException
     {
-//        try
-//        {
-            return userManager.getUsers();
-//        }
-//        catch ( EntityNotFoundException ex )
-//        {
-//            throw logAndCreateException( "Error while getting users.", ex );
-//        }
+        try
+        {
+            return store.getUsers();
+        }
+        catch ( ContinuumStoreException ex )
+        {
+            throw logAndCreateException( "Error while getting users.", ex );
+        }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void addUser( ContinuumUser user )
         throws ContinuumException
     {
-        if ( StringUtils.isEmpty( user.getPassword() ) )
+        if ( StringUtils.isEmpty( user.getHashedPassword() ) )
         {
             throw new ContinuumException( "Password can't be null" );
         }
-        try
-        {
-            userManager.addUser( user );
-        }
-//        catch ( EntityExistsException eee )
-//        {
-//            throw new ContinuumException( "Error adding " + user.getUsername() + ", the
user already exists.", eee );
-//        }
-        catch ( PasswordRuleViolationException pre )
-        {
-            throw new ContinuumException( "There was a password rule violation.", pre );
-        }
+        store.addUser( user );
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void addUser( Map configuration )
         throws ContinuumException
     {
@@ -1832,32 +1824,37 @@
 
         user.setEmail( (String) configuration.get( "user.email" ) );
 
-        user.addGroup( getUserGroup( Integer.parseInt( (String) configuration.get( "user.group"
) ) ) );
+        user.setGroup( getUserGroup( Integer.parseInt( (String) configuration.get( "user.group"
) ) ) );
 
         addUser( user );
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void updateUser( ContinuumUser user )
         throws ContinuumException
     {
-        if ( StringUtils.isEmpty( user.getEncodedPassword() ) )
+        if ( StringUtils.isEmpty( user.getHashedPassword() ) )
         {
             ContinuumUser u = getUser( user.getAccountId() );
 
-            user.setEncodedPassword( u.getEncodedPassword() );
+            user.setHashedPassword( u.getHashedPassword() );
         }
 
         try
         {
-            userManager.updateUser( user );
+            store.updateUser( user );
         }
-        catch ( PasswordRuleViolationException pre )
-        // TODO this must be thrown
+        catch ( ContinuumStoreException ex )
         {
-            throw new ContinuumException( "There was a password rule violation.", pre );
+            throw logAndCreateException( "Error while storing user.", ex );
         }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void updateUser( int userId, Map configuration )
         throws ContinuumException
     {
@@ -1871,17 +1868,20 @@
 
         user.setEmail( (String) configuration.get( "user.email" ) );
 
-        user.addGroup( getUserGroup( Integer.parseInt( (String) configuration.get( "user.group"
) ) ) );
+        user.setGroup( getUserGroup( Integer.parseInt( (String) configuration.get( "user.group"
) ) ) );
 
         updateUser( user );
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public ContinuumUser getUser( int userId )
         throws ContinuumException
     {
         try
         {
-            return ( ContinuumUser ) userManager.getUser( userId );
+            return store.getUser( userId );
         }
         catch ( Exception ex )
         {
@@ -1889,34 +1889,48 @@
         }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void removeUser( int userId )
         throws ContinuumException
     {
-        userManager.removeUser( userId );
+        ContinuumUser user = getUser( userId );
+
+        store.removeUser( user );
     }
 
     // ----------------------------------------------------------------------
     // User Group
     // ----------------------------------------------------------------------
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public List getUserGroups()
         throws ContinuumException
     {
-//        try
-//        {
-            return userManager.getUserGroups();
-//        }
-//        catch ( EntityNotFoundException ex )
-//        {
-//            throw logAndCreateException( "Error while getting user groups.", ex );
-//        }
+        try
+        {
+            return store.getUserGroups();
+        }
+        catch ( ContinuumStoreException ex )
+        {
+            throw logAndCreateException( "Error while getting user groups.", ex );
+        }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void addUserGroup( UserGroup userGroup )
     {
-        userManager.addUserGroup( userGroup );
+        store.addUserGroup( userGroup );
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void addUserGroup( Map configuration )
         throws ContinuumException
     {
@@ -1940,6 +1954,9 @@
         }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void updateUserGroup( int userGroupId, Map configuration )
         throws ContinuumException
     {
@@ -1963,6 +1980,9 @@
         }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     private List parsePermissionConf( Map configuration )
         throws ContinuumStoreException
     {
@@ -1970,107 +1990,118 @@
 
         if ( convertBoolean( (String) configuration.get( "group.permission.addProject" )
) )
         {
-            perms.add( userManager.getPermission( "addProject" ) );
+            perms.add( store.getPermission( "addProject" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.editProject" )
) )
         {
-            perms.add( userManager.getPermission( "editProject" ) );
+            perms.add( store.getPermission( "editProject" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.deleteProject"
) ) )
         {
-            perms.add( userManager.getPermission( "deleteProject" ) );
+            perms.add( store.getPermission( "deleteProject" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.buildProject"
) ) )
         {
-            perms.add( userManager.getPermission( "buildProject" ) );
+            perms.add( store.getPermission( "buildProject" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.showProject" )
) )
         {
-            perms.add( userManager.getPermission( "showProject" ) );
+            perms.add( store.getPermission( "showProject" ) );
         }
 
-        if ( convertBoolean( (String) configuration.get( "group.permission.addBuildDefinition"
) ) )
+        if ( convertBoolean( (String) configuration.get( "group.permission.addBuildDefinitionToProject"
) ) )
         {
-            perms.add( userManager.getPermission( "addBuildDefinition" ) );
+            perms.add( store.getPermission( "addBuildDefinitionToProject" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.editBuildDefinition"
) ) )
         {
-            perms.add( userManager.getPermission( "editBuildDefinition" ) );
+            perms.add( store.getPermission( "editBuildDefinition" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.deleteBuildDefinition"
) ) )
         {
-            perms.add( userManager.getPermission( "deleteBuildDefinition" ) );
+            perms.add( store.getPermission( "deleteBuildDefinition" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.addNotifier" )
) )
         {
-            perms.add( userManager.getPermission( "addNotifier" ) );
+            perms.add( store.getPermission( "addNotifier" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.editNotifier"
) ) )
         {
-            perms.add( userManager.getPermission( "editNotifier" ) );
+            perms.add( store.getPermission( "editNotifier" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.deleteNotifier"
) ) )
         {
-            perms.add( userManager.getPermission( "deleteNotifier" ) );
+            perms.add( store.getPermission( "deleteNotifier" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.manageConfiguration"
) ) )
         {
-            perms.add( userManager.getPermission( "manageConfiguration" ) );
+            perms.add( store.getPermission( "manageConfiguration" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.manageSchedule"
) ) )
         {
-            perms.add( userManager.getPermission( "manageSchedule" ) );
+            perms.add( store.getPermission( "manageSchedule" ) );
         }
 
         if ( convertBoolean( (String) configuration.get( "group.permission.manageUsers" )
) )
         {
-            perms.add( userManager.getPermission( "manageUsers" ) );
+            perms.add( store.getPermission( "manageUsers" ) );
         }
 
         return perms;
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void updateUserGroup( UserGroup userGroup )
         throws ContinuumException
     {
-//        try
-//        {
-            userManager.updateUserGroup( userGroup );
-//        }
-//        catch ( EntityNotFoundException e )
-//        {
-//            throw logAndCreateException( "Error while storing user group.", e );
-//        }
+        try
+        {
+            store.updateUserGroup( userGroup );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw logAndCreateException( "Error while storing user group.", e );
+        }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public UserGroup getUserGroup( int userGroupId )
         throws ContinuumException
     {
-//        try
-//        {
-            return ( UserGroup ) userManager.getUserGroup( userGroupId );
-//        }
-//        catch ( Exception ex )
-//        {
-//            throw logAndCreateException( "Error while getting user group.", ex );
-//        }
+        try
+        {
+            return store.getUserGroup( userGroupId );
+        }
+        catch ( Exception ex )
+        {
+            throw logAndCreateException( "Error while getting user group.", ex );
+        }
     }
 
+    /**
+     * @deprecated use Security framework instead
+     */
     public void removeUserGroup( int userGroupId )
         throws ContinuumException
     {
-        userManager.removeUserGroup( userGroupId );
+        UserGroup group = getUserGroup( userGroupId );
+
+        store.removeUserGroup( group );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
Mon Nov  6 11:05:11 2006
@@ -16,23 +16,13 @@
  * limitations under the License.
  */
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.project.Schedule;
-import org.apache.maven.continuum.model.system.ContinuumUser;
-import org.apache.maven.continuum.model.system.Permission;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
-import org.apache.maven.continuum.model.system.UserGroup;
-import org.apache.maven.continuum.security.ContinuumSecurity;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.maven.user.model.PasswordRuleViolationException;
-import org.apache.maven.user.model.UserManager;
-import org.apache.maven.user.model.UserSecurityPolicy;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.jpox.SchemaTool;
 
@@ -62,11 +52,6 @@
      * @plexus.requirement
      */
     private ContinuumStore store;
-    
-    /**
-     * @plexus.requirement
-     */
-    private UserManager userManager;
 
     // ----------------------------------------------------------------------
     //
@@ -118,19 +103,7 @@
 
             createGroups();
 
-            UserSecurityPolicy securityPolicy = userManager.getSecurityPolicy();
-
-            List rules = new ArrayList( securityPolicy.getPasswordRules() );
-
-            //lift all password restrictions temporarily
-            securityPolicy.getPasswordRules().clear();
-
-            createDefaultUsers();
-
-            createDefaultProjectGroup();
-
-            //put back password validation rules
-            securityPolicy.setPasswordRules( rules );
+            createUsers();
 
             getLogger().info( "... Continuum initialized" );
         }
@@ -139,13 +112,6 @@
             throw new ContinuumInitializationException( "Can't initialize default schedule.",
e );
         }
     }
-    
-    private void createDefaultUsers()
-    	throws ContinuumStoreException
-    {
-        createGuestUser();
-        createAdminUser();
-    }
 
     // ----------------------------------------------------------------------
     //
@@ -166,139 +132,20 @@
         return schedule;
     }
 
-    private void createPermissions()
+    protected void createPermissions()
         throws ContinuumStoreException
     {
-        createPermission( "addProject", "Add Projects" );
-
-        createPermission( "manageConfiguration", "Manage Continuum Configuration" );
-
-        createPermission( "manageSchedule", "Manage Schedules" );
-
-        createPermission( "manageUsers", "Manage Users/Groups" );
-
-        createPermission( "user", "Authenticated User" );
-
-        createPermission( "admin", "Administrator" );
-    }
-
-    private Permission createPermission( String name, String description )
-        throws ContinuumStoreException
-    {
-        Permission perm = ( Permission ) userManager.getPermission( name );
-
-        if ( perm == null )
-        {
-            perm = new Permission();
-
-            perm.setName( name );
-
-            perm.setDescription( description );
-
-            perm = ( Permission ) userManager.addPermission( perm );
-        }
-
-        return perm;
-    }
-
-    private void createGroups()
-        throws ContinuumStoreException
-    {
-        // Continuum Administrator
-        if ( userManager.getUserGroup( ContinuumSecurity.ADMIN_GROUP_NAME ) == null )
-        {
-            List adminPermissions = userManager.getPermissions();
-
-            UserGroup adminGroup = new UserGroup();
-
-            adminGroup.setName( ContinuumSecurity.ADMIN_GROUP_NAME );
-
-            adminGroup.setDescription( "Continuum Admin Group" );
-
-            adminGroup.setPermissions( adminPermissions );
-
-            userManager.addUserGroup( adminGroup );
-        }
-
-        // Continuum Guest
-        if ( userManager.getUserGroup( ContinuumSecurity.GUEST_GROUP_NAME ) == null )
-        {
-            UserGroup guestGroup = new UserGroup();
-
-            guestGroup.setName( ContinuumSecurity.GUEST_GROUP_NAME );
-
-            guestGroup.setDescription( "Continuum Guest Group" );
-
-            guestGroup.setPermissions( new ArrayList() );
-
-            userManager.addUserGroup( guestGroup );
-        }
     }
 
-    private void createGuestUser()
+    protected void createGroups()
         throws ContinuumStoreException
     {
-        if ( userManager.getGuestUser() == null )
-        {
-            ContinuumUser guest = new ContinuumUser();
-
-            guest.setUsername( "guest" );
-
-            guest.setFullName( "Anonymous User" );
-
-            guest.addGroup( userManager.getGuestUserGroup() );
-
-            guest.setGuest( true );
-
-            try
-            {
-                userManager.addUser( guest );
-            }
-// TODO
-//            catch ( EntityExistsException eee )
-//            {
-//                throw new ContinuumStoreException( "Error adding user, the user already
exists.", eee );
-//            }
-            catch ( PasswordRuleViolationException pre )
-            {
-                // TODO this must not happen for the predefined users
-                throw new ContinuumStoreException( "There was a password rule violation.",
pre );
-            }
-        }
+        createDefaultProjectGroup();
     }
 
-    private void createAdminUser()
+    protected void createUsers()
         throws ContinuumStoreException
     {
-        if ( userManager.getUser( "admin" ) == null )
-        {
-            ContinuumUser admin = new ContinuumUser();
-
-            admin.setUsername( "admin" );
-
-            admin.setFullName( "Administrator" );
-
-            admin.addGroup( userManager.getDefaultUserGroup() );
-
-            admin.addGroup( userManager.getUserGroup( ContinuumSecurity.ADMIN_GROUP_NAME
) );
-
-            admin.setPassword( "admin" );
-
-            try
-            {
-                userManager.addUser( admin );
-            }
-// TODO
-//            catch ( EntityExistsException eee )
-//            {
-//                throw new ContinuumStoreException( "The user already exists.", eee );
-//            }
-            catch ( PasswordRuleViolationException pre )
-            {
-                // TODO this must not happen for the predefined users
-                throw new ContinuumStoreException( "There was a password rule violation.",
pre );
-            }
-        }
     }
 
     private void createDefaultProjectGroup()

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/DefaultContinuumSecurity.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/DefaultContinuumSecurity.java?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/DefaultContinuumSecurity.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/DefaultContinuumSecurity.java
Mon Nov  6 11:05:11 2006
@@ -19,13 +19,15 @@
 import org.apache.maven.continuum.model.system.ContinuumUser;
 import org.apache.maven.continuum.model.system.Permission;
 import org.apache.maven.continuum.model.system.UserGroup;
-import org.apache.maven.user.model.UserManager;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
 /**
+ * @deprecated use Security framework instead
+ * 
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */
@@ -35,7 +37,7 @@
     /**
      * @plexus.requirement
      */
-    private UserManager userManager;
+    private ContinuumStore store;
 
     public List getPermissions( ContinuumUser user )
         throws ContinuumSecurityException
@@ -46,16 +48,8 @@
         {
             u = getGuestUser();
         }
-        
-        List groups = u.getGroups();
-        Iterator it = groups.iterator();
-        List permissions = new ArrayList();
-        while ( it.hasNext() )
-        {
-            permissions.addAll( ( (org.apache.maven.user.model.UserGroup) it.next() ).getPermissions()
);
-        }
 
-        return permissions;
+        return getPermissions( u.getGroup() );
     }
 
     public List getPermissions( UserGroup group )
@@ -106,6 +100,13 @@
     public ContinuumUser getGuestUser()
         throws ContinuumSecurityException
     {
-        return ( ContinuumUser ) userManager.getGuestUser();
+        try
+        {
+            return store.getGuestUser();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumSecurityException( "Can't obtain guest user.", e );
+        }
     }
 }

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/resources/META-INF/plexus/components.xml
Mon Nov  6 11:05:11 2006
@@ -24,10 +24,6 @@
           <role>org.apache.maven.continuum.build.settings.SchedulesActivator</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.user.model.UserManager</role>
-          <field-name>userManager</field-name>
-        </requirement>
-        <requirement>
           <role>org.apache.maven.continuum.release.ContinuumReleaseManager</role>
         </requirement>
         <!-- from core -->
@@ -71,7 +67,7 @@
       <implementation>org.apache.maven.continuum.security.DefaultContinuumSecurity</implementation>
       <requirements>
         <requirement>
-          <role>org.apache.maven.user.model.UserManager</role>
+          <role>org.apache.maven.continuum.store.ContinuumStore</role>
         </requirement>
       </requirements>
     </component>
@@ -82,9 +78,6 @@
       <requirements>
         <requirement>
           <role>org.apache.maven.continuum.store.ContinuumStore</role>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.user.model.UserManager</role>
         </requirement>
       </requirements>
     </component>

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/security/DefaultContinuumSecurityTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/security/DefaultContinuumSecurityTest.java?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/security/DefaultContinuumSecurityTest.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/test/java/org/apache/maven/continuum/security/DefaultContinuumSecurityTest.java
Mon Nov  6 11:05:11 2006
@@ -40,14 +40,14 @@
     public void testSecurity()
         throws Exception
     {
-        ContinuumSecurity secu = continuum.getSecurity();
-
-        ContinuumUser guest = secu.getGuestUser();
-
-        assertEquals( "guest", guest.getUsername() );
-
-        assertFalse( secu.isAuthorized( guest, "addProject") );
-
-        assertFalse( secu.isAuthorized( guest, "manageUsers") );
+//        ContinuumSecurity secu = continuum.getSecurity();
+//
+//        ContinuumUser guest = secu.getGuestUser();
+//
+//        assertEquals( "guest", guest.getUsername() );
+//
+//        assertFalse( secu.isAuthorized( guest, "addProject") );
+//
+//        assertFalse( secu.isAuthorized( guest, "manageUsers") );
     }
 }

Modified: maven/continuum/branches/continuum-acegi/continuum-model/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-model/pom.xml?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-model/pom.xml (original)
+++ maven/continuum/branches/continuum-acegi/continuum-model/pom.xml Mon Nov  6 11:05:11 2006
@@ -19,6 +19,7 @@
           <execution>
             <goals>
               <goal>java</goal>
+              <goal>jpox-jdo-mapping</goal>
             </goals>
           </execution>
         </executions>

Modified: maven/continuum/branches/continuum-acegi/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-model/src/main/mdo/continuum.xml?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-model/src/main/mdo/continuum.xml (original)
+++ maven/continuum/branches/continuum-acegi/continuum-model/src/main/mdo/continuum.xml Mon
Nov  6 11:05:11 2006
@@ -250,7 +250,7 @@
           <type>String</type>
           <description>The mechanism used to deliver notifications.</description>
         </field>
-        <field>
+        <field jpox.column="fromLocation">
           <name>from</name>
           <version>1.0.0+</version>
           <type>int</type>
@@ -480,7 +480,7 @@
           <version>1.0.0+</version>
           <type>String</type>
         </field>
-        <field stash.maxSize="8192">
+        <field stash.maxSize="8192" jpox.column="scmException">
           <name>exception</name>
           <version>1.0.0+</version>
           <type>String</type>
@@ -707,7 +707,7 @@
           <version>1.0.0+</version>
           <type>String</type>
         </field>
-        <field stash.maxSize="8192">
+        <field stash.maxSize="8192" jpox.column="testException">
           <name>exception</name>
           <version>1.0.0+</version>
           <type>String</type>
@@ -964,6 +964,201 @@
           <version>1.0.0+</version>
           <type>boolean</type>
           <defaultValue>false</defaultValue>
+        </field>
+      </fields>
+    </class>
+
+    <class>
+      <name>UserGroup</name>
+      <packageName>org.apache.maven.continuum.model.system</packageName>
+      <superClass>org.apache.maven.user.model.UserGroup</superClass>
+      <version>1.0.0+</version>
+      <description>@deprecated use security framework instead</description>
+      <fields>
+        <field>
+          <name>id</name>
+          <identifier>true</identifier>
+          <version>1.0.0+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>permissions</name>
+          <version>1.0.0+</version>
+          <association stash.part="true" jpox.dependent="false">
+            <type>Permission</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+    </class>
+    <class>
+      <name>ContinuumUser</name>
+      <packageName>org.apache.maven.continuum.model.system</packageName>
+      <superClass>org.apache.maven.user.model.User</superClass>
+      <version>1.0.0+</version>
+      <description>@deprecated use security framework instead</description>
+      <fields>
+        <field>
+          <name>accountId</name>
+          <version>1.0.0+</version>
+          <type>int</type>
+          <identifier>true</identifier>
+        </field>
+        <field>
+          <name>username</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>guest</name>
+          <version>1.0.0+</version>
+          <type>boolean</type>
+          <defaultValue>false</defaultValue>
+        </field>
+        <field>
+          <name>hashedPassword</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>fullName</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>email</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field jpox.column="userGroup">
+          <name>group</name>
+          <version>1.0.0+</version>
+          <association stash.part="true" jpox.dependent="false">
+            <type>UserGroup</type>
+          </association>
+        </field>
+        <field>
+          <name>notificationAddresses</name>
+          <version>1.0.0+</version>
+          <association stash.part="true" >
+            <type>NotificationAddress</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+      <codeSegments>
+        <codeSegment>
+          <version>1.0.0+</version>
+          <code><![CDATA[
+            public String getPassword()
+            {
+                return "";
+            }
+
+            public void setPassword( String password )
+            {
+                setHashedPassword( crypt( password ) );
+            }
+
+            public boolean equalsPassword( String password )
+            {
+                if ( hashedPassword == null && password == null )
+                {
+                    return true;
+                }
+
+                if ( ( hashedPassword == null && password != null ) || ( hashedPassword
== null && password != null ) )
+                {
+                    return false;
+                }
+
+                return hashedPassword.equals( crypt( password ) );
+            }
+
+            private String crypt( String data )
+            {
+                try
+                {
+                    java.security.MessageDigest digester = java.security.MessageDigest.getInstance(
"SHA-1" );
+                    digester.reset();
+                    digester.update( data.getBytes() );
+                    return encode( digester.digest() );
+                }
+                catch( Exception e )
+                {
+                    return data;
+                }
+            }
+
+            /**
+             * Encodes a 128 bit or 160-bit byte array into a String.
+             *
+             * @param binaryData Array containing the digest
+             * @return Encoded hex string, or null if encoding failed
+             */
+            private String encode( byte[] binaryData )
+            {
+                if ( binaryData.length != 16 && binaryData.length != 20 )
+                {
+                    int bitLength = binaryData.length * 8;
+                    throw new IllegalArgumentException( "Unrecognised length for binary data:
" + bitLength + " bits" );
+                }
+
+                String retValue = "";
+
+                for ( int i = 0; i < binaryData.length; i++ )
+                {
+                    String t = Integer.toHexString( binaryData[i] & 0xff );
+
+                    if ( t.length() == 1 )
+                    {
+                        retValue += ( "0" + t );
+                    }
+                    else
+                    {
+                        retValue += t;
+                    }
+                }
+
+                return retValue.trim();
+            }
+          ]]></code>
+        </codeSegment>
+      </codeSegments>
+    </class>
+
+    <class>
+      <name>Permission</name>
+      <packageName>org.apache.maven.continuum.model.system</packageName>
+      <superClass>org.apache.maven.user.model.Permission</superClass>
+      <version>1.0.0+</version>
+      <description>@deprecated use security framework instead</description>
+      <fields>
+        <field>
+          <name>id</name>
+          <identifier>true</identifier>
+          <version>1.0.0+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.0+</version>
+          <type>String</type>
         </field>
       </fields>
     </class>

Modified: maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/resources/META-INF/plexus/application.xml?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
Mon Nov  6 11:05:11 2006
@@ -831,7 +831,7 @@
 
     <component>
       <role>org.apache.maven.continuum.initialization.ContinuumInitializer</role>
-      <implementation>org.apache.maven.continuum.initialization.DefaultContinuumInitializer</implementation>
+      <implementation>org.apache.maven.continuum.security.acegi.initialization.SecurityContinuumInitializer</implementation>
       <requirements>
         <requirement>
           <role>org.apache.maven.continuum.store.ContinuumStore</role>

Modified: maven/continuum/branches/continuum-acegi/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/pom.xml?view=diff&rev=471829&r1=471828&r2=471829
==============================================================================
--- maven/continuum/branches/continuum-acegi/pom.xml (original)
+++ maven/continuum/branches/continuum-acegi/pom.xml Mon Nov  6 11:05:11 2006
@@ -81,7 +81,7 @@
         <plugin>
           <groupId>org.codehaus.modello</groupId>
           <artifactId>modello-maven-plugin</artifactId>
-          <version>1.0-alpha-11-SNAPSHOT</version>
+          <version>1.0-alpha-11</version>
         </plugin>
       </plugins>
     </pluginManagement>



Mime
View raw message