jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1335379 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/ oak...
Date Tue, 08 May 2012 08:42:19 GMT
Author: angela
Date: Tue May  8 08:42:18 2012
New Revision: 1335379

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

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/EveryonePrincipal.java
      - copied, changed from r1335354, jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
Removed:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/EveryonePrincipal.java
(from r1335354, jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/EveryonePrincipal.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/EveryonePrincipal.java&p1=jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java&r1=1335354&r2=1335379&rev=1335379&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/EveryonePrincipal.java
Tue May  8 08:42:18 2012
@@ -14,15 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.jcr.security.principal;
+package org.apache.jackrabbit.oak.security.principal;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.security.Principal;
+import java.util.Enumeration;
+
 /**
- * EveryonePrincipal...
+ * Built-in principal group that has every other principal as member.
  */
-public class EveryonePrincipal {
+public class EveryonePrincipal implements java.security.acl.Group {
 
     /**
      * logger instance
@@ -30,4 +33,61 @@ public class EveryonePrincipal {
     private static final Logger log = LoggerFactory.getLogger(EveryonePrincipal.class);
 
     public static final String NAME = "everyone";
+
+    private static final EveryonePrincipal INSTANCE = new EveryonePrincipal();
+
+    private EveryonePrincipal() { }
+
+    public static EveryonePrincipal getInstance() {
+        return INSTANCE;
+    }
+
+    //----------------------------------------------------------< Principal >---
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    //--------------------------------------------------------------< Group >---
+    @Override
+    public boolean addMember(Principal user) {
+        return false;
+    }
+
+    @Override
+    public boolean removeMember(Principal user) {
+        throw new UnsupportedOperationException("Cannot remove a member from the everyone
group.");
+    }
+
+    @Override
+    public boolean isMember(Principal member) {
+        return !member.equals(this);
+    }
+
+    @Override
+    public Enumeration<? extends Principal> members() {
+        throw new UnsupportedOperationException("Not implemented.");
+    }
+
+    //-------------------------------------------------------------< Object >---
+
+    @Override
+    public int hashCode() {
+        return NAME.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        } else if (obj instanceof Principal) {
+            return NAME.equals(((Principal) obj).getName());
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return NAME + " principal";
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java?rev=1335379&r1=1335378&r2=1335379&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
Tue May  8 08:42:18 2012
@@ -31,8 +31,7 @@ import java.util.NoSuchElementException;
  *
  * TODO: move to jackrabbit-jcr-commons
  */
-public class PrincipalIteratorAdapter extends RangeIteratorDecorator
-        implements PrincipalIterator {
+public class PrincipalIteratorAdapter extends RangeIteratorDecorator implements PrincipalIterator
{
 
     /**
      * Static instance of an empty {@link PrincipalIterator}.

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java?rev=1335379&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
Tue May  8 08:42:18 2012
@@ -0,0 +1,81 @@
+/*
+ * 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.jcr.security.principal;
+
+import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.apache.jackrabbit.oak.security.principal.EveryonePrincipal;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.security.Principal;
+
+/**
+ * PrincipalManagerImpl...
+ */
+public class PrincipalManagerImpl implements PrincipalManager {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(PrincipalManagerImpl.class);
+
+    @Override
+    public boolean hasPrincipal(String principalName) {
+        // TODO
+        return false;
+    }
+
+    @Override
+    public Principal getPrincipal(String principalName) {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public PrincipalIterator findPrincipals(String simpleFilter) {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public PrincipalIterator findPrincipals(String simpleFilter, int searchType) {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public PrincipalIterator getPrincipals(int searchType) {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public PrincipalIterator getGroupMembership(Principal principal) {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public Principal getEveryone() {
+        Principal everyone = getPrincipal(EveryonePrincipal.NAME);
+        if (everyone == null) {
+            everyone = EveryonePrincipal.getInstance();
+        }
+        return everyone;
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java?rev=1335379&r1=1335378&r2=1335379&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
Tue May  8 08:42:18 2012
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.jcr.se
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.oak.jcr.security.principal.EveryonePrincipal;
+import org.apache.jackrabbit.oak.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java?rev=1335379&r1=1335378&r2=1335379&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
Tue May  8 08:42:18 2012
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.jcr.se
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.jackrabbit.oak.jcr.security.principal.EveryonePrincipal;
+import org.apache.jackrabbit.oak.security.principal.EveryonePrincipal;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 



Mime
View raw message