Search in sources :

Example 21 with Role

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

the class GrpSignaturServiceTest method createUser.

private WebCertUser createUser() {
    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));
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 22 with Role

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

the class UserResource method getUserRoles.

@GET
@Path("/role")
@Produces(MediaType.APPLICATION_JSON)
@JsonPropertyDescription("Get the roles for user in session")
public Response getUserRoles() {
    final WebCertUser user = webCertUserService.getUser();
    final Map<String, Role> roles = user.getRoles();
    final Set<String> roleStrings = roles.keySet();
    return Response.ok(roleStrings).build();
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Path(javax.ws.rs.Path) JsonPropertyDescription(com.fasterxml.jackson.annotation.JsonPropertyDescription) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

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