diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/common/GenPendingTemplateFiller.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/servlet/common/GenPendingTemplateFiller.java | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/common/GenPendingTemplateFiller.java b/pki/base/common/src/com/netscape/cms/servlet/common/GenPendingTemplateFiller.java index 15456865f..1d479fef3 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/common/GenPendingTemplateFiller.java +++ b/pki/base/common/src/com/netscape/cms/servlet/common/GenPendingTemplateFiller.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.servlet.common; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.OutputStream; @@ -59,10 +58,9 @@ import com.netscape.certsrv.ra.IRegistrationAuthority; import com.netscape.certsrv.request.IRequest; import com.netscape.certsrv.request.RequestId; - /** - * default Pending template filler - * + * default Pending template filler + * * @version $Revision$, $Date$ */ public class GenPendingTemplateFiller implements ICMSTemplateFiller { @@ -72,25 +70,26 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { } /** - * fill error details and description if any. + * fill error details and description if any. + * * @param cmsReq CMS Request * @param authority this authority * @param locale locale of template. * @param e unexpected exception e. ignored. */ public CMSTemplateParams getTemplateParams( - CMSRequest cmsReq, IAuthority authority, Locale locale, Exception e) { + CMSRequest cmsReq, IAuthority authority, Locale locale, Exception e) { IArgBlock fixed = CMS.createArgBlock(); CMSTemplateParams params = new CMSTemplateParams(null, fixed); - if( cmsReq == null ) { + if (cmsReq == null) { return null; } // request status if any. Integer sts = cmsReq.getStatus(); - if (sts != null) + if (sts != null) fixed.set(ICMSTemplateFiller.REQUEST_STATUS, sts.toString()); // request id @@ -109,17 +108,17 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { PendInfo pendInfo = new PendInfo(reqId.toString(), new Date()); OtherInfo otherInfo = new - OtherInfo(OtherInfo.PEND, null, pendInfo); + OtherInfo(OtherInfo.PEND, null, pendInfo); SEQUENCE bpids = new SEQUENCE(); String[] reqIdArray = - req.getExtDataInStringArray(IRequest.CMC_REQIDS); + req.getExtDataInStringArray(IRequest.CMC_REQIDS); for (int i = 0; i < reqIdArray.length; i++) { bpids.addElement(new INTEGER(reqIdArray[i])); } CMCStatusInfo cmcStatusInfo = new - CMCStatusInfo(CMCStatusInfo.PENDING, bpids, - (String) null, otherInfo); + CMCStatusInfo(CMCStatusInfo.PENDING, bpids, + (String) null, otherInfo); TaggedAttribute ta = new TaggedAttribute(new INTEGER(bpid++), OBJECT_IDENTIFIER.id_cmc_cMCStatusInfo, @@ -130,7 +129,7 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { // create recipientNonce // create responseInfo if regInfo exist String[] transIds = - req.getExtDataInStringArray(IRequest.CMC_TRANSID); + req.getExtDataInStringArray(IRequest.CMC_TRANSID); SET ids = new SET(); for (int i = 0; i < transIds.length; i++) { @@ -167,7 +166,7 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { dig = salt.getBytes(); } String b64E = CMS.BtoA(dig); - String[] newNonce = {b64E}; + String[] newNonce = { b64E }; ta = new TaggedAttribute(new INTEGER(bpid++), @@ -180,13 +179,13 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { SEQUENCE(), new SEQUENCE()); EncapsulatedContentInfo ci = new - EncapsulatedContentInfo(OBJECT_IDENTIFIER.id_cct_PKIResponse, - rb); + EncapsulatedContentInfo(OBJECT_IDENTIFIER.id_cct_PKIResponse, + rb); org.mozilla.jss.crypto.X509Certificate x509cert = null; if (authority instanceof ICertificateAuthority) { x509cert = ((ICertificateAuthority) authority).getCaX509Cert(); - }else if (authority instanceof IRegistrationAuthority) { + } else if (authority instanceof IRegistrationAuthority) { x509cert = ((IRegistrationAuthority) authority).getRACert(); } if (x509cert == null) @@ -194,12 +193,12 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { try { X509CertImpl cert = new X509CertImpl(x509cert.getEncoded()); ByteArrayInputStream issuer1 = new - ByteArrayInputStream(((X500Name) cert.getIssuerDN()).getEncoded()); + ByteArrayInputStream(((X500Name) cert.getIssuerDN()).getEncoded()); Name issuer = (Name) Name.getTemplate().decode(issuer1); IssuerAndSerialNumber ias = new - IssuerAndSerialNumber(issuer, new INTEGER(cert.getSerialNumber().toString())); + IssuerAndSerialNumber(issuer, new INTEGER(cert.getSerialNumber().toString())); SignerIdentifier si = new - SignerIdentifier(SignerIdentifier.ISSUER_AND_SERIALNUMBER, ias, null); + SignerIdentifier(SignerIdentifier.ISSUER_AND_SERIALNUMBER, ias, null); // SHA1 is the default digest Alg for now. DigestAlgorithm digestAlg = null; @@ -207,14 +206,14 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { org.mozilla.jss.crypto.PrivateKey privKey = CryptoManager.getInstance().findPrivKeyByCert(x509cert); org.mozilla.jss.crypto.PrivateKey.Type keyType = privKey.getType(); - if( keyType.equals(org.mozilla.jss.crypto.PrivateKey.RSA ) ) { + if (keyType.equals(org.mozilla.jss.crypto.PrivateKey.RSA)) { signAlg = SignatureAlgorithm.RSASignatureWithSHA1Digest; - } else if( keyType.equals(org.mozilla.jss.crypto.PrivateKey.DSA ) ) { + } else if (keyType.equals(org.mozilla.jss.crypto.PrivateKey.DSA)) { signAlg = SignatureAlgorithm.DSASignatureWithSHA1Digest; } else { - CMS.debug( "GenPendingTemplateFiller::getTemplateParams() - " + CMS.debug("GenPendingTemplateFiller::getTemplateParams() - " + "keyType " + keyType.toString() - + " is unsupported!" ); + + " is unsupported!"); return null; } @@ -224,7 +223,7 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { try { SHADigest = MessageDigest.getInstance("SHA1"); digestAlg = DigestAlgorithm.SHA1; - + ByteArrayOutputStream ostream = new ByteArrayOutputStream(); rb.encode((OutputStream) ostream); @@ -234,31 +233,31 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { } SignerInfo signInfo = new - SignerInfo(si, null, null, - OBJECT_IDENTIFIER.id_cct_PKIResponse, - digest, signAlg, - privKey); + SignerInfo(si, null, null, + OBJECT_IDENTIFIER.id_cct_PKIResponse, + digest, signAlg, + privKey); SET signInfos = new SET(); signInfos.addElement(signInfo); - + SET digestAlgs = new SET(); if (digestAlg != null) { AlgorithmIdentifier ai = new - AlgorithmIdentifier(digestAlg.toOID(), - null); + AlgorithmIdentifier(digestAlg.toOID(), + null); digestAlgs.addElement(ai); } - + SignedData fResponse = new - SignedData(digestAlgs, ci, - null, null, signInfos); + SignedData(digestAlgs, ci, + null, null, signInfos); ContentInfo fullResponse = new - ContentInfo(ContentInfo.SIGNED_DATA, fResponse); + ContentInfo(ContentInfo.SIGNED_DATA, fResponse); ByteArrayOutputStream ostream = new - ByteArrayOutputStream(); + ByteArrayOutputStream(); fullResponse.encode((OutputStream) ostream); byte[] fr = ostream.toByteArray(); @@ -270,9 +269,9 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { } } // this authority - if (authority != null) - fixed.set(ICMSTemplateFiller.AUTHORITY, - authority.getOfficialName()); + if (authority != null) + fixed.set(ICMSTemplateFiller.AUTHORITY, + authority.getOfficialName()); return params; } @@ -286,4 +285,3 @@ public class GenPendingTemplateFiller implements ICMSTemplateFiller { return false; } } - |