Search in sources :

Example 6 with IntygUser

use of se.inera.intyg.infra.security.common.model.IntygUser in project webcert by sklintyg.

the class CommonFakeAuthenticationProvider method applyUserOrigin.

private void applyUserOrigin(Authentication token, Object details) {
    if (details instanceof IntygUser) {
        if (token.getCredentials() != null && ((FakeCredentials) token.getCredentials()).getOrigin() != null) {
            String origin = ((FakeCredentials) token.getCredentials()).getOrigin();
            try {
                // Type check.
                UserOriginType.valueOf(origin);
                ((IntygUser) details).setOrigin(origin);
            } catch (IllegalArgumentException e) {
                throw new AuthoritiesException("Could not set origin '" + origin + "'. Unknown, allowed types are NORMAL, DJUPINTEGRATION, UTHOPP");
            }
        }
    }
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) AuthoritiesException(se.inera.intyg.infra.security.authorities.AuthoritiesException) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser)

Example 7 with IntygUser

use of se.inera.intyg.infra.security.common.model.IntygUser in project webcert by sklintyg.

the class CommonFakeAuthenticationProvider method overrideSekretessMarkeringFromFakeCredentials.

private void overrideSekretessMarkeringFromFakeCredentials(Authentication token, Object details) {
    if (details instanceof IntygUser) {
        IntygUser user = (IntygUser) details;
        final FakeCredentials fakeCredentials = (FakeCredentials) token.getCredentials();
        // Only override if set
        if (fakeCredentials.getSekretessMarkerad() != null) {
            user.setSekretessMarkerad(fakeCredentials.getSekretessMarkerad());
        }
    }
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser)

Example 8 with IntygUser

use of se.inera.intyg.infra.security.common.model.IntygUser in project webcert by sklintyg.

the class WebcertUserDetailsService method buildUserPrincipal.

/**
 * Calls the default super() impl. from the base class and then builds a {@link WebCertUser} which is passed upwards
 * as Principal.
 *
 * @param credential
 *            The SAMLCredential.
 * @return
 *         WebCertUser as Principal.
 */
@Override
protected WebCertUser buildUserPrincipal(SAMLCredential credential) {
    IntygUser user = super.buildUserPrincipal(credential);
    WebCertUser webCertUser = new WebCertUser(user);
    webCertUser.setAnvandarPreference(anvandarMetadataRepository.getAnvandarPreference(webCertUser.getHsaId()));
    return webCertUser;
}
Also used : IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 9 with IntygUser

use of se.inera.intyg.infra.security.common.model.IntygUser in project webcert by sklintyg.

the class SignaturServiceImpl method getWebcertUserForSignering.

private WebCertUser getWebcertUserForSignering() {
    IntygUser user = webCertUserService.getUser();
    AuthoritiesValidator authoritiesValidator = new AuthoritiesValidator();
    if (!authoritiesValidator.given(user).privilege(AuthoritiesConstants.PRIVILEGE_SIGNERA_INTYG).isVerified()) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM, "User is not a doctor. Could not sign utkast.");
    }
    return (WebCertUser) user;
}
Also used : IntygUser(se.inera.intyg.infra.security.common.model.IntygUser) AuthoritiesValidator(se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Aggregations

IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)9 FakeCredentials (se.inera.intyg.webcert.web.auth.fake.FakeCredentials)4 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)3 Map (java.util.Map)2 AuthoritiesException (se.inera.intyg.infra.security.authorities.AuthoritiesException)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)2 TakResult (se.inera.intyg.webcert.integration.tak.model.TakResult)2 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)2 ResultValidator (se.inera.intyg.webcert.web.integration.validators.ResultValidator)2 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)2 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)1 AuthoritiesValidator (se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator)1 AuthenticationMethod (se.inera.intyg.infra.security.common.model.AuthenticationMethod)1 Privilege (se.inera.intyg.infra.security.common.model.Privilege)1 Role (se.inera.intyg.infra.security.common.model.Role)1 Utlatande (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v1.Utlatande)1 Intyg (se.riv.clinicalprocess.healthcond.certificate.createdraftcertificateresponder.v3.Intyg)1