Create key owned by the NAE user
Create an
NAESessionobject. 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 thekeynameandNAESessionobject as arguments.Obtain an instance of
KeyGenerator. Pass the key algorithm as an argument.Call the
generateKeymethod of theKeyGeneratorclass 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("mykey", 256, true, true, session);
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.