Search in sources :

Example 46 with WebCertUser

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);
}
Also used : HashMap(java.util.HashMap) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 47 with WebCertUser

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;
}
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 48 with WebCertUser

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);
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 49 with WebCertUser

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;
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 50 with WebCertUser

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;
}
Also used : Authentication(org.springframework.security.core.Authentication) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Aggregations

WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)217 Test (org.junit.Test)123 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)32 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)31 Personnummer (se.inera.intyg.schemas.contract.Personnummer)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)23 Role (se.inera.intyg.infra.security.common.model.Role)18 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)16 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)15 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)15 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)14 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)14 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)13 Feature (se.inera.intyg.infra.security.common.model.Feature)13 HashMap (java.util.HashMap)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)12 Transactional (org.springframework.transaction.annotation.Transactional)11 Path (javax.ws.rs.Path)10