Javolution 6.0.0 java
|
Classes | |
class | Permission |
Public Member Functions | |
abstract boolean | isGranted (Permission<?> permission) |
abstract void | grant (Permission<?> permission, Object certificate) |
abstract void | revoke (Permission<?> permission, Object certificate) |
final void | grant (Permission<?> permission) |
final void | revoke (Permission<?> permission) |
void | exit () |
Static Public Member Functions | |
static SecurityContext | enter () |
static void | check (Permission<?> permission) |
static AbstractContext | current () |
static< T extends AbstractContext > T | enter (Class< T > custom) |
static void | inherit (AbstractContext ctx) |
Protected Member Functions | |
SecurityContext () | |
AbstractContext | enterInner () |
AbstractContext | getOuter () |
abstract AbstractContext | inner () |
Static Protected Member Functions | |
static< T extends AbstractContext > T | current (Class< T > type) |
Static Private Member Functions | |
static SecurityContext | currentSecurityContext () |
Private Attributes | |
AbstractContext | outer |
Static Private Attributes | |
static final ThreadLocal< AbstractContext > | CURRENT = new ThreadLocal<AbstractContext>() |
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]
Definition at line 34 of file SecurityContext.java.
|
protected |
|
static |
Checks if the specified permission is granted.
permission | the permission to check. |
SecurityException | if the specified permission is not granted. |
Definition at line 195 of file SecurityContext.java.
References javolution.context.SecurityContext.currentSecurityContext(), and javolution.context.SecurityContext.isGranted().
Referenced by javolution.context.AbstractContext.enter(), and javolution.lang.Configurable< javolution.context.LogContext.Level >.reconfigure().
|
staticinherited |
Returns the current context for the current thread or
if this thread has no context (default).
Definition at line 61 of file AbstractContext.java.
References javolution.context.AbstractContext.CURRENT.
Referenced by javolution.context.LogContext.currentLogContext(), javolution.context.SecurityContext.currentSecurityContext(), javolution.text.TextContext.currentTextContext(), javolution.xml.XMLContext.currentXMLContext(), javolution.context.LocalContext.enter(), javolution.context.ConcurrentContext.enter(), and javolution.context.LocalContext.Parameter< T >.get().
|
staticprotectedinherited |
Returns the current context of specified type or
if none.
Definition at line 69 of file AbstractContext.java.
References javolution.context.AbstractContext.CURRENT, and javolution.context.AbstractContext.outer.
|
staticprivate |
Returns the current security context.
Definition at line 250 of file SecurityContext.java.
References javolution.context.AbstractContext.current(), and javolution.osgi.internal.OSGiServices.getSecurityContext().
Referenced by javolution.context.SecurityContext.check(), and javolution.context.SecurityContext.enter().
|
static |
Enters and returns a new security context instance.
Definition at line 185 of file SecurityContext.java.
References javolution.context.SecurityContext.currentSecurityContext(), and javolution.context.AbstractContext.enterInner().
|
staticinherited |
Enters the scope of a custom context. This method raises a SecurityException if the permission to enter contexts of the specified class is not granted. For example, the following disallow entering any custom context. [code] SecurityContext ctx = SecurityContext.enter(); try { ctx.revoke(new SecurityContext.Permission(AbstractContext.class, "enter")); ... // Cannot enter any custom context. } finally { ctx.exit(); // Back to previous security settings. }[/code]
custom | the custom context to enter. |
IllegalArgumentException | if the specified class default constructor cannot be instantiated. |
SecurityException | if SecurityContext.Permission(custom, "enter")
is not granted. |
Definition at line 101 of file AbstractContext.java.
References javolution.context.SecurityContext.check().
|
protectedinherited |
Enters the scope of an inner context which becomes the current context; the previous current context becomes the outer of this context.
Definition at line 141 of file AbstractContext.java.
References javolution.context.AbstractContext.CURRENT, and javolution.context.AbstractContext.outer.
Referenced by javolution.xml.XMLContext.enter(), javolution.text.TextContext.enter(), javolution.context.LogContext.enter(), javolution.context.LocalContext.enter(), javolution.context.SecurityContext.enter(), and javolution.context.ConcurrentContext.enter().
|
inherited |
Exits the scope of this context; the outer of this context becomes
the current context.
IllegalStateException | if this context is not the current context. |
Reimplemented in javolution.context.ConcurrentContext, and javolution.context.internal.ConcurrentContextImpl.
Definition at line 155 of file AbstractContext.java.
References javolution.context.AbstractContext.CURRENT.
|
protectedinherited |
Returns the outer context of this context or
if this context has no outer context.
Definition at line 167 of file AbstractContext.java.
final void javolution.context.SecurityContext.grant | ( | Permission<?> | permission | ) |
Grants the specified permission (convenience method).
permission | the permission to grant. |
SecurityException | if the specified permission cannot be granted. |
Definition at line 233 of file SecurityContext.java.
References javolution.context.SecurityContext.grant().
|
abstract |
Grants the specified permission.
permission | the permission to grant. |
certificate | the certificate used to grant that permission or null if none. |
SecurityException | if the specified permission cannot be granted. |
Reimplemented in javolution.context.internal.SecurityContextImpl.
Referenced by javolution.context.SecurityContext.grant().
|
staticinherited |
Inherits the specified context which becomes the context of the current thread. This method is particularly useful when creating new threads to make them inherits from the context stack of the parent thread. [code] //Spawns a new thread inheriting the context of the current thread. MyThread myThread = new MyThread(); myThread.inherited = AbstractContext.current(); myThread.start(); ... class MyThread extends Thread { AbstractContext inherited; public void run() { AbstractContext.inherit(inherited); // Sets current context. ... } }[/code]
Definition at line 131 of file AbstractContext.java.
Referenced by javolution.context.internal.ConcurrentThreadImpl.run().
|
abstractprotectedinherited |
Returns a new inner instance of this context inheriting the properties of this context. The new instance can be configured independently from its parent.
Reimplemented in javolution.context.internal.ConcurrentContextImpl, javolution.text.internal.TextContextImpl, javolution.context.internal.LogContextImpl, javolution.context.internal.SecurityContextImpl, javolution.xml.internal.XMLContextImpl, and javolution.context.internal.LocalContextImpl.
|
abstract |
Indicates if the specified permission is granted.
permission | the permission to check. |
Reimplemented in javolution.context.internal.SecurityContextImpl.
Referenced by javolution.context.SecurityContext.check().
final void javolution.context.SecurityContext.revoke | ( | Permission<?> | permission | ) |
Revokes the specified permission (convenience method).
permission | the permission to grant. |
SecurityException | if the specified permission cannot be revoked. |
Definition at line 243 of file SecurityContext.java.
References javolution.context.SecurityContext.revoke().
|
abstract |
Revokes the specified permission.
permission | the permission to grant. |
certificate | the certificate used to grant that permission or null if none. |
SecurityException | if the specified permission cannot be revoked. |
Reimplemented in javolution.context.internal.SecurityContextImpl.
Referenced by javolution.context.SecurityContext.revoke().
|
staticprivateinherited |
Holds the last context entered (thread-local).
Definition at line 45 of file AbstractContext.java.
Referenced by javolution.context.AbstractContext.current(), javolution.context.AbstractContext.enterInner(), and javolution.context.AbstractContext.exit().
|
privateinherited |
Holds the outer context or
if none (top context).
Definition at line 50 of file AbstractContext.java.
Referenced by javolution.context.AbstractContext.current(), and javolution.context.AbstractContext.enterInner().