use of se.inera.intyg.infra.security.common.model.Role in project webcert by sklintyg.
the class PageControllerTest method createMockUser.
private WebCertUser createMockUser(boolean doctor, String... features) {
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
if (!doctor) {
role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_ADMIN);
}
WebCertUser user = new WebCertUser();
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
user.setVardgivare(Collections.singletonList(createMockVardgivare()));
user.setFeatures(Stream.of(features).collect(Collectors.toMap(Function.identity(), s -> {
Feature feature = new Feature();
feature.setName(s);
feature.setGlobal(true);
feature.setIntygstyper(Collections.singletonList(INTYG_TYP_FK7263));
return feature;
})));
return user;
}
use of se.inera.intyg.infra.security.common.model.Role in project webcert by sklintyg.
the class IntygIntegrationControllerTest method createUser.
private WebCertUser createUser(String roleName, Privilege p, Map<String, Feature> features, String origin) {
WebCertUser user = new WebCertUser();
HashMap<String, Privilege> pMap = new HashMap<>();
pMap.put(p.getName(), p);
user.setAuthorities(pMap);
user.setOrigin(origin);
user.setFeatures(features);
HashMap<String, Role> rMap = new HashMap<>();
Role role = new Role();
role.setName(roleName);
rMap.put(roleName, role);
user.setRoles(rMap);
Vardgivare vg = new Vardgivare();
vg.setId("vg1");
Vardenhet ve = new Vardenhet();
ve.setVardgivareHsaId("vg1");
ve.setId(ENHETSID);
vg.setVardenheter(Arrays.asList(ve));
user.setVardgivare(Arrays.asList(vg));
return user;
}
use of se.inera.intyg.infra.security.common.model.Role in project webcert by sklintyg.
the class IntygIntegrationServiceImplTest method createUser.
private WebCertUser createUser(String roleName, Privilege p, Map<String, Feature> features, String origin) {
WebCertUser user = new WebCertUser();
HashMap<String, Privilege> pMap = new HashMap<>();
pMap.put(p.getName(), p);
user.setAuthorities(pMap);
user.setOrigin(origin);
user.setFeatures(features);
HashMap<String, Role> rMap = new HashMap<>();
Role role = new Role();
role.setName(roleName);
rMap.put(roleName, role);
user.setRoles(rMap);
return user;
}
use of se.inera.intyg.infra.security.common.model.Role in project webcert by sklintyg.
the class StatModuleApiControllerTest method setupDataAndExpectations.
@Before
public void setupDataAndExpectations() {
fragaSvarStatsMap = new HashMap<>();
fragaSvarStatsMap.put("VE1", 2L);
fragaSvarStatsMap.put("VE1M1", 3L);
fragaSvarStatsMap.put("VE1M2", 3L);
fragaSvarStatsMap.put("VE2", 2L);
fragaSvarStatsMap.put("VE3", 1L);
arendeStatsMap = new HashMap<>();
arendeStatsMap.put("VE1", 2L);
arendeStatsMap.put("VE1M1", 3L);
arendeStatsMap.put("VE1M2", 3L);
arendeStatsMap.put("VE2", 2L);
arendeStatsMap.put("VE3", 1L);
intygStatsMap = new HashMap<>();
intygStatsMap.put("VE1M1", 1L);
intygStatsMap.put("VE1M2", 2L);
intygStatsMap.put("VE2", 2L);
mockUser = new WebCertUser();
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
mockUser.setRoles(AuthoritiesResolverUtil.toMap(role));
mockUser.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
ve1 = new Vardenhet("VE1", "Vardenhet1");
ve1.getMottagningar().add(new Mottagning("VE1M1", "Mottagning1"));
ve1.getMottagningar().add(new Mottagning("VE1M2", "Mottagning2"));
ve2 = new Vardenhet("VE2", "Vardenhet2");
ve2.getMottagningar().add(new Mottagning("VE2M1", "Mottagning3"));
ve3 = new Vardenhet("VE3", "Vardenhet3");
ve4 = new Vardenhet("VE4", "Vardenhet4");
Vardgivare vg = new Vardgivare("VG1", "Vardgivaren");
vg.setVardenheter(Arrays.asList(ve1, ve2, ve3, ve4));
mockUser.setVardgivare(Collections.singletonList(vg));
mockUser.setValdVardgivare(vg);
when(authoritiesHelper.getIntygstyperForPrivilege(any(UserDetails.class), anyString())).thenReturn(Stream.of("fk7263").collect(Collectors.toSet()));
when(webCertUserService.getUser()).thenReturn(mockUser);
}
use of se.inera.intyg.infra.security.common.model.Role in project webcert by sklintyg.
the class ElegWebCertUserDetailsService method createUser.
// - - - - - Default scope - - - - -
protected WebCertUser createUser(SAMLCredential samlCredential) {
String personId = elegAuthenticationAttributeHelper.getAttribute(samlCredential, CgiElegAssertion.PERSON_ID_ATTRIBUTE);
assertHosPersonIsAuthorized(personId);
HoSPersonType hosPerson = getHosPerson(personId);
if (hosPerson == null) {
throw new IllegalArgumentException("No HSAPerson found for personId specified in SAML ticket");
}
// Lookup user's role
Role role = lookupUserRole();
return createWebCertUser(hosPerson, role, samlCredential);
}
Aggregations