Skip to content

Commit

Permalink
Merge pull request #20 from kolesa-team/CORE-2380
Browse files Browse the repository at this point in the history
CORE-2380 В новом NCAnode не финализируется тикет, если документ был подписан давно
  • Loading branch information
DKlygov authored Dec 12, 2023
2 parents 4eb564a + bc07f0c commit 2f951a5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/main/java/kz/ncanode/service/CmsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,23 @@ public CmsVerificationResponse verify(String signedCms, String detachedData, boo
// TSP Checking
if (signer.getUnsignedAttributes() != null) {
var attrs = signer.getUnsignedAttributes().toHashtable();

if (attrs.containsKey(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken)) {
Attribute attr = (Attribute) attrs.get(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);


if (attr.getAttrValues().size() != 1) {
Object maybeVectorOrAttr = attrs.get(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);

Optional<Attribute> attr = maybeVectorOrAttr instanceof Vector
? Optional.of(((List<Object>) maybeVectorOrAttr)
.stream()
.filter(Objects::nonNull)
.map(Attribute.class::cast)
.findFirst()
.orElseThrow(() -> new Exception("No attributes found")))
: Optional.of((Attribute) maybeVectorOrAttr);

if (attr.get().getAttrValues().size() != 1) {
throw new Exception("Too many TSP tokens");
}

CMSSignedData tspCms = new CMSSignedData(attr.getAttrValues().getObjectAt(0).getDERObject().getEncoded());
CMSSignedData tspCms = new CMSSignedData(attr.get().getAttrValues().getObjectAt(0).getDERObject().getEncoded());
TimeStampTokenInfo tspi = tspService.info(tspCms).orElseThrow();

try {
Expand Down

0 comments on commit 2f951a5

Please sign in to comment.