Remove use of Guava in services

Closes #23009
This commit is contained in:
stianst 2023-09-06 13:18:06 +02:00 committed by Stian Thorgersen
parent 5ee2ba9372
commit 211c027adb
10 changed files with 20 additions and 22 deletions

View file

@ -70,4 +70,4 @@ public class SecretGenerator {
return buf; return buf;
} }
} }

View file

@ -97,4 +97,4 @@ public class SSSDFederationProviderFactory implements UserStorageProviderFactory
public boolean isSupported() { public boolean isSupported() {
return AvailabilityChecker.isAvailable(); return AvailabilityChecker.isAvailable();
} }
} }

View file

@ -28,6 +28,10 @@ public class StringUtil {
return str != null && !"".equals(str.trim()); return str != null && !"".equals(str.trim());
} }
public static boolean isNullOrEmpty(String str) {
return str == null || str.isEmpty();
}
/** /**
* Calling: * Calling:
* <pre>joinValuesWithLogicalCondition("or", Arrays.asList("foo", "bar", "baz", "caz" ))</pre> * <pre>joinValuesWithLogicalCondition("or", Arrays.asList("foo", "bar", "baz", "caz" ))</pre>
@ -52,4 +56,4 @@ public class StringUtil {
return options.toString(); return options.toString();
} }
} }

View file

@ -17,7 +17,6 @@
package org.keycloak.authentication; package org.keycloak.authentication;
import com.google.common.collect.Sets;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.keycloak.authentication.actiontoken.ActionTokenContext; import org.keycloak.authentication.actiontoken.ActionTokenContext;
import org.keycloak.authentication.actiontoken.DefaultActionToken; import org.keycloak.authentication.actiontoken.DefaultActionToken;
@ -33,6 +32,7 @@ import org.keycloak.sessions.AuthenticationSessionModel;
import org.keycloak.utils.StringUtil; import org.keycloak.utils.StringUtil;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -94,7 +94,12 @@ public class AuthenticatorUtil {
final String callbacksFactories = authSession.getAuthNote(CALLBACKS_FACTORY_IDS_NOTE); final String callbacksFactories = authSession.getAuthNote(CALLBACKS_FACTORY_IDS_NOTE);
if (StringUtil.isNotBlank(callbacksFactories)) { if (StringUtil.isNotBlank(callbacksFactories)) {
return Sets.newHashSet(callbacksFactories.split(Constants.CFG_DELIMITER)); String[] split = callbacksFactories.split(Constants.CFG_DELIMITER);
Set<String> set = new HashSet<>(split.length);
for (String s : split) {
set.add(s);
}
return Collections.unmodifiableSet(set);
} else { } else {
return Collections.emptySet(); return Collections.emptySet();
} }

View file

@ -17,7 +17,6 @@
package org.keycloak.protocol.oidc; package org.keycloak.protocol.oidc;
import com.google.common.collect.Streams;
import org.keycloak.OAuth2Constants; import org.keycloak.OAuth2Constants;
import org.keycloak.authentication.ClientAuthenticator; import org.keycloak.authentication.ClientAuthenticator;
import org.keycloak.authentication.ClientAuthenticatorFactory; import org.keycloak.authentication.ClientAuthenticatorFactory;
@ -242,7 +241,7 @@ public class OIDCWellKnownProvider implements WellKnownProvider {
.map(ProviderFactory::getId); .map(ProviderFactory::getId);
if (includeNone) { if (includeNone) {
supportedAlgorithms = Streams.concat(supportedAlgorithms, Stream.of("none")); supportedAlgorithms = Stream.concat(supportedAlgorithms, Stream.of("none"));
} }
return supportedAlgorithms.collect(Collectors.toList()); return supportedAlgorithms.collect(Collectors.toList());
} }

View file

@ -18,18 +18,11 @@
package org.keycloak.protocol.oidc.grants.ciba; package org.keycloak.protocol.oidc.grants.ciba;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.google.common.collect.Streams;
import org.keycloak.crypto.ClientSignatureVerifierProvider;
import org.keycloak.crypto.SignatureProvider; import org.keycloak.crypto.SignatureProvider;
import org.keycloak.jose.jws.Algorithm; import org.keycloak.jose.jws.Algorithm;
import org.keycloak.models.CibaConfig; import org.keycloak.models.CibaConfig;
import org.keycloak.models.ClientModel; import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
import org.keycloak.provider.ProviderFactory;
import org.keycloak.validation.DefaultClientValidationProvider;
import org.keycloak.validation.ValidationContext; import org.keycloak.validation.ValidationContext;
import static org.keycloak.common.util.UriUtils.checkUrl; import static org.keycloak.common.util.UriUtils.checkUrl;

View file

@ -1,12 +1,12 @@
package org.keycloak.protocol.saml; package org.keycloak.protocol.saml;
import com.google.common.base.Strings;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.keycloak.models.AuthenticatedClientSessionModel; import org.keycloak.models.AuthenticatedClientSessionModel;
import org.keycloak.models.ClientModel; import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
import org.keycloak.protocol.saml.util.ArtifactBindingUtils; import org.keycloak.protocol.saml.util.ArtifactBindingUtils;
import org.keycloak.saml.common.constants.GeneralConstants; import org.keycloak.saml.common.constants.GeneralConstants;
import org.keycloak.utils.StringUtil;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -35,7 +35,7 @@ public class DefaultSamlArtifactResolver implements ArtifactResolver {
logger.tracef("Artifact response for artifact %s, is %s", artifact, artifactResponseString); logger.tracef("Artifact response for artifact %s, is %s", artifact, artifactResponseString);
if (Strings.isNullOrEmpty(artifactResponseString)) { if (StringUtil.isNullOrEmpty(artifactResponseString)) {
throw new ArtifactResolverProcessingException("Artifact not present in ClientSession."); throw new ArtifactResolverProcessingException("Artifact not present in ClientSession.");
} }

View file

@ -17,7 +17,6 @@
package org.keycloak.services.clientregistration.oidc; package org.keycloak.services.clientregistration.oidc;
import com.google.common.collect.Streams;
import org.keycloak.OAuth2Constants; import org.keycloak.OAuth2Constants;
import org.keycloak.authentication.ClientAuthenticator; import org.keycloak.authentication.ClientAuthenticator;
import org.keycloak.authentication.ClientAuthenticatorFactory; import org.keycloak.authentication.ClientAuthenticatorFactory;
@ -274,7 +273,7 @@ public class DescriptionConverter {
.map(ProviderFactory::getId); .map(ProviderFactory::getId);
if (includeNone) { if (includeNone) {
supportedAlgorithms = Streams.concat(supportedAlgorithms, Stream.of("none")); supportedAlgorithms = Stream.concat(supportedAlgorithms, Stream.of("none"));
} }
return supportedAlgorithms.collect(Collectors.toList()); return supportedAlgorithms.collect(Collectors.toList());
} }

View file

@ -18,7 +18,6 @@ package org.keycloak.services.resources.admin;
import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST;
import com.google.common.collect.Streams;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
@ -245,7 +244,7 @@ public class IdentityProviderResource {
private IdentityProviderFactory getIdentityProviderFactory() { private IdentityProviderFactory getIdentityProviderFactory() {
return Streams.concat(session.getKeycloakSessionFactory().getProviderFactoriesStream(IdentityProvider.class), return Stream.concat(session.getKeycloakSessionFactory().getProviderFactoriesStream(IdentityProvider.class),
session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class)) session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class))
.filter(providerFactory -> Objects.equals(providerFactory.getId(), identityProviderModel.getProviderId())) .filter(providerFactory -> Objects.equals(providerFactory.getId(), identityProviderModel.getProviderId()))
.map(IdentityProviderFactory.class::cast) .map(IdentityProviderFactory.class::cast)

View file

@ -17,7 +17,6 @@
package org.keycloak.services.resources.admin; package org.keycloak.services.resources.admin;
import com.google.common.collect.Streams;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
@ -281,7 +280,7 @@ public class IdentityProvidersResource {
} }
private Stream<ProviderFactory> getProviderFactories() { private Stream<ProviderFactory> getProviderFactories() {
return Streams.concat(session.getKeycloakSessionFactory().getProviderFactoriesStream(IdentityProvider.class), return Stream.concat(session.getKeycloakSessionFactory().getProviderFactoriesStream(IdentityProvider.class),
session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class)); session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class));
} }