Class SdkmsKeyService


  • public final class SdkmsKeyService
    extends java.lang.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​(java.lang.String keyId)
      Deletes a given key
      static java.security.spec.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 java.security.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 java.util.List<com.fortanix.sdkms.v1.model.KeyObject> getKeys​(java.lang.String name, java.lang.String groupId, java.lang.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​(java.lang.String keyId)
      retrieve secret of key from sdkms
      static java.security.interfaces.RSAPublicKey getRSAPublicKey​(com.fortanix.sdkms.v1.model.KeyObject keyObject)  
      static com.fortanix.sdkms.v1.model.KeyObject getSecurityObjectByName​(java.lang.String name)
      Get an SDKMS key with a given name
      static com.fortanix.sdkms.v1.model.KeyObject persistKey​(java.security.Key key, java.lang.String name, java.util.Map<java.lang.String,​java.lang.String> metaData)
      update the key name and make persistant
      static com.fortanix.sdkms.v1.model.KeyObject toKeyObject​(java.security.Key key)  
      static com.fortanix.sdkms.v1.model.ObjectType toSDKMSAlgorithm​(java.lang.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, java.lang.String newName, java.util.Map<java.lang.String,​java.lang.String> metaData)
      Update key to set name as per stored in keystore
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SdkmsKeyService

        public SdkmsKeyService()
    • Method Detail

      • toKeyObject

        public static com.fortanix.sdkms.v1.model.KeyObject toKeyObject​(java.security.Key key)
                                                                 throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • 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​(java.lang.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 java.util.List<com.fortanix.sdkms.v1.model.KeyObject> getKeys​(java.lang.String name,
                                                                                    java.lang.String groupId,
                                                                                    java.lang.String creator)
        Get all keys from sdkms. Used to get all alias in keystore.
        Parameters:
        name -
        groupId -
        creator -
        Returns:
      • deleteKey

        public static void deleteKey​(java.lang.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,
                                                                      java.lang.String newName,
                                                                      java.util.Map<java.lang.String,​java.lang.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​(java.security.Key key,
                                                                       java.lang.String name,
                                                                       java.util.Map<java.lang.String,​java.lang.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 java.security.InvalidKeyException
        Creates key agreement between aa public and private key combination
        Parameters:
        agreeKeyRequest -
        Returns:
        KeyObject
        Throws:
        java.security.InvalidKeyException
      • getKeyValue

        public static byte[] getKeyValue​(java.lang.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​(java.lang.String name)
        Get an SDKMS key with a given name
        Parameters:
        name -
        Returns:
      • getKeyFromKeyObject

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

        public static java.security.interfaces.RSAPublicKey getRSAPublicKey​(com.fortanix.sdkms.v1.model.KeyObject keyObject)
                                                                     throws java.security.NoSuchAlgorithmException,
                                                                            java.security.spec.InvalidKeySpecException,
                                                                            java.security.NoSuchProviderException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.spec.InvalidKeySpecException
        java.security.NoSuchProviderException
      • getECPrivateKeyParams

        public static java.security.spec.ECParameterSpec getECPrivateKeyParams​(com.fortanix.sdkms.v1.model.KeyObject keyObject)
                                                                        throws java.security.NoSuchAlgorithmException,
                                                                               java.security.spec.InvalidKeySpecException,
                                                                               java.security.NoSuchProviderException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.spec.InvalidKeySpecException
        java.security.NoSuchProviderException
      • getKeyDescriptor

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