javolution.context.SecurityContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javolution-core-java-msftbx
Show all versions of javolution-core-java-msftbx
Only the Java Core part of Javolution library, with slight modifications for use in MSFTBX.
The newest version!
/*
* Javolution - Java(TM) Solution for Real-Time and Embedded Systems
* Copyright (C) 2007 - Javolution (http://javolution.org/)
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software is
* freely granted, provided that this notice is preserved.
*/
package javolution.context;
import javolution.osgi.internal.OSGiServices;
/**
* A high-level security context integrated with OSGi.
*
* When granting/revoking permission the order is important.
* For example, the following code revokes all configurable permissions
* except for setting the concurrency level.
* [code]
* SecurityContext ctx = SecurityContext.enter();
* try {
* ctx.revoke(Configurable.RECONFIGURE_PERMISSION);
* ctx.grant(ConcurrentContext.CONCURRENCY.getReconfigurePermission());
* ...
* ConcurrentContext.CONCURRENCY.reconfigure(0); // Ok (permission specifically granted).
* ...
* } finally {
* ctx.exit(); // Back to previous security settings.
* }[/code]
*
* @author Jean-Marie Dautelle
* @version 6.0, July 21, 2013
*/
public abstract class SecurityContext extends AbstractContext {
/**
* A permission associated to a specific class/action/instance.
* There are three levels of permission possible, at
* the class/category level, at the action level and at the instance level.
* Any permission granted/revoked at the higher level is explicitly
* granted/revoked at the lower level. The order in which the permission
* are granted/revoked is important. For example, it is possible to grant
* a permission at the class level, then to revoke it at the action or
* instance level. In which case, for that class the permission is granted
* for all actions/instances except for those actions/instances for which the
* permission has been explicitly revoked.
*/
public static class Permission {
/**
* Holds the global permission for anything.
*/
public static final Permission