@Test(expected = WebCertServiceException.class) public void testFinalizeSignatureFailsWithDifferentVersions() { when(xmldSigService.buildKeyInfoForCertificate(anyString())).thenReturn(new ObjectFactory().createKeyInfoType()); when(prepareSignatureService.encodeSignatureIntoSignedXml(any(SignatureType.class), anyString())).thenReturn("<final-xml/>"); when(utkastModelToXMLConverter.utkastToXml(anyString(), anyString())).thenReturn("json"); when(xmldSigService.validateSignatureValidity(anyString(), anyBoolean())).thenReturn(okValidationResult); when(utkastModelToXMLConverter.utkastToXml(anyString(), anyString())).thenReturn("<xml/>"); when(prepareSignatureService.transformAndGenerateDigest(anyString(), anyString())) .thenReturn(new TransformAndDigestResponse(null, Base64.getEncoder().encode( UnderskriftTestUtil.buildIntygXMLSignature().getSignatureType().getSignedInfo().getReference().get(0) .getDigestValue()))); try { testee.finalizeSignature(createSignaturBiljett(SignaturStatus.BEARBETAR), "signatur".getBytes(Charset.forName("UTF-8")), "certifikat", createUtkast(INTYG_ID, 1111L, INTYG_TYP, UtkastStatus.DRAFT_COMPLETE, "model", createVardperson(), ENHET_ID, PERSON_ID), buildUser()); } finally { verifyNoInteractions(monitoringLogService); verify(redisTicketTracker, times(1)).updateStatus(anyString(), eq(SignaturStatus.OKAND)); verify(intygService, times(0)).storeIntyg(any(Utkast.class)); } }
@Override public SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat, final Utkast utkast, WebCertUser user) { SignaturBiljett sb = finalizeXMLDSigSignature(certifikat, user, biljett, signatur, utkast); monitoringLogService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod()); return redisTicketTracker.updateStatus(sb.getTicketId(), sb.getStatus()); }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat, final Utkast utkast, WebCertUser user) { SignaturBiljett sb = finalizeXMLDSigSignature(certifikat, user, biljett, signatur, utkast); monitoringLogService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod()); return redisTicketTracker.updateStatus(sb.getTicketId(), sb.getStatus()); } }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat, final Utkast utkast, WebCertUser user) { SignaturBiljett sb = finalizeXMLDSigSignature(certifikat, user, biljett, signatur, utkast); monitoringLogService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod()); return redisTicketTracker.updateStatus(sb.getTicketId(), sb.getStatus()); }  }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat, final Utkast utkast, WebCertUser user) { SignaturBiljett sb = finalizeXMLDSigSignature(certifikat, user, biljett, signatur, utkast); monitoringLogService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod()); return redisTicketTracker.updateStatus(sb.getTicketId(), sb.getStatus()); }  @Override SignaturBiljett skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson,
        SignMethod signMethod, String ticketId); @Override SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat,
        final Utkast utkast, WebCertUser user); }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat, final Utkast utkast, WebCertUser user) { SignaturBiljett sb = finalizeXMLDSigSignature(certifikat, user, biljett, signatur, utkast); monitoringLogService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod()); return redisTicketTracker.updateStatus(sb.getTicketId(), sb.getStatus()); }  @Override SignaturBiljett skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson,
        SignMethod signMethod, String ticketId); @Override SignaturBiljett finalizeSignature(final SignaturBiljett biljett, final byte[] signatur, final String certifikat,
        final Utkast utkast, WebCertUser user);  }