org.bouncycastle.tsp.TSPException Java Examples

The following examples show how to use org.bouncycastle.tsp.TSPException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampToken getTimeStampToken(byte[] tsToken) throws TechnicalConnectorException {
   byte[] cloneTsToken = ArrayUtils.clone(tsToken);

   try {
      cloneTsToken = ConnectorIOUtils.base64Decode(cloneTsToken, true);
      return new TimeStampToken(new CMSSignedData(cloneTsToken));
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   } catch (CMSException var5) {
      LOG.error(var5.getClass().getSimpleName() + ": " + var5.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   }
}
 
Example #2
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampResponse getTimestampResponse(byte[] tsTokenResponse) throws TechnicalConnectorException {
   try {
      byte[] clonetsTokenResponse = ArrayUtils.clone(tsTokenResponse);
      clonetsTokenResponse = ConnectorIOUtils.base64Decode(clonetsTokenResponse, true);
      TimeStampResponse tsResp = new TimeStampResponse(clonetsTokenResponse);
      if (tsResp.getTimeStampToken() == null) {
         throw new TSPException("no response for the RFC3161 token");
      } else {
         return tsResp;
      }
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   }
}
 
Example #3
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampToken getTimeStampToken(byte[] tsToken) throws TechnicalConnectorException {
   byte[] cloneTsToken = ArrayUtils.clone(tsToken);

   try {
      cloneTsToken = ConnectorIOUtils.base64Decode(cloneTsToken, true);
      return new TimeStampToken(new CMSSignedData(cloneTsToken));
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   } catch (CMSException var5) {
      LOG.error(var5.getClass().getSimpleName() + ": " + var5.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   }
}
 
Example #4
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampResponse getTimestampResponse(byte[] tsTokenResponse) throws TechnicalConnectorException {
   try {
      byte[] clonetsTokenResponse = ArrayUtils.clone(tsTokenResponse);
      clonetsTokenResponse = ConnectorIOUtils.base64Decode(clonetsTokenResponse, true);
      TimeStampResponse tsResp = new TimeStampResponse(clonetsTokenResponse);
      if (tsResp.getTimeStampToken() == null) {
         throw new TSPException("no response for the RFC3161 token");
      } else {
         return tsResp;
      }
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   }
}
 
Example #5
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampToken getTimeStampToken(byte[] tsToken) throws TechnicalConnectorException {
   byte[] cloneTsToken = ArrayUtils.clone(tsToken);

   try {
      cloneTsToken = ConnectorIOUtils.base64Decode(cloneTsToken, true);
      return new TimeStampToken(new CMSSignedData(cloneTsToken));
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   } catch (CMSException var5) {
      LOG.error(var5.getClass().getSimpleName() + ": " + var5.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   }
}
 
Example #6
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampResponse getTimestampResponse(byte[] tsTokenResponse) throws TechnicalConnectorException {
   try {
      byte[] clonetsTokenResponse = ArrayUtils.clone(tsTokenResponse);
      clonetsTokenResponse = ConnectorIOUtils.base64Decode(clonetsTokenResponse, true);
      TimeStampResponse tsResp = new TimeStampResponse(clonetsTokenResponse);
      if (tsResp.getTimeStampToken() == null) {
         throw new TSPException("no response for the RFC3161 token");
      } else {
         return tsResp;
      }
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   }
}
 
Example #7
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampResponse getTimestampResponse(byte[] tsTokenResponse) throws TechnicalConnectorException {
   try {
      byte[] clonetsTokenResponse = ArrayUtils.clone(tsTokenResponse);
      clonetsTokenResponse = ConnectorIOUtils.base64Decode(clonetsTokenResponse, true);
      TimeStampResponse tsResp = new TimeStampResponse(clonetsTokenResponse);
      if (tsResp.getTimeStampToken() == null) {
         throw new TSPException("no response for the RFC3161 token");
      } else {
         return tsResp;
      }
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   }
}
 
Example #8
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampToken getTimeStampToken(byte[] tsToken) throws TechnicalConnectorException {
   byte[] cloneTsToken = ArrayUtils.clone(tsToken);

   try {
      cloneTsToken = ConnectorIOUtils.base64Decode(cloneTsToken, true);
      return new TimeStampToken(new CMSSignedData(cloneTsToken));
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   } catch (CMSException var5) {
      LOG.error(var5.getClass().getSimpleName() + ": " + var5.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   }
}
 
Example #9
Source File: DetachedTimestampValidator.java    From dss with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns a single TimestampToken to be validated
 * 
 * @return {@link TimestampToken}
 */
public TimestampToken getTimestamp() {
	if (timestampToken == null) {

		Objects.requireNonNull(certificateVerifier, "CertificateVerifier is not defined");
		Objects.requireNonNull(document, "The timestampFile must be defined!");
		Objects.requireNonNull(timestampType, "The TimestampType must be defined!");

		try {
			timestampToken = new TimestampToken(DSSUtils.toByteArray(document), timestampType);
			timestampToken.setFileName(document.getName());
			timestampToken.matchData(getTimestampedData());
			timestampToken.setTimestampScopes(getTimestampSignatureScope());
		} catch (CMSException | TSPException | IOException e) {
			throw new DSSException("Unable to parse timestamp", e);
		}
	}

	return timestampToken;
}
 
Example #10
Source File: CAdESTimeStampSigner.java    From signer with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Timestamp checkTimeStampPDF(byte[] timeStamp, byte[] content,  byte[] hash){
	try {
		Security.addProvider(new BouncyCastleProvider());
		byte[] varTimeStamp = timeStamp;
		TimeStampOperator timeStampOperator = new TimeStampOperator();
		if (content != null){
			timeStampOperator.validate(content, varTimeStamp,null);
		}else{
			timeStampOperator.validate(null, varTimeStamp,hash);
		}			
		TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(varTimeStamp));
		Timestamp timeStampSigner = new Timestamp(timeStampToken);
		return timeStampSigner;
	} catch (CertificateCoreException | IOException | TSPException
		| CMSException e) {
		throw new SignerException(e);
	}
	
}
 
Example #11
Source File: CAdESTimeStampSigner.java    From signer with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Timestamp checkTimeStamp(byte[] timeStamp, byte[] content,  byte[] hash){
	try {
		Security.addProvider(new BouncyCastleProvider());
		ais = new ASN1InputStream(new ByteArrayInputStream(timeStamp));
	    ASN1Sequence seq=(ASN1Sequence)ais.readObject();
        Attribute attributeTimeStamp = new Attribute((ASN1ObjectIdentifier)seq.getObjectAt(0), (ASN1Set)seq.getObjectAt(1));
        byte[] varTimeStamp = attributeTimeStamp.getAttrValues().getObjectAt(0).toASN1Primitive().getEncoded();
        TimeStampOperator timeStampOperator = new TimeStampOperator();
        if (content != null){
        	timeStampOperator.validate(content, varTimeStamp,null);
        }else{
        	timeStampOperator.validate(null, varTimeStamp,hash);
        }			
		TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(varTimeStamp));
		Timestamp timeStampSigner = new Timestamp(timeStampToken);
		return timeStampSigner;
	} catch (CertificateCoreException | IOException | TSPException
			| CMSException e) {
		throw new SignerException(e);
	}

}
 
Example #12
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampResponse getTimestampResponse(byte[] tsTokenResponse) throws TechnicalConnectorException {
   try {
      byte[] clonetsTokenResponse = ArrayUtils.clone(tsTokenResponse);
      clonetsTokenResponse = ConnectorIOUtils.base64Decode(clonetsTokenResponse, true);
      TimeStampResponse tsResp = new TimeStampResponse(clonetsTokenResponse);
      if (tsResp.getTimeStampToken() == null) {
         throw new TSPException("no response for the RFC3161 token");
      } else {
         return tsResp;
      }
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   }
}
 
Example #13
Source File: TimestampUtil.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static TimeStampToken getTimeStampToken(byte[] tsToken) throws TechnicalConnectorException {
   byte[] cloneTsToken = ArrayUtils.clone(tsToken);

   try {
      cloneTsToken = ConnectorIOUtils.base64Decode(cloneTsToken, true);
      return new TimeStampToken(new CMSSignedData(cloneTsToken));
   } catch (TSPException var3) {
      LOG.error(var3.getClass().getSimpleName() + ": " + var3.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var3, new Object[]{var3.getMessage()});
   } catch (IOException var4) {
      LOG.error(var4.getClass().getSimpleName() + ": " + var4.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()});
   } catch (CMSException var5) {
      LOG.error(var5.getClass().getSimpleName() + ": " + var5.getMessage());
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var5, new Object[]{var5.getMessage()});
   }
}
 
Example #14
Source File: CAdESLevelBaselineLTA.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
private AttributeTable addValidationData(AttributeTable unsignedAttributes, final ValidationDataForInclusion validationDataForInclusion,
		final List<DSSDocument> detachedContents) throws IOException, CMSException, TSPException {
	TimeStampToken timestampTokenToExtend = getLastArchiveTimestamp(unsignedAttributes);
	if (timestampTokenToExtend != null) {
		CMSSignedData timestampCMSSignedData = timestampTokenToExtend.toCMSSignedData();
		CMSSignedData extendedTimestampCMSSignedData = cadesProfileLT.extendWithValidationData(
				timestampCMSSignedData, validationDataForInclusion, detachedContents);
				
		unsignedAttributes = replaceTimeStampAttribute(unsignedAttributes, timestampCMSSignedData, extendedTimestampCMSSignedData);
	}
	return unsignedAttributes;
}
 
Example #15
Source File: CAdESTimeStampSigner.java    From signer with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<Timestamp> checkTimeStampOnSignature(byte[] signature) {
	try {
		Security.addProvider(new BouncyCastleProvider());
		List<Timestamp> listOfTimeStamp = new ArrayList<Timestamp>();
		CMSSignedData cmsSignedData = new CMSSignedData(signature);
		SignerInformationStore signers = cmsSignedData.getSignerInfos();
		Iterator<?> it = signers.getSigners().iterator();
		while (it.hasNext()) {
			SignerInformation signer = (SignerInformation) it.next();
			AttributeTable unsignedAttributes = signer
					.getUnsignedAttributes();
			Attribute attributeTimeStamp = unsignedAttributes
					.get(new ASN1ObjectIdentifier(
							PKCSObjectIdentifiers.id_aa_signatureTimeStampToken
									.getId()));
			if (attributeTimeStamp != null) {
				TimeStampOperator timeStampOperator = new TimeStampOperator();
				byte[] varTimeStamp = attributeTimeStamp.getAttrValues()
						.getObjectAt(0).toASN1Primitive().getEncoded();
				TimeStampToken timeStampToken = new TimeStampToken(
						new CMSSignedData(varTimeStamp));
				Timestamp timeStampSigner = new Timestamp(timeStampToken);
				timeStampOperator.validate(signer.getSignature(),
						varTimeStamp, null);
				listOfTimeStamp.add(timeStampSigner);
			}
		}
		return listOfTimeStamp;
	} catch (CertificateCoreException | IOException | TSPException
			| CMSException e) {
		throw new SignerException(e);
	}		
}
 
Example #16
Source File: CAdESChecker.java    From signer with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *  validade a timestampo on signature
 * @param attributeTimeStamp
 * @param varSignature
 * @return
 */
private Timestamp validateTimestamp(Attribute attributeTimeStamp, byte[] varSignature){
	try {
		TimeStampOperator timeStampOperator = new TimeStampOperator();
		byte [] varTimeStamp = attributeTimeStamp.getAttrValues().getObjectAt(0).toASN1Primitive().getEncoded();
		TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(varTimeStamp));
		Timestamp timeStampSigner = new Timestamp(timeStampToken);
		timeStampOperator.validate(varSignature,varTimeStamp , null);
		return timeStampSigner;
	} catch (CertificateCoreException | IOException | TSPException | CMSException e) {
		throw new SignerException(e);
	}		
}
 
Example #17
Source File: CAdESService.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public TimestampToken getContentTimestamp(DSSDocument toSignDocument, CAdESSignatureParameters parameters) {
	if (tspSource == null) {
		throw new DSSException("A TSPSource is required !");
	}
	DigestAlgorithm digestAlgorithm = parameters.getContentTimestampParameters().getDigestAlgorithm();
	TimestampBinary timeStampResponse = tspSource.getTimeStampResponse(digestAlgorithm, Utils.fromBase64(toSignDocument.getDigest(digestAlgorithm)));
	try {
		return new TimestampToken(timeStampResponse.getBytes(), TimestampType.CONTENT_TIMESTAMP);
	} catch (TSPException | IOException | CMSException e) {
		throw new DSSException("Cannot create a content TimestampToken", e);
	}
}
 
Example #18
Source File: DSSASN1Utils.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a TimeStampToken from the provided {@code attribute}
 * @param attribute {@link Attribute} to generate {@link TimeStampToken} from
 * @return {@link TimeStampToken}
 */
public static TimeStampToken getTimeStampToken(Attribute attribute) {
	try {
		CMSSignedData signedData = getCMSSignedData(attribute);
		if (signedData != null) {
			return new TimeStampToken(signedData);
		}
	} catch (IOException | CMSException | TSPException e) {
		LOG.warn("The given TimeStampToken cannot be created! Reason: [{}]", e.getMessage());
	}
	return null;
}
 
Example #19
Source File: TimestampToken.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean isValidTimestamp(SignerInformationVerifier signerInformationVerifier) {
	try {
		// Validate the timestamp, the signing certificate,...
		timeStamp.validate(signerInformationVerifier);
		return true;
	} catch (TSPException e) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("Unable to validate timestamp token : ", e);
		} else {
			LOG.warn("Unable to validate timestamp token : {}", e.getMessage());
		}
		signatureInvalidityReason = e.getClass().getSimpleName() + " : " + e.getMessage();
		return false;
	}
}
 
Example #20
Source File: TimestampTokenTest.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void dss1913() throws TSPException, IOException, CMSException {
	CertificateToken tsa = DSSUtils.loadCertificateFromBase64EncodedString(
			"MIIGoTCCBImgAwIBAgIIetOCrGKYHdMwDQYJKoZIhvcNAQELBQAwYzELMAkGA1UEBhMCUEUxQjBABgNVBAoMOUVudGlkYWQgZGUgQ2VydGlmaWNhY2nD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kZSBDZXJ0aWZpY2FjacOzbiBOYWNpb25hbCBwYXJhIGVsIEVzdGFkbyBQZXJ1YW5vMRAwDgYDVQQDDAdFQy1QU1ZBAgh604KsYpgd0zANBgkqhkiG9w0BAQEFAASCAQAcsYEm1mIUlUkq+B6t4HEJf2CDh05H4WdlIcbH+8wZc/mh/OVvO3YkJfsqxOBbudykJowEoM/VIrp5mPis+I6fMUTxyh3XHkCbq3GZTGBI/VW67VlEhdZCHDPsefXmicRf6o4E7uXNKW9RpWDuJd4ZI6nQRTdjtmweoS/w0NLz5jHupLBa0RELhHoHbsO/OwnQxwDpuj/NAT1wj+xURYSj6/wKPyM0AfpOL/H/RDOVtp8I4x1RuAx6Zann4++XQLHQ+JuEaFEJ9kDE0nlaxIXhtg0JU19CPzwAC7RvIPnrl/H8ShyY7ODWo/SzP40dn9Twn7Fs42w3n8skoLMXqLbz";
	TimestampToken timestampToken = new TimestampToken(Utils.fromBase64(base64), TimestampType.SIGNATURE_TIMESTAMP);
	assertNotNull(timestampToken);

	Digest messageImprint = timestampToken.getMessageImprint();
	assertNotNull(messageImprint);
	assertEquals("13C05E933E4B709D056385D98566C39FAB3329518353B5DBE1A0F3633F6CF1E8", messageImprint.getHexValue());
	assertEquals(DigestAlgorithm.SHA256, messageImprint.getAlgorithm());

	assertTrue(timestampToken.isSignedBy(tsa));
	assertEquals(SignatureAlgorithm.RSA_SHA1, timestampToken.getSignatureAlgorithm());
	assertEquals(SignatureValidity.VALID, timestampToken.getSignatureValidity());

	// 2nd tst

	base64 = "MIIKrAYJKoZIhvcNAQcCoIIKnTCCCpkCAQMxCzAJBgUrDgMCGgUAMIIBAQYLKoZIhvcNAQkQAQSggfEEge4wgesCAQEGESsGAQQBgpNkAgEDAgBph2gAMDEwDQYJYIZIAWUDBAIBBQAEIAlnzy26I5KQ/cqJxlIO53uXHI3zyZfn9axMZTbaFmdnAghIkY3UmNe21BgPMjAxOTA2MTgyMTUzMDFaMASAAgH0AgjOO3DWnDGpKqB1pH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X0BwE5PzvtDoqNwm4lLAqtQCQm1P8OmoGqR+BE/SCmva1LVhEIy9hBHrEbgNBE/Cad8IYKaexVpp12/QzWz6CWQKEnTaFKYuiB3SGeRFTu9Qw+vU97Ru4XrW+QAoMIViOp5fY6n24y8SqcazTIUXAkAO5bmVeXA14IgWodZX+rihF2jee0xjmCrD1WE7RXpPRDx4X/FujFwVN3";
	timestampToken = new TimestampToken(Utils.fromBase64(base64), TimestampType.SIGNATURE_TIMESTAMP);
	assertNotNull(timestampToken);

	messageImprint = timestampToken.getMessageImprint();
	assertNotNull(messageImprint);
	assertEquals("0967CF2DBA239290FDCA89C6520EE77B971C8DF3C997E7F5AC4C6536DA166767", messageImprint.getHexValue());
	assertEquals(DigestAlgorithm.SHA256, messageImprint.getAlgorithm());

	assertTrue(timestampToken.isSignedBy(tsa));
	assertEquals(SignatureAlgorithm.RSA_SHA1, timestampToken.getSignatureAlgorithm());
	assertEquals(SignatureValidity.VALID, timestampToken.getSignatureValidity());
}
 
Example #21
Source File: PAdESService.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public TimestampToken getContentTimestamp(DSSDocument toSignDocument, PAdESSignatureParameters parameters) {
	final PDFSignatureService pdfSignatureService = pdfObjFactory.newContentTimestampService();
	final DigestAlgorithm digestAlgorithm = parameters.getContentTimestampParameters().getDigestAlgorithm();
	final byte[] messageDigest = pdfSignatureService.digest(toSignDocument, parameters);
	TimestampBinary timeStampResponse = tspSource.getTimeStampResponse(digestAlgorithm, messageDigest);
	try {
		return new TimestampToken(timeStampResponse.getBytes(), TimestampType.CONTENT_TIMESTAMP);
	} catch (TSPException | IOException | CMSException e) {
		throw new DSSException("Cannot obtain the content timestamp", e);
	}
}
 
Example #22
Source File: TimestampTokenConverter.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException {
	Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!");
	Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!");
	Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!");
	try {
		TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType());
		timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod());
		if (timestampDTO.getIncludes() != null) {
			timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes()));
		}
		return timestampToken;
	} catch (TSPException | IOException | CMSException e) {
		throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e);
	}
}
 
Example #23
Source File: ChapterIVKmehrResponseWithTimeStampInfo.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimeStampResponse getTimeStampResponse() {
   try {
      return new TimeStampResponse(Arrays.clone(this.timeStampBytes));
   } catch (TSPException var2) {
      LOG.error(var2.getClass().getSimpleName() + ":" + var2.getMessage(), var2);
   } catch (IOException var3) {
      LOG.error(var3.getClass().getSimpleName() + ":" + var3.getMessage(), var3);
   }

   return null;
}
 
Example #24
Source File: ChapterIVKmehrResponseWithTimeStampInfo.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimeStampResponse getTimeStampResponse() {
   try {
      return new TimeStampResponse(Arrays.clone(this.timeStampBytes));
   } catch (TSPException var2) {
      LOG.error(var2.getClass().getSimpleName() + ":" + var2.getMessage(), var2);
   } catch (IOException var3) {
      LOG.error(var3.getClass().getSimpleName() + ":" + var3.getMessage(), var3);
   }

   return null;
}
 
Example #25
Source File: ResponseBuilderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimeStampResponse convertToTimeStampResponse(byte[] bytes) throws TechnicalConnectorException {
   try {
      TimeStampResponse timeStampResponse = new TimeStampResponse(bytes);
      return timeStampResponse;
   } catch (TSPException var4) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.UNKNOWN_ERROR, var4, new Object[0]);
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.UNKNOWN_ERROR, var5, new Object[0]);
   }
}
 
Example #26
Source File: ResponseBuilderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private void validateTimeStamp(TimeStampRequest tsRequest, TimeStampResponse timeStampResponse) throws UnsealConnectorException, ChapterIVBusinessConnectorException {
   try {
      LOG.trace("validating timestamp response");
      timeStampResponse.validate(tsRequest);
      LOG.trace(" timestamp response validated , now validating timestamp token");
      this.validateTimeStampToken(timeStampResponse);
      LOG.trace(" timestamp token validated");
   } catch (TSPException var4) {
      throw new UnsealConnectorException(UnsealConnectorExceptionValues.ERROR_CRYPTO, var4, new Object[]{"time stamp was not valid :" + var4.getMessage()});
   } catch (TechnicalConnectorException var5) {
      throw new UnsealConnectorException(UnsealConnectorExceptionValues.ERROR_CRYPTO, var5, new Object[]{" error while validating timestamptoken :" + var5.getMessage()});
   }
}
 
Example #27
Source File: ChapterIVKmehrResponseWithTimeStampInfo.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimeStampResponse getTimeStampResponse() {
   try {
      return new TimeStampResponse(Arrays.clone(this.timeStampBytes));
   } catch (TSPException var2) {
      LOG.error(var2.getClass().getSimpleName() + ":" + var2.getMessage(), var2);
   } catch (IOException var3) {
      LOG.error(var3.getClass().getSimpleName() + ":" + var3.getMessage(), var3);
   }

   return null;
}
 
Example #28
Source File: ResponseBuilderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimeStampResponse convertToTimeStampResponse(byte[] bytes) throws TechnicalConnectorException {
   try {
      TimeStampResponse timeStampResponse = new TimeStampResponse(bytes);
      return timeStampResponse;
   } catch (TSPException var4) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.UNKNOWN_ERROR, var4, new Object[0]);
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.UNKNOWN_ERROR, var5, new Object[0]);
   }
}
 
Example #29
Source File: ResponseBuilderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private void validateTimeStamp(TimeStampRequest tsRequest, TimeStampResponse timeStampResponse) throws UnsealConnectorException, ChapterIVBusinessConnectorException {
   try {
      LOG.trace("validating timestamp response");
      timeStampResponse.validate(tsRequest);
      LOG.trace(" timestamp response validated , now validating timestamp token");
      this.validateTimeStampToken(timeStampResponse);
      LOG.trace(" timestamp token validated");
   } catch (TSPException var4) {
      throw new UnsealConnectorException(UnsealConnectorExceptionValues.ERROR_CRYPTO, var4, new Object[]{"time stamp was not valid :" + var4.getMessage()});
   } catch (TechnicalConnectorException var5) {
      throw new UnsealConnectorException(UnsealConnectorExceptionValues.ERROR_CRYPTO, var5, new Object[]{" error while validating timestamptoken :" + var5.getMessage()});
   }
}
 
Example #30
Source File: ResponseBuilderImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimeStampResponse convertToTimeStampResponse(byte[] bytes) throws TechnicalConnectorException {
   try {
      TimeStampResponse timeStampResponse = new TimeStampResponse(bytes);
      return timeStampResponse;
   } catch (TSPException var4) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.UNKNOWN_ERROR, var4, new Object[0]);
   } catch (IOException var5) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.UNKNOWN_ERROR, var5, new Object[0]);
   }
}