1 13 package org.ejbca.core.protocol.cmp; 14 15 import org.apache.log4j.Logger; 16 import org.bouncycastle.asn1.DERInteger; 17 import org.bouncycastle.asn1.DEROctetString; 18 import org.bouncycastle.asn1.x509.X509Name; 19 import org.ejbca.core.model.InternalResources; 20 import org.ejbca.util.Base64; 21 22 import com.novosec.pkix.asn1.cmp.CertConfirmContent; 23 import com.novosec.pkix.asn1.cmp.PKIBody; 24 import com.novosec.pkix.asn1.cmp.PKIHeader; 25 import com.novosec.pkix.asn1.cmp.PKIMessage; 26 import com.novosec.pkix.asn1.cmp.PKIStatusInfo; 27 import com.novosec.pkix.asn1.cmp.RevDetails; 28 import com.novosec.pkix.asn1.cmp.RevReqContent; 29 import com.novosec.pkix.asn1.crmf.CertTemplate; 30 31 36 public class GeneralCmpMessage extends BaseCmpMessage { 37 38 private static final Logger log = Logger.getLogger(GeneralCmpMessage .class); 39 40 private static final InternalResources intres = InternalResources.getInstance(); 41 42 51 static final long serialVersionUID = 1000L; 52 53 public GeneralCmpMessage(PKIMessage msg) { 54 PKIBody body = msg.getBody(); 55 int tag = body.getTagNo(); 56 if (tag == 19) { 57 log.debug("Received a PKIConfirm message"); 59 } 62 if (tag == 24) { 63 log.debug("Received a Cert Confirm message"); 65 CertConfirmContent obj = body.getCertConf(); 66 PKIStatusInfo status = obj.getPKIStatus(); 67 if (status != null) { 68 int st = status.getStatus().getValue().intValue(); 69 if (st != 0) { 70 String errMsg = intres.getLocalizedMessage("cmp.errorcertconfirmstatus", new Integer (st)); 71 log.error(errMsg); 72 } 74 } 75 } 76 if (tag == 11) { 77 log.debug("Received a RevReqContent"); 79 RevReqContent rr = body.getRr(); 80 RevDetails rd = rr.getRevDetails(0); 81 CertTemplate ct = rd.getCertDetails(); 82 DERInteger serno = ct.getSerialNumber(); 83 X509Name issuer = ct.getIssuer(); 84 if ( (serno != null) && (issuer != null) ) { 85 String errMsg = intres.getLocalizedMessage("cmp.receivedrevreq", issuer.toString(), serno.getValue().toString(16)); 86 log.info(errMsg); 87 } else { 88 String errMsg = intres.getLocalizedMessage("cmp.receivedrevreqnoissuer"); 89 log.info(errMsg); 90 } 91 } 92 setMessage(msg); 93 PKIHeader header = msg.getHeader(); 94 DEROctetString os = header.getTransactionID(); 95 if (os != null) { 96 byte[] val = os.getOctets(); 97 if (val != null) { 98 setTransactionId(new String (Base64.encode(val))); 99 } 100 } 101 os = header.getSenderNonce(); 102 if (os != null) { 103 byte[] val = os.getOctets(); 104 if (val != null) { 105 setSenderNonce(new String (Base64.encode(val))); 106 } 107 } 108 setRecipient(header.getRecipient()); 109 setSender(header.getSender()); 110 } 111 112 } 113 | Popular Tags |