]> source.dussan.org Git - archiva.git/commitdiff
add structure for redback-authorization-ldap new module
authorOlivier Lamy <olamy@apache.org>
Fri, 4 Jan 2013 17:33:43 +0000 (17:33 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 4 Jan 2013 17:33:43 +0000 (17:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1428994 13f79535-47bb-0310-9956-ffa450edef68

pom.xml
redback-authorization/redback-authorization-providers/pom.xml
redback-authorization/redback-authorization-providers/redback-authorization-ldap/pom.xml [new file with mode: 0644]
redback-authorization/redback-authorization-providers/redback-authorization-ldap/src/main/java/org/apache/archiva/redback/authorization/ldap/LdapAuthorizer.java [new file with mode: 0644]
redback-authorization/redback-authorization-providers/redback-authorization-ldap/src/main/resources/META-INF/spring-context.xml [new file with mode: 0644]
redback-authorization/redback-authorization-providers/redback-authorization-open/src/main/java/org/apache/archiva/redback/authorization/open/OpenAuthorizer.java
redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java
redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java [deleted file]
redback-rbac/redback-rbac-providers/redback-rbac-memory/src/main/java/org/apache/archiva/redback/rbac/memory/MemoryAuthorizer.java

diff --git a/pom.xml b/pom.xml
index 10b3cd2348093001737be99af49d0575194a4567..7718bebdd8b937f088bd6bcca034f692febc11ff 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <artifactId>redback-rbac-jdo</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.archiva.redback</groupId>
+        <artifactId>redback-rbac-ldap</artifactId>
+        <version>${project.version}</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.archiva.redback</groupId>
         <artifactId>redback-rbac-role-manager</artifactId>
index 496fd8e0ea916abe0f32cdd45711977a606d9b89..6ca72844eb3fdf033bc30bf9491d5f6ebca624fb 100644 (file)
@@ -29,5 +29,6 @@
   <packaging>pom</packaging>
   <modules>
     <module>redback-authorization-open</module>
+    <module>redback-authorization-ldap</module>
   </modules>  
 </project>
diff --git a/redback-authorization/redback-authorization-providers/redback-authorization-ldap/pom.xml b/redback-authorization/redback-authorization-providers/redback-authorization-ldap/pom.xml
new file mode 100644 (file)
index 0000000..9803c05
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.archiva.redback</groupId>
+    <artifactId>redback-authorization-providers</artifactId>
+    <version>2.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>redback-authorization-ldap</artifactId>
+  <packaging>bundle</packaging>
+  <name>Redback :: Authorization Provider :: Ldap</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.archiva.redback</groupId>
+      <artifactId>redback-authorization-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-context-support</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva.redback</groupId>
+      <artifactId>redback-rbac-ldap</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.annotation</groupId>
+      <artifactId>jsr250-api</artifactId>
+    </dependency>     
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.apache.archiva.redback.authorization.ldap;version=${project.version};-split-package:=merge-first
+            </Export-Package>
+            <Import-Package>
+              org.apache.archiva.redback.authorization;version=${project.version},
+              org.springframework.stereotype;version="[3,4)"
+            </Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/redback-authorization/redback-authorization-providers/redback-authorization-ldap/src/main/java/org/apache/archiva/redback/authorization/ldap/LdapAuthorizer.java b/redback-authorization/redback-authorization-providers/redback-authorization-ldap/src/main/java/org/apache/archiva/redback/authorization/ldap/LdapAuthorizer.java
new file mode 100644 (file)
index 0000000..edf09a7
--- /dev/null
@@ -0,0 +1,45 @@
+package org.apache.archiva.redback.authorization.ldap;
+/*
+ * 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.authorization.AuthorizationDataSource;
+import org.apache.archiva.redback.authorization.AuthorizationException;
+import org.apache.archiva.redback.authorization.AuthorizationResult;
+import org.apache.archiva.redback.authorization.Authorizer;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Olivier Lamy
+ * @since 2.1
+ */
+@Service( "authorizer#ldap" )
+public class LdapAuthorizer
+    implements Authorizer
+{
+    public String getId()
+    {
+        return "ldap";
+    }
+
+    public AuthorizationResult isAuthorized( AuthorizationDataSource source )
+        throws AuthorizationException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+}
diff --git a/redback-authorization/redback-authorization-providers/redback-authorization-ldap/src/main/resources/META-INF/spring-context.xml b/redback-authorization/redback-authorization-providers/redback-authorization-ldap/src/main/resources/META-INF/spring-context.xml
new file mode 100644 (file)
index 0000000..56f7bb1
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context 
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+       default-lazy-init="true">
+
+  <context:annotation-config />
+  <context:component-scan 
+    base-package="org.apache.archiva.redback.authorization.ldap"/>
+</beans>
\ No newline at end of file
index 4d167c8a4422d076e6f13d82c145b9f42ea19880..7c4b2d482b7f54d95b628c75ddfbb30bba604ecf 100644 (file)
@@ -29,14 +29,14 @@ import org.springframework.stereotype.Service;
  *
  * 
  */
-@Service("authorizer#rbac")
+@Service("authorizer#open")
 public class OpenAuthorizer
     implements Authorizer
 {
 
     public String getId()
     {
-        return "Open Authorizer";
+        return "open";
     }
 
     public AuthorizationResult isAuthorized( AuthorizationDataSource source )
index 0b37c299ad1c162096207ec7acd775e1a2c7336e..4312cb1bec850772cc0135799218eb0cf12b2f43 100644 (file)
@@ -67,7 +67,7 @@ public class RbacAuthorizer
 
     public String getId()
     {
-        return "RBAC Authorizer - " + this.getClass().getName();
+        return "rbac";
     }
 
     /**
diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/main/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManager.java
deleted file mode 100644 (file)
index afe54ba..0000000
+++ /dev/null
@@ -1,475 +0,0 @@
-package org.apache.archiva.redback.rbac.ldap;
-/*
- * 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.common.ldap.connection.LdapConnectionFactory;
-import org.apache.archiva.redback.rbac.AbstractRBACManager;
-import org.apache.archiva.redback.rbac.AbstractRole;
-import org.apache.archiva.redback.rbac.AbstractUserAssignment;
-import org.apache.archiva.redback.rbac.Operation;
-import org.apache.archiva.redback.rbac.Permission;
-import org.apache.archiva.redback.rbac.RBACManager;
-import org.apache.archiva.redback.rbac.RbacManagerException;
-import org.apache.archiva.redback.rbac.RbacObjectInvalidException;
-import org.apache.archiva.redback.rbac.RbacObjectNotFoundException;
-import org.apache.archiva.redback.rbac.Resource;
-import org.apache.archiva.redback.rbac.Role;
-import org.apache.archiva.redback.rbac.UserAssignment;
-import org.springframework.stereotype.Service;
-
-import javax.inject.Inject;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 2.1
- */
-@Service( "rbacManager#ldap" )
-public class LdapRbacManager
-    extends AbstractRBACManager
-    implements RBACManager
-{
-
-    @Inject
-    private LdapConnectionFactory ldapConnectionFactory;
-
-    public Role createRole( String name )
-    {
-        return new MockRole();
-    }
-
-    public Role saveRole( Role role )
-        throws RbacManagerException
-    {
-        return role;
-    }
-
-    public void saveRoles( Collection<Role> roles )
-        throws RbacManagerException
-    {
-        // no op
-    }
-
-    public Role getRole( String roleName )
-        throws RbacManagerException
-    {
-        // TODO
-        return null;
-    }
-
-    public List<Role> getAllRoles()
-        throws RbacManagerException
-    {
-        // TODO
-        return Collections.emptyList();
-    }
-
-    public void removeRole( Role role )
-        throws RbacManagerException
-    {
-        // no op
-    }
-
-    public Permission createPermission( String name )
-        throws RbacManagerException
-    {
-        return new MockPermission();
-    }
-
-    public Permission createPermission( String name, String operationName, String resourceIdentifier )
-        throws RbacManagerException
-    {
-        return new MockPermission();
-    }
-
-    public Permission savePermission( Permission permission )
-        throws RbacManagerException
-    {
-        return permission;
-    }
-
-    public Permission getPermission( String permissionName )
-        throws RbacManagerException
-    {
-        return new MockPermission();
-    }
-
-    public List<Permission> getAllPermissions()
-        throws RbacManagerException
-    {
-        // TODO
-        return Collections.emptyList();
-    }
-
-    public void removePermission( Permission permission )
-        throws RbacManagerException
-    {
-        // no op
-    }
-
-    public Operation createOperation( String name )
-        throws RbacManagerException
-    {
-        return new MockOperation();
-    }
-
-    public Operation saveOperation( Operation operation )
-        throws RbacManagerException
-    {
-        return operation;
-    }
-
-    public Operation getOperation( String operationName )
-        throws RbacManagerException
-    {
-        return new MockOperation();
-    }
-
-    public List<Operation> getAllOperations()
-        throws RbacManagerException
-    {
-        // TODO
-        return Collections.emptyList();
-    }
-
-    public void removeOperation( Operation operation )
-        throws RbacManagerException
-    {
-        // no op
-    }
-
-    public Resource createResource( String identifier )
-        throws RbacManagerException
-    {
-        return new MockResource();
-    }
-
-    public Resource saveResource( Resource resource )
-        throws RbacManagerException
-    {
-        return resource;
-    }
-
-    public Resource getResource( String resourceIdentifier )
-        throws RbacManagerException
-    {
-        // TODO
-        return new MockResource();
-    }
-
-    public List<Resource> getAllResources()
-        throws RbacManagerException
-    {
-        // TODO
-        return Collections.emptyList();
-    }
-
-    public void removeResource( Resource resource )
-        throws RbacManagerException
-    {
-        // no op
-    }
-
-    public UserAssignment createUserAssignment( String principal )
-        throws RbacManagerException
-    {
-        return new MockUserAssignment();
-    }
-
-    public UserAssignment saveUserAssignment( UserAssignment userAssignment )
-        throws RbacManagerException
-    {
-        return userAssignment;
-    }
-
-    public UserAssignment getUserAssignment( String principal )
-        throws RbacManagerException
-    {
-        // TODO
-        return new MockUserAssignment();
-    }
-
-    public List<UserAssignment> getAllUserAssignments()
-        throws RbacManagerException
-    {
-        // TODO
-        return Collections.emptyList();
-    }
-
-    public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames )
-        throws RbacManagerException
-    {
-        // TODO
-        return Collections.emptyList();
-    }
-
-    public void removeUserAssignment( UserAssignment userAssignment )
-        throws RbacManagerException
-    {
-        // no op
-    }
-
-    public void eraseDatabase()
-    {
-        // no op
-    }
-
-    //-------------------------------
-    // Mock classes
-    //-------------------------------
-
-    private static class MockRole
-        extends AbstractRole
-        implements Role
-    {
-        public void addPermission( Permission permission )
-        {
-            // no op
-        }
-
-        public void addChildRoleName( String name )
-        {
-            // no op
-        }
-
-        public List<String> getChildRoleNames()
-        {
-            return Collections.emptyList();
-        }
-
-        public String getDescription()
-        {
-            return null;
-        }
-
-        public String getName()
-        {
-            return null;
-        }
-
-        public List<Permission> getPermissions()
-        {
-            return Collections.emptyList();
-        }
-
-        public boolean isAssignable()
-        {
-            return false;
-        }
-
-        public void removePermission( Permission permission )
-        {
-            // no op
-        }
-
-        public void setAssignable( boolean assignable )
-        {
-            // no op
-        }
-
-        public void setChildRoleNames( List<String> names )
-        {
-            // no op
-        }
-
-        public void setDescription( String description )
-        {
-            // no op
-        }
-
-        public void setName( String name )
-        {
-            // no op
-        }
-
-        public void setPermissions( List<Permission> permissions )
-        {
-            //To change body of implemented methods use File | Settings | File Templates.
-        }
-
-        public boolean isPermanent()
-        {
-            return false;
-        }
-
-        public void setPermanent( boolean permanent )
-        {
-            // no op
-        }
-    }
-
-    private static class MockPermission
-        implements Permission
-    {
-        public String getDescription()
-        {
-            return null;
-        }
-
-        public String getName()
-        {
-            return null;
-        }
-
-        public Operation getOperation()
-        {
-            return null;
-        }
-
-        public Resource getResource()
-        {
-            return null;
-        }
-
-        public void setDescription( String description )
-        {
-            // no op
-        }
-
-        public void setName( String name )
-        {
-            // no op
-        }
-
-        public void setOperation( Operation operation )
-        {
-            // no op
-        }
-
-        public void setResource( Resource resource )
-        {
-            // no op
-        }
-
-        public boolean isPermanent()
-        {
-            return false;
-        }
-
-        public void setPermanent( boolean permanent )
-        {
-            // no op
-        }
-    }
-
-    private static class MockOperation
-        implements Operation
-    {
-        public String getDescription()
-        {
-            return null;
-        }
-
-        public String getName()
-        {
-            return null;
-        }
-
-        public void setDescription( String description )
-        {
-            // no op
-        }
-
-        public void setName( String name )
-        {
-            // no op
-        }
-
-        public boolean isPermanent()
-        {
-            return false;
-        }
-
-        public void setPermanent( boolean permanent )
-        {
-            // no op
-        }
-    }
-
-    private static class MockResource
-        implements Resource
-    {
-        public String getIdentifier()
-        {
-            return null;
-        }
-
-        public boolean isPattern()
-        {
-            return false;
-        }
-
-        public void setIdentifier( String identifier )
-        {
-            // no op
-        }
-
-        public void setPattern( boolean pattern )
-        {
-            // no op
-        }
-
-        public boolean isPermanent()
-        {
-            return false;
-        }
-
-        public void setPermanent( boolean permanent )
-        {
-            // no op
-        }
-    }
-
-    private static class MockUserAssignment
-        extends AbstractUserAssignment
-        implements UserAssignment
-    {
-        public String getPrincipal()
-        {
-            return null;
-        }
-
-        public List<String> getRoleNames()
-        {
-            return Collections.emptyList();
-        }
-
-        public void setPrincipal( String principal )
-        {
-            // no op
-        }
-
-        public void setRoleNames( List<String> roles )
-        {
-            // no op
-        }
-
-        public boolean isPermanent()
-        {
-            return false;
-        }
-
-        public void setPermanent( boolean permanent )
-        {
-            // no op
-        }
-    }
-}
index 0c24fbaecfd51d99d05e46428d7ef1b02ca81330..27d3208755a73525f8010366875bb299df75a962 100644 (file)
@@ -34,7 +34,7 @@ public class MemoryAuthorizer
 {
     public String getId()
     {
-        return MemoryAuthorizer.class.getName();
+        return "memory";
     }
 
     public AuthorizationResult isAuthorized( AuthorizationDataSource source )