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

nl.reinkrul.nuts.crypto.EncryptJweRequest Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
/*
 * Nuts Crypto Service API spec
 * API specification for crypto services available within nuts node
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package nl.reinkrul.nuts.crypto;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;


/**
 * EncryptJweRequest
 */
@JsonPropertyOrder({
  EncryptJweRequest.JSON_PROPERTY_RECEIVER,
  EncryptJweRequest.JSON_PROPERTY_HEADERS,
  EncryptJweRequest.JSON_PROPERTY_PAYLOAD
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-05-12T15:13:44.888654+02:00[Europe/Amsterdam]")
public class EncryptJweRequest {
  public static final String JSON_PROPERTY_RECEIVER = "receiver";
  private String receiver;

  public static final String JSON_PROPERTY_HEADERS = "headers";
  private Object headers;

  public static final String JSON_PROPERTY_PAYLOAD = "payload";
  private byte[] payload;

  public EncryptJweRequest() { 
  }

  public EncryptJweRequest receiver(String receiver) {
    this.receiver = receiver;
    return this;
  }

   /**
   * The DID reference of the message receiver OR the KID of the message receiver. 
   * @return receiver
  **/
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_RECEIVER)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public String getReceiver() {
    return receiver;
  }


  @JsonProperty(JSON_PROPERTY_RECEIVER)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setReceiver(String receiver) {
    this.receiver = receiver;
  }


  public EncryptJweRequest headers(Object headers) {
    this.headers = headers;
    return this;
  }

   /**
   * The map of protected headers. Note: The value of the kid header will be ignored and overwritten by the used receiver KID. 
   * @return headers
  **/
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_HEADERS)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public Object getHeaders() {
    return headers;
  }


  @JsonProperty(JSON_PROPERTY_HEADERS)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setHeaders(Object headers) {
    this.headers = headers;
  }


  public EncryptJweRequest payload(byte[] payload) {
    this.payload = payload;
    return this;
  }

   /**
   * The payload to be signed as bytes. The bytes must be encoded with Base64 encoding. 
   * @return payload
  **/
  @javax.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_PAYLOAD)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public byte[] getPayload() {
    return payload;
  }


  @JsonProperty(JSON_PROPERTY_PAYLOAD)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setPayload(byte[] payload) {
    this.payload = payload;
  }


  /**
   * Return true if this EncryptJweRequest object is equal to o.
   */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    EncryptJweRequest encryptJweRequest = (EncryptJweRequest) o;
    return Objects.equals(this.receiver, encryptJweRequest.receiver) &&
        Objects.equals(this.headers, encryptJweRequest.headers) &&
        Arrays.equals(this.payload, encryptJweRequest.payload);
  }

  @Override
  public int hashCode() {
    return Objects.hash(receiver, headers, Arrays.hashCode(payload));
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class EncryptJweRequest {\n");
    sb.append("    receiver: ").append(toIndentedString(receiver)).append("\n");
    sb.append("    headers: ").append(toIndentedString(headers)).append("\n");
    sb.append("    payload: ").append(toIndentedString(payload)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

  /**
   * Convert the instance into URL query string.
   *
   * @return URL query string
   */
  public String toUrlQueryString() {
    return toUrlQueryString(null);
  }

  /**
   * Convert the instance into URL query string.
   *
   * @param prefix prefix of the query string
   * @return URL query string
   */
  public String toUrlQueryString(String prefix) {
    String suffix = "";
    String containerSuffix = "";
    String containerPrefix = "";
    if (prefix == null) {
      // style=form, explode=true, e.g. /pet?name=cat&type=manx
      prefix = "";
    } else {
      // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
      prefix = prefix + "[";
      suffix = "]";
      containerSuffix = "]";
      containerPrefix = "[";
    }

    StringJoiner joiner = new StringJoiner("&");

    // add `receiver` to the URL query string
    if (getReceiver() != null) {
      joiner.add(String.format("%sreceiver%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getReceiver()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
    }

    // add `headers` to the URL query string
    if (getHeaders() != null) {
      joiner.add(String.format("%sheaders%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getHeaders()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
    }

    // add `payload` to the URL query string
    if (getPayload() != null) {
      joiner.add(String.format("%spayload%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPayload()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
    }

    return joiner.toString();
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy