Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
nl.reinkrul.nuts.vdr.DIDDocument Maven / Gradle / Ivy
Go to download
Java client library for using the Nuts Node's REST API.
/*
* Nuts Verifiable Data Registry API spec
* API specification for the Verifiable Data Registry
*
* 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.vdr;
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 java.util.ArrayList;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* A DID document according to the W3C spec following the Nuts Method rules as defined in [Nuts RFC006]
*/
@JsonPropertyOrder({
DIDDocument.JSON_PROPERTY_AT_CONTEXT,
DIDDocument.JSON_PROPERTY_CONTROLLER,
DIDDocument.JSON_PROPERTY_ID,
DIDDocument.JSON_PROPERTY_KEY_AGREEMENT,
DIDDocument.JSON_PROPERTY_SERVICE,
DIDDocument.JSON_PROPERTY_VERIFICATION_METHOD,
DIDDocument.JSON_PROPERTY_ASSERTION_METHOD,
DIDDocument.JSON_PROPERTY_AUTHENTICATION,
DIDDocument.JSON_PROPERTY_CAPABILITY_DELEGATION,
DIDDocument.JSON_PROPERTY_CAPABILITY_INVOCATION
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-05-12T15:13:43.291870+02:00[Europe/Amsterdam]")
public class DIDDocument {
public static final String JSON_PROPERTY_AT_CONTEXT = "@context";
private Object atContext = null;
public static final String JSON_PROPERTY_CONTROLLER = "controller";
private JsonNullable controller = JsonNullable.of(null);
public static final String JSON_PROPERTY_ID = "id";
private String id;
public static final String JSON_PROPERTY_KEY_AGREEMENT = "keyAgreement";
private List keyAgreement;
public static final String JSON_PROPERTY_SERVICE = "service";
private List service;
public static final String JSON_PROPERTY_VERIFICATION_METHOD = "verificationMethod";
private List verificationMethod;
public static final String JSON_PROPERTY_ASSERTION_METHOD = "assertionMethod";
private List assertionMethod;
public static final String JSON_PROPERTY_AUTHENTICATION = "authentication";
private List authentication;
public static final String JSON_PROPERTY_CAPABILITY_DELEGATION = "capabilityDelegation";
private List capabilityDelegation;
public static final String JSON_PROPERTY_CAPABILITY_INVOCATION = "capabilityInvocation";
private List capabilityInvocation;
public DIDDocument() {
}
public DIDDocument atContext(Object atContext) {
this.atContext = atContext;
return this;
}
/**
* The JSON-LD contexts that define the types used in this document. Can be a single string, or a list of strings.
* @return atContext
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_AT_CONTEXT)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public Object getAtContext() {
return atContext;
}
@JsonProperty(JSON_PROPERTY_AT_CONTEXT)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setAtContext(Object atContext) {
this.atContext = atContext;
}
public DIDDocument controller(Object controller) {
this.controller = JsonNullable.of(controller);
return this;
}
/**
* Single DID (as string) or List of DIDs that have control over the DID document
* @return controller
**/
@javax.annotation.Nullable
@JsonIgnore
public Object getController() {
return controller.orElse(null);
}
@JsonProperty(JSON_PROPERTY_CONTROLLER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public JsonNullable getController_JsonNullable() {
return controller;
}
@JsonProperty(JSON_PROPERTY_CONTROLLER)
public void setController_JsonNullable(JsonNullable controller) {
this.controller = controller;
}
public void setController(Object controller) {
this.controller = JsonNullable.of(controller);
}
public DIDDocument id(String id) {
this.id = id;
return this;
}
/**
* DID according to Nuts specification
* @return id
**/
@javax.annotation.Nonnull
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getId() {
return id;
}
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setId(String id) {
this.id = id;
}
public DIDDocument keyAgreement(List keyAgreement) {
this.keyAgreement = keyAgreement;
return this;
}
public DIDDocument addKeyAgreementItem(String keyAgreementItem) {
if (this.keyAgreement == null) {
this.keyAgreement = new ArrayList<>();
}
this.keyAgreement.add(keyAgreementItem);
return this;
}
/**
* List of KIDs that can be used for encryption
* @return keyAgreement
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_KEY_AGREEMENT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getKeyAgreement() {
return keyAgreement;
}
@JsonProperty(JSON_PROPERTY_KEY_AGREEMENT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setKeyAgreement(List keyAgreement) {
this.keyAgreement = keyAgreement;
}
public DIDDocument service(List service) {
this.service = service;
return this;
}
public DIDDocument addServiceItem(nl.reinkrul.nuts.common.Service serviceItem) {
if (this.service == null) {
this.service = new ArrayList<>();
}
this.service.add(serviceItem);
return this;
}
/**
* List of supported services by the DID subject
* @return service
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SERVICE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getService() {
return service;
}
@JsonProperty(JSON_PROPERTY_SERVICE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setService(List service) {
this.service = service;
}
public DIDDocument verificationMethod(List verificationMethod) {
this.verificationMethod = verificationMethod;
return this;
}
public DIDDocument addVerificationMethodItem(nl.reinkrul.nuts.common.VerificationMethod verificationMethodItem) {
if (this.verificationMethod == null) {
this.verificationMethod = new ArrayList<>();
}
this.verificationMethod.add(verificationMethodItem);
return this;
}
/**
* list of keys
* @return verificationMethod
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_VERIFICATION_METHOD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getVerificationMethod() {
return verificationMethod;
}
@JsonProperty(JSON_PROPERTY_VERIFICATION_METHOD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setVerificationMethod(List verificationMethod) {
this.verificationMethod = verificationMethod;
}
public DIDDocument assertionMethod(List assertionMethod) {
this.assertionMethod = assertionMethod;
return this;
}
public DIDDocument addAssertionMethodItem(String assertionMethodItem) {
if (this.assertionMethod == null) {
this.assertionMethod = new ArrayList<>();
}
this.assertionMethod.add(assertionMethodItem);
return this;
}
/**
* List of KIDs that may sign JWTs, JWSs and VCs
* @return assertionMethod
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ASSERTION_METHOD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getAssertionMethod() {
return assertionMethod;
}
@JsonProperty(JSON_PROPERTY_ASSERTION_METHOD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setAssertionMethod(List assertionMethod) {
this.assertionMethod = assertionMethod;
}
public DIDDocument authentication(List authentication) {
this.authentication = authentication;
return this;
}
public DIDDocument addAuthenticationItem(String authenticationItem) {
if (this.authentication == null) {
this.authentication = new ArrayList<>();
}
this.authentication.add(authenticationItem);
return this;
}
/**
* List of KIDs that may alter DID documents that they control
* @return authentication
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_AUTHENTICATION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getAuthentication() {
return authentication;
}
@JsonProperty(JSON_PROPERTY_AUTHENTICATION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setAuthentication(List authentication) {
this.authentication = authentication;
}
public DIDDocument capabilityDelegation(List capabilityDelegation) {
this.capabilityDelegation = capabilityDelegation;
return this;
}
public DIDDocument addCapabilityDelegationItem(String capabilityDelegationItem) {
if (this.capabilityDelegation == null) {
this.capabilityDelegation = new ArrayList<>();
}
this.capabilityDelegation.add(capabilityDelegationItem);
return this;
}
/**
* List of KIDs that can be used to delegate capabilities that can be invoked using the DID document.
* @return capabilityDelegation
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_CAPABILITY_DELEGATION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getCapabilityDelegation() {
return capabilityDelegation;
}
@JsonProperty(JSON_PROPERTY_CAPABILITY_DELEGATION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setCapabilityDelegation(List capabilityDelegation) {
this.capabilityDelegation = capabilityDelegation;
}
public DIDDocument capabilityInvocation(List capabilityInvocation) {
this.capabilityInvocation = capabilityInvocation;
return this;
}
public DIDDocument addCapabilityInvocationItem(String capabilityInvocationItem) {
if (this.capabilityInvocation == null) {
this.capabilityInvocation = new ArrayList<>();
}
this.capabilityInvocation.add(capabilityInvocationItem);
return this;
}
/**
* List of KIDs that can be used for signing
* @return capabilityInvocation
**/
@javax.annotation.Nullable
@JsonProperty(JSON_PROPERTY_CAPABILITY_INVOCATION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List getCapabilityInvocation() {
return capabilityInvocation;
}
@JsonProperty(JSON_PROPERTY_CAPABILITY_INVOCATION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setCapabilityInvocation(List capabilityInvocation) {
this.capabilityInvocation = capabilityInvocation;
}
/**
* Return true if this DIDDocument object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DIDDocument diDDocument = (DIDDocument) o;
return Objects.equals(this.atContext, diDDocument.atContext) &&
equalsNullable(this.controller, diDDocument.controller) &&
Objects.equals(this.id, diDDocument.id) &&
Objects.equals(this.keyAgreement, diDDocument.keyAgreement) &&
Objects.equals(this.service, diDDocument.service) &&
Objects.equals(this.verificationMethod, diDDocument.verificationMethod) &&
Objects.equals(this.assertionMethod, diDDocument.assertionMethod) &&
Objects.equals(this.authentication, diDDocument.authentication) &&
Objects.equals(this.capabilityDelegation, diDDocument.capabilityDelegation) &&
Objects.equals(this.capabilityInvocation, diDDocument.capabilityInvocation);
}
private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}
@Override
public int hashCode() {
return Objects.hash(atContext, hashCodeNullable(controller), id, keyAgreement, service, verificationMethod, assertionMethod, authentication, capabilityDelegation, capabilityInvocation);
}
private static int hashCodeNullable(JsonNullable a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DIDDocument {\n");
sb.append(" atContext: ").append(toIndentedString(atContext)).append("\n");
sb.append(" controller: ").append(toIndentedString(controller)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" keyAgreement: ").append(toIndentedString(keyAgreement)).append("\n");
sb.append(" service: ").append(toIndentedString(service)).append("\n");
sb.append(" verificationMethod: ").append(toIndentedString(verificationMethod)).append("\n");
sb.append(" assertionMethod: ").append(toIndentedString(assertionMethod)).append("\n");
sb.append(" authentication: ").append(toIndentedString(authentication)).append("\n");
sb.append(" capabilityDelegation: ").append(toIndentedString(capabilityDelegation)).append("\n");
sb.append(" capabilityInvocation: ").append(toIndentedString(capabilityInvocation)).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 `@context` to the URL query string
if (getAtContext() != null) {
joiner.add(String.format("%s@context%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getAtContext()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `controller` to the URL query string
if (getController() != null) {
joiner.add(String.format("%scontroller%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getController()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `id` to the URL query string
if (getId() != null) {
joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `keyAgreement` to the URL query string
if (getKeyAgreement() != null) {
for (int i = 0; i < getKeyAgreement().size(); i++) {
joiner.add(String.format("%skeyAgreement%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getKeyAgreement().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
// add `service` to the URL query string
if (getService() != null) {
for (int i = 0; i < getService().size(); i++) {
if (getService().get(i) != null) {
joiner.add(getService().get(i).toUrlQueryString(String.format("%sservice%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
}
}
}
// add `verificationMethod` to the URL query string
if (getVerificationMethod() != null) {
for (int i = 0; i < getVerificationMethod().size(); i++) {
if (getVerificationMethod().get(i) != null) {
joiner.add(getVerificationMethod().get(i).toUrlQueryString(String.format("%sverificationMethod%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
}
}
}
// add `assertionMethod` to the URL query string
if (getAssertionMethod() != null) {
for (int i = 0; i < getAssertionMethod().size(); i++) {
joiner.add(String.format("%sassertionMethod%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getAssertionMethod().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
// add `authentication` to the URL query string
if (getAuthentication() != null) {
for (int i = 0; i < getAuthentication().size(); i++) {
joiner.add(String.format("%sauthentication%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getAuthentication().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
// add `capabilityDelegation` to the URL query string
if (getCapabilityDelegation() != null) {
for (int i = 0; i < getCapabilityDelegation().size(); i++) {
joiner.add(String.format("%scapabilityDelegation%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getCapabilityDelegation().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
// add `capabilityInvocation` to the URL query string
if (getCapabilityInvocation() != null) {
for (int i = 0; i < getCapabilityInvocation().size(); i++) {
joiner.add(String.format("%scapabilityInvocation%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getCapabilityInvocation().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
return joiner.toString();
}
}