Factorize "true" string
This commit is contained in:
parent
182824a3b4
commit
62eff08fcf
4 changed files with 14 additions and 10 deletions
|
@ -10,6 +10,7 @@ import jakarta.persistence.NoResultException;
|
|||
import de.captaingoldfish.scim.sdk.common.resources.Group;
|
||||
import de.captaingoldfish.scim.sdk.common.resources.multicomplex.Member;
|
||||
import de.captaingoldfish.scim.sdk.common.resources.complex.Meta;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.models.GroupModel;
|
||||
|
@ -47,7 +48,7 @@ public class GroupAdapter extends Adapter<GroupModel, Group> {
|
|||
.getGroupMembersStream(session.getContext().getRealm(), group)
|
||||
.map(x -> x.getId())
|
||||
.collect(Collectors.toSet());
|
||||
this.skip = StringUtils.equals(group.getFirstAttribute("scim-skip"), "true");
|
||||
this.skip = BooleanUtils.TRUE.equals(group.getFirstAttribute("scim-skip"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,7 @@ import de.captaingoldfish.scim.sdk.common.resources.complex.Name;
|
|||
import de.captaingoldfish.scim.sdk.common.resources.multicomplex.PersonRole;
|
||||
import de.captaingoldfish.scim.sdk.common.resources.complex.Meta;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
|
@ -119,17 +120,17 @@ public class UserAdapter extends Adapter<UserModel, User> {
|
|||
setLastName(user.getLastName());
|
||||
var rolesSet = new HashSet<String>();
|
||||
user.getGroupsStream().flatMap(g -> g.getRoleMappingsStream())
|
||||
.filter((r) -> StringUtils.equals(r.getFirstAttribute("scim"), "true"))
|
||||
.filter((r) -> BooleanUtils.TRUE.equals(r.getFirstAttribute("scim")))
|
||||
.map((r) -> r.getName())
|
||||
.forEach(r -> rolesSet.add(r));
|
||||
user.getRoleMappingsStream()
|
||||
.filter((r) -> StringUtils.equals(r.getFirstAttribute("scim"), "true"))
|
||||
.filter((r) -> BooleanUtils.TRUE.equals(r.getFirstAttribute("scim")))
|
||||
.map((r) -> r.getName())
|
||||
.forEach(r -> rolesSet.add(r));
|
||||
var roles = new String[rolesSet.size()];
|
||||
rolesSet.toArray(roles);
|
||||
setRoles(roles);
|
||||
this.skip = StringUtils.equals(user.getFirstAttribute("scim-skip"), "true");
|
||||
this.skip = BooleanUtils.TRUE.equals(user.getFirstAttribute("scim-skip"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package sh.libre.scim.event;
|
|||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.events.Event;
|
||||
|
@ -100,7 +101,7 @@ public class ScimEventListenerProvider implements EventListenerProvider {
|
|||
var groupId = matcher.group(2);
|
||||
LOGGER.infof("%s %s from %s", event.getOperationType(), userId, groupId);
|
||||
var group = getGroup(groupId);
|
||||
group.setSingleAttribute("scim-dirty", "true");
|
||||
group.setSingleAttribute("scim-dirty", BooleanUtils.TRUE);
|
||||
var user = getUser(userId);
|
||||
dispatcher.run(ScimDispatcher.SCOPE_USER, (client) -> client.replace(UserAdapter.class, user));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.component.ComponentModel;
|
||||
|
@ -74,14 +75,14 @@ public class ScimStorageProviderFactory
|
|||
.type(ProviderConfigProperty.BOOLEAN_TYPE)
|
||||
.label("Enable user propagation")
|
||||
.helpText("Should operation on users be propagated to this provider ?")
|
||||
.defaultValue("true")
|
||||
.defaultValue(BooleanUtils.TRUE)
|
||||
.add()
|
||||
.property()
|
||||
.name("propagation-group")
|
||||
.type(ProviderConfigProperty.BOOLEAN_TYPE)
|
||||
.label("Enable group propagation")
|
||||
.helpText("Should operation on groups be propagated to this provider ?")
|
||||
.defaultValue("true")
|
||||
.defaultValue(BooleanUtils.TRUE)
|
||||
.add()
|
||||
.property()
|
||||
.name("sync-import")
|
||||
|
@ -132,10 +133,10 @@ public class ScimStorageProviderFactory
|
|||
var realm = session.realms().getRealm(realmId);
|
||||
session.getContext().setRealm(realm);
|
||||
var dispatcher = new ScimDispatcher(session);
|
||||
if (StringUtils.equals(model.get("propagation-user"), "true")) {
|
||||
if (BooleanUtils.TRUE.equals(model.get("propagation-user"))) {
|
||||
dispatcher.runOne(model, (client) -> client.sync(UserAdapter.class, result));
|
||||
}
|
||||
if (StringUtils.equals(model.get("propagation-group"), "true")) {
|
||||
if (BooleanUtils.TRUE.equals(model.get("propagation-group"))) {
|
||||
dispatcher.runOne(model, (client) -> client.sync(GroupAdapter.class, result));
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ public class ScimStorageProviderFactory
|
|||
session.getContext().setRealm(realm);
|
||||
var dispatcher = new ScimDispatcher(session);
|
||||
for (var group : session.groups().getGroupsStream(realm)
|
||||
.filter(x -> StringUtils.equals(x.getFirstAttribute("scim-dirty"), "true")).toList()) {
|
||||
.filter(x -> BooleanUtils.TRUE.equals(x.getFirstAttribute("scim-dirty"))).toList()) {
|
||||
LOGGER.debug(group.getName() + " is dirty");
|
||||
dispatcher.run(ScimDispatcher.SCOPE_GROUP,
|
||||
(client) -> client.replace(GroupAdapter.class, group));
|
||||
|
|
Loading…
Reference in a new issue