Search in sources :

Example 1 with SignResponse

use of com.secmaker.netid.nias.v1.SignResponse 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;
}
Also used : SignResponse(com.secmaker.netid.nias.v1.SignResponse) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) StringReader(java.io.StringReader) SignatureType(se.inera.intyg.infra.xmldsig.model.SignatureType) SignaturTicket(se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 2 with SignResponse

use of com.secmaker.netid.nias.v1.SignResponse in project webcert by sklintyg.

the class NiasSignaturServiceImpl method sign.

@Override
public SignResponse sign(String personalNumber, String userVisibleData, String userNonVisibleData, String endUserInfo) {
    String xml = netiDAccessServerSoap.sign(personalNumber, userVisibleData, userNonVisibleData, endUserInfo);
    SignResponse response = JAXB.unmarshal(new StringReader(xml), SignResponse.class);
    return response;
}
Also used : SignResponse(com.secmaker.netid.nias.v1.SignResponse) StringReader(java.io.StringReader)

Aggregations

SignResponse (com.secmaker.netid.nias.v1.SignResponse)2 StringReader (java.io.StringReader)2 SignatureType (se.inera.intyg.infra.xmldsig.model.SignatureType)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