Export Non-Global Key
To get an instance of a non-global key (a key that is not accessible to all users), you must pass the session object to the getSecretKey
method. The NAE Server then returns the key, provided that the key is accessible to the authenticated user.
Create an
NAESession
object.Obtain an instance of the key using the
getSecretKey
method of theNAEKey
class. Pass theNAESession
object as an argument.Export the key bytes to a byte array using the export method.
Code sample
The following code sample exports a non-global key named user1key.
NAESession session = NAESession.getSession("user1" ,"password1".toCharArray());
NAEKey key = NAEKey.getSecretKey("user1key", session);
byte[] rawkey = key.export();
Caution
While exporting a symmetric key, if the key exists in the local cache, the cached key is returned else, the key is exported from the Key Manager.