use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class UtkastModuleApiController method signeraUtkast.
/**
* Skapa signeringshash.
*
* @param intygsId intyg id
* @return SignaturTicketResponse
*/
@POST
@Path("/{intygsTyp}/{intygsId}/{version}/signeringshash")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public SignaturTicketResponse signeraUtkast(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, @PathParam("version") long version) {
authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow();
SignaturTicket ticket;
try {
ticket = signaturService.createDraftHash(intygsId, version);
} catch (OptimisticLockException | OptimisticLockingFailureException e) {
monitoringLogService.logUtkastConcurrentlyEdited(intygsId, intygsTyp);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.CONCURRENT_MODIFICATION, e.getMessage());
}
return new SignaturTicketResponse(ticket);
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class UtkastModuleApiController method biljettStatus.
/**
* Hamta signeringsstatus.
*
* @param biljettId biljett id
* @return SignaturTicketResponse
*/
@GET
@Path("/{intygsTyp}/{biljettId}/signeringsstatus")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public SignaturTicketResponse biljettStatus(@PathParam("intygsTyp") String intygsTyp, @PathParam("biljettId") String biljettId) {
authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).orThrow();
SignaturTicket ticket = signaturService.ticketStatus(biljettId);
return new SignaturTicketResponse(ticket);
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class NiasSignaturServiceImpl method startNiasAuthentication.
@Override
public SignaturTicket startNiasAuthentication(String intygId, long version) {
Utkast utkast = utkastRepository.findOne(intygId);
validateUtkast(intygId, utkast);
WebCertUser webCertUser = webCertUserService.getUser();
validateWebCertUser(webCertUser);
// Try to use personnummer. If not possible, use hsaId instead. This is a temporary hack for testing.
String personId = webCertUser.getPersonId() != null ? webCertUser.getPersonId() : webCertUser.getHsaId();
// validatePersonId(personId);
SignaturTicket draftHash = signaturService.createDraftHash(intygId, utkast.getVersion());
// För NetID Access Server signering så behöver vi göra en XMLDSig signatur
// inklusive en ordentlig digest av canoniserad XML.
// Börja med att konvertera intyget till XML-format
// String xml = utkastModelToXmlConverterService.utkastToXml(utkast);
// SignatureType signatureType = xmldSigService.prepareSignature(xml);
byte[] digestValue = "temp".getBytes(Charset.forName("UTF-8"));
SignResponse response;
try {
String result = netiDAccessServerSoap.sign(personId, "Inera Webcert: Signera intyg " + utkast.getIntygsId(), new String(digestValue, Charset.forName("UTF-8")), null);
response = JAXB.unmarshal(new StringReader(result), SignResponse.class);
} catch (Exception ex) {
signaturTicketTracker.updateStatus(draftHash.getId(), SignaturTicket.Status.OKAND);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.UNKNOWN_INTERNAL_PROBLEM, ex.getMessage());
}
// If we could init the authentication, we create a SignaturTicket, reusing
// the mechanism already present for SITHS
String orderRef = response.getSignResult();
startAsyncNiasCollectPoller(orderRef, draftHash.getId(), new SignatureType());
return draftHash;
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method clientSignatureKOMPLTSuccess.
@Test
public void clientSignatureKOMPLTSuccess() throws IOException, ModuleNotFoundException {
when(pagaendeSigneringRepository.findOne(anyLong())).thenReturn(pagaendeSignering);
completedUtkast.setRelationKod(RelationKod.KOMPLT);
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
user.setHsaId("TSTNMT2321000156-1025");
SignaturTicket ticket = intygSignatureService.createDraftHash(INTYG_ID, completedUtkast.getVersion());
SignaturTicket status = intygSignatureService.ticketStatus(ticket.getId());
assertEquals(SignaturTicket.Status.BEARBETAR, status.getStatus());
String signature = buildSignature();
when(mockUtkastRepository.save(any(Utkast.class))).thenReturn(completedUtkast);
// Do the call
SignaturTicket signatureTicket = intygSignatureService.clientSignature(ticket.getId(), signature);
verify(intygService).storeIntyg(completedUtkast);
verify(notificationService).sendNotificationForDraftSigned(any(Utkast.class));
// Assert pdl log
verify(logService).logSignIntyg(any(LogRequest.class), isNull());
assertNotNull(signatureTicket);
assertNotNull(completedUtkast.getSignatur());
assertEquals(UtkastStatus.SIGNED, completedUtkast.getStatus());
// Assert ticket status has changed from BEARBETAR to SIGNERAD
status = intygSignatureService.ticketStatus(ticket.getId());
assertEquals(SignaturTicket.Status.SIGNERAD, status.getStatus());
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImplTest method clientSignatureSuccess.
@Test
public void clientSignatureSuccess() throws IOException {
when(mockUtkastRepository.findOne(INTYG_ID)).thenReturn(completedUtkast);
when(mockUtkastRepository.save(any(Utkast.class))).thenReturn(completedUtkast);
user.setHsaId("TSTNMT2321000156-1025");
SignaturTicket ticket = intygSignatureService.createDraftHash(INTYG_ID, completedUtkast.getVersion());
SignaturTicket status = intygSignatureService.ticketStatus(ticket.getId());
assertEquals(SignaturTicket.Status.BEARBETAR, status.getStatus());
String signature = buildSignature();
// Do the call
SignaturTicket signatureTicket = intygSignatureService.clientSignature(ticket.getId(), signature);
verify(intygService).storeIntyg(completedUtkast);
verify(notificationService).sendNotificationForDraftSigned(any(Utkast.class));
// Assert pdl log
verify(logService).logSignIntyg(any(LogRequest.class), isNull());
assertNotNull(signatureTicket);
assertNotNull(completedUtkast.getSignatur());
assertEquals(UtkastStatus.SIGNED, completedUtkast.getStatus());
// Assert ticket status has changed from BEARBETAR to SIGNERAD
status = intygSignatureService.ticketStatus(ticket.getId());
assertEquals(SignaturTicket.Status.SIGNERAD, status.getStatus());
}
Aggregations