Java Code Examples for java.security.AccessControlContext#hashCode()

The following examples show how to use java.security.AccessControlContext#hashCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppGuard.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if the caller has the required permission only when security-mode is enabled.
 *
 * @param permission permission to be checked
 */
public static void checkPermission(AppPermission.Type permission) {
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        return;
    }
    AccessControlContext context = AccessController.getContext();
    if (context == null) {
        sm.checkPermission(new AppPermission((permission)));
    } else {
        int contextHash = context.hashCode() ^ permission.hashCode();
        PermissionCheckCache.getInstance().checkCache(contextHash, new AppPermission(permission));
    }
}