ARTEMIS-4179 Fix security-keycloak log errors

This commit is contained in:
Domenico Francesco Bruscino 2023-02-26 06:56:31 +01:00 committed by Bruscino Domenico Francesco
parent 438dd47a78
commit 7810a9d686
2 changed files with 795 additions and 520 deletions

View File

@ -25,18 +25,35 @@ import javax.jms.Session;
import javax.jms.Queue; import javax.jms.Queue;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.utils.Waiter;
public class KeycloakSecurityExample { public class KeycloakSecurityExample {
public static void main(final String[] args) throws Exception { public static void main(final String[] args) throws Exception {
boolean result = true;
Connection connection = null; Connection connection = null;
InitialContext initialContext = null; InitialContext initialContext = null;
try { try {
// Step 0. Wait for artemis-keycloak-demo
Waiter.waitFor(() -> {
int responseCode = 0;
try {
URL url = new URL("http://localhost:8080/realms/artemis-keycloak-demo/.well-known/openid-configuration");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
responseCode = con.getResponseCode();
con.disconnect();
} catch (Exception expectedTillInfraStarted) {
System.out.println("---- expected error on startup till artemis-keycloak-demo starts: " + expectedTillInfraStarted + ", retry in 5s");
}
return responseCode == 200;
}, TimeUnit.SECONDS, 30, TimeUnit.SECONDS, 5);
// Step 1. Create an initial context to perform the JNDI lookup. // Step 1. Create an initial context to perform the JNDI lookup.
initialContext = new InitialContext(); initialContext = new InitialContext();