/* * 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 TBSCertList implements BerType, Serializable { private static final long serialVersionUID = 1L; public static class RevokedCertificates implements BerType, Serializable { private static final long serialVersionUID = 1L; public static class SEQUENCE 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 CertificateSerialNumber userCertificate = null; private Time revocationDate = null; private Extensions crlEntryExtensions = null; public SEQUENCE() { } public SEQUENCE(byte[] code) { this.code = code; } public void setUserCertificate(CertificateSerialNumber userCertificate) { this.userCertificate = userCertificate; } public CertificateSerialNumber getUserCertificate() { return userCertificate; } public void setRevocationDate(Time revocationDate) { this.revocationDate = revocationDate; } public Time getRevocationDate() { return revocationDate; } public void setCrlEntryExtensions(Extensions crlEntryExtensions) { this.crlEntryExtensions = crlEntryExtensions; } public Extensions getCrlEntryExtensions() { return crlEntryExtensions; } @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; if (crlEntryExtensions != null) { codeLength += crlEntryExtensions.encode(reverseOS, true); } codeLength += revocationDate.encode(reverseOS); codeLength += userCertificate.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; int numDecodedBytes; BerTag berTag = new BerTag(); if (withTag) { tlByteCount += tag.decodeAndCheck(is); } BerLength length = new BerLength(); tlByteCount += length.decode(is); int lengthVal = length.val; vByteCount += berTag.decode(is); if (berTag.equals(CertificateSerialNumber.tag)) { userCertificate = new CertificateSerialNumber(); vByteCount += userCertificate.decode(is, false); vByteCount += berTag.decode(is); } else { throw new IOException("Tag does not match mandatory sequence component."); } revocationDate = new Time(); numDecodedBytes = revocationDate.decode(is, berTag); if (numDecodedBytes != 0) { vByteCount += numDecodedBytes; if (lengthVal >= 0 && vByteCount == lengthVal) { return tlByteCount + vByteCount; } vByteCount += berTag.decode(is); } else { throw new IOException("Tag does not match mandatory sequence component."); } if (berTag.equals(Extensions.tag)) { crlEntryExtensions = new Extensions(); vByteCount += crlEntryExtensions.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("{"); sb.append("\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } if (userCertificate != null) { sb.append("userCertificate: ").append(userCertificate); } else { sb.append("userCertificate: "); } sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } if (revocationDate != null) { sb.append("revocationDate: "); revocationDate.appendAsString(sb, indentLevel + 1); } else { sb.append("revocationDate: "); } if (crlEntryExtensions != null) { sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } sb.append("crlEntryExtensions: "); crlEntryExtensions.appendAsString(sb, indentLevel + 1); } sb.append("\n"); for (int i = 0; i < indentLevel; i++) { sb.append("\t"); } sb.append("}"); } } public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); private byte[] code = null; private List seqOf = null; public RevokedCertificates() { seqOf = new ArrayList<>(); } public RevokedCertificates(byte[] code) { this.code = code; } public List getSEQUENCE() { if (seqOf == null) { seqOf = new ArrayList<>(); } return seqOf; } @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; for (int i = (seqOf.size() - 1); i >= 0; i--) { codeLength += seqOf.get(i).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; while (vByteCount < lengthVal || lengthVal < 0) { vByteCount += berTag.decode(is); if (lengthVal < 0 && berTag.equals(0, 0, 0)) { vByteCount += BerLength.readEocByte(is); break; } if (!berTag.equals(SEQUENCE.tag)) { throw new IOException("Tag does not match mandatory sequence of/set of component."); } SEQUENCE element = new SEQUENCE(); vByteCount += element.decode(is, false); seqOf.add(element); } if (lengthVal >= 0 && vByteCount != lengthVal) { throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + lengthVal + " but has " + vByteCount); } return tlByteCount + 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("{\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } if (seqOf == null) { sb.append("null"); } else { Iterator it = seqOf.iterator(); if (it.hasNext()) { it.next().appendAsString(sb, indentLevel + 1); while (it.hasNext()) { sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } it.next().appendAsString(sb, indentLevel + 1); } } } sb.append("\n"); for (int i = 0; i < indentLevel; i++) { sb.append("\t"); } sb.append("}"); } } public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); private byte[] code = null; private Version version = null; private AlgorithmIdentifier signature = null; private Name issuer = null; private Time thisUpdate = null; private Time nextUpdate = null; private RevokedCertificates revokedCertificates = null; private Extensions crlExtensions = null; public TBSCertList() { } public TBSCertList(byte[] code) { this.code = code; } public void setVersion(Version version) { this.version = version; } public Version getVersion() { return version; } public void setSignature(AlgorithmIdentifier signature) { this.signature = signature; } public AlgorithmIdentifier getSignature() { return signature; } public void setIssuer(Name issuer) { this.issuer = issuer; } public Name getIssuer() { return issuer; } public void setThisUpdate(Time thisUpdate) { this.thisUpdate = thisUpdate; } public Time getThisUpdate() { return thisUpdate; } public void setNextUpdate(Time nextUpdate) { this.nextUpdate = nextUpdate; } public Time getNextUpdate() { return nextUpdate; } public void setRevokedCertificates(RevokedCertificates revokedCertificates) { this.revokedCertificates = revokedCertificates; } public RevokedCertificates getRevokedCertificates() { return revokedCertificates; } public void setCrlExtensions(Extensions crlExtensions) { this.crlExtensions = crlExtensions; } public Extensions getCrlExtensions() { return crlExtensions; } @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 (crlExtensions != null) { sublength = crlExtensions.encode(reverseOS, true); codeLength += sublength; codeLength += BerLength.encodeLength(reverseOS, sublength); // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 reverseOS.write(0xA0); codeLength += 1; } if (revokedCertificates != null) { codeLength += revokedCertificates.encode(reverseOS, true); } if (nextUpdate != null) { codeLength += nextUpdate.encode(reverseOS); } codeLength += thisUpdate.encode(reverseOS); codeLength += issuer.encode(reverseOS); codeLength += signature.encode(reverseOS, true); if (version != null) { codeLength += version.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; int numDecodedBytes; BerTag berTag = new BerTag(); if (withTag) { tlByteCount += tag.decodeAndCheck(is); } BerLength length = new BerLength(); tlByteCount += length.decode(is); int lengthVal = length.val; vByteCount += berTag.decode(is); if (berTag.equals(Version.tag)) { version = new Version(); vByteCount += version.decode(is, false); vByteCount += berTag.decode(is); } if (berTag.equals(AlgorithmIdentifier.tag)) { signature = new AlgorithmIdentifier(); vByteCount += signature.decode(is, false); vByteCount += berTag.decode(is); } else { throw new IOException("Tag does not match mandatory sequence component."); } issuer = new Name(); numDecodedBytes = issuer.decode(is, berTag); if (numDecodedBytes != 0) { vByteCount += numDecodedBytes; vByteCount += berTag.decode(is); } else { throw new IOException("Tag does not match mandatory sequence component."); } thisUpdate = new Time(); numDecodedBytes = thisUpdate.decode(is, berTag); if (numDecodedBytes != 0) { vByteCount += numDecodedBytes; if (lengthVal >= 0 && vByteCount == lengthVal) { return tlByteCount + vByteCount; } vByteCount += berTag.decode(is); } else { throw new IOException("Tag does not match mandatory sequence component."); } nextUpdate = new Time(); numDecodedBytes = nextUpdate.decode(is, berTag); if (numDecodedBytes != 0) { vByteCount += numDecodedBytes; if (lengthVal >= 0 && vByteCount == lengthVal) { return tlByteCount + vByteCount; } vByteCount += berTag.decode(is); } else { nextUpdate = null; } if (berTag.equals(RevokedCertificates.tag)) { revokedCertificates = new RevokedCertificates(); vByteCount += revokedCertificates.decode(is, false); if (lengthVal >= 0 && vByteCount == lengthVal) { return tlByteCount + vByteCount; } vByteCount += berTag.decode(is); } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { vByteCount += length.decode(is); crlExtensions = new Extensions(); vByteCount += crlExtensions.decode(is, true); vByteCount += length.readEocIfIndefinite(is); 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 (version != null) { sb.append("\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } sb.append("version: ").append(version); firstSelectedElement = false; } if (!firstSelectedElement) { sb.append(",\n"); } for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } if (signature != null) { sb.append("signature: "); signature.appendAsString(sb, indentLevel + 1); } else { sb.append("signature: "); } sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } if (issuer != null) { sb.append("issuer: "); issuer.appendAsString(sb, indentLevel + 1); } else { sb.append("issuer: "); } sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } if (thisUpdate != null) { sb.append("thisUpdate: "); thisUpdate.appendAsString(sb, indentLevel + 1); } else { sb.append("thisUpdate: "); } if (nextUpdate != null) { sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } sb.append("nextUpdate: "); nextUpdate.appendAsString(sb, indentLevel + 1); } if (revokedCertificates != null) { sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } sb.append("revokedCertificates: "); revokedCertificates.appendAsString(sb, indentLevel + 1); } if (crlExtensions != null) { sb.append(",\n"); for (int i = 0; i < indentLevel + 1; i++) { sb.append("\t"); } sb.append("crlExtensions: "); crlExtensions.appendAsString(sb, indentLevel + 1); } sb.append("\n"); for (int i = 0; i < indentLevel; i++) { sb.append("\t"); } sb.append("}"); } }