Search in sources :

Example 6 with Role

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

the class TakServiceImplTest method createUser.

private IntygUser createUser(String roleName, Privilege p, Map<String, Feature> features, String origin) {
    IntygUser user = new IntygUser(HSAID_OK);
    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;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Privilege(se.inera.intyg.infra.security.common.model.Privilege) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser)

Example 7 with Role

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

the class IntygServiceRevokeTest method buildWebCertUser.

private WebCertUser buildWebCertUser(HoSPersonal person) {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser user = new WebCertUser();
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
    user.setParameters(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    user.setNamn(person.getFullstandigtNamn());
    user.setHsaId(person.getPersonId());
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 8 with Role

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

the class IntygServiceSendTest method createUser.

private WebCertUser createUser() {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser user = new WebCertUser();
    user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
    user.setParameters(new IntegrationParameters("", "", "", "", "", "", "", "", "", false, false, false, true));
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 9 with Role

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

the class LogServiceImplTest method createUser.

private WebCertUser createUser() {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    Vardenhet ve = new Vardenhet("VARDENHET_ID", "Vårdenheten");
    Vardgivare vg = new Vardgivare("VARDGIVARE_ID", "Vårdgivaren");
    vg.setVardenheter(Collections.singletonList(ve));
    WebCertUser user = new WebCertUser();
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    user.setHsaId("HSAID");
    user.setNamn("Markus Gran");
    user.setVardgivare(Collections.singletonList(vg));
    user.changeValdVardenhet("VARDENHET_ID");
    user.setTitel("Överläkare");
    user.setMiuNamnPerEnhetsId(buildMiUMap());
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 10 with Role

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

the class GrpCollectPollerTest method buildAuthentication.

private SecurityContext buildAuthentication() {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser user = new WebCertUser();
    user.setRoles(AuthoritiesResolverUtil.toMap(role));
    user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    user.setPersonId(PERSON_ID);
    Authentication authentication = new TestingAuthenticationToken(user, null);
    SecurityContext securityContext = new SecurityContextImpl();
    securityContext.setAuthentication(authentication);
    return securityContext;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Aggregations

Role (se.inera.intyg.infra.security.common.model.Role)22 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)5 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)5 Privilege (se.inera.intyg.infra.security.common.model.Privilege)5 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)3 Authentication (org.springframework.security.core.Authentication)2 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 JsonPropertyDescription (com.fasterxml.jackson.annotation.JsonPropertyDescription)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Before (org.junit.Before)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1