Update RolePolicyRepresentation fields from 'boolean' to 'Boolean'
closes #32117 Signed-off-by: mposolda <mposolda@gmail.com>
This commit is contained in:
parent
cb6eb187ac
commit
54a538b3ad
3 changed files with 14 additions and 11 deletions
|
@ -62,9 +62,10 @@ public class RolePolicyProvider implements PolicyProvider {
|
||||||
RoleModel role = realm.getRoleById(roleDefinition.getId());
|
RoleModel role = realm.getRoleById(roleDefinition.getId());
|
||||||
|
|
||||||
if (role != null) {
|
if (role != null) {
|
||||||
boolean hasRole = hasRole(identity, role, realm, authorizationProvider, policyRep.isFetchRoles());
|
boolean isFetchRoles = policyRep.isFetchRoles() != null && policyRep.isFetchRoles();
|
||||||
|
boolean hasRole = hasRole(identity, role, realm, authorizationProvider, isFetchRoles);
|
||||||
|
|
||||||
if (!hasRole && roleDefinition.isRequired()) {
|
if (!hasRole && roleDefinition.isRequired() != null && roleDefinition.isRequired()) {
|
||||||
evaluation.deny();
|
evaluation.deny();
|
||||||
return;
|
return;
|
||||||
} else if (hasRole) {
|
} else if (hasRole) {
|
||||||
|
|
|
@ -142,7 +142,9 @@ public class RolePolicyProviderFactory implements PolicyProviderFactory<RolePoli
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRoles(Policy policy, RolePolicyRepresentation representation, AuthorizationProvider authorization) {
|
private void updateRoles(Policy policy, RolePolicyRepresentation representation, AuthorizationProvider authorization) {
|
||||||
policy.putConfig("fetchRoles", String.valueOf(representation.isFetchRoles()));
|
if (representation.isFetchRoles() != null) {
|
||||||
|
policy.putConfig("fetchRoles", String.valueOf(representation.isFetchRoles()));
|
||||||
|
}
|
||||||
updateRoles(policy, authorization, representation.getRoles());
|
updateRoles(policy, authorization, representation.getRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Set;
|
||||||
public class RolePolicyRepresentation extends AbstractPolicyRepresentation {
|
public class RolePolicyRepresentation extends AbstractPolicyRepresentation {
|
||||||
|
|
||||||
private Set<RoleDefinition> roles;
|
private Set<RoleDefinition> roles;
|
||||||
private boolean fetchRoles;
|
private Boolean fetchRoles;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -40,7 +40,7 @@ public class RolePolicyRepresentation extends AbstractPolicyRepresentation {
|
||||||
this.roles = roles;
|
this.roles = roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRole(String name, boolean required) {
|
public void addRole(String name, Boolean required) {
|
||||||
if (roles == null) {
|
if (roles == null) {
|
||||||
roles = new HashSet<>();
|
roles = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
@ -59,24 +59,24 @@ public class RolePolicyRepresentation extends AbstractPolicyRepresentation {
|
||||||
addRole(clientId + "/" + name, required);
|
addRole(clientId + "/" + name, required);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFetchRoles() {
|
public Boolean isFetchRoles() {
|
||||||
return fetchRoles;
|
return fetchRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFetchRoles(boolean fetchRoles) {
|
public void setFetchRoles(Boolean fetchRoles) {
|
||||||
this.fetchRoles = fetchRoles;
|
this.fetchRoles = fetchRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RoleDefinition implements Comparable<RoleDefinition> {
|
public static class RoleDefinition implements Comparable<RoleDefinition> {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private boolean required;
|
private Boolean required;
|
||||||
|
|
||||||
public RoleDefinition() {
|
public RoleDefinition() {
|
||||||
this(null, false);
|
this(null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleDefinition(String id, boolean required) {
|
public RoleDefinition(String id, Boolean required) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
@ -89,11 +89,11 @@ public class RolePolicyRepresentation extends AbstractPolicyRepresentation {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRequired() {
|
public Boolean isRequired() {
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequired(boolean required) {
|
public void setRequired(Boolean required) {
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue