Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 98289 invoked from network); 3 Sep 2009 13:51:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Sep 2009 13:51:55 -0000 Received: (qmail 64885 invoked by uid 500); 3 Sep 2009 13:51:55 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 64845 invoked by uid 500); 3 Sep 2009 13:51:55 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 64836 invoked by uid 99); 3 Sep 2009 13:51:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2009 13:51:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2009 13:51:53 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 394D42388896; Thu, 3 Sep 2009 13:51:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r810940 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/UnmodifiableAccessControlList.java Date: Thu, 03 Sep 2009 13:51:33 -0000 To: commits@jackrabbit.apache.org From: tripod@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090903135133.394D42388896@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tripod Date: Thu Sep 3 13:51:32 2009 New Revision: 810940 URL: http://svn.apache.org/viewvc?rev=810940&view=rev Log: Extend from JackrabbitAccessControlList Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/UnmodifiableAccessControlList.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/UnmodifiableAccessControlList.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/UnmodifiableAccessControlList.java?rev=810940&r1=810939&r2=810940&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/UnmodifiableAccessControlList.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/UnmodifiableAccessControlList.java Thu Sep 3 13:51:32 2009 @@ -22,8 +22,16 @@ import javax.jcr.security.Privilege; import javax.jcr.RepositoryException; +import javax.jcr.Value; +import javax.jcr.PropertyType; + import java.security.Principal; import java.util.List; +import java.util.Map; +import java.util.Collections; +import java.util.HashMap; + +import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; /** * An implementation of the AccessControlList interface that only @@ -32,10 +40,14 @@ * and {@link #removeAccessControlEntry(AccessControlEntry) removeAccessControlEntry}) * throw an AccessControlException. */ -public class UnmodifiableAccessControlList implements AccessControlList { +public class UnmodifiableAccessControlList implements JackrabbitAccessControlList { private final AccessControlEntry[] accessControlEntries; + private final Map restrictions; + + private final String path; + /** * Construct a new UnmodifiableAccessControlList * @@ -45,7 +57,20 @@ * specified AccessControlList. */ public UnmodifiableAccessControlList(AccessControlList acl) throws RepositoryException { - accessControlEntries = acl.getAccessControlEntries(); + if (acl instanceof JackrabbitAccessControlList) { + JackrabbitAccessControlList jAcl = (JackrabbitAccessControlList) acl; + accessControlEntries = acl.getAccessControlEntries(); + path = jAcl.getPath(); + Map r = new HashMap(); + for (String name: jAcl.getRestrictionNames()) { + r.put(name, jAcl.getRestrictionType(name)); + } + restrictions = Collections.unmodifiableMap(r); + } else { + accessControlEntries = acl.getAccessControlEntries(); + path = null; + restrictions = Collections.emptyMap(); + } } /** @@ -55,6 +80,8 @@ */ public UnmodifiableAccessControlList(List accessControlEntries) { this.accessControlEntries = accessControlEntries.toArray(new AccessControlEntry[accessControlEntries.size()]); + path = null; + restrictions = Collections.emptyMap(); } //--------------------------------------------------< AccessControlList >--- @@ -82,4 +109,36 @@ throws AccessControlException, RepositoryException { throw new AccessControlException("Unmodifiable ACL. Use AccessControlManager#getApplicablePolicies in order to obtain an modifiable ACL."); } + + public String[] getRestrictionNames() { + return restrictions.keySet().toArray(new String[restrictions.size()]); + } + + public int getRestrictionType(String restrictionName) { + if (restrictions.containsKey(restrictionName)) { + return restrictions.get(restrictionName); + } else { + return PropertyType.UNDEFINED; + } + } + + public boolean isEmpty() { + return accessControlEntries.length == 0; + } + + public int size() { + return accessControlEntries.length; + } + + public boolean addEntry(Principal principal, Privilege[] privileges, boolean isAllow) throws AccessControlException, RepositoryException { + throw new AccessControlException("Unmodifiable ACL. Use AccessControlManager#getApplicablePolicies in order to obtain an modifiable ACL."); + } + + public boolean addEntry(Principal principal, Privilege[] privileges, boolean isAllow, Map restrictions) throws AccessControlException, RepositoryException { + throw new AccessControlException("Unmodifiable ACL. Use AccessControlManager#getApplicablePolicies in order to obtain an modifiable ACL."); + } + + public String getPath() { + return path; + } } \ No newline at end of file