jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1373476 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
Date Wed, 15 Aug 2012 15:38:27 GMT
Author: angela
Date: Wed Aug 15 15:38:26 2012
New Revision: 1373476

URL: http://svn.apache.org/viewvc?rev=1373476&view=rev
Log:
OAK-90 : Implement Principal Management

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java?rev=1373476&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
Wed Aug 15 15:38:26 2012
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.spi.security.privilege;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@code PrincipalProvider} implementation that aggregates a list of principal
+ * providers into a single.
+ */
+public class CompositePrincipalProvider implements PrincipalProvider {
+
+    private static final Logger log = LoggerFactory.getLogger(CompositePrincipalProvider.class);
+
+    private final List<PrincipalProvider> providers;
+
+    public CompositePrincipalProvider(List<PrincipalProvider> providers) {
+        this.providers = providers;
+    }
+
+    //--------------------------------------------------< PrincipalProvider >---
+    @Override
+    public Principal getPrincipal(String principalName) {
+        Principal principal = null;
+        for (int i = 0; i < providers.size() && principal == null; i++) {
+            principal = providers.get(i).getPrincipal(principalName);
+
+        }
+        return principal;
+    }
+
+    @Override
+    public Set<Group> getGroupMembership(Principal principal) {
+        Set<Group> groups = new HashSet<Group>();
+        for (PrincipalProvider provider : providers) {
+            groups.addAll(provider.getGroupMembership(principal));
+        }
+        return groups;
+    }
+}
\ No newline at end of file



Mime
View raw message