use of se.inera.intyg.infra.xmldsig.model.SignatureType 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;
}
Aggregations