Example usage for java.security Permission implies

List of usage examples for java.security Permission implies

Introduction

In this page you can find the example usage for java.security Permission implies.

Prototype


public abstract boolean implies(Permission permission);

Source Link

Document

Checks if the specified permission's actions are "implied by" this object's actions.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Permission perm1 = new FilePermission("/tmp/*", "read,write");
    Permission perm2 = new FilePermission("/tmp/abc", "read");

    if (perm1.implies(perm2)) {
        System.out.println("perm1 implies perm2");
    }//  w  ww  .ja  v a2s.c  o  m

}

From source file:IDPermission.java

public static void main(String[] argv) throws Exception {
    Permission p1 = new IDPermission("1");

    Permission p2 = new IDPermission("2");
    boolean b = p1.implies(p2);

    p2 = new IDPermission("3");
    b = p1.implies(p2);//from w  w w  . j  a  v  a 2s  .c  o  m

    p2 = new IDPermission("4");
    b = p1.implies(p2);

    p2 = new IDPermission("5");
    b = p1.implies(p2);

    p2 = new IDPermission("6");
    b = p1.implies(p2);
}

From source file:org.knowhowlab.osgi.monitoradmin.mocks.SecutiryMockBundle.java

@Override
public boolean hasPermission(Object permission) {
    if (permissions != null) {
        for (Permission perm : permissions) {
            if (perm.implies((Permission) permission)) {
                return true;
            }/*from   w  ww.j  a v a2 s . c  o m*/
        }
        return false;
    } else {
        return false;
    }
}

From source file:org.pepstock.jem.node.security.BatchSecurityManager.java

/**
 * Check the batch permission//from  w w  w  .j  av  a2  s  .co  m
 * 
 * @param permission is a shiro permission that can be:
 *            <p>
 * @see org.pepstock.jem.node.security.RegExpPermission or
 *      <p>
 * @see org.pepstock.jem.node.security.StringPermission
 * @return true if user has the right permission, false otherwise
 */
public boolean checkBatchPermission(String permission) {
    StringPermission sPermission = new StringPermission(permission);
    for (org.apache.shiro.authz.Permission perm : permissions) {
        if (perm.implies(sPermission)) {
            return true;
        }
    }
    return false;
}