@Test public void createSignatureRequestDTO() throws ModuleNotFoundException { when(dssMetadataService.getDssActionUrl()).thenReturn("ActionUrl"); when(webCertUserService.getUser()).thenReturn(user); when(user.getPersonId()).thenReturn("191212121212"); when(utkastRepository.findById(Mockito.anyString())).thenReturn(utkastOptional); when(utkastOptional.orElse(Mockito.any())).thenReturn(utkast); when(utkast.getIntygsTyp()).thenReturn("intygsTyp"); when(utkast.getPatientPersonnummer()).thenReturn(patient); when(patient.getPersonnummerWithDash()).thenReturn("19121212-1212"); when(dssSignMessageService.signSignRequest(Mockito.any())) .thenReturn("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"); when(moduleRegistry.getIntygModule(anyString())) .thenReturn(new IntygModule("intygsTyp", "intygsTyp", null, null, "intygsTyp", null, null, null, null, false, false)); ReflectionTestUtils.setField(dssSignatureService, "dssClientEntityHostUrl", "https: ReflectionTestUtils.setField(dssSignatureService, "dssClientResponseHostUrl", "https: ReflectionTestUtils.setField(dssSignatureService, "customerId", "AnUn3ss3c@ary_Long--$@ClientIDwithr4nd0mCharacters"); ReflectionTestUtils.setField(dssSignatureService, "applicationId", "App/ID\\With--w€|rd__CH@r$"); ReflectionTestUtils.setField(dssSignatureService, "idpUrl", "https: ReflectionTestUtils.setField(dssSignatureService, "serviceUrl", "https: var signMessageTemplate = "Härmed skriver jag under {intygsTyp} utfärdat för {patientPnr}<br/><br/>Intygs-id: {intygsId}"; ReflectionTestUtils.setField(dssSignatureService, "signMessage", signMessageTemplate); var sb = SignaturBiljettBuilder.aSignaturBiljett("ticketId", SignaturTyp.XMLDSIG, SignMethod.SIGN_SERVICE).withIntygsId("intygsId") .withHash("HASH").build(); var createSignatureRequestDTOResponse = dssSignatureService.createSignatureRequestDTO(sb); assertNotNull(createSignatureRequestDTOResponse); verify(dssSignMessageService).signSignRequest(signRequestCaptor.capture()); var capturedSignRequest = signRequestCaptor.getValue(); assertNotNull(capturedSignRequest); assertEquals("Profile", "http: assertNotNull(capturedSignRequest.getInputDocuments()); assertNotNull(capturedSignRequest.getOptionalInputs()); assertNotNull(capturedSignRequest.getOptionalInputs().getAny()); assertEquals(1, capturedSignRequest.getOptionalInputs().getAny().size()); var signRequestExtensionTypeJAXBElement = (JAXBElement<SignRequestExtensionType>) capturedSignRequest.getOptionalInputs().getAny() .get(0); assertNotNull(signRequestExtensionTypeJAXBElement); var actualSignMessageBytes = signRequestExtensionTypeJAXBElement.getValue().getSignMessage().getMessage(); assertNotNull(actualSignMessageBytes); var actualSignMessage = new String(actualSignMessageBytes, StandardCharsets.UTF_8); var expectedSignMessage = signMessageTemplate.replace("{intygsTyp}", "intygsTyp").replace("{patientPnr}", "19121212-1212") .replace("{intygsId}", "intygsId"); assertEquals(expectedSignMessage, actualSignMessage); }
public DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb) { var dateTimeNow = DateTime.now(); var dssSignRequestDTO = new DssSignRequestDTO(); String transactionID = sb.getTicketId(); dssSignRequestDTO.setTransactionId(transactionID); dssSignRequestDTO.setActionUrl(dssMetadataService.getDssActionUrl()); String signRequest = dssSignMessageService.signSignRequest(createSignRequest(dateTimeNow, sb, transactionID)); String base64EncodedSignRequest = Base64.getEncoder().encodeToString(signRequest.getBytes(Charset.forName("UTF-8"))); dssSignRequestDTO.setSignRequest(base64EncodedSignRequest); return dssSignRequestDTO; }
DssSignatureService { public DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb) { var dateTimeNow = DateTime.now(); var dssSignRequestDTO = new DssSignRequestDTO(); String transactionID = sb.getTicketId(); dssSignRequestDTO.setTransactionId(transactionID); dssSignRequestDTO.setActionUrl(dssMetadataService.getDssActionUrl()); String signRequest = dssSignMessageService.signSignRequest(createSignRequest(dateTimeNow, sb, transactionID)); String base64EncodedSignRequest = Base64.getEncoder().encodeToString(signRequest.getBytes(Charset.forName("UTF-8"))); dssSignRequestDTO.setSignRequest(base64EncodedSignRequest); return dssSignRequestDTO; } }
DssSignatureService { public DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb) { var dateTimeNow = DateTime.now(); var dssSignRequestDTO = new DssSignRequestDTO(); String transactionID = sb.getTicketId(); dssSignRequestDTO.setTransactionId(transactionID); dssSignRequestDTO.setActionUrl(dssMetadataService.getDssActionUrl()); String signRequest = dssSignMessageService.signSignRequest(createSignRequest(dateTimeNow, sb, transactionID)); String base64EncodedSignRequest = Base64.getEncoder().encodeToString(signRequest.getBytes(Charset.forName("UTF-8"))); dssSignRequestDTO.setSignRequest(base64EncodedSignRequest); return dssSignRequestDTO; } @Autowired  DssSignatureService(DssMetadataService dssMetadataService, DssSignMessageService dssSignMessageService,
        WebCertUserService userService, UtkastRepository utkastRepository, UnderskriftService underskriftService,
        RedisTicketTracker redisTicketTracker, MonitoringLogService monitoringLogService, IntygModuleRegistry moduleRegistry); }
DssSignatureService { public DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb) { var dateTimeNow = DateTime.now(); var dssSignRequestDTO = new DssSignRequestDTO(); String transactionID = sb.getTicketId(); dssSignRequestDTO.setTransactionId(transactionID); dssSignRequestDTO.setActionUrl(dssMetadataService.getDssActionUrl()); String signRequest = dssSignMessageService.signSignRequest(createSignRequest(dateTimeNow, sb, transactionID)); String base64EncodedSignRequest = Base64.getEncoder().encodeToString(signRequest.getBytes(Charset.forName("UTF-8"))); dssSignRequestDTO.setSignRequest(base64EncodedSignRequest); return dssSignRequestDTO; } @Autowired  DssSignatureService(DssMetadataService dssMetadataService, DssSignMessageService dssSignMessageService,
        WebCertUserService userService, UtkastRepository utkastRepository, UnderskriftService underskriftService,
        RedisTicketTracker redisTicketTracker, MonitoringLogService monitoringLogService, IntygModuleRegistry moduleRegistry); boolean isUnitInIeWhitelist(String currentCareUnitHsaId); DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb); String createTransactionID(); @SuppressWarnings("unchecked") SignaturBiljett receiveSignResponse(String relayState, String eIdSignResponse); String findReturnErrorUrl(String intygsId, String ticketId); String findReturnUrl(String intygsId); SignaturBiljett updateSignatureTicketWithError(String relayState); }
DssSignatureService { public DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb) { var dateTimeNow = DateTime.now(); var dssSignRequestDTO = new DssSignRequestDTO(); String transactionID = sb.getTicketId(); dssSignRequestDTO.setTransactionId(transactionID); dssSignRequestDTO.setActionUrl(dssMetadataService.getDssActionUrl()); String signRequest = dssSignMessageService.signSignRequest(createSignRequest(dateTimeNow, sb, transactionID)); String base64EncodedSignRequest = Base64.getEncoder().encodeToString(signRequest.getBytes(Charset.forName("UTF-8"))); dssSignRequestDTO.setSignRequest(base64EncodedSignRequest); return dssSignRequestDTO; } @Autowired  DssSignatureService(DssMetadataService dssMetadataService, DssSignMessageService dssSignMessageService,
        WebCertUserService userService, UtkastRepository utkastRepository, UnderskriftService underskriftService,
        RedisTicketTracker redisTicketTracker, MonitoringLogService monitoringLogService, IntygModuleRegistry moduleRegistry); boolean isUnitInIeWhitelist(String currentCareUnitHsaId); DssSignRequestDTO createSignatureRequestDTO(SignaturBiljett sb); String createTransactionID(); @SuppressWarnings("unchecked") SignaturBiljett receiveSignResponse(String relayState, String eIdSignResponse); String findReturnErrorUrl(String intygsId, String ticketId); String findReturnUrl(String intygsId); SignaturBiljett updateSignatureTicketWithError(String relayState); static final String RESULTMAJOR_SUCCESS; static final String REQUESTED_SIGN_ALGORITHM; }