Search in sources :

Example 1 with AuthenticateRequestType

use of se.funktionstjanster.grp.v1.AuthenticateRequestType 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 AuthenticateRequestType

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

the class GrpSignaturServiceImpl method buildAuthRequest.

private AuthenticateRequestType buildAuthRequest(String personId, SignaturTicket draftHash) {
    AuthenticateRequestType authRequest = new AuthenticateRequestType();
    authRequest.setPersonalNumber(personId);
    authRequest.setTransactionId(draftHash.getId());
    authRequest.setPolicy(serviceId);
    authRequest.setProvider(BANK_ID_PROVIDER);
    authRequest.setDisplayName(displayName);
    return authRequest;
}
Also used : AuthenticateRequestType(se.funktionstjanster.grp.v1.AuthenticateRequestType)

Aggregations

AuthenticateRequestType (se.funktionstjanster.grp.v1.AuthenticateRequestType)2 Optional (java.util.Optional)1 GrpFault (se.funktionstjanster.grp.v1.GrpFault)1 OrderResponseType (se.funktionstjanster.grp.v1.OrderResponseType)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