protected DVCSRequest createDVCRequest(Data data) throws DVCSException { if (!extGenerator.isEmpty()) { requestInformationBuilder.setExtensions(extGenerator.generate()); } org.bouncycastle.asn1.dvcs.DVCSRequest request = new org.bouncycastle.asn1.dvcs.DVCSRequest(requestInformationBuilder.build(), data); return new DVCSRequest(new ContentInfo(DVCSObjectIdentifiers.id_ct_DVCSRequestData, request)); }
/** * Construct a DVCS Request from a ContentInfo * * @param contentInfo the contentInfo representing the DVCSRequest * @throws org.bouncycastle.dvcs.DVCSConstructionException */ public DVCSResponse(ContentInfo contentInfo) throws DVCSConstructionException { super(contentInfo); if (!DVCSObjectIdentifiers.id_ct_DVCSResponseData.equals(contentInfo.getContentType())) { throw new DVCSConstructionException("ContentInfo not a DVCS Request"); } try { if (contentInfo.getContent().toASN1Primitive() instanceof ASN1Sequence) { this.asn1 = org.bouncycastle.asn1.dvcs.DVCSResponse.getInstance(contentInfo.getContent()); } else { this.asn1 = org.bouncycastle.asn1.dvcs.DVCSResponse.getInstance(ASN1OctetString.getInstance(contentInfo.getContent()).getOctets()); } } catch (Exception e) { throw new DVCSConstructionException("Unable to parse content: " + e.getMessage(), e); } }
/** * Construct a DVCS Request from a ContentInfo * * @param contentInfo the contentInfo representing the DVCSRequest * @throws DVCSConstructionException */ public DVCSRequest(ContentInfo contentInfo) throws DVCSConstructionException { super(contentInfo); if (!DVCSObjectIdentifiers.id_ct_DVCSRequestData.equals(contentInfo.getContentType())) { throw new DVCSConstructionException("ContentInfo not a DVCS Request"); } try { if (contentInfo.getContent().toASN1Primitive() instanceof ASN1Sequence) { this.asn1 = org.bouncycastle.asn1.dvcs.DVCSRequest.getInstance(contentInfo.getContent()); } else { this.asn1 = org.bouncycastle.asn1.dvcs.DVCSRequest.getInstance(ASN1OctetString.getInstance(contentInfo.getContent()).getOctets()); } } catch (Exception e) { throw new DVCSConstructionException("Unable to parse content: " + e.getMessage(), e); } this.reqInfo = new DVCSRequestInfo(asn1.getRequestInformation()); int service = reqInfo.getServiceType(); if (service == ServiceType.CPD.getValue().intValue()) { this.data = new CPDRequestData(asn1.getData()); } else if (service == ServiceType.VSD.getValue().intValue()) { this.data = new VSDRequestData(asn1.getData()); } else if (service == ServiceType.VPKC.getValue().intValue()) { this.data = new VPKCRequestData(asn1.getData()); } else if (service == ServiceType.CCPD.getValue().intValue()) { this.data = new CCPDRequestData(asn1.getData()); } else { throw new DVCSConstructionException("Unknown service type: " + service); } }