|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.owasp.esapi.reference.AbstractAccessReferenceMap<K>
public abstract class AbstractAccessReferenceMap<K>
Abstract Implementation of the AccessReferenceMap that is backed by ConcurrentHashMaps to provide a thread-safe implementation of the AccessReferenceMap. Implementations of this abstract class should implement the #getUniqueReference() method.
Field Summary | |
---|---|
protected java.util.Map<java.lang.Object,K> |
dtoi
The Direct to Indirect Map |
protected java.util.Map<K,java.lang.Object> |
itod
The Indirect to Direct Map |
Constructor Summary | |
---|---|
AbstractAccessReferenceMap()
Instantiates a new access reference map. |
|
AbstractAccessReferenceMap(int initialSize)
Instantiates a new access reference map with the specified size allotment to reduce Map resizing overhead. |
|
AbstractAccessReferenceMap(java.util.Set<java.lang.Object> directReferences)
Deprecated. This constructor internally calls the abstract method getUniqueReference() . Since this is a constructor, any
subclass that implements getUniqueReference() has not had it's
own constructor run. This leads to strange bugs because subclass
internal state is initializaed after calls to getUniqueReference()
have already happened. If this constructor is desired in a
subclass, consider running update(Set) in the subclass
constructor instead. |
|
AbstractAccessReferenceMap(java.util.Set<java.lang.Object> directReferences,
int initialSize)
Deprecated. This constructor internally calls the abstract method getUniqueReference() . Since this is a constructor, any
subclass that implements getUniqueReference() has not had it's
own constructor run. This leads to strange bugs because subclass
internal state is initializaed after calls to getUniqueReference()
have already happened. If this constructor is desired in a
subclass, consider running update(Set) in the subclass
constructor instead. |
Method Summary | ||
---|---|---|
|
addDirectReference(T direct)
Adds a direct reference to the AccessReferenceMap, then generates and returns an associated indirect reference. |
|
|
getDirectReference(K indirectReference)
Get the original direct object reference from an indirect reference. |
|
|
getIndirectReference(T directReference)
Get a safe indirect reference to use in place of a potentially sensitive direct object reference. |
|
protected abstract K |
getUniqueReference()
Returns a Unique Reference Key to be associated with a new directReference being inserted into the AccessReferenceMap. |
|
java.util.Iterator |
iterator()
Get an iterator through the direct object references. |
|
|
removeDirectReference(T direct)
Removes a direct reference and its associated indirect reference from the AccessReferenceMap. |
|
void |
update(java.util.Set directReferences)
Updates the access reference map with a new set of direct references, maintaining any existing indirect references associated with items that are in the new list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<K,java.lang.Object> itod
protected java.util.Map<java.lang.Object,K> dtoi
Constructor Detail |
---|
public AbstractAccessReferenceMap()
ConcurrentHashMap.DEFAULT_INITIAL_CAPACITY
and that resizing a Map is an expensive process. Consider
using a constructor where the initialSize is passed in to maximize performance of the AccessReferenceMap.
AbstractAccessReferenceMap(java.util.Set, int)
,
AbstractAccessReferenceMap(int)
public AbstractAccessReferenceMap(int initialSize)
initialSize
- The initial size of the underlying maps@Deprecated public AbstractAccessReferenceMap(java.util.Set<java.lang.Object> directReferences)
getUniqueReference()
. Since this is a constructor, any
subclass that implements getUniqueReference() has not had it's
own constructor run. This leads to strange bugs because subclass
internal state is initializaed after calls to getUniqueReference()
have already happened. If this constructor is desired in a
subclass, consider running update(Set)
in the subclass
constructor instead.
directReferences
- the direct references@Deprecated public AbstractAccessReferenceMap(java.util.Set<java.lang.Object> directReferences, int initialSize)
getUniqueReference()
. Since this is a constructor, any
subclass that implements getUniqueReference() has not had it's
own constructor run. This leads to strange bugs because subclass
internal state is initializaed after calls to getUniqueReference()
have already happened. If this constructor is desired in a
subclass, consider running update(Set)
in the subclass
constructor instead.
directReferences
- The references to initialize the access reference mapinitialSize
- The initial size to set the map to.Method Detail |
---|
protected abstract K getUniqueReference()
public java.util.Iterator iterator()
iterator
in interface AccessReferenceMap<K>
public <T> K addDirectReference(T direct)
addDirectReference
in interface AccessReferenceMap<K>
direct
- the direct reference
public <T> K removeDirectReference(T direct) throws AccessControlException
removeDirectReference
in interface AccessReferenceMap<K>
direct
- the direct reference to remove
AccessControlException
- if the reference does not exist.public final void update(java.util.Set directReferences)
update
in interface AccessReferenceMap<K>
directReferences
- a Set of direct references to addpublic <T> K getIndirectReference(T directReference)
getIndirectReference
in interface AccessReferenceMap<K>
directReference
- the direct reference
public <T> T getDirectReference(K indirectReference) throws AccessControlException
UserProfile profile = arm.getDirectReference( indirectRef );Will throw a AccessControlException if the object stored in memory is not of type UserProfile. However,
Object uncastObject = arm.getDirectReference( indirectRef );Will never throw a AccessControlException as long as the object exists. If you are unsure of the object type of that an indirect reference references you should get the uncast object and test for type in the calling code.
Object uncastProfile = arm.getDirectReference( indirectRef ); if ( uncastProfile instanceof UserProfile ) { UserProfile userProfile = (UserProfile) uncastProfile; // ... } else { EmployeeProfile employeeProfile = (EmployeeProfile) uncastProfile; // ... }
getDirectReference
in interface AccessReferenceMap<K>
indirectReference
- the indirect reference
AccessControlException
- if no direct reference exists for the specified indirect reference
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |