Class DynaBeanACRParameter
- java.lang.Object
-
- org.owasp.esapi.reference.accesscontrol.DynaBeanACRParameter
-
- All Implemented Interfaces:
PolicyParameters
public class DynaBeanACRParameter extends java.lang.Object implements PolicyParameters
A DynaBean comes from the apache bean utils. It is basically a convenient way to dynamically assign getters and setters. Essentially, the way we use DynaBean is a HashMap that can be set to read only.- Author:
- Mike H. Fauzy
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.beanutils.LazyDynaMap
policyProperties
-
Constructor Summary
Constructors Constructor Description DynaBeanACRParameter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.String key)
Follows the contract for java.util.Map;java.math.BigDecimal
getBigDecimal(java.lang.String key)
Convenience method to avoid common casts.java.math.BigInteger
getBigInteger(java.lang.String key)
Convenience method to avoid common casts.boolean
getBoolean(java.lang.String key)
Convenience method to avoid common casts.byte
getByte(java.lang.String key)
Convenience method to avoid common casts.char
getChar(java.lang.String key)
Convenience method to avoid common casts.java.util.Date
getDate(java.lang.String key)
Convenience method to avoid common casts.double
getDouble(java.lang.String key)
Convenience method to avoid common casts.float
getFloat(java.lang.String key)
Convenience method to avoid common casts.int
getInt(java.lang.String key)
Convenience method to avoid common casts.long
getLong(java.lang.String key)
Convenience method to avoid common casts.java.lang.Object
getObject(java.lang.String key)
Convenience method to avoid common casts.java.lang.String
getString(java.lang.String key)
Convenience method to avoid common casts.java.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
Convenience method to avoid common casts.java.lang.String[]
getStringArray(java.lang.String key)
Convenience method to avoid common casts.java.util.Date
getTime(java.lang.String key)
Convenience method to avoid common casts.void
lock()
This makes the map itself read only, but the mutability of objects that this map contains is not affected.void
put(java.lang.String key, java.lang.Object value)
This is a convenience method for developers that prefer to think of this as a map instead of being bean-like.void
set(java.lang.String key, java.lang.Object value)
This works just like a Map, except it will throw an exception if lock() has been called.java.lang.String
toString()
-
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.String key)
Description copied from interface:PolicyParameters
Follows the contract for java.util.Map;- Specified by:
get
in interfacePolicyParameters
- Returns:
- The Object referred to by this key, if it exists.
- See Also:
Map
-
getBoolean
public boolean getBoolean(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The true/false value of the specified key. False if not found.
-
getByte
public byte getByte(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The byte value of the specified key.
-
getChar
public char getChar(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The char value of the specified key.
-
getInt
public int getInt(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The int value of the specified key.
-
getLong
public long getLong(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The long value of the specified key.
-
getFloat
public float getFloat(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The float value of the specified key.
-
getDouble
public double getDouble(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The double value of the specified key.
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The BigDecimal value of the specified key.
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The BigInteger value of the specified key.
-
getDate
public java.util.Date getDate(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The Date value of the specified key.
-
getTime
public java.util.Date getTime(java.lang.String key)
Convenience method to avoid common casts. Note that the time object is the same as a date object- Parameters:
key
-- Returns:
- The Date value of the specified key.
-
getString
public java.lang.String getString(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The String value of the specified key. null if the key is not defined.
-
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The String value of the specified key. If the key is not defined, the default value is returned instead.
-
getStringArray
public java.lang.String[] getStringArray(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The String[] value of the specified key.
-
getObject
public java.lang.Object getObject(java.lang.String key)
Convenience method to avoid common casts.- Parameters:
key
-- Returns:
- The value of the specified key, returned generically as an Object.
-
set
public void set(java.lang.String key, java.lang.Object value) throws java.lang.IllegalArgumentException
Description copied from interface:PolicyParameters
This works just like a Map, except it will throw an exception if lock() has been called.- Specified by:
set
in interfacePolicyParameters
- Throws:
java.lang.IllegalArgumentException
- if this DynaBeanACRParameter instance has already been locked.
-
put
public void put(java.lang.String key, java.lang.Object value) throws java.lang.IllegalArgumentException
Description copied from interface:PolicyParameters
This is a convenience method for developers that prefer to think of this as a map instead of being bean-like.- Specified by:
put
in interfacePolicyParameters
- Throws:
java.lang.IllegalArgumentException
- See Also:
PolicyParameters.set(String, Object)
-
lock
public void lock()
This makes the map itself read only, but the mutability of objects that this map contains is not affected. Specifically, properties cannot be added or removed and the reference cannot be changed to a different object, but this does not change whether the values that the object contains can be changed.- Specified by:
lock
in interfacePolicyParameters
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-