Skip to content

Commit

Permalink
Sync clients from latest Keycloak
Browse files Browse the repository at this point in the history
Signed-off-by: mposolda <[email protected]>
  • Loading branch information
mposolda committed Aug 15, 2024
1 parent f093048 commit a950a6c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ public static String replaceProperties(final String string, final Properties pro
if (props == null) {
return replaceProperties(string, (PropertyResolver) null);
}
return replaceProperties(string, new PropertyResolver() {
@Override
public String resolve(String property) {
return props.getProperty(property);
}
});
return replaceProperties(string, props::getProperty);
}

public static String replaceProperties(final String string, PropertyResolver resolver)
Expand Down Expand Up @@ -249,29 +244,6 @@ else if (PATH_SEPARATOR_ALIAS.equals(key))
return buffer.toString();
}

/**
* Try to resolve a "key" from the provided properties by
* checking if it is actually a "key1,key2", in which case
* try first "key1", then "key2". If all fails, return null.
*
* It also accepts "key1," and ",key2".
*
* @param key the key to resolve
* @param props the properties to use
* @return the resolved key or null
*/
private static String resolveCompositeKey(String key, final Properties props) {
if (props == null) {
return resolveCompositeKey(key, (PropertyResolver) null);
}
return resolveCompositeKey(key, new PropertyResolver() {
@Override
public String resolve(String property) {
return props.getProperty(property);
}
});
}

private static String resolveCompositeKey(String key, PropertyResolver resolver)
{
String value = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class RolePolicyRepresentation extends AbstractPolicyRepresentation {

private Set<RoleDefinition> roles;
private boolean fetchRoles;
private Boolean fetchRoles;

@Override
public String getType() {
Expand All @@ -40,7 +40,7 @@ public void setRoles(Set<RoleDefinition> roles) {
this.roles = roles;
}

public void addRole(String name, boolean required) {
public void addRole(String name, Boolean required) {
if (roles == null) {
roles = new HashSet<>();
}
Expand All @@ -59,24 +59,24 @@ public void addClientRole(String clientId, String name, boolean required) {
addRole(clientId + "/" + name, required);
}

public boolean isFetchRoles() {
public Boolean isFetchRoles() {
return fetchRoles;
}

public void setFetchRoles(boolean fetchRoles) {
public void setFetchRoles(Boolean fetchRoles) {
this.fetchRoles = fetchRoles;
}

public static class RoleDefinition implements Comparable<RoleDefinition> {

private String id;
private boolean required;
private Boolean required;

public RoleDefinition() {
this(null, false);
}

public RoleDefinition(String id, boolean required) {
public RoleDefinition(String id, Boolean required) {
this.id = id;
this.required = required;
}
Expand All @@ -89,11 +89,11 @@ public void setId(String id) {
this.id = id;
}

public boolean isRequired() {
public Boolean isRequired() {
return required;
}

public void setRequired(boolean required) {
public void setRequired(Boolean required) {
this.required = required;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ public static String replaceProperties(final String string, final Properties pro
if (props == null) {
return replaceProperties(string, (PropertyResolver) null);
}
return replaceProperties(string, new PropertyResolver() {
@Override
public String resolve(String property) {
return props.getProperty(property);
}
});
return replaceProperties(string, props::getProperty);
}

public static String replaceProperties(final String string, PropertyResolver resolver)
Expand Down Expand Up @@ -249,29 +244,6 @@ else if (PATH_SEPARATOR_ALIAS.equals(key))
return buffer.toString();
}

/**
* Try to resolve a "key" from the provided properties by
* checking if it is actually a "key1,key2", in which case
* try first "key1", then "key2". If all fails, return null.
*
* It also accepts "key1," and ",key2".
*
* @param key the key to resolve
* @param props the properties to use
* @return the resolved key or null
*/
private static String resolveCompositeKey(String key, final Properties props) {
if (props == null) {
return resolveCompositeKey(key, (PropertyResolver) null);
}
return resolveCompositeKey(key, new PropertyResolver() {
@Override
public String resolve(String property) {
return props.getProperty(property);
}
});
}

private static String resolveCompositeKey(String key, PropertyResolver resolver)
{
String value = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class RolePolicyRepresentation extends AbstractPolicyRepresentation {

private Set<RoleDefinition> roles;
private boolean fetchRoles;
private Boolean fetchRoles;

@Override
public String getType() {
Expand All @@ -40,7 +40,7 @@ public void setRoles(Set<RoleDefinition> roles) {
this.roles = roles;
}

public void addRole(String name, boolean required) {
public void addRole(String name, Boolean required) {
if (roles == null) {
roles = new HashSet<>();
}
Expand All @@ -59,24 +59,24 @@ public void addClientRole(String clientId, String name, boolean required) {
addRole(clientId + "/" + name, required);
}

public boolean isFetchRoles() {
public Boolean isFetchRoles() {
return fetchRoles;
}

public void setFetchRoles(boolean fetchRoles) {
public void setFetchRoles(Boolean fetchRoles) {
this.fetchRoles = fetchRoles;
}

public static class RoleDefinition implements Comparable<RoleDefinition> {

private String id;
private boolean required;
private Boolean required;

public RoleDefinition() {
this(null, false);
}

public RoleDefinition(String id, boolean required) {
public RoleDefinition(String id, Boolean required) {
this.id = id;
this.required = required;
}
Expand All @@ -89,11 +89,11 @@ public void setId(String id) {
this.id = id;
}

public boolean isRequired() {
public Boolean isRequired() {
return required;
}

public void setRequired(boolean required) {
public void setRequired(Boolean required) {
this.required = required;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ public static String replaceProperties(final String string, final Properties pro
if (props == null) {
return replaceProperties(string, (PropertyResolver) null);
}
return replaceProperties(string, new PropertyResolver() {
@Override
public String resolve(String property) {
return props.getProperty(property);
}
});
return replaceProperties(string, props::getProperty);
}

public static String replaceProperties(final String string, PropertyResolver resolver)
Expand Down Expand Up @@ -249,29 +244,6 @@ else if (PATH_SEPARATOR_ALIAS.equals(key))
return buffer.toString();
}

/**
* Try to resolve a "key" from the provided properties by
* checking if it is actually a "key1,key2", in which case
* try first "key1", then "key2". If all fails, return null.
*
* It also accepts "key1," and ",key2".
*
* @param key the key to resolve
* @param props the properties to use
* @return the resolved key or null
*/
private static String resolveCompositeKey(String key, final Properties props) {
if (props == null) {
return resolveCompositeKey(key, (PropertyResolver) null);
}
return resolveCompositeKey(key, new PropertyResolver() {
@Override
public String resolve(String property) {
return props.getProperty(property);
}
});
}

private static String resolveCompositeKey(String key, PropertyResolver resolver)
{
String value = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class RolePolicyRepresentation extends AbstractPolicyRepresentation {

private Set<RoleDefinition> roles;
private boolean fetchRoles;
private Boolean fetchRoles;

@Override
public String getType() {
Expand All @@ -40,7 +40,7 @@ public void setRoles(Set<RoleDefinition> roles) {
this.roles = roles;
}

public void addRole(String name, boolean required) {
public void addRole(String name, Boolean required) {
if (roles == null) {
roles = new HashSet<>();
}
Expand All @@ -59,24 +59,24 @@ public void addClientRole(String clientId, String name, boolean required) {
addRole(clientId + "/" + name, required);
}

public boolean isFetchRoles() {
public Boolean isFetchRoles() {
return fetchRoles;
}

public void setFetchRoles(boolean fetchRoles) {
public void setFetchRoles(Boolean fetchRoles) {
this.fetchRoles = fetchRoles;
}

public static class RoleDefinition implements Comparable<RoleDefinition> {

private String id;
private boolean required;
private Boolean required;

public RoleDefinition() {
this(null, false);
}

public RoleDefinition(String id, boolean required) {
public RoleDefinition(String id, Boolean required) {
this.id = id;
this.required = required;
}
Expand All @@ -89,11 +89,11 @@ public void setId(String id) {
this.id = id;
}

public boolean isRequired() {
public Boolean isRequired() {
return required;
}

public void setRequired(boolean required) {
public void setRequired(Boolean required) {
this.required = required;
}

Expand Down

0 comments on commit a950a6c

Please sign in to comment.