Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Developer
Posts: 2
Registered: ‎04-22-2013
My Device: bold 9780
My Carrier: etisalat

Data Access Control using code signing key in Native code

Hello, looking at the java code below, which enforces data access control using code signing keys, is there a way to implement this in native code on the bb10 platform? Thank you.

Here's the code:

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
BlackBerry Development Advisor
Posts: 15,852
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Data Access Control using code signing key in Native code

This isn't applicable to BlackBerry 10.  In BlackBerry 10, each application has its own sandbox area to store data that only the application has access to.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.