Skip to content
Permalink
Browse files

log returning null ACL

  • Loading branch information...
brad
brad committed Aug 27, 2015
1 parent e94b4ff commit b5851c12717b8efeddbeec01ff0217f7bd546590
Showing with 15 additions and 12 deletions.
  1. +15 −12 milton-api/src/main/java/io/milton/http/AclUtils.java
@@ -29,19 +29,22 @@
* @author brad
*/
public class AclUtils {

/**
* Recurisve function which checks the given collection of priviledges,
* Recurisve function which checks the given collection of priviledges,
* and checks inside the contains property of those priviledges
*
*
* Returns true if the required priviledge is directly present in the collection
* or is implied
*
*
* @param required
* @param privs
* @return
* @return
*/
public static boolean containsPriviledge(AccessControlledResource.Priviledge required, Iterable<AccessControlledResource.Priviledge> privs) {
if( privs == null ) {
return false;
}
for (AccessControlledResource.Priviledge p : privs) {
if (p.equals(required)) {
return true;
@@ -51,18 +54,18 @@ public static boolean containsPriviledge(AccessControlledResource.Priviledge req
}
}
return false;
}
}

public static Set<AccessControlledResource.Priviledge> asSet(AccessControlledResource.Priviledge ... privs) {
Set<AccessControlledResource.Priviledge> set = new HashSet<AccessControlledResource.Priviledge>(privs.length);
set.addAll(Arrays.asList(privs));
return set;
}

/**
* Return a set containing all privs in the given collection, and also all priviledges
* Return a set containing all privs in the given collection, and also all priviledges
* implies by those, and so on recursively
*
*
* @param privs
* @return - a set containiing all priviledges, direct or implied, by the given collection
*/
@@ -71,7 +74,7 @@ public static boolean containsPriviledge(AccessControlledResource.Priviledge req
_expand(privs, set);
return set;
}

private static void _expand(Iterable<AccessControlledResource.Priviledge> privs, Set<AccessControlledResource.Priviledge> output) {
if( privs == null ) {
return ;
@@ -80,6 +83,6 @@ private static void _expand(Iterable<AccessControlledResource.Priviledge> privs,
output.add(p);
_expand(p.contains, output);
}

}
}

0 comments on commit b5851c1

Please sign in to comment.
You can’t perform that action at this time.