add structure for redback-authorization-ldap new module

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1428994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-04 17:33:43 +00:00
parent f5554e0452
commit 07df166f7f
9 changed files with 162 additions and 479 deletions

View File

@ -277,6 +277,11 @@
<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>

View File

@ -29,5 +29,6 @@
<packaging>pom</packaging>
<modules>
<module>redback-authorization-open</module>
<module>redback-authorization-ldap</module>
</modules>
</project>

View File

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

View File

@ -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.
}
}

View File

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

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

View File

@ -67,7 +67,7 @@ public class RbacAuthorizer
public String getId()
{
return "RBAC Authorizer - " + this.getClass().getName();
return "rbac";
}
/**

View File

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

View File

@ -34,7 +34,7 @@ public class MemoryAuthorizer
{
public String getId()
{
return MemoryAuthorizer.class.getName();
return "memory";
}
public AuthorizationResult isAuthorized( AuthorizationDataSource source )