jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1550384 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
Date Thu, 12 Dec 2013 09:30:45 GMT
Author: angela
Date: Thu Dec 12 09:30:45 2013
New Revision: 1550384

URL: http://svn.apache.org/r1550384
Log:
OAK-754 : Pluggable Security Setup (resolve todo wrt authorizable node name generation)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java?rev=1550384&r1=1550383&r2=1550384&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
Thu Dec 12 09:30:45 2013
@@ -91,6 +91,12 @@ public class OsgiSecurityProvider implem
             policyOption = ReferencePolicyOption.GREEDY)
     private CompositeTokenConfiguration tokenConfiguration = new CompositeTokenConfiguration(this);
 
+    @Reference(referenceInterface = AuthorizableNodeName.class,
+            bind = "bindAuthorizableNodeName",
+            cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            policyOption = ReferencePolicyOption.GREEDY)
+    private NameGenerator authorizableNodeName = new NameGenerator();
+
     private final WhiteboardAuthorizableActionProvider authorizableActionProvider = new WhiteboardAuthorizableActionProvider();
     private final WhiteboardRestrictionProvider restrictionProvider = new WhiteboardRestrictionProvider();
 
@@ -99,7 +105,7 @@ public class OsgiSecurityProvider implem
     public OsgiSecurityProvider() {
         Map<String, Object> userMap = ImmutableMap.of(
                 UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, authorizableActionProvider,
-                UserConstants.PARAM_AUTHORIZABLE_NODE_NAME, AuthorizableNodeName.DEFAULT);
// TODO
+                UserConstants.PARAM_AUTHORIZABLE_NODE_NAME, authorizableNodeName);
 
         Map<String, WhiteboardRestrictionProvider> authorizMap = ImmutableMap.of(
                 AccessControlConstants.PARAM_RESTRICTION_PROVIDER, restrictionProvider
@@ -212,6 +218,13 @@ public class OsgiSecurityProvider implem
         }
     }
 
+    protected void bindAuthorizableNodeName(@Nonnull ServiceReference reference) {
+        Object ann = reference.getBundle().getBundleContext().getService(reference);
+        if (ann instanceof AuthorizableNodeName) {
+            authorizableNodeName.dlg = (AuthorizableNodeName) ann;
+        }
+    }
+
     private Object initConfiguration(@Nonnull ServiceReference reference) {
         Object service = reference.getBundle().getBundleContext().getService(reference);
         if (service instanceof ConfigurationBase) {
@@ -219,4 +232,15 @@ public class OsgiSecurityProvider implem
         }
         return service;
     }
+
+    private final class NameGenerator implements AuthorizableNodeName {
+
+        private AuthorizableNodeName dlg = AuthorizableNodeName.DEFAULT;
+
+        @Nonnull
+        @Override
+        public String generateNodeName(@Nonnull String authorizableId) {
+            return dlg.generateNodeName(authorizableId);
+        }
+    }
 }



Mime
View raw message