use of org.demoiselle.signer.timestamp.connector.TimeStampOperator in project signer by demoiselle.
the class CAdESChecker method validateTimestamp.
/**
* 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);
}
}
use of org.demoiselle.signer.timestamp.connector.TimeStampOperator in project signer by demoiselle.
the class CAdESSigner method validateTimestamp.
/**
* validade a timestampo on signature
* @param attributeTimeStamp
* @param varSignature
* @return
*/
@Deprecated
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);
}
}
use of org.demoiselle.signer.timestamp.connector.TimeStampOperator in project signer by demoiselle.
the class TimestampGeneratorImpl method validateTimeStamp.
/**
* Validate a time stamp and the original content
*
* @param content content to be validated
* @param timestamp timestamp
* @param hash hash
*/
@Override
public void validateTimeStamp(byte[] content, byte[] timestamp, byte[] hash) throws CertificateCoreException {
// Valida a assinatura digital do carimbo de tempo
TimeStampOperator timeStampOperator = new TimeStampOperator();
timeStampOperator.validate(content, timestamp, hash);
}
use of org.demoiselle.signer.timestamp.connector.TimeStampOperator in project signer by demoiselle.
the class CAdESTimeStampSigner method checkTimeStampOnSignature.
@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);
}
}
use of org.demoiselle.signer.timestamp.connector.TimeStampOperator in project signer by demoiselle.
the class CAdESTimeStampSigner method checkTimeStamp.
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);
}
}
Aggregations