/** * @deprecated use method taking ANS1ObjectIdentifier */ public TimeStampRequest generate( String digestAlgorithmOID, byte[] digest, BigInteger nonce) { if (digestAlgorithmOID == null) { throw new IllegalArgumentException("No digest algorithm specified"); } ASN1ObjectIdentifier digestAlgOID = new ASN1ObjectIdentifier(digestAlgorithmOID); AlgorithmIdentifier algID = new AlgorithmIdentifier(digestAlgOID, DERNull.INSTANCE); MessageImprint messageImprint = new MessageImprint(algID, digest); Extensions ext = null; if (!extGenerator.isEmpty()) { ext = extGenerator.generate(); } if (nonce != null) { return new TimeStampRequest(new TimeStampReq(messageImprint, reqPolicy, new ASN1Integer(nonce), certReq, ext)); } else { return new TimeStampRequest(new TimeStampReq(messageImprint, reqPolicy, null, certReq, ext)); } }
/** * Checks if the timestamp refers to this document. * @throws java.security.NoSuchAlgorithmException on error * @return true if it checks false otherwise * @since 2.1.6 */ public boolean verifyTimestampImprint() throws NoSuchAlgorithmException { if (timeStampToken == null) return false; MessageImprint imprint = timeStampToken.getTimeStampInfo().toASN1Structure().getMessageImprint(); byte[] md = MessageDigest.getInstance("SHA-1").digest(digest); byte[] imphashed = imprint.getHashedMessage(); boolean res = Arrays.equals(md, imphashed); return res; }