jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r794644 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security: authentication/ authorization/ simple/
Date Thu, 16 Jul 2009 12:02:27 GMT
Author: thomasm
Date: Thu Jul 16 12:02:27 2009
New Revision: 794644

URL: http://svn.apache.org/viewvc?rev=794644&view=rev
Log:
JCR-2087 Upgrade to Java 5 as the base platform

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryIterator.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlUtils.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java?rev=794644&r1=794643&r2=794644&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
Thu Jul 16 12:02:27 2009
@@ -133,7 +133,7 @@
         } else {
             AppConfigurationEntry[] entries = getJAASConfig();
             if (entries != null) {
-                List tmp = new ArrayList(entries.length);
+                List<Properties> tmp = new ArrayList<Properties>(entries.length);
                 for (int i = 0; i < entries.length; i++) {
                     Map opt = entries[i].getOptions();
                     if (opt != null) {
@@ -142,7 +142,7 @@
                         tmp.add(prop);
                     }
                 }
-                props = (Properties[]) tmp.toArray(new Properties[tmp.size()]);
+                props = tmp.toArray(new Properties[tmp.size()]);
             }
         }
         return props;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java?rev=794644&r1=794643&r2=794644&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AbstractAccessControlProvider.java
Thu Jul 16 12:02:27 2009
@@ -29,7 +29,6 @@
 import javax.jcr.Session;
 import javax.jcr.observation.ObservationManager;
 import java.security.Principal;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -131,9 +130,8 @@
     /**
      * @see AccessControlUtils#isAdminOrSystem(Set)
      */
-    public boolean isAdminOrSystem(Set principals) {
-        for (Iterator it = principals.iterator(); it.hasNext();) {
-            Principal p = (Principal) it.next();
+    public boolean isAdminOrSystem(Set<Principal> principals) {
+        for (Principal p : principals) {
             if (p instanceof AdminPrincipal || p instanceof SystemPrincipal) {
                 return true;
             }
@@ -144,7 +142,7 @@
     /**
      * @see AccessControlUtils#isReadOnly(Set)
      */
-    public boolean isReadOnly(Set principals) {
+    public boolean isReadOnly(Set<Principal> principals) {
         // TODO: find ways to determine read-only status
         return false;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryIterator.java?rev=794644&r1=794643&r2=794644&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryIterator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryIterator.java
Thu Jul 16 12:02:27 2009
@@ -31,21 +31,21 @@
 /**
  * <code>AccessControlEntryIterator</code>...
  */
-public class AccessControlEntryIterator implements Iterator {
+public class AccessControlEntryIterator implements Iterator<AccessControlEntry> {
 
     private static Logger log = LoggerFactory.getLogger(AccessControlEntryIterator.class);
 
-    private final List acls = new ArrayList();
-    private Iterator currentEntries;
-    private Object next;
+    private final List<AccessControlList> acls = new ArrayList<AccessControlList>();
+    private Iterator<AccessControlEntry> currentEntries;
+    private AccessControlEntry next;
 
-    public AccessControlEntryIterator(List aces) {
+    public AccessControlEntryIterator(List<AccessControlList> aces) {
         this(new AccessControlList[] {new UnmodifiableAccessControlList(aces)});
     }
 
     public AccessControlEntryIterator(AccessControlList[] acls) {
-        for (int i = 0; i < acls.length; i++) {
-            this.acls.add(acls[i]);
+        for (AccessControlList a : acls) {
+            this.acls.add(a);
         }
         next = seekNext();
     }
@@ -58,16 +58,16 @@
         return next != null;
     }
 
-    public Object next() {
+    public AccessControlEntry next() {
         if (next == null) {
             throw new NoSuchElementException();
         }
-        Object ret = next;
+        AccessControlEntry ret = next;
         next = seekNext();
         return ret;
     }
 
-    private Object seekNext() {
+    private AccessControlEntry seekNext() {
         while (currentEntries == null || !currentEntries.hasNext()) {
             if (acls.isEmpty()) {
                 // reached last acl -> break out of while loop
@@ -76,7 +76,7 @@
             } else {
                 AccessControlEntry[] entries = new AccessControlEntry[0];
                 try {
-                    entries = ((AccessControlList) acls.remove(0)).getAccessControlEntries();
+                    entries = (acls.remove(0)).getAccessControlEntries();
                 } catch (RepositoryException e) {
                     log.error("Unable to retrieve ACEs: " + e.getMessage() + " -> try
next.");
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProvider.java?rev=794644&r1=794643&r2=794644&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProvider.java
Thu Jul 16 12:02:27 2009
@@ -22,9 +22,10 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+
+import java.security.Principal;
 import java.util.Map;
 import java.util.Set;
-import java.security.Principal;
 
 /**
  * The AccessControlProvider is used to provide access control policy and entry

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlUtils.java?rev=794644&r1=794643&r2=794644&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlUtils.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlUtils.java
Thu Jul 16 12:02:27 2009
@@ -20,6 +20,8 @@
 import org.apache.jackrabbit.core.ItemImpl;
 
 import javax.jcr.RepositoryException;
+
+import java.security.Principal;
 import java.util.Set;
 
 /**
@@ -58,7 +60,7 @@
      * @return true if the specified set of principals contains an
      * <code>AdminPrincipal</code> or a <code>SystemPrincipal</code>.
      */
-    boolean isAdminOrSystem(Set principals);
+    boolean isAdminOrSystem(Set<Principal> principals);
 
     /**
      * Test if if the specified set of principals will have read-only permissions
@@ -69,6 +71,6 @@
      * @return true if the specified set of principals will only be granted
      * read permission on all items.
      */
-    boolean isReadOnly(Set principals);
+    boolean isReadOnly(Set<Principal> principals);
 
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java?rev=794644&r1=794643&r2=794644&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
Thu Jul 16 12:02:27 2009
@@ -223,9 +223,9 @@
     public String getUserID(Subject subject) throws RepositoryException {
         String uid = null;
         // if SimpleCredentials are present, the UserID can easily be retrieved.
-        Iterator creds = subject.getPublicCredentials(SimpleCredentials.class).iterator();
+        Iterator<SimpleCredentials> creds = subject.getPublicCredentials(SimpleCredentials.class).iterator();
         if (creds.hasNext()) {
-            SimpleCredentials sc = (SimpleCredentials) creds.next();
+            SimpleCredentials sc = creds.next();
             uid = sc.getUserID();
         } else if (anonymID != null && !subject.getPrincipals(AnonymousPrincipal.class).isEmpty())
{
             uid = anonymID;
@@ -233,8 +233,7 @@
             // assume that UserID and principal name
             // are the same (not totally correct) and thus return the name
             // of the first non-group principal.
-            for (Iterator it = subject.getPrincipals().iterator(); it.hasNext();) {
-                Principal p = (Principal) it.next();
+            for (Principal p : subject.getPrincipals()) {
                 if (!(p instanceof Group)) {
                     uid = p.getName();
                     break;
@@ -271,7 +270,7 @@
      */
     private class SimplePrincipalProvider implements PrincipalProvider {
 
-        private final Map principals = new HashMap();
+        private final Map<String, Principal> principals = new HashMap<String, Principal>();
 
         private SimplePrincipalProvider() {
             if (adminID != null) {
@@ -287,7 +286,7 @@
 
         public Principal getPrincipal(String principalName) {
             if (principals.containsKey(principalName)) {
-                return (Principal) principals.get(principalName);
+                return principals.get(principalName);
             } else {
                 return new UserPrincipal(principalName);
             }
@@ -316,7 +315,7 @@
                     it = new PrincipalIteratorAdapter(Collections.singletonList(EveryonePrincipal.getInstance()));
                     break;
                 case PrincipalManager.SEARCH_TYPE_NOT_GROUP:
-                    Set set = new HashSet(principals.values());
+                    Set<Principal> set = new HashSet<Principal>(principals.values());
                     set.remove(EveryonePrincipal.getInstance());
                     it = new PrincipalIteratorAdapter(set);
                     break;



Mime
View raw message