Create key owned by the NAE user
Create an
NAESession
object. Pass the NAE username and password as arguments. You may also need to pass a client certificate, depending on your SSL settings.Create
NAEParameterSpec
. Pass thekeyname
andNAESession
object as arguments.Obtain an instance of
KeyGenerator
. Pass the key algorithm as an argument.Call the
generateKey
method of theKeyGenerator
class to create the key.
Code sample
The following sample generates an AES key, named mykey which is owned by user1 .
NAESession session = NAESession.getSession ("user1" ,"password1".toCharArray());
NAEParameterSpec spec = new NAEParameterSpec("foo", true, true, 256);
KeyGenerator keygen = KeyGenerator.getInstance("AES", "IngrianProvider");
keygen.init(spec);
SecretKey aesKey = keygen.generateKey();
To create a key for another NAE user, create the object of NAEParameterSpec
and use spec.setKeyowner("user")
. For example, if spec.setKeyowner("user2")
, the key will be owned by user2 . The user who creates the key for another user must have administrator privileges.