Generate KMIP Public-Private Key Pair
The user can get the group permissions applicable on an existing key through API.
Create an
NAEParameterSpec
object. Pass the keyname as an argument.Obtain an instance of
KeyPairGenerator
. Pass the key type as an argument.Call the
genKeyPair
method of theKeyPairGenerator
object.
Code sample
This code snippet generates two KMIP keys named myKeyPublic and myKeyPrivate owned by user1 that contain two custom attributes: first_attribute and second_attribute.
KMIPSession session = KMIPSession.getSession(new NAEClientCertificate("ClientCertificatename", "ClientCerticate password".toCharArray()));
CustomAttributes custatts = new CustomAttributes("first_attribute", "abcd");
custatts.addAttribute("second_attribute", "efgh");
// In a KMIP session, the following lines generate key pairs.
NAEParameterSpec spec = new NAEParameterSpec("mykey", true, true, 256, custatts,session);
KeyGenerator keygen = KeyGenerator.getInstance("AES", "IngrianProvider");
keygen.init(spec);
SecretKey aesKey = keygen.generateKey();
KMIP Objects MUST have unique names, so, by default, the KMIP key pairs are assigned with the suffixes Public or Private. Thus, if you generate testKey, the default result would be testKeyPublic and testKeyPrivate. If you do not want to use the default suffixes, configure them in the CADP_for_JAVA.properties
file and use these suffix config parameters:
KMIP_Private_Suffix
KMIP_Public_Suffix