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