@Test public void testSigneringsBiljettMedDigest() { when(utkastModelToXMLConverter.utkastToXml(anyString(), anyString())).thenReturn("<xml/>"); when(prepareSignatureService.prepareSignature(anyString(), anyString(), anyString())).thenReturn(buildIntygXMLSignature()); SignaturBiljett signaturBiljett = testee.skapaSigneringsBiljettMedDigest(INTYG_ID, INTYG_TYP, VERSION, "json", SignMethod.FAKE, TICKET_ID); assertNotNull(signaturBiljett); verify(redisTicketTracker, times(1)).trackBiljett(any(SignaturBiljett.class)); }
@Override public SignaturBiljett skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson, SignMethod signMethod, String ticketId) { String registerCertificateXml = utkastModelToXMLConverter.utkastToXml(utkastJson, intygsTyp); String signatureAlgorithm; if (SignMethod.SIGN_SERVICE.equals(signMethod)) { signatureAlgorithm = DssSignatureService.REQUESTED_SIGN_ALGORITHM; } else { signatureAlgorithm = PartialSignatureFactory.DEFAULT_SIGNATURE_ALGORITHM; } IntygXMLDSignature intygSignature = prepareSignatureService .prepareSignature(registerCertificateXml, intygsId, signatureAlgorithm); intygSignature.setIntygJson(utkastJson); SignaturBiljett biljett = SignaturBiljett.SignaturBiljettBuilder .aSignaturBiljett(ticketId, SignaturTyp.XMLDSIG, signMethod) .withIntygsId(intygsId) .withVersion(version) .withIntygSignature(intygSignature) .withStatus(SignaturStatus.BEARBETAR) .withSkapad(LocalDateTime.now()) .withHash(intygSignature.getSignedInfoForSigning()) .build(); redisTicketTracker.trackBiljett(biljett); return biljett; }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson, SignMethod signMethod, String ticketId) { String registerCertificateXml = utkastModelToXMLConverter.utkastToXml(utkastJson, intygsTyp); String signatureAlgorithm; if (SignMethod.SIGN_SERVICE.equals(signMethod)) { signatureAlgorithm = DssSignatureService.REQUESTED_SIGN_ALGORITHM; } else { signatureAlgorithm = PartialSignatureFactory.DEFAULT_SIGNATURE_ALGORITHM; } IntygXMLDSignature intygSignature = prepareSignatureService .prepareSignature(registerCertificateXml, intygsId, signatureAlgorithm); intygSignature.setIntygJson(utkastJson); SignaturBiljett biljett = SignaturBiljett.SignaturBiljettBuilder .aSignaturBiljett(ticketId, SignaturTyp.XMLDSIG, signMethod) .withIntygsId(intygsId) .withVersion(version) .withIntygSignature(intygSignature) .withStatus(SignaturStatus.BEARBETAR) .withSkapad(LocalDateTime.now()) .withHash(intygSignature.getSignedInfoForSigning()) .build(); redisTicketTracker.trackBiljett(biljett); return biljett; } }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson, SignMethod signMethod, String ticketId) { String registerCertificateXml = utkastModelToXMLConverter.utkastToXml(utkastJson, intygsTyp); String signatureAlgorithm; if (SignMethod.SIGN_SERVICE.equals(signMethod)) { signatureAlgorithm = DssSignatureService.REQUESTED_SIGN_ALGORITHM; } else { signatureAlgorithm = PartialSignatureFactory.DEFAULT_SIGNATURE_ALGORITHM; } IntygXMLDSignature intygSignature = prepareSignatureService .prepareSignature(registerCertificateXml, intygsId, signatureAlgorithm); intygSignature.setIntygJson(utkastJson); SignaturBiljett biljett = SignaturBiljett.SignaturBiljettBuilder .aSignaturBiljett(ticketId, SignaturTyp.XMLDSIG, signMethod) .withIntygsId(intygsId) .withVersion(version) .withIntygSignature(intygSignature) .withStatus(SignaturStatus.BEARBETAR) .withSkapad(LocalDateTime.now()) .withHash(intygSignature.getSignedInfoForSigning()) .build(); redisTicketTracker.trackBiljett(biljett); return biljett; }  }
XmlUnderskriftServiceImpl extends BaseXMLSignatureService implements CommonUnderskriftService { @Override public SignaturBiljett skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson, SignMethod signMethod, String ticketId) { String registerCertificateXml = utkastModelToXMLConverter.utkastToXml(utkastJson, intygsTyp); String signatureAlgorithm; if (SignMethod.SIGN_SERVICE.equals(signMethod)) { signatureAlgorithm = DssSignatureService.REQUESTED_SIGN_ALGORITHM; } else { signatureAlgorithm = PartialSignatureFactory.DEFAULT_SIGNATURE_ALGORITHM; } IntygXMLDSignature intygSignature = prepareSignatureService .prepareSignature(registerCertificateXml, intygsId, signatureAlgorithm); intygSignature.setIntygJson(utkastJson); SignaturBiljett biljett = SignaturBiljett.SignaturBiljettBuilder .aSignaturBiljett(ticketId, SignaturTyp.XMLDSIG, signMethod) .withIntygsId(intygsId) .withVersion(version) .withIntygSignature(intygSignature) .withStatus(SignaturStatus.BEARBETAR) .withSkapad(LocalDateTime.now()) .withHash(intygSignature.getSignedInfoForSigning()) .build(); redisTicketTracker.trackBiljett(biljett); return biljett; }  @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 skapaSigneringsBiljettMedDigest(String intygsId, String intygsTyp, long version, String utkastJson, SignMethod signMethod, String ticketId) { String registerCertificateXml = utkastModelToXMLConverter.utkastToXml(utkastJson, intygsTyp); String signatureAlgorithm; if (SignMethod.SIGN_SERVICE.equals(signMethod)) { signatureAlgorithm = DssSignatureService.REQUESTED_SIGN_ALGORITHM; } else { signatureAlgorithm = PartialSignatureFactory.DEFAULT_SIGNATURE_ALGORITHM; } IntygXMLDSignature intygSignature = prepareSignatureService .prepareSignature(registerCertificateXml, intygsId, signatureAlgorithm); intygSignature.setIntygJson(utkastJson); SignaturBiljett biljett = SignaturBiljett.SignaturBiljettBuilder .aSignaturBiljett(ticketId, SignaturTyp.XMLDSIG, signMethod) .withIntygsId(intygsId) .withVersion(version) .withIntygSignature(intygSignature) .withStatus(SignaturStatus.BEARBETAR) .withSkapad(LocalDateTime.now()) .withHash(intygSignature.getSignedInfoForSigning()) .build(); redisTicketTracker.trackBiljett(biljett); return biljett; }  @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);  }