Example usage for java.security AccessControlException AccessControlException

List of usage examples for java.security AccessControlException AccessControlException

Introduction

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

Prototype

public AccessControlException(String s, Permission p) 

Source Link

Document

Constructs an AccessControlException with the specified, detailed message, and the requested permission that caused the exception.

Usage

From source file:net.sourceforge.safr.jaas.permission.PermissionManagerImpl.java

public void checkPermission(Permission permission) {
    Subject current = Subject.getSubject(AccessController.getContext());
    if (!implies(permission, current) && activated) {
        throw new AccessControlException("access denied", permission);
    }/* w ww  .  j  a  v  a2  s  . c  o  m*/
}

From source file:com.jpeterson.littles3.bo.Acp.java

/**
 * Determines whether the access request indicated by the specified
 * permission should be allowed or denied, based on the Access Control
 * Policy. This method quietly returns if the access request is permitted,
 * or throws a suitable <code>AccessControlException</code> otherwise.
 * //from   w  ww.ja v  a 2  s . co m
 * @param permission
 *            the request permission
 * @throws AccessControlException
 *             if the specified permission is not permitted.
 */
public void checkPermission(Permission permission) throws AccessControlException {
    if (permissions.implies(permission)) {
        // permission granted
        return;
    }

    throw new AccessControlException("Access Control Policy does not grant this permission", permission);
}