/** * Parse a {@link OCSPStatusRequest} from an {@link InputStream}. * * @param input the {@link InputStream} to parse from. * @return a {@link OCSPStatusRequest} object. * @throws IOException */ public static OCSPStatusRequest parse(InputStream input) throws IOException { Vector responderIDList = new Vector(); { int length = TlsUtils.readUint16(input); if (length > 0) { byte[] data = TlsUtils.readFully(length, input); ByteArrayInputStream buf = new ByteArrayInputStream(data); do { byte[] derEncoding = TlsUtils.readOpaque16(buf); ResponderID responderID = ResponderID.getInstance(TlsUtils.readDERObject(derEncoding)); responderIDList.addElement(responderID); } while (buf.available() > 0); } } Extensions requestExtensions = null; { int length = TlsUtils.readUint16(input); if (length > 0) { byte[] derEncoding = TlsUtils.readFully(length, input); requestExtensions = Extensions.getInstance(TlsUtils.readDERObject(derEncoding)); } } return new OCSPStatusRequest(responderIDList, requestExtensions); }
/** * Parse a {@link CertificateRequest} from an {@link InputStream}. * * @param context the {@link TlsContext} of the current connection. * @param input the {@link InputStream} to parse from. * @return a {@link CertificateRequest} object. * @throws IOException */ public static CertificateRequest parse(TlsContext context, InputStream input) throws IOException { int numTypes = TlsUtils.readUint8(input); short[] certificateTypes = new short[numTypes]; for (int i = 0; i < numTypes; ++i) { certificateTypes[i] = TlsUtils.readUint8(input); } Vector supportedSignatureAlgorithms = null; if (TlsUtils.isTLSv12(context)) { // TODO Check whether SignatureAlgorithm.anonymous is allowed here supportedSignatureAlgorithms = TlsUtils.parseSupportedSignatureAlgorithms(false, input); } Vector certificateAuthorities = new Vector(); byte[] certAuthData = TlsUtils.readOpaque16(input); ByteArrayInputStream bis = new ByteArrayInputStream(certAuthData); while (bis.available() > 0) { byte[] derEncoding = TlsUtils.readOpaque16(bis); ASN1Primitive asn1 = TlsUtils.readDERObject(derEncoding); certificateAuthorities.addElement(X500Name.getInstance(asn1)); } return new CertificateRequest( certificateTypes, supportedSignatureAlgorithms, certificateAuthorities); }