Search in sources :

Example 1 with KeySignParameters

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

the class KeyVaultClientImpl method signWithServiceResponseAsync.

/**
     * Creates a signature from a digest using the 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 The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL'
     * @param value the Base64Url value
     * @return the observable to the KeyOperationResult object
     */
public Observable<ServiceResponse<KeyOperationResult>> signWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm 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.");
    }
    KeySignParameters parameters = new KeySignParameters();
    parameters.withAlgorithm(algorithm);
    parameters.withValue(value);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.sign(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 = signDelegate(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) KeySignParameters(com.microsoft.azure.keyvault.models.KeySignParameters) KeyOperationResult(com.microsoft.azure.keyvault.models.KeyOperationResult) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

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