Search in sources :

Example 21 with SignaturTicket

use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.

the class SignaturTicketTrackerTest method prune.

@Test
public void prune() {
    for (int i = 1; i < 100; i++) {
        tracker.trackTicket(new SignaturTicket("old-" + i, PAGAENDE_SIG_ID, BEARBETAR, "intygid", 1, LocalDateTime.now(), "1234", LocalDateTime.now().minusMinutes(6)));
        tracker.trackTicket(new SignaturTicket(String.valueOf(i), PAGAENDE_SIG_ID, BEARBETAR, "intygid", 1, LocalDateTime.now(), "1234", LocalDateTime.now()));
    }
    SignaturTicket tracked = tracker.getTicket("1");
    assertEquals(BEARBETAR, tracked.getStatus());
    assertNull(tracker.getTicket("old-1"));
}
Also used : SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) Test(org.junit.Test)

Example 22 with SignaturTicket

use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.

the class UtkastModuleApiController method klientSigneraUtkast.

/**
 * Signera utkast.
 *
 * @param biljettId biljett id
 * @return BiljettResponse
 */
@POST
@Path("/{intygsTyp}/{biljettId}/signeraklient")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM })
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public SignaturTicketResponse klientSigneraUtkast(@PathParam("intygsTyp") String intygsTyp, @PathParam("biljettId") String biljettId, @Context HttpServletRequest request, byte[] rawSignatur) {
    verifyIsAuthorizedToSignIntyg(intygsTyp);
    LOG.debug("Signerar intyg med biljettId {}", biljettId);
    if (rawSignatur.length == 0) {
        LOG.error("Inkommande signatur parameter saknas");
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Signatur saknas");
    }
    String rawSignaturString = fromBytesToString(rawSignatur);
    SignaturTicket ticket;
    try {
        ticket = signaturService.clientSignature(biljettId, rawSignaturString);
    } catch (OptimisticLockException | OptimisticLockingFailureException e) {
        ticket = signaturService.ticketStatus(biljettId);
        monitoringLogService.logUtkastConcurrentlyEdited(ticket.getIntygsId(), intygsTyp);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.CONCURRENT_MODIFICATION, e.getMessage());
    }
    request.getSession(true).removeAttribute(LAST_SAVED_DRAFT);
    return new SignaturTicketResponse(ticket);
}
Also used : OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) OptimisticLockException(javax.persistence.OptimisticLockException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) SignaturTicketResponse(se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 23 with SignaturTicket

use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.

the class UtkastModuleApiController method serverSigneraUtkastMedGrp.

/**
 * Signera utkast mha Bank ID GRP API.
 *
 * @param intygsId intyg id
 * @return SignaturTicketResponse
 */
@POST
@Path("/{intygsTyp}/{intygsId}/{version}/grp/signeraserver")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public SignaturTicketResponse serverSigneraUtkastMedGrp(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, @PathParam("version") long version, @Context HttpServletRequest request) {
    verifyIsAuthorizedToSignIntyg(intygsTyp);
    SignaturTicket ticket;
    try {
        ticket = grpSignaturService.startGrpAuthentication(intygsId, version);
    } catch (OptimisticLockException | OptimisticLockingFailureException e) {
        monitoringLogService.logUtkastConcurrentlyEdited(intygsId, intygsTyp);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.CONCURRENT_MODIFICATION, e.getMessage());
    }
    request.getSession(true).removeAttribute(LAST_SAVED_DRAFT);
    return new SignaturTicketResponse(ticket);
}
Also used : OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) OptimisticLockException(javax.persistence.OptimisticLockException) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) SignaturTicketResponse(se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 24 with SignaturTicket

use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.

the class UtkastModuleApiController method serverSigneraUtkast.

/**
 * Signera utkast. Endast fejkinloggning.
 *
 * @param intygsId intyg id
 * @return SignaturTicketResponse
 */
@POST
@Path("/{intygsTyp}/{intygsId}/{version}/signeraserver")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public SignaturTicketResponse serverSigneraUtkast(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, @PathParam("version") long version, @Context HttpServletRequest request) {
    verifyIsAuthorizedToSignIntyg(intygsTyp);
    SignaturTicket ticket;
    try {
        ticket = signaturService.serverSignature(intygsId, version);
    } catch (OptimisticLockException | OptimisticLockingFailureException e) {
        monitoringLogService.logUtkastConcurrentlyEdited(intygsId, intygsTyp);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.CONCURRENT_MODIFICATION, e.getMessage());
    }
    request.getSession(true).removeAttribute(LAST_SAVED_DRAFT);
    return new SignaturTicketResponse(ticket);
}
Also used : OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) OptimisticLockException(javax.persistence.OptimisticLockException) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) SignaturTicketResponse(se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 25 with SignaturTicket

use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.

the class UtkastModuleApiController method serverSigneraUtkastMedNias.

/**
 * Signera utkast mha NetiD Access Server (nias).
 *
 * @param intygsId intyg id
 * @return SignaturTicketResponse
 */
@POST
@Path("/{intygsTyp}/{intygsId}/{version}/nias/signeraserver")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public SignaturTicketResponse serverSigneraUtkastMedNias(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, @PathParam("version") long version, @Context HttpServletRequest request) {
    verifyIsAuthorizedToSignIntyg(intygsTyp);
    SignaturTicket ticket;
    try {
        ticket = niasSignaturService.startNiasAuthentication(intygsId, version);
    } catch (OptimisticLockException | OptimisticLockingFailureException e) {
        monitoringLogService.logUtkastConcurrentlyEdited(intygsId, intygsTyp);
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.CONCURRENT_MODIFICATION, e.getMessage());
    }
    request.getSession(true).removeAttribute(LAST_SAVED_DRAFT);
    return new SignaturTicketResponse(ticket);
}
Also used : OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) OptimisticLockException(javax.persistence.OptimisticLockException) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) SignaturTicketResponse(se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)28 Test (org.junit.Test)15 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)10 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 SignaturTicketResponse (se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse)6 OptimisticLockException (javax.persistence.OptimisticLockException)5 POST (javax.ws.rs.POST)5 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)5 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)3 SignResponse (com.secmaker.netid.nias.v1.SignResponse)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Optional (java.util.Optional)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Transactional (org.springframework.transaction.annotation.Transactional)1