Create EC key owned by 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 an
ECCParameterSpec
. Pass the keyname, CurveID, and NAESession object as arguments.Obtain an instance of
KeyPairGenerator
. Pass the key algorithm as an argument.Call the
generateKeyPair
method of theKeyPairGenerator
class to create the key.
Code sample
The following code sample generates an EC key named keyName that is owned by user1:
NAESession session = NAESession.getSession("user1", "password".toCharArray());
ECCParameterSpec spec = new ECCParameterSpec("keyName", true, true, session, null,
ECCParameterSpec.CurveId.brainpoolP384t1);
KeyPairGenerator gen= KeyPairGenerator.getInstance("EC", "IngrianProvider");
gen.initialize(spec);
gen.generateKeyPair();
To create a key for another NAE user, use spec.setKeyowner("user2")
; after creating the object of the ECCParameterSpec
. The key created will be owned by user2. Also, the user creating the key for other user should have administrator privileges.