From 70d2aa24ed28322fdf9e0d4a7ccc552c44054d1b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 5 Jan 2013 15:15:12 +0000 Subject: [PATCH] add some methods for dynamic selection of authorizer git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1429312 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/redback/authorization/Authorizer.java | 12 ++++++++++++ .../redback/authorization/ldap/LdapAuthorizer.java | 10 ++++++++++ .../redback/authorization/open/OpenAuthorizer.java | 10 ++++++++++ .../redback/authorization/rbac/RbacAuthorizer.java | 10 ++++++++++ .../redback/rbac/memory/MemoryAuthorizer.java | 10 ++++++++++ 5 files changed, 52 insertions(+) diff --git a/redback-authorization/redback-authorization-api/src/main/java/org/apache/archiva/redback/authorization/Authorizer.java b/redback-authorization/redback-authorization-api/src/main/java/org/apache/archiva/redback/authorization/Authorizer.java index 0b3051f73..c45230daf 100644 --- a/redback-authorization/redback-authorization-api/src/main/java/org/apache/archiva/redback/authorization/Authorizer.java +++ b/redback-authorization/redback-authorization-api/src/main/java/org/apache/archiva/redback/authorization/Authorizer.java @@ -35,4 +35,16 @@ public interface Authorizer AuthorizationResult isAuthorized( AuthorizationDataSource source ) throws AuthorizationException; + + /** + * @return true if this implementation is a final one and not a wrapper + * @since 2.1 + */ + boolean isFinalImplementation(); + + /** + * @return a key to be able to customize label in UI + * @since 2.1 + */ + String getDescriptionKey(); } 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 index 969a8a0a7..f7191a853 100644 --- 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 @@ -42,4 +42,14 @@ public class LdapAuthorizer { return null; } + + public boolean isFinalImplementation() + { + return true; + } + + public String getDescriptionKey() + { + return "archiva.redback.authorizer.ldap"; + } } diff --git a/redback-authorization/redback-authorization-providers/redback-authorization-open/src/main/java/org/apache/archiva/redback/authorization/open/OpenAuthorizer.java b/redback-authorization/redback-authorization-providers/redback-authorization-open/src/main/java/org/apache/archiva/redback/authorization/open/OpenAuthorizer.java index 7c4b2d482..e9ff0d16b 100644 --- a/redback-authorization/redback-authorization-providers/redback-authorization-open/src/main/java/org/apache/archiva/redback/authorization/open/OpenAuthorizer.java +++ b/redback-authorization/redback-authorization-providers/redback-authorization-open/src/main/java/org/apache/archiva/redback/authorization/open/OpenAuthorizer.java @@ -45,4 +45,14 @@ public class OpenAuthorizer return new AuthorizationResult( true, source.getPermission(), null ); } + public boolean isFinalImplementation() + { + return true; + } + + public String getDescriptionKey() + { + return "archiva.redback.authorizer.open"; + } + } diff --git a/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java b/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java index 4312cb1be..2ce17b4c8 100644 --- a/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java +++ b/redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java @@ -186,4 +186,14 @@ public class RbacAuthorizer { this.evaluator = evaluator; } + + public boolean isFinalImplementation() + { + return true; + } + + public String getDescriptionKey() + { + return "archiva.redback.authorizer.rbac"; + } } diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-memory/src/main/java/org/apache/archiva/redback/rbac/memory/MemoryAuthorizer.java b/redback-rbac/redback-rbac-providers/redback-rbac-memory/src/main/java/org/apache/archiva/redback/rbac/memory/MemoryAuthorizer.java index 27d320875..6e492430c 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-memory/src/main/java/org/apache/archiva/redback/rbac/memory/MemoryAuthorizer.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-memory/src/main/java/org/apache/archiva/redback/rbac/memory/MemoryAuthorizer.java @@ -54,5 +54,15 @@ public class MemoryAuthorizer return new AuthorizationResult( false, principal, null ); } } + + public boolean isFinalImplementation() + { + return true; + } + + public String getDescriptionKey() + { + return "archiva.redback.authorizer.memory"; + } } -- 2.39.5