use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class IntygIntegrationController method resumeRedirectToIntyg.
@GET
@Path("/{certType}/{certId}/resume")
public Response resumeRedirectToIntyg(@Context UriInfo uriInfo, @PathParam(PARAM_CERT_TYPE) String intygTyp, @PathParam(PARAM_CERT_ID) String intygId, @DefaultValue("") @QueryParam(PARAM_ENHET_ID) String enhetId) {
Map<String, Object> params = new HashMap<>();
params.put("intygTyp", intygTyp);
params.put(PARAM_CERT_ID, intygId);
params.put(PARAM_ENHET_ID, enhetId);
// validate the request
validateRequest(params);
WebCertUser user = getWebCertUser();
// Reset state parameter telling us that we have been redirected to 'enhetsvaljaren'
user.getParameters().getState().setRedirectToEnhetsval(false);
return handleRedirectToIntyg(uriInfo, intygTyp, intygId, enhetId, user);
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser 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;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class WebCertUserServiceImpl method deleteUserPreference.
@Override
public void deleteUserPreference(String key) {
WebCertUser user = getUser();
String hsaId = user.getHsaId();
AnvandarPreference am = anvandarPreferenceRepository.findByHsaIdAndKey(hsaId, key);
if (am != null) {
anvandarPreferenceRepository.delete(am);
}
user.getAnvandarPreference().remove(key);
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class AbstractApiController method getEnhetIdsForCurrentUser.
protected List<String> getEnhetIdsForCurrentUser() {
WebCertUser webCertUser = webCertUserService.getUser();
List<String> vardenheterIds = webCertUser.getIdsOfSelectedVardenhet();
LOG.debug("Current user '{}' has assignments: {}", webCertUser.getHsaId(), vardenheterIds);
return vardenheterIds;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class OriginConverter method convert.
@Override
public String convert(ILoggingEvent event) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth == null) {
return NO_ORIGIN;
}
Object principal = auth.getPrincipal();
if (principal instanceof WebCertUser) {
WebCertUser user = (WebCertUser) auth.getPrincipal();
return user.getOrigin();
}
return NO_ORIGIN;
}
Aggregations