org.apache.slide.common
Class SlideTokenWrapper

java.lang.Object
  extended byorg.apache.slide.common.SlideTokenWrapper
All Implemented Interfaces:
SlideToken

public final class SlideTokenWrapper
extends java.lang.Object
implements SlideToken

The SlideTokenWrapper wraps around an existing token. It delegated all work to that token, except that it may have a different policy for store enlistment, security and locking.


Constructor Summary
SlideTokenWrapper(SlideToken token)
          Constructor.
 
Method Summary
 void addLockToken(java.lang.String lockId)
          Add a new lock token to the lock token list.
 void addParameter(java.lang.String parameterName, java.lang.Object parameterValue)
          Add a new parameter to the parameter list.
 void cacheLock(ObjectNode object, ActionNode action, boolean lock)
          allows to cache the result of a lock check
 void cacheMatchPrincipal(SubjectNode checkSubject, SubjectNode matchSubject, boolean match)
          Allows to cache the result of a matchPrincipal operation
 void cachePermission(ObjectNode object, ActionNode action, boolean permission)
          allows to cache the result of a permission check
 void cacheResolve(Uri uri, ResourceId resourceId)
          Allows to cache the result of a resolve operation
 java.lang.Boolean checkLockCache(ObjectNode object, ActionNode action)
          checks if the lock cache contains an entry for the ObjectNode and ActionNode combination.
 boolean checkLockToken(java.lang.String lockToken)
          Checks if the given lock token is present.
 java.lang.Boolean checkMatchPrincipalCache(SubjectNode checkSubject, SubjectNode matchSubject)
          Checks if the matchPrincipal cache
 java.lang.Boolean checkPermissionCache(ObjectNode object, ActionNode action)
          checks if the permission cache contains an entry for the ObjectNode and ActionNode combination.
 ResourceId checkResolveCache(Uri uri)
          Checks if the resolve cache contains an entry for the specified uri.
 void clearLockTokens()
          Clears the lock token list.
 void clearParameters()
          Clears the parameter list.
 CacheInfoToken getCacheInfoToken()
          Returns the CacheInfo token.
 CredentialsToken getCredentialsToken()
          Returns the credentials token.
 java.lang.Object getParameter(java.lang.String name)
          Returns a named parameter.
 java.util.Enumeration getParameterNames()
          Return parameter list.
 boolean isEnforceLockTokens()
          Use lock tokens in lock resolution ?
 boolean isExternalTransaction()
          Checks if this request is part of an externally controlled transaction.
 boolean isForceLock()
          Force lock check.
 boolean isForceSecurity()
          Force security check.
 boolean isForceStoreEnlistment()
          Force store enlistment flag accessor.
 void removeLockToken(java.lang.String lockId)
          Removes a lock token from the lock token list.
 void removeParameter(java.lang.String parameterName)
          Removes a parameter from the parameter list.
 void setCacheInfoToken(CacheInfoToken cacheInfoToken)
          CacheInfo token mutator.
 void setCredentialsToken(CredentialsToken credentialsToken)
          Credentials token mutator.
 void setEnforceLockTokens(boolean enforceLockTokens)
          Enforce lock tokens flag mutator.
 void setExternalTx()
          Sets if this request is part of an externally controlled transaction.
 void setForceLock(boolean forceLock)
           
 void setForceSecurity(boolean forceSecurity)
           
 void setForceStoreEnlistment(boolean forceStoreEnlistment)
          Force store enlistment flag mutator.
 java.util.List showLockTokens()
          For debugging purposes ONLY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlideTokenWrapper

public SlideTokenWrapper(SlideToken token)
Constructor.

Parameters:
token - The token to wrap.
Method Detail

getCredentialsToken

public CredentialsToken getCredentialsToken()
Returns the credentials token.

Specified by:
getCredentialsToken in interface SlideToken
Returns:
String

setCredentialsToken

public void setCredentialsToken(CredentialsToken credentialsToken)
Credentials token mutator.

Specified by:
setCredentialsToken in interface SlideToken

getCacheInfoToken

public CacheInfoToken getCacheInfoToken()
Returns the CacheInfo token.

Specified by:
getCacheInfoToken in interface SlideToken
Returns:
CacheInfoToken

setCacheInfoToken

public void setCacheInfoToken(CacheInfoToken cacheInfoToken)
CacheInfo token mutator.

Specified by:
setCacheInfoToken in interface SlideToken

isEnforceLockTokens

public boolean isEnforceLockTokens()
Use lock tokens in lock resolution ?

Specified by:
isEnforceLockTokens in interface SlideToken
Returns:
boolean

setEnforceLockTokens

public void setEnforceLockTokens(boolean enforceLockTokens)
Enforce lock tokens flag mutator.

Specified by:
setEnforceLockTokens in interface SlideToken
Parameters:
enforceLockTokens - New flag value

isForceStoreEnlistment

public boolean isForceStoreEnlistment()
Force store enlistment flag accessor. If true, that will cause Slide to enlist the store in the current transaction for all operations, to be able to prevent dirty reads when doing complex updates.

Specified by:
isForceStoreEnlistment in interface SlideToken
Returns:
boolean

setForceStoreEnlistment

public void setForceStoreEnlistment(boolean forceStoreEnlistment)
Force store enlistment flag mutator. If set to true, that will cause Slide to enlist the store in the current transaction for all operations, to be able to prevent dirty reads when doing complex updates. That value should be set to true only in some very specific critical sections of the code, as this would greatly decrease the ability of Slide to handle multiple concurrent requests.

Specified by:
setForceStoreEnlistment in interface SlideToken
Parameters:
forceStoreEnlistment - New flag value

addLockToken

public void addLockToken(java.lang.String lockId)
Add a new lock token to the lock token list.

Specified by:
addLockToken in interface SlideToken
Parameters:
lockId - Lock token to add

removeLockToken

public void removeLockToken(java.lang.String lockId)
Removes a lock token from the lock token list.

Specified by:
removeLockToken in interface SlideToken
Parameters:
lockId - Lock token to remove

clearLockTokens

public void clearLockTokens()
Clears the lock token list.

Specified by:
clearLockTokens in interface SlideToken

checkLockToken

public boolean checkLockToken(java.lang.String lockToken)
Checks if the given lock token is present.

Specified by:
checkLockToken in interface SlideToken
Parameters:
lockToken - Lock token to check
Returns:
boolean True if the given lock token is present

showLockTokens

public java.util.List showLockTokens()
Description copied from interface: SlideToken
For debugging purposes ONLY

Specified by:
showLockTokens in interface SlideToken

addParameter

public void addParameter(java.lang.String parameterName,
                         java.lang.Object parameterValue)
Add a new parameter to the parameter list.

Specified by:
addParameter in interface SlideToken
Parameters:
parameterName - Parameter to add
parameterValue - Parameter value

removeParameter

public void removeParameter(java.lang.String parameterName)
Removes a parameter from the parameter list.

Specified by:
removeParameter in interface SlideToken
Parameters:
parameterName - Parameter to remove

clearParameters

public void clearParameters()
Clears the parameter list.

Specified by:
clearParameters in interface SlideToken

getParameter

public java.lang.Object getParameter(java.lang.String name)
Returns a named parameter.

Specified by:
getParameter in interface SlideToken
Returns:
the Object associated with name or null if no such parameter exists.

getParameterNames

public java.util.Enumeration getParameterNames()
Return parameter list.

Specified by:
getParameterNames in interface SlideToken

cachePermission

public void cachePermission(ObjectNode object,
                            ActionNode action,
                            boolean permission)
allows to cache the result of a permission check

Specified by:
cachePermission in interface SlideToken
Returns:
true if successful added to cache, false else

checkPermissionCache

public java.lang.Boolean checkPermissionCache(ObjectNode object,
                                              ActionNode action)
checks if the permission cache contains an entry for the ObjectNode and ActionNode combination.

Specified by:
checkPermissionCache in interface SlideToken
Returns:
true if granted, false if denied, null if nothing in the cache.

isForceSecurity

public boolean isForceSecurity()
Force security check. If false, checkCredentials of SecurityImpl will return immediately.

Specified by:
isForceSecurity in interface SlideToken
Returns:
a boolean

setForceSecurity

public void setForceSecurity(boolean forceSecurity)
Specified by:
setForceSecurity in interface SlideToken

isForceLock

public boolean isForceLock()
Force lock check. If false, checkLock of LockImpl will return immediately.

Specified by:
isForceLock in interface SlideToken
Returns:
a boolean

setForceLock

public void setForceLock(boolean forceLock)
Specified by:
setForceLock in interface SlideToken

cacheLock

public void cacheLock(ObjectNode object,
                      ActionNode action,
                      boolean lock)
allows to cache the result of a lock check

Specified by:
cacheLock in interface SlideToken

checkLockCache

public java.lang.Boolean checkLockCache(ObjectNode object,
                                        ActionNode action)
checks if the lock cache contains an entry for the ObjectNode and ActionNode combination.

Specified by:
checkLockCache in interface SlideToken
Returns:
true if locked, false otherwise

cacheResolve

public void cacheResolve(Uri uri,
                         ResourceId resourceId)
Allows to cache the result of a resolve operation

Specified by:
cacheResolve in interface SlideToken

checkResolveCache

public ResourceId checkResolveCache(Uri uri)
Checks if the resolve cache contains an entry for the specified uri.

Specified by:
checkResolveCache in interface SlideToken
Returns:
the cached resourceId or null

cacheMatchPrincipal

public void cacheMatchPrincipal(SubjectNode checkSubject,
                                SubjectNode matchSubject,
                                boolean match)
Allows to cache the result of a matchPrincipal operation

Specified by:
cacheMatchPrincipal in interface SlideToken

checkMatchPrincipalCache

public java.lang.Boolean checkMatchPrincipalCache(SubjectNode checkSubject,
                                                  SubjectNode matchSubject)
Checks if the matchPrincipal cache

Specified by:
checkMatchPrincipalCache in interface SlideToken
Returns:
the cached Boolean or null

isExternalTransaction

public boolean isExternalTransaction()
Checks if this request is part of an externally controlled transaction.

Specified by:
isExternalTransaction in interface SlideToken

setExternalTx

public void setExternalTx()
Sets if this request is part of an externally controlled transaction.

Specified by:
setExternalTx in interface SlideToken