Allows a developer to compress and encrypt Strings and byte arrays.
This API was designed to allow applications to protect data in a database
if the user has enabled Content Protection on their device.
To encode an object:
String data = "This is a secret.";
// first compress and encrypt data
Object encoding = PersistentContent.encode( data, true, true );
... // then persist encoding
To decode an object:
try {
...
data = PersistentContent.decodeString( encoding );
...
} catch( IllegalStateException e ) {
// unable to decode data; the device must be locked.
}
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeAndAppend(byte[] data,
boolean compress,
boolean encrypt,
Object content)
Encrypts and/or compresses a byte array and appends it to provided content.
encodeAndAppend(byte[] data,
int offset,
int length,
boolean compress,
boolean encrypt,
Object content)
Encrypts and/or compresses portion of a byte array and appends it to provided
content.
True if the device supports content encryption and is secure;
otherwise, false.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
isContentProtectionSupported
public static boolean isContentProtectionSupported()
Determines whether or not Content Protection is supported by this device.
Returns:
True if content protection is supported; otherwise, false.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
isEncryptionEnabled
public static boolean isEncryptionEnabled()
Determines if Content Encryption is enabled by the user.
Returns:
True if content encryption is currently enabled; otherwise, false.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
isCompressionEnabled
public static boolean isCompressionEnabled()
Determines if Content Compression is enabled by the user.
Returns:
True if content compression is currently enabled; otherwise, false.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
getModeGeneration
public static int getModeGeneration()
Retrieves a counter that changes every time the user has changed their Content
Protection settings.
The value returned by this method should be considered for comparison purposes only.
That is, comparing the return value to a previously returned value lets the caller know whether the Content Protection settings have changed
since the previous call. If the values are different, then the Content Protection settings have changed.
Returns:
A counter that can be compared to previously returned values that will indicate if the Content Protection
settings have changed since the last call.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
getLockGeneration
public static int getLockGeneration()
Retrieves a counter that changes every time the user locks or unlocks their device.
The value returned by this method should be considered for comparison purposes only.
That is, comparing the return value to a previously returned value lets the caller know whether the device has locked or unlocked
since the previous call. If the values are different, then the device has locked and/or unlocked.
Returns:
A counter that can be compared to previously returned values that will indicate if the device has locked or unlocked since the last call.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
requestReEncode
public static void requestReEncode()
Request that all registered PersistentContentListeners re-encode their data.
This function should be called if the app wants to enable or disable the use of encryption on a field,
eg the user may have changed an option that requires some data
to be availble while the device is locked (hence the encryption must be disabled for this field).
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
If the device is currently unlocked, use this method to retrieve a ticket
the caller can use to decrypt protected data, for as long as the ticket
is strongly referenced. This allows the calling process to gain access to
protected data during potentially long operations, such as sorting.
Note: please release all references to the returned
ticket as soon as possible.
Returns:
Ticket object, or null, if the device is locked.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
This method behaves like getTicket(), except that, if the
device is locked, it waits for the device to unlock and then returns the
ticket.
Returns:
Ticket object.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Encrypts and/or compresses an arbitrary object. Note that only Strings and byte arrays are actually encoded.
Parameters:
obj - Object to encode and compress.
Returns:
Encoded and commpressed object.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeObject
public static ObjectencodeObject(Object obj,
boolean compress,
boolean encrypt)
Encrypts and compresses an arbitrary object. Note that only Strings and byte arrays are actually encoded.
Parameters:
string - String to encode and/or compress.
compress - If true, this method compresses string; otherwise, no
compression performed.
encrypt - If true, this method encodes string; otherwise, no
cyphering performed.
Returns:
Encoded/compressed string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encode
public static Objectencode(String string,
boolean compress,
boolean encrypt)
Encrypts and/or compresses a string.
Parameters:
string - String to encode and/or compress.
compress - If true, this method compresses string; otherwise, no
compression performed.
encrypt - If true, this method encodes string; otherwise, no
cyphering performed.
Returns:
Encoded/compressed string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encode
public static Objectencode(String string,
int index,
int length,
boolean compress,
boolean encrypt)
Encrypts and/or compresses a sub-string.
Parameters:
string - String to provide source of sub-string to encode and/or
compress.
index - First character in string to encode/compress.
length - Number of characters from string to encode/compress.
compress - If true, this method compresses string; otherwise, no
compression performed.
encrypt - If true, this method encodes string; otherwise, no
cyphering performed.
Returns:
Encoded/compressed sub-string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Encodes and compresses a string and appends to provided content.
Parameters:
string - String to encode and compress.
content - Content object to which to append encoded and compressed
string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeAndAppend
public static ObjectencodeAndAppend(String string,
boolean compress,
boolean encrypt,
Object content)
Encrypts and/or compresses string and appends to provided content.
Parameters:
string - String to encode and/or compress.
compress - If true, this method compresses string; otherwise, no
compression performed.
encrypt - If true, this method encodes string; otherwise, no
cyphering performed.
content - Content object to which to append encoded/compressed
string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeAndAppend
public static ObjectencodeAndAppend(String string,
int index,
int length,
boolean compress,
boolean encrypt,
Object content)
Encrypts and/or compresses a sub-string.
Parameters:
string - String to provide source of sub-string to encode and/or
compress.
index - First character in string to encode/compress.
length - Number of characters from string encode/compress.
compress - If true, this method compresses string; otherwise, no
compression performed.
encrypt - If true, this method encodes string; otherwise, no
cyphering performed.
content - Content object to which to append encoded/compressed
string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encode
public static Objectencode(byte[] data,
boolean compress,
boolean encrypt)
Encrypts and/or compresses a byte array.
Parameters:
data - Data to encode/compress.
compress - If true, this method compresses data; otherwise, no
compression performed.
encrypt - If true, this method encodes data; otheriwse, no
cyphering performed.
Returns:
Encoded/compressed data.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encode
public static Objectencode(byte[] data,
int offset,
int length,
boolean compress,
boolean encrypt)
Encrypts and/or compresses a portion of a byte array.
Parameters:
data - Data to encode/compress.
offset - First byte in data to encode/compress.
length - Number of bytes from data to encode/compress.
compress - If true, this method compresses data; otherwise, no
compression performed.
encrypt - If true, this method encodes data; otherwise, no
cyphering performed.
Returns:
Encoded/compressed string.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeAndAppend
public static ObjectencodeAndAppend(byte[] data,
Object content)
Encrypts and compresses a byte array and appends it to provided content.
Parameters:
data - Data to encode and compress.
content - Content object to which to append encoded and compressed
data.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeAndAppend
public static ObjectencodeAndAppend(byte[] data,
boolean compress,
boolean encrypt,
Object content)
Encrypts and/or compresses a byte array and appends it to provided content.
Parameters:
data - Data to encode/compress.
compress - If true, this method compresses string; otherwise, no
compression performed.
encrypt - If true, this method encrypts string; otherwise, no
cyphering performed.
content - Content object to which to append encoded/compressed
data.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
encodeAndAppend
public static ObjectencodeAndAppend(byte[] data,
int offset,
int length,
boolean compress,
boolean encrypt,
Object content)
Encrypts and/or compresses portion of a byte array and appends it to provided
content.
Parameters:
data - Data to encode/compress.
offset - First byte in data to encode/compress.
length - Number of bytes from data to encode/compress.
compress - If true, this method compresses data; otherwise, no
compression performed.
encrypt - If true, this method encrypts data; otherwise, no
cyphering performed.
content - Content object to which to append encoded/compressed
data.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
decodeString
public static StringdecodeString(Object content,
boolean firstBlockOnly)
Decodes portion of string.
Parameters:
content - Data object to decode.
firstBlockOnly - If true, decode only first block of data;
otherwise, decode entire data object.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
decodeByteArray
public static byte[] decodeByteArray(Object content)
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
decodeByteArray
public static byte[] decodeByteArray(Object content,
boolean firstBlockOnly)
Decodes portion of byte array.
Parameters:
content - Data object to decode.
firstBlockOnly - If true, decode only first block of data;
otherwise, decode entire data object.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
decode
public static Objectdecode(Object content,
boolean firstBlockOnly)
Decodes portion of data object.
Parameters:
content - Data object to decode.
firstBlockOnly - If true, decode only first block of data;
otherwise, decode entire data object.
Returns:
Decoded data object, or first block of object.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
True if encoding represents a string; otherwise, false.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
isByteArray
public static boolean isByteArray(Object encoding)
Determines if the encoding represents a byte array.
Parameters:
encoding - Encoding to test.
Returns:
True if encoding represents a byte array; otherwise, false.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
If the encoding represents a string, then this method returns
String.length(). If the encoding represents a byte array, then
this method returns the number of byte elements in the array.
Parameters:
encoding - Encoding to measure.
Returns:
Length of the encoding.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
checkEncoding
public static boolean checkEncoding(Object encoding)
Determines if provided encoding is protected under user's settings.
Use this method to determine if the provided encoding is protected
according to the user's settings.
Parameters:
encoding - Encoding to check.
Returns:
True if the data is protected and OK; otherwise, the data
should be rencoded with reEncode(java.lang.Object).
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
checkEncoding
public static boolean checkEncoding(Object encoding,
boolean compress,
boolean encrypt)
Determines if provided encoding is protected under provided settings.
Use this method to determine if the provided encoding is protected
according to the provided settings and the user's setting.
checkEncoding() will return true iff all the following consitions are true:
The user has disabled content protection or encrypt is false, and the data is not encrypted.
The user has disabled content compression or compress is false, and the data is not compressed.
Parameters:
encoding - Encoding to check.
compress - Compression setting to use.
encrypt - Encryption setting to use.
Returns:
True if the data is protected and OK; otherwise, the data should
be rencoded with reEncode(java.lang.Object).
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Re-encodes an object according to the user's current Content Protection
setting.
This method encrypts or decrypts the current encoding as required, and
returns the results.
Parameters:
encoding - Encoding to re-encode.
Returns:
Re-encoded object.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
reEncode
public static ObjectreEncode(Object encoding,
boolean compress,
boolean encrypt)
Re-encodes an object according to provided Content Protection setting.
This method encrypts or decrypts the current encoding as required,
and returns the result.
Parameters:
encoding - Encoding to re-encode.
compress - Compression setting to use.
encrypt - Encryption setting to use.
Returns:
Re-encoded object.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
convertEncodingToByteArray
public static byte[] convertEncodingToByteArray(Object encoding)
Converts a PersistentContent encoding of an object to a byte array.
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
convertByteArrayToEncoding
public static ObjectconvertByteArrayToEncoding(byte[] array)
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Copyright 1999-2004 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved. Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. Copyright 2002-2003 Nokia Corporation All Rights Reserved. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.