@Test public void testNetidSignature() { Utkast utkast = createUtkast(INTYG_ID, 1L, INTYG_TYP, UtkastStatus.DRAFT_COMPLETE, "model", vardperson, ENHET_ID, PERSON_ID); when(utkastRepository.findById(INTYG_ID)).thenReturn(Optional.of(utkast)); SignaturBiljett signaturBiljett = createSignaturBiljett(SignaturStatus.BEARBETAR); when(redisTicketTracker.findBiljett(TICKET_ID)).thenReturn(signaturBiljett); when(xmlUnderskriftService.finalizeSignature(any(SignaturBiljett.class), any(byte[].class), anyString(), any(Utkast.class), any(WebCertUser.class))) .thenReturn(createSignaturBiljett(SIGNERAD)); SignaturBiljett sb = testee.netidSignature(TICKET_ID, "signatur".getBytes(StandardCharsets.UTF_8), "certifikat"); assertNotNull(sb); assertEquals(SIGNERAD, sb.getStatus()); verify(certificateEventService) .createCertificateEvent(anyString(), anyString(), eq(EventCode.SIGNAT), anyString()); }
@Override public SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat) { SignaturBiljett signaturBiljett = redisTicketTracker.findBiljett(biljettId); if (signaturBiljett == null) { String errMsg = "No SignaturBiljett found for ticketId '{}' when finalizing signature. " + "Has Redis evicted the ticket early or has Redis crashed during the signature process?"; LOG.error(errMsg, biljettId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, errMsg); } WebCertUser user = webCertUserService.getUser(); Utkast utkast = getUtkastForSignering(signaturBiljett.getIntygsId(), signaturBiljett.getVersion(), user); SignaturBiljett finishedSignaturBiljett = xmlUnderskriftService.finalizeSignature(signaturBiljett, signatur, certifikat, utkast, user); finalizeSignature(utkast, user); return finishedSignaturBiljett; }
UnderskriftServiceImpl implements UnderskriftService { @Override public SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat) { SignaturBiljett signaturBiljett = redisTicketTracker.findBiljett(biljettId); if (signaturBiljett == null) { String errMsg = "No SignaturBiljett found for ticketId '{}' when finalizing signature. " + "Has Redis evicted the ticket early or has Redis crashed during the signature process?"; LOG.error(errMsg, biljettId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, errMsg); } WebCertUser user = webCertUserService.getUser(); Utkast utkast = getUtkastForSignering(signaturBiljett.getIntygsId(), signaturBiljett.getVersion(), user); SignaturBiljett finishedSignaturBiljett = xmlUnderskriftService.finalizeSignature(signaturBiljett, signatur, certifikat, utkast, user); finalizeSignature(utkast, user); return finishedSignaturBiljett; } }
UnderskriftServiceImpl implements UnderskriftService { @Override public SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat) { SignaturBiljett signaturBiljett = redisTicketTracker.findBiljett(biljettId); if (signaturBiljett == null) { String errMsg = "No SignaturBiljett found for ticketId '{}' when finalizing signature. " + "Has Redis evicted the ticket early or has Redis crashed during the signature process?"; LOG.error(errMsg, biljettId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, errMsg); } WebCertUser user = webCertUserService.getUser(); Utkast utkast = getUtkastForSignering(signaturBiljett.getIntygsId(), signaturBiljett.getVersion(), user); SignaturBiljett finishedSignaturBiljett = xmlUnderskriftService.finalizeSignature(signaturBiljett, signatur, certifikat, utkast, user); finalizeSignature(utkast, user); return finishedSignaturBiljett; }  }
UnderskriftServiceImpl implements UnderskriftService { @Override public SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat) { SignaturBiljett signaturBiljett = redisTicketTracker.findBiljett(biljettId); if (signaturBiljett == null) { String errMsg = "No SignaturBiljett found for ticketId '{}' when finalizing signature. " + "Has Redis evicted the ticket early or has Redis crashed during the signature process?"; LOG.error(errMsg, biljettId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, errMsg); } WebCertUser user = webCertUserService.getUser(); Utkast utkast = getUtkastForSignering(signaturBiljett.getIntygsId(), signaturBiljett.getVersion(), user); SignaturBiljett finishedSignaturBiljett = xmlUnderskriftService.finalizeSignature(signaturBiljett, signatur, certifikat, utkast, user); finalizeSignature(utkast, user); return finishedSignaturBiljett; }  @Override SignaturBiljett startSigningProcess(String intygsId, String intygsTyp, long version, SignMethod signMethod,
        String ticketId); @Override SignaturBiljett fakeSignature(String intygsId, String intygsTyp, long version, String ticketId); @Override SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat); @Override SignaturBiljett grpSignature(String biljettId, byte[] signatur); @Override SignaturBiljett signeringsStatus(String ticketId); }
UnderskriftServiceImpl implements UnderskriftService { @Override public SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat) { SignaturBiljett signaturBiljett = redisTicketTracker.findBiljett(biljettId); if (signaturBiljett == null) { String errMsg = "No SignaturBiljett found for ticketId '{}' when finalizing signature. " + "Has Redis evicted the ticket early or has Redis crashed during the signature process?"; LOG.error(errMsg, biljettId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, errMsg); } WebCertUser user = webCertUserService.getUser(); Utkast utkast = getUtkastForSignering(signaturBiljett.getIntygsId(), signaturBiljett.getVersion(), user); SignaturBiljett finishedSignaturBiljett = xmlUnderskriftService.finalizeSignature(signaturBiljett, signatur, certifikat, utkast, user); finalizeSignature(utkast, user); return finishedSignaturBiljett; }  @Override SignaturBiljett startSigningProcess(String intygsId, String intygsTyp, long version, SignMethod signMethod,
        String ticketId); @Override SignaturBiljett fakeSignature(String intygsId, String intygsTyp, long version, String ticketId); @Override SignaturBiljett netidSignature(String biljettId, byte[] signatur, String certifikat); @Override SignaturBiljett grpSignature(String biljettId, byte[] signatur); @Override SignaturBiljett signeringsStatus(String ticketId);  }