public abstract class Security extends Base
Consider the following code example:
Subject subject = Security.login(sPrincipal, acPassword);
PrivilegedAction action =
new PrivilegedAction()
{
public Object run()
{
return CacheFactory.getCache(sCacheName);
}
};
NamedCache cache = (NamedCache) Security.runAs(subject, action);
The implementation of the run() method in PrivilegedAction does not have to be an immediate CacheFactory related call; it could be any sequence of code. Any calls that made within that context will be executed with the same privileges.
If a call that accesses a protected clustered resource is made outside of the "runAs" scope, the AccessController will instantiate and use a CallbackHandler specified in the tangosol-coherence.xml descriptor. If it is not specified and security is enabled the resource access request will be rejected.
A SecurityException is thrown if the caller does not have permission to call a particular method; the controlling permissions are instances of javax.security.auth.AuthPermission with corresponding target names such as "coherence.login" or "coherence.runAs".
Base.LoggingWriter, Base.StackFrame| Modifier and Type | Field and Description |
|---|---|
static boolean |
ENABLED
Indicates if security is enabled by the operational configuration.
|
static boolean |
SUBJECT_SCOPED
Indicates if subject scope is enabled by the operational configuration.
|
| Constructor and Description |
|---|
Security() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkPermission(Cluster cluster, String sServiceName, String sCacheName, String sAction)
Check if the current user has permission to perform the action against "clustered resources", such as clustered services and caches.
|
static Subject |
login(CallbackHandler handler)
Perform the authentication.
|
static Subject |
login(String sName, char[] acPassword)
Perform the authentication.
|
static Object |
runAs(Subject subject, PrivilegedAction action)
Executes a privileged action on behalf of the user identity.
|
static Object |
runAs(Subject subject, PrivilegedExceptionAction action)
Executes a privileged exception action on behalf of the user identity.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, waitpublic static final boolean ENABLED
public static final boolean SUBJECT_SCOPED
public static Subject login(String sName, char[] acPassword)
sName - the user name to use for authenticationacPassword - the password to use for authenticationSecurityException - if authentication failspublic static Subject login(CallbackHandler handler)
handler - the CallbackHandler to be used for authenticationSecurityException - if authentication failspublic static Object runAs(Subject subject, PrivilegedAction action)
subject - the identity to perform action on behalf ofaction - the privileged action to performpublic static Object runAs(Subject subject, PrivilegedExceptionAction action) throws PrivilegedActionException
subject - the identity to perform action on behalf ofaction - the privileged exception action to performPrivilegedActionException - if the specified action's run method threw a checked exceptionpublic static void checkPermission(Cluster cluster, String sServiceName, String sCacheName, String sAction)
cluster - the Cluster objectsServiceName - the name of the ServicesCacheName - the name of the CachesAction - the action to be performed (for example, "create", "destroy", "join")SecurityException - if permission is denied