private ASN1Encodable extractGeneralRepContent(PKIMessage response, String expectedType) throws Exception { PKIBody respBody = response.getBody(); int bodyType = respBody.getType(); if (PKIBody.TYPE_ERROR == bodyType) { ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new Exception("Server returned PKIStatus: " + buildText(content.getPKIStatusInfo())); } else if (PKIBody.TYPE_GEN_REP != bodyType) { throw new Exception(String.format("unknown PKI body type %s instead the expected [%s, %s]", bodyType, PKIBody.TYPE_GEN_REP, PKIBody.TYPE_ERROR)); } GenRepContent genRep = GenRepContent.getInstance(respBody.getContent()); InfoTypeAndValue[] itvs = genRep.toInfoTypeAndValueArray(); InfoTypeAndValue itv = null; if (itvs != null && itvs.length > 0) { for (InfoTypeAndValue entry : itvs) { if (expectedType.equals(entry.getInfoType().getId())) { itv = entry; break; } } } if (itv == null) { throw new Exception("the response does not contain InfoTypeAndValue " + expectedType); } return itv.getInfoValue(); } // method extractGeneralRepContent
ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new Exception("Server returned PKIStatus: " + content.getPKIStatusInfo()); } else if (PKIBody.TYPE_REVOCATION_REP != bodyType) { RevRepContent content = RevRepContent.getInstance(respBody.getContent()); PKIStatusInfo[] statuses = content.getStatus(); int statusesLen = (statuses == null) ? 0 : statuses.length;
checkPermission(requestor, PermissionConstants.ENROLL_CERT); respBody = processIr(dfltCertprofileName, dfltCaGenKeypair, request, requestor, tid, reqHeader, CertReqMessages.getInstance(reqBody.getContent()), cmpControl, msgId, event); break; case PKIBody.TYPE_CERT_REQ: checkPermission(requestor, PermissionConstants.ENROLL_CERT); respBody = processCr(dfltCertprofileName, dfltCaGenKeypair, request, requestor, tid, reqHeader, CertReqMessages.getInstance(reqBody.getContent()), cmpControl, msgId, event); break; case PKIBody.TYPE_KEY_UPDATE_REQ: checkPermission(requestor, PermissionConstants.KEY_UPDATE); respBody = processKur(dfltCertprofileName, dfltCaGenKeypair, request, requestor, tid, reqHeader, CertReqMessages.getInstance(reqBody.getContent()), cmpControl, msgId, event); break; case PKIBody.TYPE_P10_CERT_REQ: checkPermission(requestor, PermissionConstants.ENROLL_CERT); respBody = processP10cr(dfltCertprofileName, request, requestor, tid, reqHeader, CertificationRequest.getInstance(reqBody.getContent()), cmpControl, msgId, event); break; case PKIBody.TYPE_CROSS_CERT_REQ: checkPermission(requestor, PermissionConstants.ENROLL_CROSS); respBody = processCcp(dfltCertprofileName, request, requestor, tid, reqHeader, CertReqMessages.getInstance(reqBody.getContent()), cmpControl, msgId, event); break; default:
ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new Exception("Server returned PKIStatus: " + buildText(content.getPKIStatusInfo())); } else if (resonseBodyType != bodyType) { CertRepMessage certRep = CertRepMessage.getInstance(respBody.getContent()); CertResponse[] certResponses = certRep.getResponse();
ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new CmpClientException(CmpFailureUtil.formatPkiStatusInfo( content.getPKIStatusInfo())); GenRepContent genRep = GenRepContent.getInstance(respBody.getContent());
ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new PkiErrorException(content.getPKIStatusInfo()); } else if (PKIBody.TYPE_GEN_REP != bodyType) { ? CMPObjectIdentifiers.it_currentCRL : ObjectIdentifiers.id_xipki_cmp_cmpGenmsg; GenRepContent genRep = GenRepContent.getInstance(respBody.getContent());
ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new PkiErrorException(content.getPKIStatusInfo()); } else if (PKIBody.TYPE_REVOCATION_REP != bodyType) { RevRepContent content = RevRepContent.getInstance(respBody.getContent()); PKIStatusInfo[] statuses = content.getStatus(); if (statuses == null || statuses.length != reqEntries.size()) {
ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent()); throw new PkiErrorException(content.getPKIStatusInfo()); } else if (expectedBodyType != bodyType) { CertRepMessage certRep = CertRepMessage.getInstance(respBody.getContent()); CertResponse[] certResponses = certRep.getResponse();
case PKIBody.TYPE_CERT_CONFIRM: event.addEventType(CaAuditConstants.TYPE_CMP_certConf); CertConfirmContent certConf = (CertConfirmContent) reqBody.getContent(); respBody = confirmCertificates(tid, certConf, msgId); break; ErrorMsgContent errorMsgContent = (ErrorMsgContent) respBody.getContent();
boolean allRevdetailsOfSameType = true; RevReqContent rr = RevReqContent.getInstance(reqBody.getContent()); RevDetails[] revContent = rr.toRevDetailsArray();
private PKIBody cmpGeneralMsg(PKIHeaderBuilder respHeader, CmpControl cmpControl, PKIHeader reqHeader, PKIBody reqBody, CmpRequestorInfo requestor, ASN1OctetString tid, String msgId, AuditEvent event) throws InsuffientPermissionException { GenMsgContent genMsgBody = GenMsgContent.getInstance(reqBody.getContent()); InfoTypeAndValue[] itvs = genMsgBody.toInfoTypeAndValueArray();