software.amazon.awssdk.services.acmpca.model.ASN1Subject Maven / Gradle / Ivy
Show all versions of acmpca Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.acmpca.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains information about the certificate subject. The Subject
field in the certificate identifies the
* entity that owns or controls the public key in the certificate. The entity can be a user, computer, device, or
* service. The Subject
must contain an X.500 distinguished name (DN). A DN is a sequence of relative
* distinguished names (RDNs). The RDNs are separated by commas in the certificate.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ASN1Subject implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField COUNTRY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Country")
.getter(getter(ASN1Subject::country)).setter(setter(Builder::country))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Country").build()).build();
private static final SdkField ORGANIZATION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Organization").getter(getter(ASN1Subject::organization)).setter(setter(Builder::organization))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Organization").build()).build();
private static final SdkField ORGANIZATIONAL_UNIT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OrganizationalUnit").getter(getter(ASN1Subject::organizationalUnit))
.setter(setter(Builder::organizationalUnit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OrganizationalUnit").build())
.build();
private static final SdkField DISTINGUISHED_NAME_QUALIFIER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("DistinguishedNameQualifier")
.getter(getter(ASN1Subject::distinguishedNameQualifier))
.setter(setter(Builder::distinguishedNameQualifier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DistinguishedNameQualifier").build())
.build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(ASN1Subject::state)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField COMMON_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CommonName").getter(getter(ASN1Subject::commonName)).setter(setter(Builder::commonName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CommonName").build()).build();
private static final SdkField SERIAL_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SerialNumber").getter(getter(ASN1Subject::serialNumber)).setter(setter(Builder::serialNumber))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SerialNumber").build()).build();
private static final SdkField LOCALITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Locality").getter(getter(ASN1Subject::locality)).setter(setter(Builder::locality))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Locality").build()).build();
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Title")
.getter(getter(ASN1Subject::title)).setter(setter(Builder::title))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Title").build()).build();
private static final SdkField SURNAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Surname")
.getter(getter(ASN1Subject::surname)).setter(setter(Builder::surname))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Surname").build()).build();
private static final SdkField GIVEN_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("GivenName").getter(getter(ASN1Subject::givenName)).setter(setter(Builder::givenName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GivenName").build()).build();
private static final SdkField INITIALS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Initials").getter(getter(ASN1Subject::initials)).setter(setter(Builder::initials))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Initials").build()).build();
private static final SdkField PSEUDONYM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Pseudonym").getter(getter(ASN1Subject::pseudonym)).setter(setter(Builder::pseudonym))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Pseudonym").build()).build();
private static final SdkField GENERATION_QUALIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("GenerationQualifier").getter(getter(ASN1Subject::generationQualifier))
.setter(setter(Builder::generationQualifier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GenerationQualifier").build())
.build();
private static final SdkField> CUSTOM_ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("CustomAttributes")
.getter(getter(ASN1Subject::customAttributes))
.setter(setter(Builder::customAttributes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomAttributes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(CustomAttribute::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(COUNTRY_FIELD,
ORGANIZATION_FIELD, ORGANIZATIONAL_UNIT_FIELD, DISTINGUISHED_NAME_QUALIFIER_FIELD, STATE_FIELD, COMMON_NAME_FIELD,
SERIAL_NUMBER_FIELD, LOCALITY_FIELD, TITLE_FIELD, SURNAME_FIELD, GIVEN_NAME_FIELD, INITIALS_FIELD, PSEUDONYM_FIELD,
GENERATION_QUALIFIER_FIELD, CUSTOM_ATTRIBUTES_FIELD));
private static final long serialVersionUID = 1L;
private final String country;
private final String organization;
private final String organizationalUnit;
private final String distinguishedNameQualifier;
private final String state;
private final String commonName;
private final String serialNumber;
private final String locality;
private final String title;
private final String surname;
private final String givenName;
private final String initials;
private final String pseudonym;
private final String generationQualifier;
private final List customAttributes;
private ASN1Subject(BuilderImpl builder) {
this.country = builder.country;
this.organization = builder.organization;
this.organizationalUnit = builder.organizationalUnit;
this.distinguishedNameQualifier = builder.distinguishedNameQualifier;
this.state = builder.state;
this.commonName = builder.commonName;
this.serialNumber = builder.serialNumber;
this.locality = builder.locality;
this.title = builder.title;
this.surname = builder.surname;
this.givenName = builder.givenName;
this.initials = builder.initials;
this.pseudonym = builder.pseudonym;
this.generationQualifier = builder.generationQualifier;
this.customAttributes = builder.customAttributes;
}
/**
*
* Two-digit code that specifies the country in which the certificate subject located.
*
*
* @return Two-digit code that specifies the country in which the certificate subject located.
*/
public final String country() {
return country;
}
/**
*
* Legal name of the organization with which the certificate subject is affiliated.
*
*
* @return Legal name of the organization with which the certificate subject is affiliated.
*/
public final String organization() {
return organization;
}
/**
*
* A subdivision or unit of the organization (such as sales or finance) with which the certificate subject is
* affiliated.
*
*
* @return A subdivision or unit of the organization (such as sales or finance) with which the certificate subject
* is affiliated.
*/
public final String organizationalUnit() {
return organizationalUnit;
}
/**
*
* Disambiguating information for the certificate subject.
*
*
* @return Disambiguating information for the certificate subject.
*/
public final String distinguishedNameQualifier() {
return distinguishedNameQualifier;
}
/**
*
* State in which the subject of the certificate is located.
*
*
* @return State in which the subject of the certificate is located.
*/
public final String state() {
return state;
}
/**
*
* For CA and end-entity certificates in a private PKI, the common name (CN) can be any string within the length
* limit.
*
*
* Note: In publicly trusted certificates, the common name must be a fully qualified domain name (FQDN) associated
* with the certificate subject.
*
*
* @return For CA and end-entity certificates in a private PKI, the common name (CN) can be any string within the
* length limit.
*
* Note: In publicly trusted certificates, the common name must be a fully qualified domain name (FQDN)
* associated with the certificate subject.
*/
public final String commonName() {
return commonName;
}
/**
*
* The certificate serial number.
*
*
* @return The certificate serial number.
*/
public final String serialNumber() {
return serialNumber;
}
/**
*
* The locality (such as a city or town) in which the certificate subject is located.
*
*
* @return The locality (such as a city or town) in which the certificate subject is located.
*/
public final String locality() {
return locality;
}
/**
*
* A title such as Mr. or Ms., which is pre-pended to the name to refer formally to the certificate subject.
*
*
* @return A title such as Mr. or Ms., which is pre-pended to the name to refer formally to the certificate subject.
*/
public final String title() {
return title;
}
/**
*
* Family name. In the US and the UK, for example, the surname of an individual is ordered last. In Asian cultures
* the surname is typically ordered first.
*
*
* @return Family name. In the US and the UK, for example, the surname of an individual is ordered last. In Asian
* cultures the surname is typically ordered first.
*/
public final String surname() {
return surname;
}
/**
*
* First name.
*
*
* @return First name.
*/
public final String givenName() {
return givenName;
}
/**
*
* Concatenation that typically contains the first letter of the GivenName, the first letter of the middle
* name if one exists, and the first letter of the Surname.
*
*
* @return Concatenation that typically contains the first letter of the GivenName, the first letter of the
* middle name if one exists, and the first letter of the Surname.
*/
public final String initials() {
return initials;
}
/**
*
* Typically a shortened version of a longer GivenName. For example, Jonathan is often shortened to John.
* Elizabeth is often shortened to Beth, Liz, or Eliza.
*
*
* @return Typically a shortened version of a longer GivenName. For example, Jonathan is often shortened to
* John. Elizabeth is often shortened to Beth, Liz, or Eliza.
*/
public final String pseudonym() {
return pseudonym;
}
/**
*
* Typically a qualifier appended to the name of an individual. Examples include Jr. for junior, Sr. for senior, and
* III for third.
*
*
* @return Typically a qualifier appended to the name of an individual. Examples include Jr. for junior, Sr. for
* senior, and III for third.
*/
public final String generationQualifier() {
return generationQualifier;
}
/**
* For responses, this returns true if the service returned a value for the CustomAttributes property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasCustomAttributes() {
return customAttributes != null && !(customAttributes instanceof SdkAutoConstructList);
}
/**
*
*
* Contains a sequence of one or more X.500 relative distinguished names (RDNs), each of which consists of an object
* identifier (OID) and a value. For more information, see NIST’s definition of Object Identifier (OID).
*
*
*
* Custom attributes cannot be used in combination with standard attributes.
*
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasCustomAttributes} method.
*
*
* @return
* Contains a sequence of one or more X.500 relative distinguished names (RDNs), each of which consists of
* an object identifier (OID) and a value. For more information, see NIST’s definition of Object Identifier (OID).
*
*
*
* Custom attributes cannot be used in combination with standard attributes.
*
*/
public final List customAttributes() {
return customAttributes;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(country());
hashCode = 31 * hashCode + Objects.hashCode(organization());
hashCode = 31 * hashCode + Objects.hashCode(organizationalUnit());
hashCode = 31 * hashCode + Objects.hashCode(distinguishedNameQualifier());
hashCode = 31 * hashCode + Objects.hashCode(state());
hashCode = 31 * hashCode + Objects.hashCode(commonName());
hashCode = 31 * hashCode + Objects.hashCode(serialNumber());
hashCode = 31 * hashCode + Objects.hashCode(locality());
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(surname());
hashCode = 31 * hashCode + Objects.hashCode(givenName());
hashCode = 31 * hashCode + Objects.hashCode(initials());
hashCode = 31 * hashCode + Objects.hashCode(pseudonym());
hashCode = 31 * hashCode + Objects.hashCode(generationQualifier());
hashCode = 31 * hashCode + Objects.hashCode(hasCustomAttributes() ? customAttributes() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ASN1Subject)) {
return false;
}
ASN1Subject other = (ASN1Subject) obj;
return Objects.equals(country(), other.country()) && Objects.equals(organization(), other.organization())
&& Objects.equals(organizationalUnit(), other.organizationalUnit())
&& Objects.equals(distinguishedNameQualifier(), other.distinguishedNameQualifier())
&& Objects.equals(state(), other.state()) && Objects.equals(commonName(), other.commonName())
&& Objects.equals(serialNumber(), other.serialNumber()) && Objects.equals(locality(), other.locality())
&& Objects.equals(title(), other.title()) && Objects.equals(surname(), other.surname())
&& Objects.equals(givenName(), other.givenName()) && Objects.equals(initials(), other.initials())
&& Objects.equals(pseudonym(), other.pseudonym())
&& Objects.equals(generationQualifier(), other.generationQualifier())
&& hasCustomAttributes() == other.hasCustomAttributes()
&& Objects.equals(customAttributes(), other.customAttributes());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("ASN1Subject").add("Country", country()).add("Organization", organization())
.add("OrganizationalUnit", organizationalUnit()).add("DistinguishedNameQualifier", distinguishedNameQualifier())
.add("State", state()).add("CommonName", commonName()).add("SerialNumber", serialNumber())
.add("Locality", locality()).add("Title", title()).add("Surname", surname()).add("GivenName", givenName())
.add("Initials", initials()).add("Pseudonym", pseudonym()).add("GenerationQualifier", generationQualifier())
.add("CustomAttributes", hasCustomAttributes() ? customAttributes() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Country":
return Optional.ofNullable(clazz.cast(country()));
case "Organization":
return Optional.ofNullable(clazz.cast(organization()));
case "OrganizationalUnit":
return Optional.ofNullable(clazz.cast(organizationalUnit()));
case "DistinguishedNameQualifier":
return Optional.ofNullable(clazz.cast(distinguishedNameQualifier()));
case "State":
return Optional.ofNullable(clazz.cast(state()));
case "CommonName":
return Optional.ofNullable(clazz.cast(commonName()));
case "SerialNumber":
return Optional.ofNullable(clazz.cast(serialNumber()));
case "Locality":
return Optional.ofNullable(clazz.cast(locality()));
case "Title":
return Optional.ofNullable(clazz.cast(title()));
case "Surname":
return Optional.ofNullable(clazz.cast(surname()));
case "GivenName":
return Optional.ofNullable(clazz.cast(givenName()));
case "Initials":
return Optional.ofNullable(clazz.cast(initials()));
case "Pseudonym":
return Optional.ofNullable(clazz.cast(pseudonym()));
case "GenerationQualifier":
return Optional.ofNullable(clazz.cast(generationQualifier()));
case "CustomAttributes":
return Optional.ofNullable(clazz.cast(customAttributes()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function