Search in sources :

Example 1 with KeyOperationsParameters

use of com.microsoft.azure.keyvault.models.KeyOperationsParameters in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method decryptWithServiceResponseAsync.

/**
     * Decrypts a single block of encrypted data.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name of the key.
     * @param keyVersion The version of the key.
     * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'
     * @param value the Base64Url value
     * @return the observable to the KeyOperationResult object
     */
public Observable<ServiceResponse<KeyOperationResult>> decryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (keyVersion == null) {
        throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (algorithm == null) {
        throw new IllegalArgumentException("Parameter algorithm is required and cannot be null.");
    }
    if (value == null) {
        throw new IllegalArgumentException("Parameter value is required and cannot be null.");
    }
    KeyOperationsParameters parameters = new KeyOperationsParameters();
    parameters.withAlgorithm(algorithm);
    parameters.withValue(value);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyOperationResult>>>() {

        @Override
        public Observable<ServiceResponse<KeyOperationResult>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<KeyOperationResult> clientResponse = decryptDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyOperationResult(com.microsoft.azure.keyvault.models.KeyOperationResult) KeyOperationsParameters(com.microsoft.azure.keyvault.models.KeyOperationsParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 2 with KeyOperationsParameters

use of com.microsoft.azure.keyvault.models.KeyOperationsParameters in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method unwrapKeyWithServiceResponseAsync.

/**
     * Unwraps a symmetric key using the specified key that was initially used for wrapping that key.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name of the key.
     * @param keyVersion The version of the key.
     * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'
     * @param value the Base64Url value
     * @return the observable to the KeyOperationResult object
     */
public Observable<ServiceResponse<KeyOperationResult>> unwrapKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (keyVersion == null) {
        throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (algorithm == null) {
        throw new IllegalArgumentException("Parameter algorithm is required and cannot be null.");
    }
    if (value == null) {
        throw new IllegalArgumentException("Parameter value is required and cannot be null.");
    }
    KeyOperationsParameters parameters = new KeyOperationsParameters();
    parameters.withAlgorithm(algorithm);
    parameters.withValue(value);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyOperationResult>>>() {

        @Override
        public Observable<ServiceResponse<KeyOperationResult>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<KeyOperationResult> clientResponse = unwrapKeyDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyOperationResult(com.microsoft.azure.keyvault.models.KeyOperationResult) KeyOperationsParameters(com.microsoft.azure.keyvault.models.KeyOperationsParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 3 with KeyOperationsParameters

use of com.microsoft.azure.keyvault.models.KeyOperationsParameters in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method encryptWithServiceResponseAsync.

/**
     * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name of the key.
     * @param keyVersion The version of the key.
     * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'
     * @param value the Base64Url value
     * @return the observable to the KeyOperationResult object
     */
public Observable<ServiceResponse<KeyOperationResult>> encryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (keyVersion == null) {
        throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (algorithm == null) {
        throw new IllegalArgumentException("Parameter algorithm is required and cannot be null.");
    }
    if (value == null) {
        throw new IllegalArgumentException("Parameter value is required and cannot be null.");
    }
    KeyOperationsParameters parameters = new KeyOperationsParameters();
    parameters.withAlgorithm(algorithm);
    parameters.withValue(value);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyOperationResult>>>() {

        @Override
        public Observable<ServiceResponse<KeyOperationResult>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<KeyOperationResult> clientResponse = encryptDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyOperationResult(com.microsoft.azure.keyvault.models.KeyOperationResult) KeyOperationsParameters(com.microsoft.azure.keyvault.models.KeyOperationsParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 4 with KeyOperationsParameters

use of com.microsoft.azure.keyvault.models.KeyOperationsParameters in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method wrapKeyWithServiceResponseAsync.

/**
     * Wraps a symmetric key using a specified key.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name of the key.
     * @param keyVersion The version of the key.
     * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'
     * @param value the Base64Url value
     * @return the observable to the KeyOperationResult object
     */
public Observable<ServiceResponse<KeyOperationResult>> wrapKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (keyVersion == null) {
        throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (algorithm == null) {
        throw new IllegalArgumentException("Parameter algorithm is required and cannot be null.");
    }
    if (value == null) {
        throw new IllegalArgumentException("Parameter value is required and cannot be null.");
    }
    KeyOperationsParameters parameters = new KeyOperationsParameters();
    parameters.withAlgorithm(algorithm);
    parameters.withValue(value);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyOperationResult>>>() {

        @Override
        public Observable<ServiceResponse<KeyOperationResult>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<KeyOperationResult> clientResponse = wrapKeyDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyOperationResult(com.microsoft.azure.keyvault.models.KeyOperationResult) KeyOperationsParameters(com.microsoft.azure.keyvault.models.KeyOperationsParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

KeyOperationResult (com.microsoft.azure.keyvault.models.KeyOperationResult)4 KeyOperationsParameters (com.microsoft.azure.keyvault.models.KeyOperationsParameters)4 ServiceResponse (com.microsoft.rest.ServiceResponse)4 ResponseBody (okhttp3.ResponseBody)4 Response (retrofit2.Response)4 Observable (rx.Observable)4