Class SdkmsKeyService


  • public final class SdkmsKeyService
    extends Object
    Encapsulate Key existence check and other Key related API
    • Constructor Summary

      Constructors 
      Constructor Description
      SdkmsKeyService()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.fortanix.sdkms.v1.model.KeyObject agreeKey​(com.fortanix.sdkms.v1.model.AgreeKeyRequest agreeKeyRequest)
      Creates key agreement between aa public and private key combination
      static void deleteKey​(String keyId)
      Deletes a given key
      static ECParameterSpec getECPrivateKeyParams​(com.fortanix.sdkms.v1.model.KeyObject keyObject)  
      static com.fortanix.sdkms.v1.model.SobjectDescriptor getKeyDescriptor​(com.fortanix.sdkms.v1.model.KeyObject keyObject)  
      static Key getKeyFromKeyObject​(com.fortanix.sdkms.v1.model.KeyObject keyObject, boolean isPublic)
      Gets a new instance of SDKMSKey from the KeyObject instance.
      static com.fortanix.sdkms.v1.model.KeyObject getKeyObject​(com.fortanix.sdkms.v1.model.SobjectDescriptor descriptor)
      Look-up key in SDKMS and raise error if not found.
      static List<com.fortanix.sdkms.v1.model.KeyObject> getKeys​(String name, String groupId, String creator)
      Get all keys from sdkms.
      static byte[] getKeyValue​(com.fortanix.sdkms.v1.model.SobjectDescriptor descriptor)
      retrieve secret of key from sdkms.
      static byte[] getKeyValue​(String keyId)
      retrieve secret of key from sdkms
      static RSAPublicKey getRSAPublicKey​(com.fortanix.sdkms.v1.model.KeyObject keyObject)  
      static com.fortanix.sdkms.v1.model.KeyObject getSecurityObjectByName​(String name)
      Get an SDKMS key with a given name
      static com.fortanix.sdkms.v1.model.KeyObject persistKey​(Key key, String name, Map<String,​String> metaData)
      update the key name and make persistant
      static com.fortanix.sdkms.v1.model.KeyObject toKeyObject​(Key key)  
      static com.fortanix.sdkms.v1.model.ObjectType toSDKMSAlgorithm​(String jceAlgorithm)
      This method returns the Algorithm enum supported by SDKMS
      static com.fortanix.sdkms.v1.model.KeyObject updateKey​(com.fortanix.sdkms.v1.model.SobjectDescriptor key, String newName, Map<String,​String> metaData)
      Update key to set name as per stored in keystore
    • Constructor Detail

      • SdkmsKeyService

        public SdkmsKeyService()
    • Method Detail

      • getKeyObject

        public static com.fortanix.sdkms.v1.model.KeyObject getKeyObject​(com.fortanix.sdkms.v1.model.SobjectDescriptor descriptor)
        Look-up key in SDKMS and raise error if not found.
        Parameters:
        descriptor - SobjectDescriptor
      • toSDKMSAlgorithm

        public static com.fortanix.sdkms.v1.model.ObjectType toSDKMSAlgorithm​(String jceAlgorithm)
        This method returns the Algorithm enum supported by SDKMS
        Parameters:
        jceAlgorithm - JCE standard algorithm name Possible values are: RSA DSA DESede TripleDES AES
        Returns:
      • getKeys

        public static List<com.fortanix.sdkms.v1.model.KeyObject> getKeys​(String name,
                                                                          String groupId,
                                                                          String creator)
        Get all keys from sdkms. Used to get all alias in keystore.
        Parameters:
        name -
        groupId -
        creator -
        Returns:
      • deleteKey

        public static void deleteKey​(String keyId)
        Deletes a given key
        Parameters:
        keyId -
      • updateKey

        public static com.fortanix.sdkms.v1.model.KeyObject updateKey​(com.fortanix.sdkms.v1.model.SobjectDescriptor key,
                                                                      String newName,
                                                                      Map<String,​String> metaData)
        Update key to set name as per stored in keystore
        Parameters:
        keyId -
        name -
        metaData -
        Returns:
      • persistKey

        public static com.fortanix.sdkms.v1.model.KeyObject persistKey​(Key key,
                                                                       String name,
                                                                       Map<String,​String> metaData)
        update the key name and make persistant
        Parameters:
        key -
        name -
        metaData -
        Returns:
      • agreeKey

        public static com.fortanix.sdkms.v1.model.KeyObject agreeKey​(com.fortanix.sdkms.v1.model.AgreeKeyRequest agreeKeyRequest)
                                                              throws InvalidKeyException
        Creates key agreement between aa public and private key combination
        Parameters:
        agreeKeyRequest -
        Returns:
        KeyObject
        Throws:
        InvalidKeyException
      • getKeyValue

        public static byte[] getKeyValue​(String keyId)
        retrieve secret of key from sdkms
        Parameters:
        keyId -
        Returns:
        key value in bytes
      • getKeyValue

        public static byte[] getKeyValue​(com.fortanix.sdkms.v1.model.SobjectDescriptor descriptor)
        retrieve secret of key from sdkms. .returns null on export failure
        Parameters:
        descriptor -
        Returns:
        key value in bytes
      • getSecurityObjectByName

        public static com.fortanix.sdkms.v1.model.KeyObject getSecurityObjectByName​(String name)
        Get an SDKMS key with a given name
        Parameters:
        name -
        Returns:
      • getKeyFromKeyObject

        public static Key getKeyFromKeyObject​(com.fortanix.sdkms.v1.model.KeyObject keyObject,
                                              boolean isPublic)
                                       throws InvalidKeyException
        Gets a new instance of SDKMSKey from the KeyObject instance. Essentially converting SDKKS Key to JCE type Keys.
        Parameters:
        keyObject -
        Returns:
        Throws:
        InvalidKeyException
      • getKeyDescriptor

        public static com.fortanix.sdkms.v1.model.SobjectDescriptor getKeyDescriptor​(com.fortanix.sdkms.v1.model.KeyObject keyObject)