Search in sources :

Example 1 with AuthoritiesValidator

use of se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImpl method validateSekretessmarkeringOchIntygsTyp.

private void validateSekretessmarkeringOchIntygsTyp(ResultValidator errors, Personnummer personnummer, TypAvIntyg typAvIntyg, IntygUser user) {
    AuthoritiesValidator authoritiesValidator = new AuthoritiesValidator();
    String intygsTyp = IntygsTypToInternal.convertToInternalIntygsTyp(typAvIntyg.getCode());
    if (!authoritiesValidator.given(user, intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).privilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG).isVerified()) {
        errors.addError("Du saknar behörighet att skapa intyg med denna typ.");
    } else {
        validateBusinessRulesForSekretessmarkeradPatient(errors, personnummer, intygsTyp, user);
    }
}
Also used : AuthoritiesValidator(se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator)

Example 2 with AuthoritiesValidator

use of se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator in project webcert by sklintyg.

the class CreateDraftCertificateValidatorImpl method validateSekretessmarkeringOchIntygsTyp.

private void validateSekretessmarkeringOchIntygsTyp(ResultValidator errors, Personnummer personnummer, TypAvUtlatande typAvUtlatande, IntygUser user) {
    // If intygstyp is NOT allowed to issue for sekretessmarkerad patient
    // we check sekretessmarkerad state through the PU-service.
    String intygsTyp = IntygsTypToInternal.convertToInternalIntygsTyp(typAvUtlatande.getCode());
    AuthoritiesValidator authoritiesValidator = new AuthoritiesValidator();
    if (!authoritiesValidator.given(user, intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).privilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG).isVerified()) {
        errors.addError("Du saknar behörighet att skapa intyg med denna typ.");
    } else {
        validateBusinessRulesForSekretessmarkeradPatient(errors, personnummer, intygsTyp, user);
    }
}
Also used : AuthoritiesValidator(se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator)

Example 3 with AuthoritiesValidator

use of se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator 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

AuthoritiesValidator (se.inera.intyg.infra.security.authorities.validation.AuthoritiesValidator)3 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)1