You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2011/03/05 23:17:07 UTC

svn commit: r1078374 - /shiro/trunk/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java

Author: lhazlewood
Date: Sat Mar  5 22:17:07 2011
New Revision: 1078374

URL: http://svn.apache.org/viewvc?rev=1078374&view=rev
Log:
SHIRO-234: fix implemented

Modified:
    shiro/trunk/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java

Modified: shiro/trunk/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java
URL: http://svn.apache.org/viewvc/shiro/trunk/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java?rev=1078374&r1=1078373&r2=1078374&view=diff
==============================================================================
--- shiro/trunk/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java (original)
+++ shiro/trunk/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java Sat Mar  5 22:17:07 2011
@@ -213,14 +213,14 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , String)} returns <code>true</code>,
+     * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String)} returns <code>true</code>,
      * <code>false</code> otherwise.
      */
     public boolean isPermitted(PrincipalCollection principals, String permission) {
         assertRealmsConfigured();
         for (Realm realm : getRealms()) {
             if (!(realm instanceof Authorizer)) continue;
-            if (((Authorizer)realm).isPermitted(principals, permission)) {
+            if (((Authorizer) realm).isPermitted(principals, permission)) {
                 return true;
             }
         }
@@ -229,14 +229,14 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , Permission)} call returns <code>true</code>,
+     * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission)} call returns <code>true</code>,
      * <code>false</code> otherwise.
      */
     public boolean isPermitted(PrincipalCollection principals, Permission permission) {
         assertRealmsConfigured();
         for (Realm realm : getRealms()) {
             if (!(realm instanceof Authorizer)) continue;
-            if (((Authorizer)realm).isPermitted(principals, permission)) {
+            if (((Authorizer) realm).isPermitted(principals, permission)) {
                 return true;
             }
         }
@@ -245,7 +245,7 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link Realm#isPermittedAll(org.apache.shiro.subject.PrincipalCollection, String...)} call returns
+     * {@link #isPermittedAll(org.apache.shiro.subject.PrincipalCollection, String...)} call returns
      * <code>true</code>, <code>false</code> otherwise.
      */
     public boolean[] isPermitted(PrincipalCollection principals, String... permissions) {
@@ -262,7 +262,7 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link org.apache.shiro.realm.Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , List)} call returns <code>true</code>,
+     * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, List)} call returns <code>true</code>,
      * <code>false</code> otherwise.
      */
     public boolean[] isPermitted(PrincipalCollection principals, List<Permission> permissions) {
@@ -281,7 +281,7 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , String)} call returns <code>true</code>
+     * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code>
      * for <em>all</em> of the specified string permissions, <code>false</code> otherwise.
      */
     public boolean isPermittedAll(PrincipalCollection principals, String... permissions) {
@@ -298,7 +298,7 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link Realm#isPermitted(org.apache.shiro.subject.PrincipalCollection , Permission)} call returns <code>true</code>
+     * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission)} call returns <code>true</code>
      * for <em>all</em> of the specified Permissions, <code>false</code> otherwise.
      */
     public boolean isPermittedAll(PrincipalCollection principals, Collection<Permission> permissions) {
@@ -314,7 +314,7 @@ public class ModularRealmAuthorizer impl
     }
 
     /**
-     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection , String) isPermitted(permission)}, throws
+     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String) isPermitted(permission)}, throws
      * an <code>UnauthorizedException</code> otherwise returns quietly.
      */
     public void checkPermission(PrincipalCollection principals, String permission) throws AuthorizationException {
@@ -325,7 +325,7 @@ public class ModularRealmAuthorizer impl
     }
 
     /**
-     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection , Permission) isPermitted(permission)}, throws
+     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission) isPermitted(permission)}, throws
      * an <code>UnauthorizedException</code> otherwise returns quietly.
      */
     public void checkPermission(PrincipalCollection principals, Permission permission) throws AuthorizationException {
@@ -336,7 +336,7 @@ public class ModularRealmAuthorizer impl
     }
 
     /**
-     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection , String...) isPermitted(permission)},
+     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String...) isPermitted(permission)},
      * throws an <code>UnauthorizedException</code> otherwise returns quietly.
      */
     public void checkPermissions(PrincipalCollection principals, String... permissions) throws AuthorizationException {
@@ -349,7 +349,7 @@ public class ModularRealmAuthorizer impl
     }
 
     /**
-     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection , Permission) isPermitted(permission)} for
+     * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission) isPermitted(permission)} for
      * <em>all</em> the given Permissions, throws
      * an <code>UnauthorizedException</code> otherwise returns quietly.
      */
@@ -364,14 +364,14 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> if any of the configured realms'
-     * {@link Realm#hasRole(org.apache.shiro.subject.PrincipalCollection , String)} call returns <code>true</code>,
+     * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code>,
      * <code>false</code> otherwise.
      */
     public boolean hasRole(PrincipalCollection principals, String roleIdentifier) {
         assertRealmsConfigured();
         for (Realm realm : getRealms()) {
             if (!(realm instanceof Authorizer)) continue;
-            if (((Authorizer)realm).hasRole(principals, roleIdentifier)) {
+            if (((Authorizer) realm).hasRole(principals, roleIdentifier)) {
                 return true;
             }
         }
@@ -379,7 +379,7 @@ public class ModularRealmAuthorizer impl
     }
 
     /**
-     * Calls {@link #hasRole(org.apache.shiro.subject.PrincipalCollection , String)} for each role name in the specified
+     * Calls {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} for each role name in the specified
      * collection and places the return value from each call at the respective location in the returned array.
      */
     public boolean[] hasRoles(PrincipalCollection principals, List<String> roleIdentifiers) {
@@ -398,7 +398,7 @@ public class ModularRealmAuthorizer impl
 
     /**
      * Returns <code>true</code> iff any of the configured realms'
-     * {@link Realm#hasRole(org.apache.shiro.subject.PrincipalCollection , String)} call returns <code>true</code> for
+     * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns <code>true</code> for
      * <em>all</em> roles specified, <code>false</code> otherwise.
      */
     public boolean hasAllRoles(PrincipalCollection principals, Collection<String> roleIdentifiers) {
@@ -412,7 +412,7 @@ public class ModularRealmAuthorizer impl
     }
 
     /**
-     * If !{@link #hasRole(org.apache.shiro.subject.PrincipalCollection , String) hasRole(role)}, throws
+     * If !{@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String) hasRole(role)}, throws
      * an <code>UnauthorizedException</code> otherwise returns quietly.
      */
     public void checkRole(PrincipalCollection principals, String role) throws AuthorizationException {
@@ -426,11 +426,12 @@ public class ModularRealmAuthorizer impl
      * Calls {@link #checkRoles(PrincipalCollection principals, String... roles) checkRoles(PrincipalCollection principals, String... roles) }.
      */
     public void checkRoles(PrincipalCollection principals, Collection<String> roles) throws AuthorizationException {
-	if (roles != null && !roles.isEmpty()) checkRoles(principals, (String[])roles.toArray() );
+        //SHIRO-234 - roles.toArray() -> roles.toArray(new String[roles.size()])
+        if (roles != null && !roles.isEmpty()) checkRoles(principals, roles.toArray(new String[roles.size()]));
     }
 
     /**
-     * Calls {@link #checkRole(org.apache.shiro.subject.PrincipalCollection , String) checkRole} for each role specified.
+     * Calls {@link #checkRole(org.apache.shiro.subject.PrincipalCollection, String) checkRole} for each role specified.
      */
     public void checkRoles(PrincipalCollection principals, String... roles) throws AuthorizationException {
         assertRealmsConfigured();