]> source.dussan.org Git - archiva.git/commitdiff
package move to o.a.a.r module redback-data-management
authorOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 21:43:40 +0000 (21:43 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 21:43:40 +0000 (21:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1310878 13f79535-47bb-0310-9956-ffa450edef68

redback-data-management/src/main/java/org/apache/archiva/redback/management/DataManagementTool.java [new file with mode: 0644]
redback-data-management/src/main/java/org/apache/archiva/redback/management/JdoDataManagementTool.java [new file with mode: 0644]
redback-data-management/src/main/java/org/codehaus/plexus/redback/management/DataManagementTool.java [deleted file]
redback-data-management/src/main/java/org/codehaus/plexus/redback/management/JdoDataManagementTool.java [deleted file]
redback-data-management/src/main/resources/META-INF/spring-context.xml
redback-data-management/src/test/java/org/apache/archiva/redback/management/DataManagementTest.java [new file with mode: 0644]
redback-data-management/src/test/java/org/codehaus/plexus/redback/management/DataManagementTest.java [deleted file]
redback-data-management/src/test/resources/org/apache/archiva/redback/config-defaults.properties [new file with mode: 0644]
redback-data-management/src/test/resources/org/codehaus/plexus/redback/config-defaults.properties [deleted file]
redback-integrations/redback-struts2/redback-struts2-integration/src/main/java/org/codehaus/plexus/redback/struts2/action/admin/BackupRestoreAction.java

diff --git a/redback-data-management/src/main/java/org/apache/archiva/redback/management/DataManagementTool.java b/redback-data-management/src/main/java/org/apache/archiva/redback/management/DataManagementTool.java
new file mode 100644 (file)
index 0000000..3df1800
--- /dev/null
@@ -0,0 +1,64 @@
+package org.apache.archiva.redback.management;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.redback.users.UserManager;
+import org.codehaus.plexus.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.rbac.RBACManager;
+import org.codehaus.plexus.redback.rbac.RbacManagerException;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Data management tool API.
+ */
+public interface DataManagementTool
+{
+    /**
+     * Plexus role.
+     */
+    String ROLE = DataManagementTool.class.getName();
+
+    void backupRBACDatabase( RBACManager manager, File backupDirectory )
+        throws RbacManagerException, IOException, XMLStreamException;
+
+    void backupUserDatabase( UserManager manager, File backupDirectory )
+        throws IOException, XMLStreamException;
+
+    void backupKeyDatabase( KeyManager manager, File backupDirectory )
+        throws IOException, XMLStreamException;
+
+    void restoreRBACDatabase( RBACManager manager, File backupDirectory )
+        throws IOException, XMLStreamException, RbacManagerException;
+
+    void restoreUsersDatabase( UserManager manager, File backupDirectory )
+        throws IOException, XMLStreamException;
+
+    void restoreKeysDatabase( KeyManager manager, File backupDirectory )
+        throws IOException, XMLStreamException;
+
+    void eraseRBACDatabase( RBACManager manager );
+
+    void eraseUsersDatabase( UserManager manager );
+
+    void eraseKeysDatabase( KeyManager manager );
+}
diff --git a/redback-data-management/src/main/java/org/apache/archiva/redback/management/JdoDataManagementTool.java b/redback-data-management/src/main/java/org/apache/archiva/redback/management/JdoDataManagementTool.java
new file mode 100644 (file)
index 0000000..c0cb689
--- /dev/null
@@ -0,0 +1,307 @@
+package org.apache.archiva.redback.management;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.archiva.redback.management.DataManagementTool;
+import org.apache.archiva.redback.users.UserManager;
+import org.codehaus.plexus.redback.keys.AuthenticationKey;
+import org.codehaus.plexus.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.keys.KeyManagerException;
+import org.codehaus.plexus.redback.keys.jdo.AuthenticationKeyDatabase;
+import org.codehaus.plexus.redback.keys.jdo.io.stax.RedbackKeyManagementJdoStaxReader;
+import org.codehaus.plexus.redback.keys.jdo.io.stax.RedbackKeyManagementJdoStaxWriter;
+import org.codehaus.plexus.redback.rbac.Operation;
+import org.codehaus.plexus.redback.rbac.Permission;
+import org.codehaus.plexus.redback.rbac.RBACManager;
+import org.codehaus.plexus.redback.rbac.RbacManagerException;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.redback.rbac.Role;
+import org.codehaus.plexus.redback.rbac.UserAssignment;
+import org.codehaus.plexus.redback.rbac.jdo.RbacDatabase;
+import org.codehaus.plexus.redback.rbac.jdo.io.stax.RbacJdoModelStaxReader;
+import org.codehaus.plexus.redback.rbac.jdo.io.stax.RbacJdoModelStaxWriter;
+import org.apache.archiva.redback.users.User;
+import org.codehaus.plexus.redback.users.jdo.UserDatabase;
+import org.codehaus.plexus.redback.users.jdo.io.stax.UsersManagementStaxReader;
+import org.codehaus.plexus.redback.users.jdo.io.stax.UsersManagementStaxWriter;
+import org.codehaus.plexus.util.IOUtil;
+import org.springframework.stereotype.Service;
+
+/**
+ * JDO implementation of the data management tool.
+ *
+ * @todo do we really need JDO specifics here? Could optimize by going straight to JDOFactory
+ * @todo check whether this current method logs everything unnecessarily.
+ */
+@Service("dataManagementTool#jdo")
+public class JdoDataManagementTool
+    implements DataManagementTool
+{
+    private static final String USERS_XML_NAME = "users.xml";
+
+    private static final String KEYS_XML_NAME = "keys.xml";
+
+    private static final String RBAC_XML_NAME = "rbac.xml";
+
+    public void backupRBACDatabase( RBACManager manager, File backupDirectory )
+        throws RbacManagerException, IOException, XMLStreamException
+    {
+        RbacDatabase database = new RbacDatabase();
+        database.setRoles( manager.getAllRoles() );
+        database.setUserAssignments( manager.getAllUserAssignments() );
+        database.setPermissions( manager.getAllPermissions() );
+        database.setOperations( manager.getAllOperations() );
+        database.setResources( manager.getAllResources() );
+
+        RbacJdoModelStaxWriter writer = new RbacJdoModelStaxWriter();
+        Writer fileWriter = createWriter( backupDirectory, RBAC_XML_NAME, database.getModelEncoding() );
+        try
+        {
+            writer.write( fileWriter, database );
+        }
+        finally
+        {
+            IOUtil.close( fileWriter );
+        }
+    }
+
+    public void backupUserDatabase( UserManager manager, File backupDirectory )
+        throws IOException, XMLStreamException
+    {
+        UserDatabase database = new UserDatabase();
+        database.setUsers( manager.getUsers() );
+
+        UsersManagementStaxWriter writer = new UsersManagementStaxWriter();
+        Writer fileWriter = createWriter( backupDirectory, USERS_XML_NAME, database.getModelEncoding() );
+        try
+        {
+            writer.write( fileWriter, database );
+        }
+        finally
+        {
+            IOUtil.close( fileWriter );
+        }
+    }
+
+    public void backupKeyDatabase( KeyManager manager, File backupDirectory )
+        throws IOException, XMLStreamException
+    {
+        try
+        {
+            manager.removeExpiredKeys();
+        }
+        catch ( KeyManagerException e )
+        {
+            throw new IOException( "Error removing expired keys" );
+        }
+
+        AuthenticationKeyDatabase database = new AuthenticationKeyDatabase();
+        database.setKeys( manager.getAllKeys() );
+
+        RedbackKeyManagementJdoStaxWriter writer = new RedbackKeyManagementJdoStaxWriter();
+        Writer fileWriter = createWriter( backupDirectory, KEYS_XML_NAME, database.getModelEncoding() );
+        try
+        {
+            writer.write( fileWriter, database );
+        }
+        finally
+        {
+            IOUtil.close( fileWriter );
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void restoreRBACDatabase( RBACManager manager, File backupDirectory )
+        throws IOException, XMLStreamException, RbacManagerException
+    {
+        RbacJdoModelStaxReader reader = new RbacJdoModelStaxReader();
+
+        FileReader fileReader = new FileReader( new File( backupDirectory, RBAC_XML_NAME ) );
+
+        RbacDatabase database;
+        try
+        {
+            database = reader.read( fileReader );
+        }
+        finally
+        {
+            IOUtil.close( fileReader );
+        }
+
+        Map<String, Permission> permissionMap = new HashMap<String, Permission>();
+        Map<String, Resource> resources = new HashMap<String, Resource>();
+        Map<String, Operation> operations = new HashMap<String, Operation>();
+        for ( Role role : (List<Role>) database.getRoles() )
+        {
+            // TODO: this could be generally useful and put into saveRole itself as long as the performance penalty isn't too harsh.
+            //   Currently it always saves everything where it could pull pack the existing permissions, etc if they exist
+            List<Permission> permissions = new ArrayList<Permission>();
+            for ( Permission permission : role.getPermissions() )
+            {
+                if ( permissionMap.containsKey( permission.getName() ) )
+                {
+                    permission = permissionMap.get( permission.getName() );
+                }
+                else if ( manager.permissionExists( permission ) )
+                {
+                    permission = manager.getPermission( permission.getName() );
+                    permissionMap.put( permission.getName(), permission );
+                }
+                else
+                {
+                    Operation operation = permission.getOperation();
+                    if ( operations.containsKey( operation.getName() ) )
+                    {
+                        operation = operations.get( operation.getName() );
+                    }
+                    else if ( manager.operationExists( operation ) )
+                    {
+                        operation = manager.getOperation( operation.getName() );
+                        operations.put( operation.getName(), operation );
+                    }
+                    else
+                    {
+                        operation = manager.saveOperation( operation );
+                        operations.put( operation.getName(), operation );
+                    }
+                    permission.setOperation( operation );
+
+                    Resource resource = permission.getResource();
+                    if ( resources.containsKey( resource.getIdentifier() ) )
+                    {
+                        resource = resources.get( resource.getIdentifier() );
+                    }
+                    else if ( manager.resourceExists( resource ) )
+                    {
+                        resource = manager.getResource( resource.getIdentifier() );
+                        resources.put( resource.getIdentifier(), resource );
+                    }
+                    else
+                    {
+                        resource = manager.saveResource( resource );
+                        resources.put( resource.getIdentifier(), resource );
+                    }
+                    permission.setResource( resource );
+
+                    permission = manager.savePermission( permission );
+                    permissionMap.put( permission.getName(), permission );
+                }
+                permissions.add( permission );
+            }
+            role.setPermissions( permissions );
+
+            manager.saveRole( role );
+        }
+
+        for ( UserAssignment userAssignment : (List<UserAssignment>) database.getUserAssignments() )
+        {
+            manager.saveUserAssignment( userAssignment );
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void restoreUsersDatabase( UserManager manager, File backupDirectory )
+        throws IOException, XMLStreamException
+    {
+        UsersManagementStaxReader reader = new UsersManagementStaxReader();
+
+        FileReader fileReader = new FileReader( new File( backupDirectory, USERS_XML_NAME ) );
+
+        UserDatabase database;
+        try
+        {
+            database = reader.read( fileReader );
+        }
+        finally
+        {
+            IOUtil.close( fileReader );
+        }
+
+        for ( User user : (List<User>) database.getUsers() )
+        {
+            manager.addUserUnchecked( user );
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void restoreKeysDatabase( KeyManager manager, File backupDirectory )
+        throws IOException, XMLStreamException
+    {
+        RedbackKeyManagementJdoStaxReader reader = new RedbackKeyManagementJdoStaxReader();
+
+        FileReader fileReader = new FileReader( new File( backupDirectory, KEYS_XML_NAME ) );
+
+        AuthenticationKeyDatabase database;
+        try
+        {
+            database = reader.read( fileReader );
+        }
+        finally
+        {
+            IOUtil.close( fileReader );
+        }
+
+        for ( AuthenticationKey key : (List<AuthenticationKey>) database.getKeys() )
+        {
+            manager.addKey( key );
+        }
+    }
+
+    public void eraseRBACDatabase( RBACManager manager )
+    {
+        manager.eraseDatabase();
+    }
+
+    public void eraseUsersDatabase( UserManager manager )
+    {
+        manager.eraseDatabase();
+    }
+
+    public void eraseKeysDatabase( KeyManager manager )
+    {
+        manager.eraseDatabase();
+    }
+
+    private Writer createWriter( File directory, String file, String encoding )
+        throws FileNotFoundException
+    {
+        File f = new File( directory, file );
+        File parentFile = f.getParentFile();
+        parentFile.mkdirs();
+
+        FileOutputStream out = new FileOutputStream( f );
+        return new OutputStreamWriter( out, Charset.forName( encoding ) );
+    }
+}
diff --git a/redback-data-management/src/main/java/org/codehaus/plexus/redback/management/DataManagementTool.java b/redback-data-management/src/main/java/org/codehaus/plexus/redback/management/DataManagementTool.java
deleted file mode 100644 (file)
index d371d63..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.codehaus.plexus.redback.management;
-
-/*
- * 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.
- */
-
-import org.apache.archiva.redback.users.UserManager;
-import org.codehaus.plexus.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.rbac.RBACManager;
-import org.codehaus.plexus.redback.rbac.RbacManagerException;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Data management tool API.
- */
-public interface DataManagementTool
-{
-    /**
-     * Plexus role.
-     */
-    String ROLE = DataManagementTool.class.getName();
-
-    void backupRBACDatabase( RBACManager manager, File backupDirectory )
-        throws RbacManagerException, IOException, XMLStreamException;
-
-    void backupUserDatabase( UserManager manager, File backupDirectory )
-        throws IOException, XMLStreamException;
-
-    void backupKeyDatabase( KeyManager manager, File backupDirectory )
-        throws IOException, XMLStreamException;
-
-    void restoreRBACDatabase( RBACManager manager, File backupDirectory )
-        throws IOException, XMLStreamException, RbacManagerException;
-
-    void restoreUsersDatabase( UserManager manager, File backupDirectory )
-        throws IOException, XMLStreamException;
-
-    void restoreKeysDatabase( KeyManager manager, File backupDirectory )
-        throws IOException, XMLStreamException;
-
-    void eraseRBACDatabase( RBACManager manager );
-
-    void eraseUsersDatabase( UserManager manager );
-
-    void eraseKeysDatabase( KeyManager manager );
-}
diff --git a/redback-data-management/src/main/java/org/codehaus/plexus/redback/management/JdoDataManagementTool.java b/redback-data-management/src/main/java/org/codehaus/plexus/redback/management/JdoDataManagementTool.java
deleted file mode 100644 (file)
index 28682c8..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-package org.codehaus.plexus.redback.management;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.archiva.redback.users.UserManager;
-import org.codehaus.plexus.redback.keys.AuthenticationKey;
-import org.codehaus.plexus.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.keys.KeyManagerException;
-import org.codehaus.plexus.redback.keys.jdo.AuthenticationKeyDatabase;
-import org.codehaus.plexus.redback.keys.jdo.io.stax.RedbackKeyManagementJdoStaxReader;
-import org.codehaus.plexus.redback.keys.jdo.io.stax.RedbackKeyManagementJdoStaxWriter;
-import org.codehaus.plexus.redback.rbac.Operation;
-import org.codehaus.plexus.redback.rbac.Permission;
-import org.codehaus.plexus.redback.rbac.RBACManager;
-import org.codehaus.plexus.redback.rbac.RbacManagerException;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.plexus.redback.rbac.Role;
-import org.codehaus.plexus.redback.rbac.UserAssignment;
-import org.codehaus.plexus.redback.rbac.jdo.RbacDatabase;
-import org.codehaus.plexus.redback.rbac.jdo.io.stax.RbacJdoModelStaxReader;
-import org.codehaus.plexus.redback.rbac.jdo.io.stax.RbacJdoModelStaxWriter;
-import org.apache.archiva.redback.users.User;
-import org.codehaus.plexus.redback.users.jdo.UserDatabase;
-import org.codehaus.plexus.redback.users.jdo.io.stax.UsersManagementStaxReader;
-import org.codehaus.plexus.redback.users.jdo.io.stax.UsersManagementStaxWriter;
-import org.codehaus.plexus.util.IOUtil;
-import org.springframework.stereotype.Service;
-
-/**
- * JDO implementation of the data management tool.
- *
- * @todo do we really need JDO specifics here? Could optimize by going straight to JDOFactory
- * @todo check whether this current method logs everything unnecessarily.
- */
-@Service("dataManagementTool#jdo")
-public class JdoDataManagementTool
-    implements DataManagementTool
-{
-    private static final String USERS_XML_NAME = "users.xml";
-
-    private static final String KEYS_XML_NAME = "keys.xml";
-
-    private static final String RBAC_XML_NAME = "rbac.xml";
-
-    public void backupRBACDatabase( RBACManager manager, File backupDirectory )
-        throws RbacManagerException, IOException, XMLStreamException
-    {
-        RbacDatabase database = new RbacDatabase();
-        database.setRoles( manager.getAllRoles() );
-        database.setUserAssignments( manager.getAllUserAssignments() );
-        database.setPermissions( manager.getAllPermissions() );
-        database.setOperations( manager.getAllOperations() );
-        database.setResources( manager.getAllResources() );
-
-        RbacJdoModelStaxWriter writer = new RbacJdoModelStaxWriter();
-        Writer fileWriter = createWriter( backupDirectory, RBAC_XML_NAME, database.getModelEncoding() );
-        try
-        {
-            writer.write( fileWriter, database );
-        }
-        finally
-        {
-            IOUtil.close( fileWriter );
-        }
-    }
-
-    public void backupUserDatabase( UserManager manager, File backupDirectory )
-        throws IOException, XMLStreamException
-    {
-        UserDatabase database = new UserDatabase();
-        database.setUsers( manager.getUsers() );
-
-        UsersManagementStaxWriter writer = new UsersManagementStaxWriter();
-        Writer fileWriter = createWriter( backupDirectory, USERS_XML_NAME, database.getModelEncoding() );
-        try
-        {
-            writer.write( fileWriter, database );
-        }
-        finally
-        {
-            IOUtil.close( fileWriter );
-        }
-    }
-
-    public void backupKeyDatabase( KeyManager manager, File backupDirectory )
-        throws IOException, XMLStreamException
-    {
-        try
-        {
-            manager.removeExpiredKeys();
-        }
-        catch ( KeyManagerException e )
-        {
-            throw new IOException( "Error removing expired keys" );
-        }
-
-        AuthenticationKeyDatabase database = new AuthenticationKeyDatabase();
-        database.setKeys( manager.getAllKeys() );
-
-        RedbackKeyManagementJdoStaxWriter writer = new RedbackKeyManagementJdoStaxWriter();
-        Writer fileWriter = createWriter( backupDirectory, KEYS_XML_NAME, database.getModelEncoding() );
-        try
-        {
-            writer.write( fileWriter, database );
-        }
-        finally
-        {
-            IOUtil.close( fileWriter );
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    public void restoreRBACDatabase( RBACManager manager, File backupDirectory )
-        throws IOException, XMLStreamException, RbacManagerException
-    {
-        RbacJdoModelStaxReader reader = new RbacJdoModelStaxReader();
-
-        FileReader fileReader = new FileReader( new File( backupDirectory, RBAC_XML_NAME ) );
-
-        RbacDatabase database;
-        try
-        {
-            database = reader.read( fileReader );
-        }
-        finally
-        {
-            IOUtil.close( fileReader );
-        }
-
-        Map<String, Permission> permissionMap = new HashMap<String, Permission>();
-        Map<String, Resource> resources = new HashMap<String, Resource>();
-        Map<String, Operation> operations = new HashMap<String, Operation>();
-        for ( Role role : (List<Role>) database.getRoles() )
-        {
-            // TODO: this could be generally useful and put into saveRole itself as long as the performance penalty isn't too harsh.
-            //   Currently it always saves everything where it could pull pack the existing permissions, etc if they exist
-            List<Permission> permissions = new ArrayList<Permission>();
-            for ( Permission permission : role.getPermissions() )
-            {
-                if ( permissionMap.containsKey( permission.getName() ) )
-                {
-                    permission = permissionMap.get( permission.getName() );
-                }
-                else if ( manager.permissionExists( permission ) )
-                {
-                    permission = manager.getPermission( permission.getName() );
-                    permissionMap.put( permission.getName(), permission );
-                }
-                else
-                {
-                    Operation operation = permission.getOperation();
-                    if ( operations.containsKey( operation.getName() ) )
-                    {
-                        operation = operations.get( operation.getName() );
-                    }
-                    else if ( manager.operationExists( operation ) )
-                    {
-                        operation = manager.getOperation( operation.getName() );
-                        operations.put( operation.getName(), operation );
-                    }
-                    else
-                    {
-                        operation = manager.saveOperation( operation );
-                        operations.put( operation.getName(), operation );
-                    }
-                    permission.setOperation( operation );
-
-                    Resource resource = permission.getResource();
-                    if ( resources.containsKey( resource.getIdentifier() ) )
-                    {
-                        resource = resources.get( resource.getIdentifier() );
-                    }
-                    else if ( manager.resourceExists( resource ) )
-                    {
-                        resource = manager.getResource( resource.getIdentifier() );
-                        resources.put( resource.getIdentifier(), resource );
-                    }
-                    else
-                    {
-                        resource = manager.saveResource( resource );
-                        resources.put( resource.getIdentifier(), resource );
-                    }
-                    permission.setResource( resource );
-
-                    permission = manager.savePermission( permission );
-                    permissionMap.put( permission.getName(), permission );
-                }
-                permissions.add( permission );
-            }
-            role.setPermissions( permissions );
-
-            manager.saveRole( role );
-        }
-
-        for ( UserAssignment userAssignment : (List<UserAssignment>) database.getUserAssignments() )
-        {
-            manager.saveUserAssignment( userAssignment );
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    public void restoreUsersDatabase( UserManager manager, File backupDirectory )
-        throws IOException, XMLStreamException
-    {
-        UsersManagementStaxReader reader = new UsersManagementStaxReader();
-
-        FileReader fileReader = new FileReader( new File( backupDirectory, USERS_XML_NAME ) );
-
-        UserDatabase database;
-        try
-        {
-            database = reader.read( fileReader );
-        }
-        finally
-        {
-            IOUtil.close( fileReader );
-        }
-
-        for ( User user : (List<User>) database.getUsers() )
-        {
-            manager.addUserUnchecked( user );
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    public void restoreKeysDatabase( KeyManager manager, File backupDirectory )
-        throws IOException, XMLStreamException
-    {
-        RedbackKeyManagementJdoStaxReader reader = new RedbackKeyManagementJdoStaxReader();
-
-        FileReader fileReader = new FileReader( new File( backupDirectory, KEYS_XML_NAME ) );
-
-        AuthenticationKeyDatabase database;
-        try
-        {
-            database = reader.read( fileReader );
-        }
-        finally
-        {
-            IOUtil.close( fileReader );
-        }
-
-        for ( AuthenticationKey key : (List<AuthenticationKey>) database.getKeys() )
-        {
-            manager.addKey( key );
-        }
-    }
-
-    public void eraseRBACDatabase( RBACManager manager )
-    {
-        manager.eraseDatabase();
-    }
-
-    public void eraseUsersDatabase( UserManager manager )
-    {
-        manager.eraseDatabase();
-    }
-
-    public void eraseKeysDatabase( KeyManager manager )
-    {
-        manager.eraseDatabase();
-    }
-
-    private Writer createWriter( File directory, String file, String encoding )
-        throws FileNotFoundException
-    {
-        File f = new File( directory, file );
-        File parentFile = f.getParentFile();
-        parentFile.mkdirs();
-
-        FileOutputStream out = new FileOutputStream( f );
-        return new OutputStreamWriter( out, Charset.forName( encoding ) );
-    }
-}
index 0c1d12adbcf98d3348b77b069ac6425b1b6429c7..735227811ded2aeab17ad00ad0fb54172340dc0e 100644 (file)
@@ -29,6 +29,6 @@
 
   <context:annotation-config />
   <context:component-scan 
-    base-package="org.codehaus.plexus.redback.management"/>
+    base-package="org.apache.archiva.redback.management"/>
  
 </beans>
\ No newline at end of file
diff --git a/redback-data-management/src/test/java/org/apache/archiva/redback/management/DataManagementTest.java b/redback-data-management/src/test/java/org/apache/archiva/redback/management/DataManagementTest.java
new file mode 100644 (file)
index 0000000..6540892
--- /dev/null
@@ -0,0 +1,447 @@
+package org.apache.archiva.redback.management;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+import org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory;
+import org.apache.archiva.redback.management.DataManagementTool;
+import org.apache.archiva.redback.users.UserManager;
+import org.apache.commons.lang.SystemUtils;
+import org.codehaus.plexus.redback.keys.AuthenticationKey;
+import org.codehaus.plexus.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.keys.KeyManagerException;
+import org.codehaus.plexus.redback.rbac.Permission;
+import org.codehaus.plexus.redback.rbac.RBACManager;
+import org.codehaus.plexus.redback.rbac.RbacManagerException;
+import org.codehaus.plexus.redback.rbac.Role;
+import org.codehaus.plexus.redback.rbac.UserAssignment;
+import org.codehaus.plexus.redback.tests.utils.RBACDefaults;
+import org.apache.archiva.redback.users.User;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class DataManagementTest
+    extends TestCase
+{
+    @Inject
+    private DataManagementTool dataManagementTool;
+
+    private File targetDirectory;
+
+    @Inject
+    @Named( value = "jdoFactory#users" )
+    UserConfigurableJdoFactory jdoFactory;
+
+    @Inject
+    @Named( value = "userManager#jdo" )
+    UserManager userManager;
+
+    @Inject
+    @Named( value = "keyManager#jdo" )
+    KeyManager keyManager;
+
+
+    @Inject
+    @Named( value = "rBACManager#jdo" )
+    RBACManager rbacManager;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        targetDirectory = createBackupDirectory();
+    }
+
+    @Test
+    public void testEraseUsers()
+        throws Exception
+    {
+
+        dataManagementTool.eraseUsersDatabase( userManager );
+
+        createUserDatabase( userManager );
+
+        dataManagementTool.eraseUsersDatabase( userManager );
+
+        assertEmpty( userManager );
+    }
+
+    @Test
+    public void testEraseKeys()
+        throws Exception
+    {
+
+        createKeyDatabase( keyManager );
+
+        dataManagementTool.eraseKeysDatabase( keyManager );
+
+        assertEmpty( keyManager );
+    }
+
+    @Test
+    public void testBackupRbac()
+        throws Exception
+    {
+        RBACManager manager = rbacManager;
+
+        dataManagementTool.eraseRBACDatabase( manager );
+
+        createRbacDatabase( manager );
+
+        dataManagementTool.backupRBACDatabase( manager, targetDirectory );
+
+        File backupFile = new File( targetDirectory, "rbac.xml" );
+
+        assertTrue( "Check database exists", backupFile.exists() );
+
+        StringWriter sw = new StringWriter();
+
+        IOUtil.copy( getClass().getResourceAsStream( "/expected-rbac.xml" ), sw );
+
+        XMLAssert.assertXMLEqual( new StringReader( sw.toString() ),
+                                  new StringReader( FileUtils.fileRead( backupFile ) ) );
+
+    }
+
+    private void createRbacDatabase( RBACManager manager )
+        throws RbacManagerException
+    {
+        RBACDefaults defaults = new RBACDefaults( manager );
+
+        defaults.createDefaults();
+
+        UserAssignment assignment = manager.createUserAssignment( "bob" );
+        assignment.addRoleName( "Developer" );
+        manager.saveUserAssignment( assignment );
+
+        assignment = manager.createUserAssignment( "betty" );
+        assignment.addRoleName( "System Administrator" );
+        manager.saveUserAssignment( assignment );
+    }
+
+    @Test
+    public void testBackupUsers()
+        throws Exception
+    {
+        UserManager manager = userManager;
+
+        createUserDatabase( manager );
+
+        dataManagementTool.backupUserDatabase( manager, targetDirectory );
+
+        File backupFile = new File( targetDirectory, "users.xml" );
+
+        assertTrue( "Check database exists", backupFile.exists() );
+
+        StringWriter sw = new StringWriter();
+
+        IOUtil.copy( getClass().getResourceAsStream( "/expected-users.xml" ), sw );
+
+        String actual = FileUtils.fileRead( backupFile ).trim();
+        String expected = sw.toString().trim();
+
+        XMLAssert.assertXMLEqual( removeTimestampVariance( expected ), removeTimestampVariance( actual ) );
+
+    }
+
+    private void createUserDatabase( UserManager manager )
+    {
+        User user = manager.createUser( "smcqueen", "Steve McQueen", "the cooler king" );
+        user.setPassword( "abc123" );
+        manager.addUser( user );
+
+        user = manager.createUser( "bob", "Sideshow Bob", "bob_862@hotmail.com" );
+        user.setPassword( "bobby862" );
+        manager.addUser( user );
+
+        user = manager.createUser( "betty", "Betty", "betty@aol.com" );
+        user.setPassword( "rover2" );
+        manager.addUser( user );
+    }
+
+    @Test
+    public void testBackupKeys()
+        throws Exception
+    {
+        KeyManager manager = keyManager;
+
+        createKeyDatabase( manager );
+
+        Thread.sleep( 60000 );
+
+        dataManagementTool.backupKeyDatabase( manager, targetDirectory );
+
+        File backupFile = new File( targetDirectory, "keys.xml" );
+
+        assertTrue( "Check database exists", backupFile.exists() );
+
+        StringWriter sw = new StringWriter();
+
+        IOUtil.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), sw );
+
+        String actual = FileUtils.fileRead( backupFile ).trim();
+        String expected = sw.toString().trim();
+
+        XMLAssert.assertXMLEqual( removeKeyAndTimestampVariance( expected ), removeKeyAndTimestampVariance( actual ) );
+
+    }
+
+    private static void createKeyDatabase( KeyManager manager )
+        throws KeyManagerException
+    {
+        manager.createKey( "bob", "Testing", 15 );
+        manager.createKey( "betty", "Something", 25 );
+        manager.createKey( "fred", "Else", 30 );
+        manager.createKey( "tony", "Expired", 0 );
+    }
+
+    @Test
+    public void testRestoreRbac()
+        throws Exception
+    {
+        RBACManager manager = rbacManager;
+
+        dataManagementTool.eraseRBACDatabase( manager );
+
+        assertEmpty( manager );
+
+        File backupFile = new File( targetDirectory, "rbac.xml" );
+
+        IOUtil.copy( getClass().getResourceAsStream( "/expected-rbac.xml" ), new FileWriter( backupFile ) );
+
+        dataManagementTool.restoreRBACDatabase( manager, targetDirectory );
+
+        List<Role> roles = manager.getAllRoles();
+        List<UserAssignment> assignments = manager.getAllUserAssignments();
+        assertEquals( 4, roles.size() );
+        assertEquals( 2, assignments.size() );
+        assertEquals( 6, manager.getAllOperations().size() );
+        assertEquals( 1, manager.getAllResources().size() );
+        assertEquals( 6, manager.getAllPermissions().size() );
+
+        Role role = roles.get( 0 );
+        assertEquals( "User Administrator", role.getName() );
+        assertTrue( role.isAssignable() );
+        assertEquals( 2, role.getPermissions().size() );
+        assertPermission( role.getPermissions().get( 0 ), "Edit All Users", "edit-all-users", "*" );
+        assertPermission( role.getPermissions().get( 1 ), "Remove Roles", "remove-roles", "*" );
+
+        role = roles.get( 1 );
+        assertEquals( "System Administrator", role.getName() );
+        assertTrue( role.isAssignable() );
+        assertEquals( 1, role.getChildRoleNames().size() );
+        assertEquals( "User Administrator", role.getChildRoleNames().get( 0 ) );
+        assertEquals( 4, role.getPermissions().size() );
+        assertPermission( role.getPermissions().get( 0 ), "Edit Configuration", "edit-configuration", "*" );
+        assertPermission( role.getPermissions().get( 1 ), "Run Indexer", "run-indexer", "*" );
+        assertPermission( role.getPermissions().get( 2 ), "Add Repository", "add-repository", "*" );
+        assertPermission( role.getPermissions().get( 3 ), "Regenerate Index", "regenerate-index", "*" );
+
+        role = roles.get( 2 );
+        assertEquals( "Trusted Developer", role.getName() );
+        assertTrue( role.isAssignable() );
+        assertEquals( 1, role.getChildRoleNames().size() );
+        assertEquals( "System Administrator", role.getChildRoleNames().get( 0 ) );
+        assertEquals( 1, role.getPermissions().size() );
+        assertPermission( role.getPermissions().get( 0 ), "Run Indexer", "run-indexer", "*" );
+
+        role = roles.get( 3 );
+        assertEquals( "Developer", role.getName() );
+        assertTrue( role.isAssignable() );
+        assertEquals( 1, role.getChildRoleNames().size() );
+        assertEquals( "Trusted Developer", role.getChildRoleNames().get( 0 ) );
+        assertEquals( 1, role.getPermissions().size() );
+        assertPermission( role.getPermissions().get( 0 ), "Run Indexer", "run-indexer", "*" );
+
+        UserAssignment assignment = assignments.get( 0 );
+        assertEquals( "bob", assignment.getPrincipal() );
+        assertEquals( 1, assignment.getRoleNames().size() );
+        assertEquals( "Developer", assignment.getRoleNames().get( 0 ) );
+
+        assignment = assignments.get( 1 );
+        assertEquals( "betty", assignment.getPrincipal() );
+        assertEquals( 1, assignment.getRoleNames().size() );
+        assertEquals( "System Administrator", assignment.getRoleNames().get( 0 ) );
+    }
+
+    private void assertEmpty( RBACManager manager )
+        throws RbacManagerException
+    {
+        assertEquals( 0, manager.getAllRoles().size() );
+        assertEquals( 0, manager.getAllUserAssignments().size() );
+        assertEquals( 0, manager.getAllOperations().size() );
+        assertEquals( 0, manager.getAllResources().size() );
+        assertEquals( 0, manager.getAllPermissions().size() );
+    }
+
+    @Test
+    public void testRestoreUsers()
+        throws Exception
+    {
+        UserManager manager = userManager;
+
+        dataManagementTool.eraseUsersDatabase( manager );
+
+        assertEmpty( manager );
+
+        File backupFile = new File( targetDirectory, "users.xml" );
+
+        IOUtil.copy( getClass().getResourceAsStream( "/expected-users.xml" ), new FileWriter( backupFile ) );
+
+        dataManagementTool.restoreUsersDatabase( manager, targetDirectory );
+
+        List<User> users = manager.getUsers();
+        assertEquals( 3, users.size() );
+
+        User user = users.get( 0 );
+        assertEquals( "smcqueen", user.getUsername() );
+        assertEquals( "bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=", user.getEncodedPassword() );
+        assertEquals( "Steve McQueen", user.getFullName() );
+        assertEquals( "the cooler king", user.getEmail() );
+        assertEquals( 1164424661686L, user.getLastPasswordChange().getTime() );
+        assertEquals( Arrays.asList( new String[]{ "bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=" } ),
+                      user.getPreviousEncodedPasswords() );
+
+        user = users.get( 1 );
+        assertEquals( "bob", user.getUsername() );
+        assertEquals( "A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=", user.getEncodedPassword() );
+        assertEquals( "Sideshow Bob", user.getFullName() );
+        assertEquals( "bob_862@hotmail.com", user.getEmail() );
+        assertEquals( 1164424669526L, user.getLastPasswordChange().getTime() );
+        assertEquals( Arrays.asList( new String[]{ "A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=" } ),
+                      user.getPreviousEncodedPasswords() );
+
+        user = users.get( 2 );
+        assertEquals( "betty", user.getUsername() );
+        assertEquals( "L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=", user.getEncodedPassword() );
+        assertEquals( "Betty", user.getFullName() );
+        assertEquals( "betty@aol.com", user.getEmail() );
+        assertEquals( 1164424669536L, user.getLastPasswordChange().getTime() );
+        assertEquals( Arrays.asList( new String[]{ "L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=" } ),
+                      user.getPreviousEncodedPasswords() );
+    }
+
+    private void assertEmpty( UserManager manager )
+    {
+        List<User> users = manager.getUsers();
+        assertEquals( 0, users.size() );
+    }
+
+    @Test
+    public void testRestoreKeys()
+        throws Exception
+    {
+        KeyManager manager = keyManager;
+
+        dataManagementTool.eraseKeysDatabase( manager );
+
+        assertEmpty( manager );
+
+        File backupFile = new File( targetDirectory, "keys.xml" );
+
+        IOUtil.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), new FileWriter( backupFile ) );
+
+        dataManagementTool.restoreKeysDatabase( manager, targetDirectory );
+
+        List<AuthenticationKey> keys = manager.getAllKeys();
+        assertEquals( 3, keys.size() );
+
+        AuthenticationKey key = keys.get( 0 );
+        assertEquals( "248df0fec5d54e3eb11339f5e81d8bd7", key.getKey() );
+        assertEquals( "bob", key.getForPrincipal() );
+        assertEquals( "Testing", key.getPurpose() );
+        assertEquals( 1164426311921L, key.getDateCreated().getTime() );
+        assertEquals( 1164427211921L, key.getDateExpires().getTime() );
+
+        key = keys.get( 1 );
+        assertEquals( "a98dddc2ae614a7c82f8afd3ba6e39fb", key.getKey() );
+        assertEquals( "betty", key.getForPrincipal() );
+        assertEquals( "Something", key.getPurpose() );
+        assertEquals( 1164426315657L, key.getDateCreated().getTime() );
+        assertEquals( 1164427815657L, key.getDateExpires().getTime() );
+
+        key = keys.get( 2 );
+        assertEquals( "1428d2ca3a0246f0a1d979504e351388", key.getKey() );
+        assertEquals( "fred", key.getForPrincipal() );
+        assertEquals( "Else", key.getPurpose() );
+        assertEquals( 1164426315664L, key.getDateCreated().getTime() );
+        assertEquals( 1164428115664L, key.getDateExpires().getTime() );
+    }
+
+    private void assertEmpty( KeyManager manager )
+    {
+        assertEquals( 0, manager.getAllKeys().size() );
+    }
+
+    private String removeKeyAndTimestampVariance( String content )
+    {
+        return removeTagContent( removeTagContent( removeTagContent( content, "dateCreated" ), "dateExpires" ), "key" );
+    }
+
+    private static String removeTimestampVariance( String content )
+    {
+        return removeTagContent( removeTagContent( content, "lastPasswordChange" ), "accountCreationDate" );
+    }
+
+    private static String removeTagContent( String content, String field )
+    {
+        return content.replaceAll( "<" + field + ">.*</" + field + ">", "<" + field + "></" + field + ">" );
+    }
+
+    private static void assertPermission( Permission permission, String name, String operation, String resource )
+    {
+        assertEquals( name, permission.getName() );
+        assertEquals( operation, permission.getOperation().getName() );
+        assertEquals( resource, permission.getResource().getIdentifier() );
+    }
+
+    private static File createBackupDirectory()
+    {
+        String timestamp = new SimpleDateFormat( "yyyyMMdd.HHmmss", Locale.US ).format( new Date() );
+
+        File targetDirectory = new File( SystemUtils.getJavaIoTmpDir(), "./target/backups/" + timestamp );
+        targetDirectory.mkdirs();
+
+        return targetDirectory;
+    }
+
+}
diff --git a/redback-data-management/src/test/java/org/codehaus/plexus/redback/management/DataManagementTest.java b/redback-data-management/src/test/java/org/codehaus/plexus/redback/management/DataManagementTest.java
deleted file mode 100644 (file)
index e52aff9..0000000
+++ /dev/null
@@ -1,446 +0,0 @@
-package org.codehaus.plexus.redback.management;
-
-/*
- * 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.
- */
-
-import junit.framework.TestCase;
-import org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory;
-import org.apache.archiva.redback.users.UserManager;
-import org.apache.commons.lang.SystemUtils;
-import org.codehaus.plexus.redback.keys.AuthenticationKey;
-import org.codehaus.plexus.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.keys.KeyManagerException;
-import org.codehaus.plexus.redback.rbac.Permission;
-import org.codehaus.plexus.redback.rbac.RBACManager;
-import org.codehaus.plexus.redback.rbac.RbacManagerException;
-import org.codehaus.plexus.redback.rbac.Role;
-import org.codehaus.plexus.redback.rbac.UserAssignment;
-import org.codehaus.plexus.redback.tests.utils.RBACDefaults;
-import org.apache.archiva.redback.users.User;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.custommonkey.xmlunit.XMLAssert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-
-@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
-public class DataManagementTest
-    extends TestCase
-{
-    @Inject
-    private DataManagementTool dataManagementTool;
-
-    private File targetDirectory;
-
-    @Inject
-    @Named( value = "jdoFactory#users" )
-    UserConfigurableJdoFactory jdoFactory;
-
-    @Inject
-    @Named( value = "userManager#jdo" )
-    UserManager userManager;
-
-    @Inject
-    @Named( value = "keyManager#jdo" )
-    KeyManager keyManager;
-
-
-    @Inject
-    @Named( value = "rBACManager#jdo" )
-    RBACManager rbacManager;
-
-    @Before
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-        targetDirectory = createBackupDirectory();
-    }
-
-    @Test
-    public void testEraseUsers()
-        throws Exception
-    {
-
-        dataManagementTool.eraseUsersDatabase( userManager );
-
-        createUserDatabase( userManager );
-
-        dataManagementTool.eraseUsersDatabase( userManager );
-
-        assertEmpty( userManager );
-    }
-
-    @Test
-    public void testEraseKeys()
-        throws Exception
-    {
-
-        createKeyDatabase( keyManager );
-
-        dataManagementTool.eraseKeysDatabase( keyManager );
-
-        assertEmpty( keyManager );
-    }
-
-    @Test
-    public void testBackupRbac()
-        throws Exception
-    {
-        RBACManager manager = rbacManager;
-
-        dataManagementTool.eraseRBACDatabase( manager );
-
-        createRbacDatabase( manager );
-
-        dataManagementTool.backupRBACDatabase( manager, targetDirectory );
-
-        File backupFile = new File( targetDirectory, "rbac.xml" );
-
-        assertTrue( "Check database exists", backupFile.exists() );
-
-        StringWriter sw = new StringWriter();
-
-        IOUtil.copy( getClass().getResourceAsStream( "/expected-rbac.xml" ), sw );
-
-        XMLAssert.assertXMLEqual( new StringReader( sw.toString() ),
-                                  new StringReader( FileUtils.fileRead( backupFile ) ) );
-
-    }
-
-    private void createRbacDatabase( RBACManager manager )
-        throws RbacManagerException
-    {
-        RBACDefaults defaults = new RBACDefaults( manager );
-
-        defaults.createDefaults();
-
-        UserAssignment assignment = manager.createUserAssignment( "bob" );
-        assignment.addRoleName( "Developer" );
-        manager.saveUserAssignment( assignment );
-
-        assignment = manager.createUserAssignment( "betty" );
-        assignment.addRoleName( "System Administrator" );
-        manager.saveUserAssignment( assignment );
-    }
-
-    @Test
-    public void testBackupUsers()
-        throws Exception
-    {
-        UserManager manager = userManager;
-
-        createUserDatabase( manager );
-
-        dataManagementTool.backupUserDatabase( manager, targetDirectory );
-
-        File backupFile = new File( targetDirectory, "users.xml" );
-
-        assertTrue( "Check database exists", backupFile.exists() );
-
-        StringWriter sw = new StringWriter();
-
-        IOUtil.copy( getClass().getResourceAsStream( "/expected-users.xml" ), sw );
-
-        String actual = FileUtils.fileRead( backupFile ).trim();
-        String expected = sw.toString().trim();
-
-        XMLAssert.assertXMLEqual( removeTimestampVariance( expected ), removeTimestampVariance( actual ) );
-
-    }
-
-    private void createUserDatabase( UserManager manager )
-    {
-        User user = manager.createUser( "smcqueen", "Steve McQueen", "the cooler king" );
-        user.setPassword( "abc123" );
-        manager.addUser( user );
-
-        user = manager.createUser( "bob", "Sideshow Bob", "bob_862@hotmail.com" );
-        user.setPassword( "bobby862" );
-        manager.addUser( user );
-
-        user = manager.createUser( "betty", "Betty", "betty@aol.com" );
-        user.setPassword( "rover2" );
-        manager.addUser( user );
-    }
-
-    @Test
-    public void testBackupKeys()
-        throws Exception
-    {
-        KeyManager manager = keyManager;
-
-        createKeyDatabase( manager );
-
-        Thread.sleep( 60000 );
-
-        dataManagementTool.backupKeyDatabase( manager, targetDirectory );
-
-        File backupFile = new File( targetDirectory, "keys.xml" );
-
-        assertTrue( "Check database exists", backupFile.exists() );
-
-        StringWriter sw = new StringWriter();
-
-        IOUtil.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), sw );
-
-        String actual = FileUtils.fileRead( backupFile ).trim();
-        String expected = sw.toString().trim();
-
-        XMLAssert.assertXMLEqual( removeKeyAndTimestampVariance( expected ), removeKeyAndTimestampVariance( actual ) );
-
-    }
-
-    private static void createKeyDatabase( KeyManager manager )
-        throws KeyManagerException
-    {
-        manager.createKey( "bob", "Testing", 15 );
-        manager.createKey( "betty", "Something", 25 );
-        manager.createKey( "fred", "Else", 30 );
-        manager.createKey( "tony", "Expired", 0 );
-    }
-
-    @Test
-    public void testRestoreRbac()
-        throws Exception
-    {
-        RBACManager manager = rbacManager;
-
-        dataManagementTool.eraseRBACDatabase( manager );
-
-        assertEmpty( manager );
-
-        File backupFile = new File( targetDirectory, "rbac.xml" );
-
-        IOUtil.copy( getClass().getResourceAsStream( "/expected-rbac.xml" ), new FileWriter( backupFile ) );
-
-        dataManagementTool.restoreRBACDatabase( manager, targetDirectory );
-
-        List<Role> roles = manager.getAllRoles();
-        List<UserAssignment> assignments = manager.getAllUserAssignments();
-        assertEquals( 4, roles.size() );
-        assertEquals( 2, assignments.size() );
-        assertEquals( 6, manager.getAllOperations().size() );
-        assertEquals( 1, manager.getAllResources().size() );
-        assertEquals( 6, manager.getAllPermissions().size() );
-
-        Role role = roles.get( 0 );
-        assertEquals( "User Administrator", role.getName() );
-        assertTrue( role.isAssignable() );
-        assertEquals( 2, role.getPermissions().size() );
-        assertPermission( role.getPermissions().get( 0 ), "Edit All Users", "edit-all-users", "*" );
-        assertPermission( role.getPermissions().get( 1 ), "Remove Roles", "remove-roles", "*" );
-
-        role = roles.get( 1 );
-        assertEquals( "System Administrator", role.getName() );
-        assertTrue( role.isAssignable() );
-        assertEquals( 1, role.getChildRoleNames().size() );
-        assertEquals( "User Administrator", role.getChildRoleNames().get( 0 ) );
-        assertEquals( 4, role.getPermissions().size() );
-        assertPermission( role.getPermissions().get( 0 ), "Edit Configuration", "edit-configuration", "*" );
-        assertPermission( role.getPermissions().get( 1 ), "Run Indexer", "run-indexer", "*" );
-        assertPermission( role.getPermissions().get( 2 ), "Add Repository", "add-repository", "*" );
-        assertPermission( role.getPermissions().get( 3 ), "Regenerate Index", "regenerate-index", "*" );
-
-        role = roles.get( 2 );
-        assertEquals( "Trusted Developer", role.getName() );
-        assertTrue( role.isAssignable() );
-        assertEquals( 1, role.getChildRoleNames().size() );
-        assertEquals( "System Administrator", role.getChildRoleNames().get( 0 ) );
-        assertEquals( 1, role.getPermissions().size() );
-        assertPermission( role.getPermissions().get( 0 ), "Run Indexer", "run-indexer", "*" );
-
-        role = roles.get( 3 );
-        assertEquals( "Developer", role.getName() );
-        assertTrue( role.isAssignable() );
-        assertEquals( 1, role.getChildRoleNames().size() );
-        assertEquals( "Trusted Developer", role.getChildRoleNames().get( 0 ) );
-        assertEquals( 1, role.getPermissions().size() );
-        assertPermission( role.getPermissions().get( 0 ), "Run Indexer", "run-indexer", "*" );
-
-        UserAssignment assignment = assignments.get( 0 );
-        assertEquals( "bob", assignment.getPrincipal() );
-        assertEquals( 1, assignment.getRoleNames().size() );
-        assertEquals( "Developer", assignment.getRoleNames().get( 0 ) );
-
-        assignment = assignments.get( 1 );
-        assertEquals( "betty", assignment.getPrincipal() );
-        assertEquals( 1, assignment.getRoleNames().size() );
-        assertEquals( "System Administrator", assignment.getRoleNames().get( 0 ) );
-    }
-
-    private void assertEmpty( RBACManager manager )
-        throws RbacManagerException
-    {
-        assertEquals( 0, manager.getAllRoles().size() );
-        assertEquals( 0, manager.getAllUserAssignments().size() );
-        assertEquals( 0, manager.getAllOperations().size() );
-        assertEquals( 0, manager.getAllResources().size() );
-        assertEquals( 0, manager.getAllPermissions().size() );
-    }
-
-    @Test
-    public void testRestoreUsers()
-        throws Exception
-    {
-        UserManager manager = userManager;
-
-        dataManagementTool.eraseUsersDatabase( manager );
-
-        assertEmpty( manager );
-
-        File backupFile = new File( targetDirectory, "users.xml" );
-
-        IOUtil.copy( getClass().getResourceAsStream( "/expected-users.xml" ), new FileWriter( backupFile ) );
-
-        dataManagementTool.restoreUsersDatabase( manager, targetDirectory );
-
-        List<User> users = manager.getUsers();
-        assertEquals( 3, users.size() );
-
-        User user = users.get( 0 );
-        assertEquals( "smcqueen", user.getUsername() );
-        assertEquals( "bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=", user.getEncodedPassword() );
-        assertEquals( "Steve McQueen", user.getFullName() );
-        assertEquals( "the cooler king", user.getEmail() );
-        assertEquals( 1164424661686L, user.getLastPasswordChange().getTime() );
-        assertEquals( Arrays.asList( new String[]{ "bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=" } ),
-                      user.getPreviousEncodedPasswords() );
-
-        user = users.get( 1 );
-        assertEquals( "bob", user.getUsername() );
-        assertEquals( "A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=", user.getEncodedPassword() );
-        assertEquals( "Sideshow Bob", user.getFullName() );
-        assertEquals( "bob_862@hotmail.com", user.getEmail() );
-        assertEquals( 1164424669526L, user.getLastPasswordChange().getTime() );
-        assertEquals( Arrays.asList( new String[]{ "A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=" } ),
-                      user.getPreviousEncodedPasswords() );
-
-        user = users.get( 2 );
-        assertEquals( "betty", user.getUsername() );
-        assertEquals( "L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=", user.getEncodedPassword() );
-        assertEquals( "Betty", user.getFullName() );
-        assertEquals( "betty@aol.com", user.getEmail() );
-        assertEquals( 1164424669536L, user.getLastPasswordChange().getTime() );
-        assertEquals( Arrays.asList( new String[]{ "L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=" } ),
-                      user.getPreviousEncodedPasswords() );
-    }
-
-    private void assertEmpty( UserManager manager )
-    {
-        List<User> users = manager.getUsers();
-        assertEquals( 0, users.size() );
-    }
-
-    @Test
-    public void testRestoreKeys()
-        throws Exception
-    {
-        KeyManager manager = keyManager;
-
-        dataManagementTool.eraseKeysDatabase( manager );
-
-        assertEmpty( manager );
-
-        File backupFile = new File( targetDirectory, "keys.xml" );
-
-        IOUtil.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), new FileWriter( backupFile ) );
-
-        dataManagementTool.restoreKeysDatabase( manager, targetDirectory );
-
-        List<AuthenticationKey> keys = manager.getAllKeys();
-        assertEquals( 3, keys.size() );
-
-        AuthenticationKey key = keys.get( 0 );
-        assertEquals( "248df0fec5d54e3eb11339f5e81d8bd7", key.getKey() );
-        assertEquals( "bob", key.getForPrincipal() );
-        assertEquals( "Testing", key.getPurpose() );
-        assertEquals( 1164426311921L, key.getDateCreated().getTime() );
-        assertEquals( 1164427211921L, key.getDateExpires().getTime() );
-
-        key = keys.get( 1 );
-        assertEquals( "a98dddc2ae614a7c82f8afd3ba6e39fb", key.getKey() );
-        assertEquals( "betty", key.getForPrincipal() );
-        assertEquals( "Something", key.getPurpose() );
-        assertEquals( 1164426315657L, key.getDateCreated().getTime() );
-        assertEquals( 1164427815657L, key.getDateExpires().getTime() );
-
-        key = keys.get( 2 );
-        assertEquals( "1428d2ca3a0246f0a1d979504e351388", key.getKey() );
-        assertEquals( "fred", key.getForPrincipal() );
-        assertEquals( "Else", key.getPurpose() );
-        assertEquals( 1164426315664L, key.getDateCreated().getTime() );
-        assertEquals( 1164428115664L, key.getDateExpires().getTime() );
-    }
-
-    private void assertEmpty( KeyManager manager )
-    {
-        assertEquals( 0, manager.getAllKeys().size() );
-    }
-
-    private String removeKeyAndTimestampVariance( String content )
-    {
-        return removeTagContent( removeTagContent( removeTagContent( content, "dateCreated" ), "dateExpires" ), "key" );
-    }
-
-    private static String removeTimestampVariance( String content )
-    {
-        return removeTagContent( removeTagContent( content, "lastPasswordChange" ), "accountCreationDate" );
-    }
-
-    private static String removeTagContent( String content, String field )
-    {
-        return content.replaceAll( "<" + field + ">.*</" + field + ">", "<" + field + "></" + field + ">" );
-    }
-
-    private static void assertPermission( Permission permission, String name, String operation, String resource )
-    {
-        assertEquals( name, permission.getName() );
-        assertEquals( operation, permission.getOperation().getName() );
-        assertEquals( resource, permission.getResource().getIdentifier() );
-    }
-
-    private static File createBackupDirectory()
-    {
-        String timestamp = new SimpleDateFormat( "yyyyMMdd.HHmmss", Locale.US ).format( new Date() );
-
-        File targetDirectory = new File( SystemUtils.getJavaIoTmpDir(), "./target/backups/" + timestamp );
-        targetDirectory.mkdirs();
-
-        return targetDirectory;
-    }
-
-}
diff --git a/redback-data-management/src/test/resources/org/apache/archiva/redback/config-defaults.properties b/redback-data-management/src/test/resources/org/apache/archiva/redback/config-defaults.properties
new file mode 100644 (file)
index 0000000..6409f97
--- /dev/null
@@ -0,0 +1,130 @@
+# 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.
+
+jdbc.url=jdbc:derby:target/database;create=true
+
+
+# --------------------------------------------------------------------
+# Application Configuration
+
+application.timestamp=EEE d MMM yyyy HH:mm:ss Z
+
+# --------------------------------------------------------------------
+# JDBC Setup
+
+jdbc.driver.name=org.apache.derby.jdbc.EmbeddedDriver
+jdbc.username=sa
+jdbc.password=
+
+# --------------------------------------------------------------------
+# Email Settings
+
+email.jndiSessionName=java:comp/env/mail/Session
+email.smtp.host=localhost
+email.smtp.port=25
+email.smtp.ssl.enabled=false
+email.smtp.tls.enabled=false
+email.smtp.username=
+email.smtp.password=
+
+#TODO: move description elsewhere, remove bad default
+# All emails sent by the system will be from the following address
+#email.from.address=${user.name}@localhost
+# All emails sent by the system will be from the following user name (used in conjunction with address)
+#email.from.name=Unconfigured Username
+
+# If all email addresses (from new user registration) require an account validation email.
+email.validation.required=true
+# Timeout (in minutes) for the key generated for an email validation to remain valid.
+# 2880 minutes = 48 hours
+email.validation.timeout=2880
+# The subject line for the email message.
+email.validation.subject=Welcome
+
+#TODO: move description elsewhere, remove bad default
+# Get the Feedback to use for any outgoing emails.
+# NOTE: if feedback.path starts with a "/" it is appended to the end of the value provided in application.url
+# This value can be in the format/syntax of "/feedback.action" or even "mailto:feedback@application.com"
+#email.feedback.path=/feedback.action
+
+#Set the application base URL. The default is to derive it from the HTTP request
+#application.url=http://myurl.mycompany.com
+
+# --------------------------------------------------------------------
+# Auto Login Settings
+
+security.rememberme.enabled=true
+# Timeout in minutes ( 525600 minutes = 1 year )
+security.rememberme.timeout=525600
+
+# Single Sign On
+# Timeout in minutes
+security.signon.timeout=30
+
+# --------------------------------------------------------------------
+# Default Username Values
+redback.default.admin=admin
+
+# --------------------------------------------------------------------
+# Security Policies
+
+#security.policy.password.encoder=
+security.policy.password.previous.count=6
+security.policy.password.expiration.enabled=true
+security.policy.password.expiration.days=90
+security.policy.password.expiration.notify.days=10
+security.policy.allowed.login.attempt=10
+
+# turn off the perclick enforcement of various security policies, slightly
+# more heavyweight since it will ensure that the User object on each click
+# is up to date
+security.policy.strict.enforcement.enabled=true
+security.policy.strict.force.password.change.enabled=true
+
+# --------------------------------------------------------------------
+# Password Rules
+security.policy.password.rule.alphanumeric.enabled=false
+security.policy.password.rule.alphacount.enabled=true
+security.policy.password.rule.alphacount.minimum=1
+security.policy.password.rule.characterlength.enabled=true
+security.policy.password.rule.characterlength.minimum=1
+security.policy.password.rule.characterlength.maximum=24
+security.policy.password.rule.musthave.enabled=true
+security.policy.password.rule.numericalcount.enabled=true
+security.policy.password.rule.numericalcount.minimum=1
+security.policy.password.rule.reuse.enabled=true
+security.policy.password.rule.nowhitespace.enabled=true
+
+# --------------------------------------------------------------------
+# ldap settings
+#
+ldap.bind.authenticator.enabled=false
+
+# ldap options for configuration via properties file
+#ldap.config.hostname=
+#ldap.config.port=
+#ldap.config.base.dn=
+#ldap.config.context.factory=
+#ldap.config.bind.dn=
+#ldap.config.password=
+#ldap.config.authentication.method=
+
+# config parameter for the ConfigurableUserManager
+user.manager.impl=cached
+
+
+
diff --git a/redback-data-management/src/test/resources/org/codehaus/plexus/redback/config-defaults.properties b/redback-data-management/src/test/resources/org/codehaus/plexus/redback/config-defaults.properties
deleted file mode 100644 (file)
index 6409f97..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-# 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.
-
-jdbc.url=jdbc:derby:target/database;create=true
-
-
-# --------------------------------------------------------------------
-# Application Configuration
-
-application.timestamp=EEE d MMM yyyy HH:mm:ss Z
-
-# --------------------------------------------------------------------
-# JDBC Setup
-
-jdbc.driver.name=org.apache.derby.jdbc.EmbeddedDriver
-jdbc.username=sa
-jdbc.password=
-
-# --------------------------------------------------------------------
-# Email Settings
-
-email.jndiSessionName=java:comp/env/mail/Session
-email.smtp.host=localhost
-email.smtp.port=25
-email.smtp.ssl.enabled=false
-email.smtp.tls.enabled=false
-email.smtp.username=
-email.smtp.password=
-
-#TODO: move description elsewhere, remove bad default
-# All emails sent by the system will be from the following address
-#email.from.address=${user.name}@localhost
-# All emails sent by the system will be from the following user name (used in conjunction with address)
-#email.from.name=Unconfigured Username
-
-# If all email addresses (from new user registration) require an account validation email.
-email.validation.required=true
-# Timeout (in minutes) for the key generated for an email validation to remain valid.
-# 2880 minutes = 48 hours
-email.validation.timeout=2880
-# The subject line for the email message.
-email.validation.subject=Welcome
-
-#TODO: move description elsewhere, remove bad default
-# Get the Feedback to use for any outgoing emails.
-# NOTE: if feedback.path starts with a "/" it is appended to the end of the value provided in application.url
-# This value can be in the format/syntax of "/feedback.action" or even "mailto:feedback@application.com"
-#email.feedback.path=/feedback.action
-
-#Set the application base URL. The default is to derive it from the HTTP request
-#application.url=http://myurl.mycompany.com
-
-# --------------------------------------------------------------------
-# Auto Login Settings
-
-security.rememberme.enabled=true
-# Timeout in minutes ( 525600 minutes = 1 year )
-security.rememberme.timeout=525600
-
-# Single Sign On
-# Timeout in minutes
-security.signon.timeout=30
-
-# --------------------------------------------------------------------
-# Default Username Values
-redback.default.admin=admin
-
-# --------------------------------------------------------------------
-# Security Policies
-
-#security.policy.password.encoder=
-security.policy.password.previous.count=6
-security.policy.password.expiration.enabled=true
-security.policy.password.expiration.days=90
-security.policy.password.expiration.notify.days=10
-security.policy.allowed.login.attempt=10
-
-# turn off the perclick enforcement of various security policies, slightly
-# more heavyweight since it will ensure that the User object on each click
-# is up to date
-security.policy.strict.enforcement.enabled=true
-security.policy.strict.force.password.change.enabled=true
-
-# --------------------------------------------------------------------
-# Password Rules
-security.policy.password.rule.alphanumeric.enabled=false
-security.policy.password.rule.alphacount.enabled=true
-security.policy.password.rule.alphacount.minimum=1
-security.policy.password.rule.characterlength.enabled=true
-security.policy.password.rule.characterlength.minimum=1
-security.policy.password.rule.characterlength.maximum=24
-security.policy.password.rule.musthave.enabled=true
-security.policy.password.rule.numericalcount.enabled=true
-security.policy.password.rule.numericalcount.minimum=1
-security.policy.password.rule.reuse.enabled=true
-security.policy.password.rule.nowhitespace.enabled=true
-
-# --------------------------------------------------------------------
-# ldap settings
-#
-ldap.bind.authenticator.enabled=false
-
-# ldap options for configuration via properties file
-#ldap.config.hostname=
-#ldap.config.port=
-#ldap.config.base.dn=
-#ldap.config.context.factory=
-#ldap.config.bind.dn=
-#ldap.config.password=
-#ldap.config.authentication.method=
-
-# config parameter for the ConfigurableUserManager
-user.manager.impl=cached
-
-
-
index 74b5331ba117105283e5248f51f2dce7e6456800..04fbaa7f0b1925b49f4de9a6bd063d1d357ca414 100644 (file)
@@ -22,7 +22,7 @@ package org.codehaus.plexus.redback.struts2.action.admin;
 import com.opensymphony.xwork2.Preparable;
 import org.apache.commons.lang.StringUtils;
 import org.codehaus.plexus.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.management.DataManagementTool;
+import org.apache.archiva.redback.management.DataManagementTool;
 import org.codehaus.plexus.redback.rbac.RBACManager;
 import org.codehaus.plexus.redback.rbac.Resource;
 import org.codehaus.plexus.redback.struts2.action.AbstractSecurityAction;