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

com.cosmian.rest.kmip.operations.CreateKeyPair Maven / Gradle / Ivy

package com.cosmian.rest.kmip.operations;

import java.util.Objects;
import java.util.Optional;

import com.cosmian.rest.kmip.json.KmipStruct;
import com.cosmian.rest.kmip.json.KmipStructDeserializer;
import com.cosmian.rest.kmip.json.KmipStructSerializer;
import com.cosmian.rest.kmip.types.Attributes;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * This operation requests the server to generate a new public/private key pair and register the two corresponding new
 * Managed Cryptographic Objects. The request contains attributes to be assigned to the objects (e.g., Cryptographic
 * Algorithm, Cryptographic Length, etc.). Attributes MAY be specified for both keys at the same time by specifying a
 * Common Attributes object in the request. Attributes not common to both keys (e.g., Name, Cryptographic Usage Mask)
 * MAY be specified using the Private Key Attributes and Public Key Attributes objects in the request, which take
 * precedence over the Common Attributes object. For the Private Key, the server SHALL create a Link attribute of Link
 * Type Public Key pointing to the Public Key. For the Public Key, the server SHALL create a Link attribute of Link Type
 * Private Key pointing to the Private Key. The response contains the Unique Identifiers of both created objects. The ID
 * Placeholder value SHALL be set to the Unique Identifier of the Private Key.
 */
@JsonSerialize(using = KmipStructSerializer.class)
@JsonDeserialize(using = KmipStructDeserializer.class)
public class CreateKeyPair implements KmipStruct {

    /**
     * Specifies desired attributes to be associated with the new object that apply to both the Private and Public Key
     * Objects
     */
    @JsonProperty("CommonAttributes")
    private Optional commonAttributes = Optional.empty();

    /**
     * Specifies the attributes to be associated with the new object that apply to the Private Key Object.
     */
    @JsonProperty("PrivateKeyAttributes")
    private Optional privateKeyAttributes = Optional.empty();

    /**
     * Specifies the attributes to be associated with the new object that apply to the Public Key Object.
     */
    @JsonProperty("PublicKeyAttributes")
    private Optional publicKeyAttributes = Optional.empty();

    /**
     * Specifies all ProtectionStorage Mask selections that are permissible for the new Private Key and Public Key
     * objects.
     */
    @JsonProperty(value = "CommonProtectionStorageMasks")
    private Optional commonProtectionStorageMasks = Optional.empty();

    /**
     * Specifies all ProtectionStorage Mask selections that are permissible for the new Private Key object.
     */
    @JsonProperty(value = "PrivateProtectionStorageMasks")
    private Optional privateProtectionStorageMasks = Optional.empty();

    /**
     * Specifies all ProtectionStorage Mask selections that are permissible for the new PublicKey object.
     */
    @JsonProperty(value = "PublicProtectionStorageMasks")
    private Optional publicProtectionStorageMasks = Optional.empty();

    public CreateKeyPair() {
    }

    public CreateKeyPair(Optional commonAttributes, Optional privateKeyAttributes,
        Optional publicKeyAttributes, Optional commonProtectionStorageMasks,
        Optional privateProtectionStorageMasks, Optional publicProtectionStorageMasks) {
        this.commonAttributes = commonAttributes;
        this.privateKeyAttributes = privateKeyAttributes;
        this.publicKeyAttributes = publicKeyAttributes;
        this.commonProtectionStorageMasks = commonProtectionStorageMasks;
        this.privateProtectionStorageMasks = privateProtectionStorageMasks;
        this.publicProtectionStorageMasks = publicProtectionStorageMasks;
    }

    public CreateKeyPair(Optional commonAttributes, Optional commonProtectionStorageMasks) {
        this.commonAttributes = commonAttributes;
        this.commonProtectionStorageMasks = commonProtectionStorageMasks;
    }

    public Optional getCommonAttributes() {
        return this.commonAttributes;
    }

    public void setCommonAttributes(Optional commonAttributes) {
        this.commonAttributes = commonAttributes;
    }

    public Optional getPrivateKeyAttributes() {
        return this.privateKeyAttributes;
    }

    public void setPrivateKeyAttributes(Optional privateKeyAttributes) {
        this.privateKeyAttributes = privateKeyAttributes;
    }

    public Optional getPublicKeyAttributes() {
        return this.publicKeyAttributes;
    }

    public void setPublicKeyAttributes(Optional publicKeyAttributes) {
        this.publicKeyAttributes = publicKeyAttributes;
    }

    public Optional getCommonProtectionStorageMasks() {
        return this.commonProtectionStorageMasks;
    }

    public void setCommonProtectionStorageMasks(Optional commonProtectionStorageMasks) {
        this.commonProtectionStorageMasks = commonProtectionStorageMasks;
    }

    public Optional getPrivateProtectionStorageMasks() {
        return this.privateProtectionStorageMasks;
    }

    public void setPrivateProtectionStorageMasks(Optional privateProtectionStorageMasks) {
        this.privateProtectionStorageMasks = privateProtectionStorageMasks;
    }

    public Optional getPublicProtectionStorageMasks() {
        return this.publicProtectionStorageMasks;
    }

    public void setPublicProtectionStorageMasks(Optional publicProtectionStorageMasks) {
        this.publicProtectionStorageMasks = publicProtectionStorageMasks;
    }

    public CreateKeyPair commonAttributes(Optional commonAttributes) {
        setCommonAttributes(commonAttributes);
        return this;
    }

    public CreateKeyPair privateKeyAttributes(Optional privateKeyAttributes) {
        setPrivateKeyAttributes(privateKeyAttributes);
        return this;
    }

    public CreateKeyPair publicKeyAttributes(Optional publicKeyAttributes) {
        setPublicKeyAttributes(publicKeyAttributes);
        return this;
    }

    public CreateKeyPair commonProtectionStorageMasks(Optional commonProtectionStorageMasks) {
        setCommonProtectionStorageMasks(commonProtectionStorageMasks);
        return this;
    }

    public CreateKeyPair privateProtectionStorageMasks(Optional privateProtectionStorageMasks) {
        setPrivateProtectionStorageMasks(privateProtectionStorageMasks);
        return this;
    }

    public CreateKeyPair publicProtectionStorageMasks(Optional publicProtectionStorageMasks) {
        setPublicProtectionStorageMasks(publicProtectionStorageMasks);
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof CreateKeyPair)) {
            return false;
        }
        CreateKeyPair createKeyPair = (CreateKeyPair) o;
        return Objects.equals(commonAttributes, createKeyPair.commonAttributes)
            && Objects.equals(privateKeyAttributes, createKeyPair.privateKeyAttributes)
            && Objects.equals(publicKeyAttributes, createKeyPair.publicKeyAttributes)
            && Objects.equals(commonProtectionStorageMasks, createKeyPair.commonProtectionStorageMasks)
            && Objects.equals(privateProtectionStorageMasks, createKeyPair.privateProtectionStorageMasks)
            && Objects.equals(publicProtectionStorageMasks, createKeyPair.publicProtectionStorageMasks);
    }

    @Override
    public int hashCode() {
        return Objects.hash(commonAttributes, privateKeyAttributes, publicKeyAttributes, commonProtectionStorageMasks,
            privateProtectionStorageMasks, publicProtectionStorageMasks);
    }

    @Override
    public String toString() {
        return "{" + " commonAttributes='" + getCommonAttributes() + "'" + ", privateKeyAttributes='"
            + getPrivateKeyAttributes() + "'" + ", publicKeyAttributes='" + getPublicKeyAttributes() + "'"
            + ", commonProtectionStorageMasks='" + getCommonProtectionStorageMasks() + "'"
            + ", privateProtectionStorageMasks='" + getPrivateProtectionStorageMasks() + "'"
            + ", publicProtectionStorageMasks='" + getPublicProtectionStorageMasks() + "'" + "}";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy