447 lines
12 KiB
Java
447 lines
12 KiB
Java
/*
|
|
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
|
|
*/
|
|
|
|
package com.truphone.rsp.dto.asn1.pkix1explicit88;
|
|
|
|
import java.io.IOException;
|
|
import java.io.EOFException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.util.List;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.math.BigInteger;
|
|
import java.io.Serializable;
|
|
import com.beanit.asn1bean.ber.*;
|
|
import com.beanit.asn1bean.ber.types.*;
|
|
import com.beanit.asn1bean.ber.types.string.*;
|
|
|
|
|
|
public class BuiltInStandardAttributes implements BerType, Serializable {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
|
|
|
|
private byte[] code = null;
|
|
private CountryName countryName = null;
|
|
private AdministrationDomainName administrationDomainName = null;
|
|
private NetworkAddress networkAddress = null;
|
|
private TerminalIdentifier terminalIdentifier = null;
|
|
private PrivateDomainName privateDomainName = null;
|
|
private OrganizationName organizationName = null;
|
|
private NumericUserIdentifier numericUserIdentifier = null;
|
|
private PersonalName personalName = null;
|
|
private OrganizationalUnitNames organizationalUnitNames = null;
|
|
|
|
public BuiltInStandardAttributes() {
|
|
}
|
|
|
|
public BuiltInStandardAttributes(byte[] code) {
|
|
this.code = code;
|
|
}
|
|
|
|
public void setCountryName(CountryName countryName) {
|
|
this.countryName = countryName;
|
|
}
|
|
|
|
public CountryName getCountryName() {
|
|
return countryName;
|
|
}
|
|
|
|
public void setAdministrationDomainName(AdministrationDomainName administrationDomainName) {
|
|
this.administrationDomainName = administrationDomainName;
|
|
}
|
|
|
|
public AdministrationDomainName getAdministrationDomainName() {
|
|
return administrationDomainName;
|
|
}
|
|
|
|
public void setNetworkAddress(NetworkAddress networkAddress) {
|
|
this.networkAddress = networkAddress;
|
|
}
|
|
|
|
public NetworkAddress getNetworkAddress() {
|
|
return networkAddress;
|
|
}
|
|
|
|
public void setTerminalIdentifier(TerminalIdentifier terminalIdentifier) {
|
|
this.terminalIdentifier = terminalIdentifier;
|
|
}
|
|
|
|
public TerminalIdentifier getTerminalIdentifier() {
|
|
return terminalIdentifier;
|
|
}
|
|
|
|
public void setPrivateDomainName(PrivateDomainName privateDomainName) {
|
|
this.privateDomainName = privateDomainName;
|
|
}
|
|
|
|
public PrivateDomainName getPrivateDomainName() {
|
|
return privateDomainName;
|
|
}
|
|
|
|
public void setOrganizationName(OrganizationName organizationName) {
|
|
this.organizationName = organizationName;
|
|
}
|
|
|
|
public OrganizationName getOrganizationName() {
|
|
return organizationName;
|
|
}
|
|
|
|
public void setNumericUserIdentifier(NumericUserIdentifier numericUserIdentifier) {
|
|
this.numericUserIdentifier = numericUserIdentifier;
|
|
}
|
|
|
|
public NumericUserIdentifier getNumericUserIdentifier() {
|
|
return numericUserIdentifier;
|
|
}
|
|
|
|
public void setPersonalName(PersonalName personalName) {
|
|
this.personalName = personalName;
|
|
}
|
|
|
|
public PersonalName getPersonalName() {
|
|
return personalName;
|
|
}
|
|
|
|
public void setOrganizationalUnitNames(OrganizationalUnitNames organizationalUnitNames) {
|
|
this.organizationalUnitNames = organizationalUnitNames;
|
|
}
|
|
|
|
public OrganizationalUnitNames getOrganizationalUnitNames() {
|
|
return organizationalUnitNames;
|
|
}
|
|
|
|
@Override public int encode(OutputStream reverseOS) throws IOException {
|
|
return encode(reverseOS, true);
|
|
}
|
|
|
|
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
|
|
|
|
if (code != null) {
|
|
reverseOS.write(code);
|
|
if (withTag) {
|
|
return tag.encode(reverseOS) + code.length;
|
|
}
|
|
return code.length;
|
|
}
|
|
|
|
int codeLength = 0;
|
|
int sublength;
|
|
|
|
if (organizationalUnitNames != null) {
|
|
codeLength += organizationalUnitNames.encode(reverseOS, false);
|
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 6
|
|
reverseOS.write(0xA6);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (personalName != null) {
|
|
codeLength += personalName.encode(reverseOS, false);
|
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 5
|
|
reverseOS.write(0xA5);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (numericUserIdentifier != null) {
|
|
codeLength += numericUserIdentifier.encode(reverseOS, false);
|
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 4
|
|
reverseOS.write(0x84);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (organizationName != null) {
|
|
codeLength += organizationName.encode(reverseOS, false);
|
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 3
|
|
reverseOS.write(0x83);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (privateDomainName != null) {
|
|
sublength = privateDomainName.encode(reverseOS);
|
|
codeLength += sublength;
|
|
codeLength += BerLength.encodeLength(reverseOS, sublength);
|
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
|
|
reverseOS.write(0xA2);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (terminalIdentifier != null) {
|
|
codeLength += terminalIdentifier.encode(reverseOS, false);
|
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 1
|
|
reverseOS.write(0x81);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (networkAddress != null) {
|
|
codeLength += networkAddress.encode(reverseOS, false);
|
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 0
|
|
reverseOS.write(0x80);
|
|
codeLength += 1;
|
|
}
|
|
|
|
if (administrationDomainName != null) {
|
|
codeLength += administrationDomainName.encode(reverseOS, true);
|
|
}
|
|
|
|
if (countryName != null) {
|
|
codeLength += countryName.encode(reverseOS, true);
|
|
}
|
|
|
|
codeLength += BerLength.encodeLength(reverseOS, codeLength);
|
|
|
|
if (withTag) {
|
|
codeLength += tag.encode(reverseOS);
|
|
}
|
|
|
|
return codeLength;
|
|
|
|
}
|
|
|
|
@Override public int decode(InputStream is) throws IOException {
|
|
return decode(is, true);
|
|
}
|
|
|
|
public int decode(InputStream is, boolean withTag) throws IOException {
|
|
int tlByteCount = 0;
|
|
int vByteCount = 0;
|
|
BerTag berTag = new BerTag();
|
|
|
|
if (withTag) {
|
|
tlByteCount += tag.decodeAndCheck(is);
|
|
}
|
|
|
|
BerLength length = new BerLength();
|
|
tlByteCount += length.decode(is);
|
|
int lengthVal = length.val;
|
|
if (lengthVal == 0) {
|
|
return tlByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
|
|
if (berTag.equals(CountryName.tag)) {
|
|
countryName = new CountryName();
|
|
vByteCount += countryName.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(AdministrationDomainName.tag)) {
|
|
administrationDomainName = new AdministrationDomainName();
|
|
vByteCount += administrationDomainName.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
|
|
networkAddress = new NetworkAddress();
|
|
vByteCount += networkAddress.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
|
|
terminalIdentifier = new TerminalIdentifier();
|
|
vByteCount += terminalIdentifier.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
|
|
vByteCount += length.decode(is);
|
|
privateDomainName = new PrivateDomainName();
|
|
vByteCount += privateDomainName.decode(is, null);
|
|
vByteCount += length.readEocIfIndefinite(is);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
|
|
organizationName = new OrganizationName();
|
|
vByteCount += organizationName.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
|
|
numericUserIdentifier = new NumericUserIdentifier();
|
|
vByteCount += numericUserIdentifier.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
|
|
personalName = new PersonalName();
|
|
vByteCount += personalName.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
|
|
organizationalUnitNames = new OrganizationalUnitNames();
|
|
vByteCount += organizationalUnitNames.decode(is, false);
|
|
if (lengthVal >= 0 && vByteCount == lengthVal) {
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
vByteCount += berTag.decode(is);
|
|
}
|
|
|
|
if (lengthVal < 0) {
|
|
if (!berTag.equals(0, 0, 0)) {
|
|
throw new IOException("Decoded sequence has wrong end of contents octets");
|
|
}
|
|
vByteCount += BerLength.readEocByte(is);
|
|
return tlByteCount + vByteCount;
|
|
}
|
|
|
|
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
|
|
|
|
}
|
|
|
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
|
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
|
encode(reverseOS, false);
|
|
code = reverseOS.getArray();
|
|
}
|
|
|
|
@Override public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
appendAsString(sb, 0);
|
|
return sb.toString();
|
|
}
|
|
|
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
|
|
|
sb.append("{");
|
|
boolean firstSelectedElement = true;
|
|
if (countryName != null) {
|
|
sb.append("\n");
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("countryName: ");
|
|
countryName.appendAsString(sb, indentLevel + 1);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (administrationDomainName != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("administrationDomainName: ");
|
|
administrationDomainName.appendAsString(sb, indentLevel + 1);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (networkAddress != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("networkAddress: ").append(networkAddress);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (terminalIdentifier != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("terminalIdentifier: ").append(terminalIdentifier);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (privateDomainName != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("privateDomainName: ");
|
|
privateDomainName.appendAsString(sb, indentLevel + 1);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (organizationName != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("organizationName: ").append(organizationName);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (numericUserIdentifier != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("numericUserIdentifier: ").append(numericUserIdentifier);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (personalName != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("personalName: ");
|
|
personalName.appendAsString(sb, indentLevel + 1);
|
|
firstSelectedElement = false;
|
|
}
|
|
|
|
if (organizationalUnitNames != null) {
|
|
if (!firstSelectedElement) {
|
|
sb.append(",\n");
|
|
}
|
|
for (int i = 0; i < indentLevel + 1; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("organizationalUnitNames: ");
|
|
organizationalUnitNames.appendAsString(sb, indentLevel + 1);
|
|
}
|
|
|
|
sb.append("\n");
|
|
for (int i = 0; i < indentLevel; i++) {
|
|
sb.append("\t");
|
|
}
|
|
sb.append("}");
|
|
}
|
|
|
|
}
|
|
|