|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.system.ControlledAccess
public final class ControlledAccess
Restricts access to an object to those callers than have permission.
You can use this class to enforce Data Access Control.
Typical uses for this class include enforcing access control in the
RuntimeStore
or in a PersistentObject
: you can control
read and replace access to any object you want to place in the RuntimeStore
or in a persistent object by wrapping it in a controlled access
object.
To control access to an object in the RuntimeStore
Use code similar to this example:
long MY_DATA_ID = 0x33abf322367f9018L; Hashtable myHashtable = new Hashtable(); // Get the code signing key associated with "ACME" CodeSigningKey codeSigningKey = CodeSigningKey.get( moduleHandle, "ACME" ); // Store myHashtable in the RuntimeStore but protect it // with the "ACME" code signing key RuntimeStore.put( MY_DATA_ID, new ControlledAccess( myHashtable, codeSigningKey ) ); // Now, only code files signed with the ACME key can read or replace myHashtable
To retrieve something from the RuntimeStore, use code similar to this example:
Hashtable myHashtable = (Hashtable) RuntimeStore.get( MY_DATA_ID ); // Note: no need to unwrap ControlledAccess
Or, to check if your data is protected with a particular code signing key, use code similar to this:
Hashtable myHashtable = (Hashtable) RuntimeStore.get( MY_DATA_ID, codeSigningKey ); // Note: no need to unwrap ControlledAccess
To control access to an object in a persistent object
Use code similar to this example:
long MY_DATA_ID = 0x33abf322367f9018L; Hashtable myHashtable = new Hashtable(); PersistentObject persistentObject = PersistentStore.getPersistentObject( MY_DATA_ID ); // Get the code signing key associated with "ACME" CodeSigningKey codeSigningKey = CodeSigningKey.get( moduleHandle, "ACME" ); // Store myHashtable in the PersistentObject but protect it with the "ACME" code signing key persistentObject.setContents( new ControlledAccess( myHashtable, codeSigningKey ) ); // Now, only code files signed with the ACME key can read or replace myHashtable
To retrieve something from the persistent object, use code similar to this example:
Hashtable myHashtable = (Hashtable) persistentObject.getContents(); // Note: no need to unwrap ControlledAccess
Or, to check if your data is protected by your ControlledAccess object, use code similar to this:
Hashtable myHashtable = (Hashtable) persistentObject.getContents( codeSigningKey ); // Note: no need to unwrap ControlledAccess
Constructor Summary | ||
---|---|---|
ControlledAccess(Object obj)
Creates new ControlledAccess instance for wrapping provided object. |
||
ControlledAccess(Object obj,
CodeSigningKey readAndReplaceKey)
Creates new ControlledAccess object for wrapping provided object using
provided key. |
||
ControlledAccess(Object obj,
CodeSigningKey readKey,
CodeSigningKey replaceKey)
Creates new ControlledAccess object for wrapping provided object using provided keys. |
Method Summary | ||
---|---|---|
void |
assertKeys(CodeSigningKey readKey,
CodeSigningKey replaceKey)
Determines if provided code signing keys match wrapped object's keys. |
|
boolean |
checkKeys(CodeSigningKey readKey,
CodeSigningKey replaceKey)
Determines if the specified code signing keys match the wrapped object's keys. |
|
static boolean |
verifyCodeModuleSignature(int moduleHandle,
CodeSigningKey key)
Determines if provided code module has been signed with provided key. |
|
static boolean |
verifySignatures(boolean checkProcess,
int signerId)
Determines If signature on caller's code file is verified with the provided key. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ControlledAccess(Object obj) throws ControlledAccessException
ControlledAccess
instance for wrapping provided object.
This method uses the code signing key associated with the provided object's class to control read and replace permissions.
obj
- Object to which to control access.
ControlledAccessException
- If the calling code file is not signed
with the associated code signing key.public ControlledAccess(Object obj, CodeSigningKey readAndReplaceKey) throws ControlledAccessException
ControlledAccess
object for wrapping provided object using
provided key.
obj
- Object to which to control access.readAndReplaceKey
- Key used to control read and replace permission;
if null, then everyone has read and replace permission.
ControlledAccessException
- If the calling code file is not signed
with provided key.public ControlledAccess(Object obj, CodeSigningKey readKey, CodeSigningKey replaceKey) throws ControlledAccessException
obj
- Object to which to control access.readKey
- Key used to control read permission; if null, then
everyone has read permission.replaceKey
- Key used to control replace permission; if null, then
everyone has replace permission.
ControlledAccessException
- If the calling code file is not signed
with both provided keys.Method Detail |
---|
public boolean checkKeys(CodeSigningKey readKey, CodeSigningKey replaceKey)
readKey
- Key to match against wrapped object's read key; if null is
specified instead of a key, the match will return true.replaceKey
- Key to match against wrapped object's replace key; if null is
specified instead of a key, the match will return true.
public void assertKeys(CodeSigningKey readKey, CodeSigningKey replaceKey) throws ControlledAccessException
Note that this method simply invokes ControlledAccess.checkKeys(net.rim.device.api.system.CodeSigningKey, net.rim.device.api.system.CodeSigningKey)
.
readKey
- Key to match against wrapped object's read key; if null,
this always matches.replaceKey
- Key to match against wrapped object's replace key; if
null, this always matches.
ControlledAccessException
- If one or both keys do not match
wrapped object's keys.public static boolean verifyCodeModuleSignature(int moduleHandle, CodeSigningKey key)
moduleHandle
- Handle to code module.key
- the key to use to verify the signature
public static boolean verifySignatures(boolean checkProcess, int signerId)
checkProcess
- true
if the process module should also be checkedsignerId
- the key to use to verify the signature
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal