Search in sources :

Example 1 with SignaturTicketResponse

use of se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse 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);
}
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 2 with SignaturTicketResponse

use of se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse 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);
}
Also used : 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) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with SignaturTicketResponse

use of se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse 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 4 with SignaturTicketResponse

use of se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse 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 5 with SignaturTicketResponse

use of se.inera.intyg.webcert.web.web.controller.moduleapi.dto.SignaturTicketResponse 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)

Aggregations

Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)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 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)5 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1