Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.module.ModuleDependency;
import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.jboss.modules.ModuleClassLoader;
import org.jboss.modules.ModuleLoader;

/**
Expand All @@ -47,10 +46,4 @@ protected void addPlatformSpecificModules(DeploymentPhaseContext phaseContext, M
throw new RuntimeException("Legacy WildFly security layer is no longer supported by the Keycloak WildFly adapter");
}
}

private boolean isJakarta() {
ClassLoader classLoader = getClass().getClassLoader();
String classLoaderName = (classLoader instanceof ModuleClassLoader ? ((ModuleClassLoader) classLoader).getName() : "");
return classLoaderName.contains("jakarta");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,6 @@ public static <A extends AccessibleObject> A unsetAccessible(A member) {
return member;
}

private static String buildSetFieldValueErrorMessage(Field field, Object obj, Object value) {
return String.format("Exception setting [%s] field on object [%s] to value [%s]", field.getName(), obj, value);
}

private static String buildGetFieldValueErrorMessage(Field field, Object obj) {
return String.format("Exception reading [%s] field from object [%s].", field.getName(), obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ private void bootReload() {
}
}

private void onInvalidCertificate() {
logger.info("On certificate exception");
blockingManager.runBlocking(this::reloadCertificate, "invalid-certificate");
}

private void onCertificateReloadResponse(Address address, Void unused, Throwable throwable) {
if (throwable != null) {
logger.warnf(throwable, "Node %s failed to handle JGroups certificate reload notification.", address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1092,11 +1092,6 @@ public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, String searc
return getGroupDelegate().getTopLevelGroupsStream(realm, search, exact, first, max);
}

private boolean hasInvalidation(RealmModel realm, String cacheKey) {
return invalidations.contains(cacheKey) || listInvalidations.contains(cacheKey)
|| listInvalidations.contains(realm.getId());
}

@Override
public Stream<GroupModel> searchForGroupByNameStream(RealmModel realm, String search, Integer first, Integer max) {
return getGroupDelegate().searchForGroupByNameStream(realm, search, false, first, max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ public Entry(String name, Collection<String> values) {
this.values = values.toArray(new String[values.size()]);
}

private String getName() {
return this.name;
}

public int size() {
return values.length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,6 @@ private AuthenticationManager.AuthResult getAuthResult() {
return authResult;
}

// get the auth result from the authentication manager
private AuthenticationManager.AuthResult getAuthResult(WebApplicationException errorResponse) {
AuthenticationManager.AuthResult authResult = bearerTokenAuthenticator.authenticate();
if (authResult == null) {
throw errorResponse;
}
return authResult;
}

/**
* Get a signed credential
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ public static String getServiceURL(SPSSODescriptorType sp, String bindingURI) {
return null;
}

/**
* Gets from a SPSSO descriptor the artifact resolution service for a given index
* @param sp an SPSSO descriptor
* @param index the index of the artifact resolution service to return
* @return the location of the artifact resolution service
*/
private static String getArtifactResolutionService(SPSSODescriptorType sp, int index) {
List<IndexedEndpointType> endpoints = sp.getArtifactResolutionService();
for (IndexedEndpointType endpoint : endpoints) {
if (endpoint.getIndex() == index) {
return endpoint.getLocation().toString();
}
}
return null;
}

/**
* Tries to get from a SPSSO descriptor the default artifact resolution service. Or if it doesn't
* exist, the artifact resolution service with the lowest index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ public Object resolveRealmExtension(@PathParam("realm") String realmName, @PathP
throw new NotFoundException();
}

private void checkSsl(RealmModel realm) {
checkSsl(session, realm);
}

private static void checkSsl(KeycloakSession session, RealmModel realm) {
if (!"https".equals(session.getContext().getUri().getBaseUri().getScheme())
&& realm.getSslRequired().isRequired(session.getContext().getConnection())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,6 @@ public static void main(String[] args) throws Exception {
}
}

// 2 ms
private static Foo test1() throws Exception {
Foo f = new Foo();
InetAddress addr = InetAddress.getByName("10.40.2.225");
f.ipAddr = addr.getHostAddress();
f.hostname = "";
return f;
}

// 231 ms - increasing linearly
private static Foo test2() throws Exception {
Foo f = new Foo();
InetAddress addr = InetAddress.getByName("10.40.2.225");
f.ipAddr = addr.getHostAddress();
f.hostname = addr.getHostName();
return f;
}

// 240 ms - increasing linearly
private static Foo test3() throws Exception {
Foo f = new Foo();
InetAddress addr = InetAddress.getByName("10.40.2.225");
f.ipAddr = addr.getHostAddress();
for (int i=0 ; i<10 ; i++) {
f.hostname = addr.getHostName();
}
return f;
}

// 27 ms (Everything at 1st call)
private static Foo test4() throws Exception {
Foo f = new Foo();
Expand All @@ -79,21 +50,6 @@ private static Foo test4() throws Exception {
return f;
}

// 257 ms - increasing
private static Foo test5() throws Exception {
Foo f = new Foo();
InetAddress addr = InetAddress.getByName("77.75.77.53");
f.ipAddr = addr.getHostAddress();
f.hostname = addr.getHostName();
return f;
}

// Test DNS caching
private static Foo test6() throws Exception {
Thread.sleep(1000);
return test4();
}


private static class Foo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,6 @@ private static IdentityProviderRepresentation createIdentityProvider(String alia
return identityProviderRepresentation;
}

private boolean isUUID(String uuid) {
return 36 == uuid.length()
&& uuid.charAt(8) == '-'
&& uuid.charAt(13) == '-'
&& uuid.charAt(18) == '-'
&& uuid.charAt(23) == '-';
}

private static class UserRealmUserConf implements UserConfig {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ private void badLogin() {
oAuthClient.doLogin("bad", "user");
}

private void pause(int seconds) {
try {
Thread.sleep(seconds * 1000L);
} catch (InterruptedException e) {
Assertions.fail(e.getMessage());
}
}

@Test
public void eventAttributesTest() {
badLogin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,6 @@ private void compileGroups(Set<String> found, GroupRepresentation g) {
}
}
}
private void checkDefaultRoles(List<String> defaultRoles) {
HashSet<String> roles = new HashSet<>(defaultRoles);
Assert.assertTrue(roles.contains("uma_authorization"), "Default role 'uma_authorization'");
Assert.assertTrue(roles.contains("offline_access"), "Default role 'offline_access'");
Assert.assertTrue(roles.contains("user"), "Default role 'user'");
}

private static <T> T loadJson(InputStream is, Class<T> type) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,4 @@ private void assertNotNull(Object obj) {
}
}

private void assertEquals(Object obj1, Object obj2) {
if (!(obj1.equals(obj2))) {
throw new AssertionError("Objects not equals");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,4 @@ public static String getAppServerContextRoot(int clusterPortOffset) {
public static String removeDefaultPorts(String url) {
return url != null ? url.replaceFirst("(.*)(:80)(\\/.*)?$", "$1$3").replaceFirst("(.*)(:443)(\\/.*)?$", "$1$3") : null;
}

private static int parsePort(String property) {
try {
return parseInt(System.getProperty(property));
} catch (NumberFormatException ex) {
throw new RuntimeException("Failed to get " + property, ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,6 @@ private boolean handleManualMigration() {
private static final Pattern RECOGNIZED_ERRORS = Pattern.compile("ERROR \\[|SEVERE \\[|Exception ");
private static final Pattern IGNORED = Pattern.compile("Jetty ALPN support not found|org.keycloak.events");

private static final boolean isRecognizedErrorLog(String logText) {
//There is expected string "Exception" in server log: Adding provider
//singleton org.keycloak.services.resources.ModelExceptionMapper
return RECOGNIZED_ERRORS.matcher(logText).find() && ! IGNORED.matcher(logText).find();
}

private static final void failOnRecognizedErrorInLog(Stream<String> logStream) {
Optional<String> anyRecognizedError = logStream.filter(AuthServerTestEnricher::isRecognizedErrorLog).findAny();
if (anyRecognizedError.isPresent()) {
throw new RuntimeException(String.format("Server log file contains ERROR: '%s'", anyRecognizedError.get()));
}
}

public void checkServerLogs(@Observes(precedence = -1) BeforeSuite event) {
suiteContext.setServerLogChecker(new TextFileChecker());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
Expand Down Expand Up @@ -198,13 +197,6 @@ public void stop() throws LifecycleException {
log.info("Infinispan server stopped");
}

private long getPID() throws IOException {
if (pidFile == null) {
throw new IllegalStateException(String.format("Unable to find PID file '%s'", pidFile));
}
return Long.parseLong(Files.readAllLines(pidFile.toPath()).get(0).trim());
}

/**
* Attach to a local Infinispan JVM, launch a management-agent, and return
* its JMXServiceURL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.stream.Collectors;

import org.junit.Assert;
import org.keycloak.common.util.Retry;
import org.keycloak.testsuite.util.UIUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
Expand Down Expand Up @@ -132,14 +131,4 @@ public void selectOtpCredential(String credentialName) {
UIUtils.click(webElement);
}


// Workaround, but works with HtmlUnit (WaitUtils.waitForElement doesn't). Find better solution for the future...
private void waitForElement(By by) {
Retry.executeWithBackoff((currentCount) -> {

driver.findElement(by);

}, 10, 10);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import org.keycloak.admin.client.resource.AggregatePoliciesResource;
import org.keycloak.admin.client.resource.AggregatePolicyResource;
import org.keycloak.admin.client.resource.AuthorizationResource;
import org.keycloak.admin.client.resource.UserPoliciesResource;
import org.keycloak.admin.client.resource.UserPolicyResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation;
Expand Down Expand Up @@ -168,29 +166,9 @@ private void assertCreated(AuthorizationResource authorization, AggregatePolicyR
}
}

private void assertCreated(AuthorizationResource authorization, UserPolicyRepresentation representation) {
UserPoliciesResource permissions = authorization.policies().user();

try (Response response = permissions.create(representation)) {
UserPolicyRepresentation created = response.readEntity(UserPolicyRepresentation.class);
UserPolicyResource permission = permissions.findById(created.getId());
assertRepresentation(representation, permission);
}
}

private void assertRepresentation(AggregatePolicyRepresentation representation, AggregatePolicyResource policy) {
AggregatePolicyRepresentation actual = policy.toRepresentation();
assertRepresentation(representation, actual, () -> policy.resources(), () -> Collections.emptyList(), () -> policy.associatedPolicies());
}

private void assertRepresentation(UserPolicyRepresentation representation, UserPolicyResource permission) {
UserPolicyRepresentation actual = permission.toRepresentation();
assertRepresentation(representation, actual, () -> permission.resources(), () -> Collections.emptyList(), () -> permission.associatedPolicies());
assertEquals(representation.getUsers().size(), actual.getUsers().size());
assertEquals(0, actual.getUsers().stream().filter(userId -> !representation.getUsers().stream()
.filter(userName -> getRealm().users().get(userId).toRepresentation().getUsername().equalsIgnoreCase(userName))
.findFirst().isPresent())
.count());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ public OIDCClientRepresentation create() throws ClientRegistrationException {
return response;
}

private void assertOidcFail(ClientRegOp operation, OIDCClientRepresentation client, int expectedStatusCode) {
assertOidcFail(operation, client, expectedStatusCode, null);
}

private void assertOidcFail(ClientRegOp operation, OIDCClientRepresentation client, int expectedStatusCode, String expectedErrorContains) {
try {
switch (operation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ public OIDCClientRepresentation create() throws ClientRegistrationException {
return response;
}

private void assertCreateFail(OIDCClientRepresentation client, int expectedStatusCode) {
assertCreateFail(client, expectedStatusCode, null);
}

private void assertCreateFail(OIDCClientRepresentation client, int expectedStatusCode, String expectedErrorContains) {
try {
reg.oidc().create(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ private void enableEventMetricsOptions(String tags, String events) {
}
}

private static void setConfigProperty(String name, String value) {
if (value != null) {
System.setProperty(name, value);
}
else {
System.clearProperty(name);
}
}

@Override
public void addTestRealms(List<RealmRepresentation> testRealms) {
RealmBuilder realm = RealmBuilder.create().name(TEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1264,10 +1264,6 @@ private void assertUserDisabledEvent(String error) {
events.expect(EventType.LOGIN_ERROR).error(error).assertEvent();
}

private void assertUserPermanentlyDisabledEvent() {
events.expect(EventType.LOGIN_ERROR).error(Errors.USER_DISABLED).assertEvent();
}

private void assertUserDisabledReason(String expected) {
String actual = adminClient.realm("test").users()
.search("test-user@localhost", 0, 1)
Expand Down
Loading
Loading