All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.akeyless.AkeylessUser Maven / Gradle / Ivy

There is a newer version: 0.0.10
Show newest version
package com.akeyless;

import com.akeyless.api.AkeylessApi;
import com.akeyless.api.exceptions.*;
import com.akeyless.auth.CredsRenewal;
import com.akeyless.config.AkeylessUserConfiguration;
import com.akeyless.config.ConfigUtils;
import com.akeyless.crypto.exceptions.BadCiphertextException;
import com.akeyless.exceptions.AkeylessCryptoException;
import com.akeyless.uam.swagger.model.GetItemReplyObj;
import com.akeyless.uam.swagger.model.GetUserItemsReplyObj;

import javax.crypto.BadPaddingException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
import java.security.InvalidKeyException;

public interface AkeylessUser {


    class Factory {

        /**
         * Create a new instance of AkeylessUser
         *
         * @param userConfig The configuration parameters for the AkeylessUser
         * @return AkeylessUser
         * @throws UnsupportedEncodingException If the API key provided in the configuration parameters is incorrect
         * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body

         */
        public static AkeylessUser newInstance(AkeylessUserConfiguration userConfig
        ) throws UnsupportedEncodingException, ApiCommunicationException {
            return new AkeylessUserImpl(userConfig);
        }

        /**
         * Create a new instance of AkeylessUser
         *
         * @param configFilePath The path to a file that contains the configuration parameters for the AkeylessUser
         * @return AkeylessUser
         * @throws FileNotFoundException If the configuration file is not found.
         * @throws UnsupportedEncodingException If the API key provided in the configuration parameters is incorrect
         * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body

         */
        public static AkeylessUser newInstance(Path configFilePath
        ) throws UnsupportedEncodingException, ApiCommunicationException, FileNotFoundException {
            return new AkeylessUserImpl(ConfigUtils.loadSdkConfigurationFromFile(configFilePath));
        }
    }

    AkeylessApi getApi();
    CredsRenewal getCredsRenewal();

    /**
     * Encrypts plaintext into ciphertext by using an AES key.
     *
     * @param keyName The name of the key to use in the encryption process (required)
     * @param plaintext Data to be encrypted (required)
     * @return String - The encrypted data in base64 encoding
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the encryption process fails.
     */
    String encryptString(final String keyName, final String plaintext)
            throws CredentialsNotFoundException, InvalidParamException, AkeylessCryptoException,
            MissingRequiredParamException, InvalidCredentialsException, NotFoundException,
            ApiCommunicationException;


    /**
     * Decrypts ciphertext into plaintext by using an AES key.
     *
     * @param keyName The name of the key to use in the decryption process (required)
     * @param ciphertext cipher to be decrypted (required)
     * @return String - The decrypted data.
     * @throws BadCiphertextException If the supplied ciphertext is invalid
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the encryption process fails.
     */
    String decryptString(final String keyName, final String ciphertext)
            throws ApiCommunicationException, AkeylessCryptoException, MissingRequiredParamException,
            InvalidCredentialsException, InvalidParamException, CredentialsNotFoundException,
            NotFoundException, BadCiphertextException;

    /**
     * Encrypts plaintext into ciphertext by using an AES key.
     *
     * @param keyName The name of the key to use in the encryption process (required)
     * @param plaintext Data to be encrypted (required)
     * @param aad (optional) Additional authenticated data (AAD) is any string that specifies the encryption context to be used for authenticated encryption. If used here, the same value must be supplied to the decrypt command or decryption will fail.
     * @return byte[] - The encrypted data in bytes.
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the encryption process fails.
     */
    byte[] encryptData(final String keyName, final byte[] plaintext, final byte[] aad)
            throws CredentialsNotFoundException, InvalidParamException, AkeylessCryptoException,
            MissingRequiredParamException, InvalidCredentialsException, NotFoundException,
            ApiCommunicationException;


    /**
     * Decrypts ciphertext into plaintext by using an AES key.
     *
     * @param keyName The name of the key to use in the decryption process (required)
     * @param ciphertext cipher to be decrypted (required)
     * @param aad (optional) The Additional authenticated data. If this was specified in the encrypt process, it must be specified in the decrypt process or the decryption operation will fail.
     * @return byte[] - The decrypted data in bytes.
     * @throws BadCiphertextException If the supplied ciphertext is invalid
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the decryption process fails.
     */
    byte[] decryptData(final String keyName, final byte[] ciphertext, final byte[] aad)
            throws ApiCommunicationException, AkeylessCryptoException, MissingRequiredParamException,
            InvalidCredentialsException, InvalidParamException, CredentialsNotFoundException,
            NotFoundException, BadCiphertextException;


    /**
     * Decrypts a ciphertext using RSA and the padding scheme from PKCS#1 v1.5.
     *
     * @param keyName The name of the key to use in the decryption process (required)
     * @param ciphertext cipher to be decrypted (required)
     * @return byte[] - The decrypted data in bytes.
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the decryption process fails.
     */
    byte[] decryptPKCS1v15(final String keyName, final byte[] ciphertext)
            throws NotFoundException, InvalidParamException, CredentialsNotFoundException, InvalidCredentialsException,
            MissingRequiredParamException, ApiCommunicationException, AkeylessCryptoException ;


    /**
     * Encrypts a plaintext using RSA and the padding scheme from PKCS#1 v1.5.
     *
     * @param keyName The name of the key to use in the decryption process (required)
     * @param plaintext plaintext to be encrypted (required)
     * @return byte[] - The encrypted data in bytes.
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the encryption process fails.
     */
    byte[] encryptPKCS1v15(final String keyName, final byte[] plaintext)
            throws NotFoundException, InvalidParamException, CredentialsNotFoundException, InvalidCredentialsException,
            MissingRequiredParamException, ApiCommunicationException, AkeylessCryptoException;



    /**
     * Calculates the signature of hashed using RSASSA-PKCS1-V1_5-SIGN from RSA PKCS#1 v1.5.
     *
     * @param keyName The name of the key to use in the signing process (required)
     * @param message The message to be signed (required)
     * @return byte[] - the signature in bytes.
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the signing process fails.
     */
    byte[] signPKCS1v15(final String keyName, final byte[] message)
            throws NotFoundException, InvalidParamException, CredentialsNotFoundException, InvalidCredentialsException,
            MissingRequiredParamException, ApiCommunicationException, AkeylessCryptoException;


    /**
     * Verifies an RSA PKCS#1 v1.5 signature.
     *
     * @param keyName The name of the key to use in the signing process (required)
     * @param message The message to be verified (required)
     * @param signature The message's signature (required)
     * @return boolean
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials or operation credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials or operation credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If key not found.
     * @throws AkeylessCryptoException If the signing process fails.
     */
    boolean verifyPKCS1v15(final String keyName,
                          final byte[] message,
                          final byte[] signature
    ) throws NotFoundException, InvalidParamException, CredentialsNotFoundException, InvalidCredentialsException,
            MissingRequiredParamException, ApiCommunicationException, AkeylessCryptoException;


    /**
     * Return key details.
     *
     * @param keyName Key name. (required)
     * @return GetItemReplyObj
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If the key not found or no access permissions were found for the key.
     */
    GetItemReplyObj describeKey(String keyName) throws NotFoundException, InvalidParamException,
            CredentialsNotFoundException, InvalidCredentialsException,
            MissingRequiredParamException, ApiCommunicationException;


    /**
     * Get All the keys associated with the user.
     *
     * @return GetUserItemsReplyObj
     * @throws ApiCommunicationException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws CredentialsNotFoundException If the user access credentials not found.
     * @throws InvalidCredentialsException If the user's access credentials are invalid.
     * @throws MissingRequiredParamException Missing required parameter.
     * @throws InvalidParamException Invalid parameter.
     * @throws NotFoundException If no key is found that the user has access to.
     */
    GetUserItemsReplyObj describeUserKeys() throws NotFoundException, InvalidParamException,
            CredentialsNotFoundException, InvalidCredentialsException,
            MissingRequiredParamException, ApiCommunicationException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy