Search in sources :

Example 1 with KeyCreateParameters

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

the class KeyVaultClientImpl method createKeyWithServiceResponseAsync.

/**
     * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name for the new key. The system will generate the version name for the new key.
     * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'
     * @return the observable to the KeyBundle object
     */
public Observable<ServiceResponse<KeyBundle>> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) {
    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 (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (kty == null) {
        throw new IllegalArgumentException("Parameter kty is required and cannot be null.");
    }
    final Integer keySize = null;
    final List<JsonWebKeyOperation> keyOps = null;
    final KeyAttributes keyAttributes = null;
    final Map<String, String> tags = null;
    KeyCreateParameters parameters = new KeyCreateParameters();
    parameters.withKty(kty);
    parameters.withKeySize(null);
    parameters.withKeyOps(null);
    parameters.withKeyAttributes(null);
    parameters.withTags(null);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyBundle>>>() {

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

Example 2 with KeyCreateParameters

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

the class KeyVaultClientImpl method createKeyWithServiceResponseAsync.

/**
     * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name for the new key. The system will generate the version name for the new key.
     * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'
     * @param keySize The key size in bytes. For example, 1024 or 2048.
     * @param keyOps the List&lt;JsonWebKeyOperation&gt; value
     * @param keyAttributes the KeyAttributes value
     * @param tags Application specific metadata in the form of key-value pairs.
     * @return the observable to the KeyBundle object
     */
public Observable<ServiceResponse<KeyBundle>> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags) {
    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 (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (kty == null) {
        throw new IllegalArgumentException("Parameter kty is required and cannot be null.");
    }
    Validator.validate(keyOps);
    Validator.validate(keyAttributes);
    Validator.validate(tags);
    KeyCreateParameters parameters = new KeyCreateParameters();
    parameters.withKty(kty);
    parameters.withKeySize(keySize);
    parameters.withKeyOps(keyOps);
    parameters.withKeyAttributes(keyAttributes);
    parameters.withTags(tags);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyBundle>>>() {

        @Override
        public Observable<ServiceResponse<KeyBundle>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<KeyBundle> clientResponse = createKeyDelegate(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) KeyBundle(com.microsoft.azure.keyvault.models.KeyBundle) KeyCreateParameters(com.microsoft.azure.keyvault.models.KeyCreateParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

KeyBundle (com.microsoft.azure.keyvault.models.KeyBundle)2 KeyCreateParameters (com.microsoft.azure.keyvault.models.KeyCreateParameters)2 ServiceResponse (com.microsoft.rest.ServiceResponse)2 ResponseBody (okhttp3.ResponseBody)2 Response (retrofit2.Response)2 Observable (rx.Observable)2 KeyAttributes (com.microsoft.azure.keyvault.models.KeyAttributes)1 JsonWebKeyOperation (com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation)1