jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1393945 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi/securit...
Date Thu, 04 Oct 2012 07:57:07 GMT
Author: angela
Date: Thu Oct  4 07:57:07 2012
New Revision: 1393945

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

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/OpenPrincipalProvider.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/TmpPrincipalProvider.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java?rev=1393945&r1=1393944&r2=1393945&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
Thu Oct  4 07:57:07 2012
@@ -16,21 +16,21 @@
  */
 package org.apache.jackrabbit.oak.security.authentication;
 
-import org.apache.jackrabbit.oak.security.principal.TmpPrincipalProvider;
-import org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext;
-import org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider;
-import org.apache.jackrabbit.oak.spi.security.authentication.OakLoginContext;
-import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import java.security.AccessController;
 import javax.annotation.Nonnull;
 import javax.jcr.Credentials;
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginException;
-import java.security.AccessController;
+
+import org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext;
+import org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider;
+import org.apache.jackrabbit.oak.spi.security.authentication.OakLoginContext;
+import org.apache.jackrabbit.oak.spi.security.principal.OpenPrincipalProvider;
+import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * LoginContextProviderImpl...  TODO
@@ -47,10 +47,11 @@ public class LoginContextProviderImpl im
     public LoginContextProviderImpl() {
         // TODO: use configurable authentication config and principal provider
         authConfig = new ConfigurationImpl();
-        principalProvider = new TmpPrincipalProvider();
+        principalProvider = new OpenPrincipalProvider();
     }
 
-    @Override @Nonnull
+    @Override
+    @Nonnull
     public OakLoginContext getLoginContext(
             Credentials credentials, String workspaceName)
             throws LoginException {
@@ -58,12 +59,11 @@ public class LoginContextProviderImpl im
         // TODO  - authentication against configurable spi-authentication
         // TODO  - validation of workspace name (including access rights for the given 'user')
         Subject subject = getSubject();
-        CallbackHandler handler =
-                new CallbackHandlerImpl(credentials, principalProvider);
+        CallbackHandler handler = new CallbackHandlerImpl(credentials, principalProvider);
         return new JaasLoginContext(APP_NAME, subject, handler, authConfig);
     }
 
-    //-------------------------------------------------===--------< private >---
+    //------------------------------------------------------------< private >---
     private Subject getSubject() {
         Subject subject = null;
         try {

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/OpenPrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/OpenPrincipalProvider.java?rev=1393945&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/OpenPrincipalProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/OpenPrincipalProvider.java
Thu Oct  4 07:57:07 2012
@@ -0,0 +1,64 @@
+/*
+ * 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.principal;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * OpenPrincipalProvider... TODO
+ */
+public class OpenPrincipalProvider implements PrincipalProvider {
+
+    //--------------------------------------------------< PrincipalProvider >---
+    @Override
+    public Principal getPrincipal(final String principalName) {
+        return new Principal() {
+            @Override
+            public String getName() {
+                return principalName;
+            }
+        };
+    }
+
+    @Override
+    public Set<Group> getGroupMembership(Principal principal) {
+        return Collections.<Group>singleton(EveryonePrincipal.getInstance());
+    }
+
+    @Override
+    public Set<Principal> getPrincipals(String userID) {
+        Set<Principal> principals = new HashSet<Principal>();
+        Principal p = getPrincipal(userID);
+        principals.add(p);
+        principals.addAll(getGroupMembership(p));
+        // TODO: remove again (currently needed because LoginContextProviderImpl uses this
dummy principal provider)
+        if ("admin".equals(userID)) {
+            principals.add(AdminPrincipal.INSTANCE);
+        }
+        return principals;
+    }
+
+    @Override
+    public Iterator<Principal> findPrincipals(String nameHint, int searchType) {
+        return PrincipalIteratorAdapter.EMPTY;
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1393945&r1=1393944&r2=1393945&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Thu Oct  4 07:57:07 2012
@@ -49,8 +49,8 @@ import org.apache.jackrabbit.oak.jcr.sec
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
-import org.apache.jackrabbit.oak.security.principal.TmpPrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.spi.security.principal.OpenPrincipalProvider;
 import org.apache.jackrabbit.oak.util.TODO;
 import org.apache.jackrabbit.oak.value.ValueFactoryImpl;
 import org.slf4j.Logger;
@@ -480,7 +480,7 @@ public class SessionDelegate {
     @Nonnull
     PrincipalManager getPrincipalManager() throws RepositoryException {
         // TODO
-        return TODO.unimplemented().returnValue(new PrincipalManagerImpl(new TmpPrincipalProvider()));
+        return TODO.unimplemented().returnValue(new PrincipalManagerImpl(new OpenPrincipalProvider()));
     }
 
     @Nonnull



Mime
View raw message