private static void traceTimestampRequest(final DigestAlgorithm digestAlgorithm, final byte[] digest) { if (LOG.isTraceEnabled()) { LOG.trace("Timestamp digest algorithm: " + digestAlgorithm.getName()); LOG.trace("Timestamp digest value : " + DSSUtils.toHex(digest)); } }
/** * return a unique id for a date and the certificateToken id. * * @param signingTime * @param id * @return */ public static String getDeterministicId(final Date signingTime, final int id) { final Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("Z")); Date signingTime_ = signingTime; if (signingTime_ == null) { signingTime_ = deterministicDate; } calendar.setTime(signingTime_); final Date time = calendar.getTime(); final long milliseconds = time.getTime(); final long droppedMillis = 1000 * (milliseconds / 1000); final byte[] timeBytes = Long.toString(droppedMillis).getBytes(); final ByteBuffer byteBuffer = ByteBuffer.allocate(4); byteBuffer.putInt(id); final byte[] certificateBytes = byteBuffer.array(); final byte[] digestValue = DSSUtils.digest(DigestAlgorithm.MD5, timeBytes, certificateBytes); final String deterministicId = "id-" + toHex(digestValue); return deterministicId; }
private void handleRevocationEncoded(ArrayList<DEROctetString> crlHashesList, byte[] ocspHolderEncoded) { final byte[] digest = DSSUtils.digest(hashIndexDigestAlgorithm, ocspHolderEncoded); final DEROctetString derOctetStringDigest = new DEROctetString(digest); if (crlHashesList.remove(derOctetStringDigest)) { // attribute present in signature and in timestamp if (LOG.isDebugEnabled()) { LOG.debug("CRL/OCSP present in timestamp {}", DSSUtils.toHex(derOctetStringDigest.getOctets())); } } else { if (LOG.isDebugEnabled()) { LOG.debug("CRL/OCSP not present in timestamp {}", DSSUtils.toHex(derOctetStringDigest.getOctets())); } } }
final byte[] contentInfoBytes = info2.getEncoded(); if (LOG.isTraceEnabled()) { LOG.trace("Content Info: {}", DSSUtils.toHex(contentInfoBytes)); LOG.trace("Certificates: {}", DSSUtils.toHex(certificatesBytes)); LOG.trace("CRLs: {}", DSSUtils.toHex(crlBytes)); LOG.trace("SignerInfoBytes: {}", DSSUtils.toHex(signerInfoBytes));
@Override public byte[] post(final String urlString, final byte[] requestBytes, boolean refresh) throws DSSException { final String fileName = ResourceLoader.getNormalizedFileName(urlString); final byte[] digest = DSSUtils.digest(DigestAlgorithm.MD5, requestBytes); final String digestHexEncoded = DSSUtils.toHex(digest); final String cacheFileName = fileName + "." + digestHexEncoded; final byte[] cachedFileContent = getCachedFileContent(cacheFileName, refresh); if (cachedFileContent != null) { return cachedFileContent; } if (!isNetworkProtocol(urlString)) { return getContentUsingNotNetworkProtocol(urlString); } final byte[] returnedBytes = super.post(urlString, requestBytes); if (returnedBytes.length != 0) { final File cacheFile = getCacheFile(cacheFileName); DSSUtils.saveToFile(returnedBytes, cacheFile); } return returnedBytes; }
final String policyDigestHexValue = DSSUtils.toHex(digestValueBytes); signaturePolicy.setDigestValue(policyDigestHexValue);