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);
}
}
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);
}
}
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;
}
Aggregations