use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImpl method serverSignature.
@Override
@Transactional("jpaTransactionManager")
public SignaturTicket serverSignature(String intygsId, long version) {
LOG.debug("Signera utkast '{}'", intygsId);
// On server side we need to create our own signature ticket
SignaturTicket ticket = createDraftHash(intygsId, version);
// Fetch Webcert user
WebCertUser user = getWebcertUserForSignering();
// Fetch the certificate
Utkast utkast = getUtkastForSignering(intygsId, ticket.getVersion(), user);
// Create and persist signature
ticket = createAndPersistSignature(utkast, ticket, "Signatur", user);
// Audit signing
monitoringService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod());
// Notify stakeholders when a draft has been signed
notificationService.sendNotificationForDraftSigned(utkast);
LogRequest logRequest = LogRequestFactory.createLogRequestFromUtkast(utkast);
logService.logSignIntyg(logRequest);
intygService.handleAfterSigned(utkast);
return ticketTracker.updateStatus(ticket.getId(), SignaturTicket.Status.SIGNERAD);
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImpl method finalizeClientSignature.
private SignaturTicket finalizeClientSignature(String ticketId, String rawSignatur, WebCertUser user) {
// Lookup signature ticket
SignaturTicket ticket = ticketTracker.getTicket(ticketId);
if (ticket == null) {
LOG.warn("Ticket '{}' hittades ej", ticketId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Biljett " + ticketId + " hittades ej");
}
LOG.debug("Klientsignering ticket '{}' intyg '{}'", ticket.getId(), ticket.getIntygsId());
// Fetch the draft
Utkast utkast = getUtkastForSignering(ticket.getIntygsId(), ticket.getVersion(), user);
// Create and persist the new signature
ticket = createAndPersistSignature(utkast, ticket, rawSignatur, user);
monitoringService.logIntygSigned(utkast.getIntygsId(), utkast.getIntygsTyp(), user.getHsaId(), user.getAuthenticationScheme(), utkast.getRelationKod());
// Notify stakeholders when certificate has been signed
notificationService.sendNotificationForDraftSigned(utkast);
LogRequest logRequest = LogRequestFactory.createLogRequestFromUtkast(utkast);
// Note that we explictly supplies the WebCertUser here. The BankID finalization is not executed in a HTTP
// request context and thus we need to supply the user instance manually.
logService.logSignIntyg(logRequest, logService.getLogUser(user));
intygService.handleAfterSigned(utkast);
return ticketTracker.updateStatus(ticket.getId(), SignaturTicket.Status.SIGNERAD);
}
use of se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket in project webcert by sklintyg.
the class SignaturServiceImpl method createSignaturTicket.
private SignaturTicket createSignaturTicket(String intygId, long pagaendeSigneringInternreferens, long version, String payload, LocalDateTime signeringstid) {
try {
String hash = createHash(payload);
String id = UUID.randomUUID().toString();
SignaturTicket statusTicket = new SignaturTicket(id, pagaendeSigneringInternreferens, SignaturTicket.Status.BEARBETAR, intygId, version, signeringstid, hash, LocalDateTime.now());
ticketTracker.trackTicket(statusTicket);
return statusTicket;
} catch (IllegalStateException e) {
LOG.error("Error occured when generating signing hash for intyg {}: {}", intygId, e);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.UNKNOWN_INTERNAL_PROBLEM, "Internal error signing intyg " + intygId + ", problem when creating signing ticket", e);
}
}
Aggregations