Class SensitiveArrays
SensitiveArrays class provides methods for creating and handling
integrity-sensitive array objects.
The makeIntegritySensitiveArray method can be
used to create integrity-sensitive array objects. Integrity-sensitive array
objects include an integrity control element that is automatically and
transparently updated by the platform whenever the array content is legally
modified. The integrity control element is automatically checked by the
platform before any array update operation. If an inconsistency is detected
during an array integrity check a SecurityException is thrown. The
integrity control element is not automatically checked by the platform before
a read operation: it is up to the applet to trigger such a check by calling
the assertIntegrity method.
- Since:
- 3.0.5
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertIntegrity(Object obj) Checks the integrity of the specified integrity-sensitive array object.static shortclearArray(Object obj) Clears the specified array object.static booleanReturns whether the provided object is an integrity-sensitive array.static booleanReturns whether the implementation for the Java Card platform supports integrity-sensitive arrays.static ObjectmakeIntegritySensitiveArray(byte type, byte memory, short length) Creates an integrity-sensitive array of the specified array and memory type, with the specified array length.
-
Method Details
-
assertIntegrity
Checks the integrity of the specified integrity-sensitive array object.- Parameters:
obj- the integrity-sensitive array object being queried- Throws:
NullPointerException- ifobjisnull.SecurityException- if the integrity ofobjhas been compromised.SystemException- with the following reason codes:ILLEGAL_VALUEif the specified object is not an integrity-sensitive array object.
- See Also:
-
isIntegritySensitive
Returns whether the provided object is an integrity-sensitive array.In addition to returning a
booleanresult, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResultclass.- Parameters:
obj- the object being queried.- Returns:
trueif the provided object is an integrity-sensitive array or a view on an integrity-sensitive array;falseotherwise.- Throws:
NullPointerException- ifobjisnull.- See Also:
-
isIntegritySensitiveArraysSupported
public static boolean isIntegritySensitiveArraysSupported()Returns whether the implementation for the Java Card platform supports integrity-sensitive arrays.In addition to returning a
booleanresult, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResultclass.- Returns:
trueif integrity-sensitive arrays are supported;falseotherwise.- See Also:
-
makeIntegritySensitiveArray
Creates an integrity-sensitive array of the specified array and memory type, with the specified array length.Note: only the content of the array is sensitive, in particular in the case of an array of object references, only the references stored in the array are sensitive, not the objects themselves.
- Parameters:
type- the array type - must be one of:ARRAY_TYPE_BOOLEAN,ARRAY_TYPE_BYTE,ARRAY_TYPE_SHORT,ARRAY_TYPE_INTorARRAY_TYPE_OBJECT.memory- the memory type - must be one of:MEMORY_TYPE_PERSISTENT,MEMORY_TYPE_TRANSIENT_RESETorMEMORY_TYPE_TRANSIENT_DESELECT.length- the length of the sensitive array.- Returns:
- the new integrity-sensitive array.
- Throws:
NegativeArraySizeException- if thelengthparameter is negativeSystemException- with the following reason codes:ILLEGAL_USEif integrity-sensitive arrays are not supported.ILLEGAL_VALUEiftypeormemoryis not a valid type code. An implementation which does not support integrity-sensitive array objects ofintarray type may throw this exception.NO_TRANSIENT_SPACEif no sufficient transient space is available.NO_RESOURCEif no sufficient persistent space is available.
-
clearArray
Clears the specified array object. This method sets all the values in the array tonullforARRAY_TYPE_OBJECTarrays and to zero for all other array types. The integrity of the array object is not checked by this method before the clearing and the reinitialization of the integrity-control information.In addition to returning a
shortresult, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResultclass.Note:
- The clearing operation is atomic.
- When a transaction is in progress, the clearing of a
persistent integrity-sensitive array participates
to the transaction and is therefore subject
to atomic commit capacity limitations. If the commit capacity is exceeded,
no clearing is performed and a
TransactionExceptionexception is thrown. - The clearing cannot be performed on a view, even if it is a view on a sensitive array, because it operates on the entire array whereas a view gives only access to a subset of the elements.
- Parameters:
obj- the array being cleared.- Returns:
- the length of the specified array object.
- Throws:
SystemException- with the following reason codes:ILLEGAL_VALUEif the specified object is not an integrity-sensitive array object or is an array view.
NullPointerException- ifobjisnull.TransactionException- if clearing would cause the commit capacity to be exceeded.- See Also:
-