Search in sources :

Example 1 with OrderResponseType

use of se.funktionstjanster.grp.v1.OrderResponseType in project webcert by sklintyg.

the class GrpSignaturServiceImpl method startGrpAuthentication.

@Override
public SignaturTicket startGrpAuthentication(String intygId, long version) {
    Utkast utkast = utkastRepository.findOne(intygId);
    validateUtkast(intygId, utkast);
    WebCertUser webCertUser = webCertUserService.getUser();
    validateWebCertUser(webCertUser);
    String personId = webCertUser.getPersonId();
    validatePersonId(personId);
    SignaturTicket draftHash = signaturService.createDraftHash(intygId, utkast.getVersion());
    AuthenticateRequestType authRequest = buildAuthRequest(personId, draftHash);
    OrderResponseType orderResponse;
    try {
        orderResponse = grpService.authenticate(authRequest);
    } catch (GrpFault grpFault) {
        signaturTicketTracker.updateStatus(draftHash.getId(), SignaturTicket.Status.OKAND);
        Optional<FaultStatusType> status = Optional.ofNullable(grpFault.getFaultInfo()).map(GrpFaultType::getFaultStatus);
        if (status.isPresent()) {
            LOG.warn("Fault signing utkast with id {} with GRP. FaultStatus: {}", intygId, status.get().name());
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.GRP_PROBLEM, status.get().name());
        } else {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.UNKNOWN_INTERNAL_PROBLEM, grpFault.getMessage());
        }
    }
    // If we could init the authentication, we create a SignaturTicket, reusing
    // the mechanism already present for SITHS
    String orderRef = orderResponse.getOrderRef();
    String transactionId = validateOrderResponseTxId(authRequest, orderResponse);
    startAsyncCollectPoller(orderRef, transactionId);
    return draftHash;
}
Also used : Optional(java.util.Optional) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) OrderResponseType(se.funktionstjanster.grp.v1.OrderResponseType) AuthenticateRequestType(se.funktionstjanster.grp.v1.AuthenticateRequestType) GrpFault(se.funktionstjanster.grp.v1.GrpFault) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 2 with OrderResponseType

use of se.funktionstjanster.grp.v1.OrderResponseType in project webcert by sklintyg.

the class GrpSignaturServiceTest method buildOrderResponse.

private OrderResponseType buildOrderResponse() {
    OrderResponseType resp = new OrderResponseType();
    resp.setTransactionId(TX_ID);
    resp.setOrderRef(ORDER_REF);
    return resp;
}
Also used : OrderResponseType(se.funktionstjanster.grp.v1.OrderResponseType)

Aggregations

OrderResponseType (se.funktionstjanster.grp.v1.OrderResponseType)2 Optional (java.util.Optional)1 AuthenticateRequestType (se.funktionstjanster.grp.v1.AuthenticateRequestType)1 GrpFault (se.funktionstjanster.grp.v1.GrpFault)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)1 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)1