Added setRoles

This commit is contained in:
Luca Frosini 2022-01-31 15:48:03 +01:00
parent 778a7cba0b
commit 6731b8f6a6
5 changed files with 22 additions and 4 deletions

View File

@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Authorization utils
## [v1.0.1-SNAPSHOT]
- Fixed getRoles for JWTSecret [#22754]
-
## [v1.0.0]
- First Release

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.common</groupId>
<artifactId>authorization-utils</artifactId>
<version>1.0.0</version>
<version>1.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -2,6 +2,7 @@ package org.gcube.common.authorization.utils.user;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@ -66,8 +67,9 @@ public class GCubeUser implements User {
return roles;
}
public void setRoles(Set<String> roles) {
this.roles = roles;
@Override
public void setRoles(Collection<String> roles) {
this.roles = new HashSet<>(roles);
}
@Override
public String getGivenName() {

View File

@ -15,6 +15,9 @@ public class KeycloakUser extends AccessToken implements User {
*/
private static final long serialVersionUID = -7083648026885406300L;
protected Collection<String> roles;
@Override
@JsonIgnore
public String getUsername() {
@ -24,7 +27,13 @@ public class KeycloakUser extends AccessToken implements User {
@Override
@JsonIgnore
public Collection<String> getRoles() {
return getRealmAccess().getRoles();
return roles;
}
@Override
@JsonIgnore
public void setRoles(Collection<String> roles) {
this.roles = roles;
}
@Override

View File

@ -11,6 +11,8 @@ public interface User {
public Collection<String> getRoles();
public void setRoles(Collection<String> roles);
public String getGivenName();
public String getFamilyName();