Merge pull request #3002 from pedroigor/KEYCLOAK-3249
[KEYCLOAK-3249] - AuthorizationContext.hasScopePermission() gives NPE
This commit is contained in:
commit
80a67149af
2 changed files with 8 additions and 8 deletions
|
@ -16,8 +16,10 @@
|
|||
*/
|
||||
package org.keycloak.representations.idm.authorization;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +33,7 @@ public class Permission {
|
|||
@JsonProperty("resource_set_name")
|
||||
private final String resourceSetName;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private Set<String> scopes;
|
||||
|
||||
public Permission() {
|
||||
|
@ -52,6 +55,10 @@ public class Permission {
|
|||
}
|
||||
|
||||
public Set<String> getScopes() {
|
||||
if (this.scopes == null) {
|
||||
this.scopes = new HashSet<>();
|
||||
}
|
||||
|
||||
return this.scopes;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,11 +95,7 @@ public final class Permissions {
|
|||
resourceName = resource.getName();
|
||||
}
|
||||
|
||||
Set<String> scopes = null;
|
||||
|
||||
if (!permission.getScopes().isEmpty()) {
|
||||
scopes = permission.getScopes().stream().map(Scope::getName).collect(Collectors.toSet());
|
||||
}
|
||||
Set<String> scopes = permission.getScopes().stream().map(Scope::getName).collect(Collectors.toSet());
|
||||
|
||||
return new Permission(resourceId, resourceName, scopes);
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -111,9 +107,6 @@ public final class Permissions {
|
|||
|
||||
if (evalPermission == null) {
|
||||
evalPermission = permission;
|
||||
if (evalPermission.getScopes() != null && evalPermission.getScopes().isEmpty()) {
|
||||
evalPermission.setScopes(null);
|
||||
}
|
||||
perms.put(permission.getResourceSetId(), evalPermission);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue