Changed to an implementation more resilient to the absence of the orchestrator and keycloak clients
This commit is contained in:
parent
9ab6a6f22f
commit
44a75b2aff
|
@ -73,11 +73,14 @@ public class OrchestratorEventPublisherProvider extends AbstractEventPublisher
|
||||||
OrchestratorEventPublisherProviderFactory.KEYCLOAK_ENDPOINT,
|
OrchestratorEventPublisherProviderFactory.KEYCLOAK_ENDPOINT,
|
||||||
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_ID);
|
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_ID);
|
||||||
|
|
||||||
return new HTTPWithUMAAuthEventSender(OrchestratorEventPublisherProviderFactory.ORCHESTRATOR_ENDPOINT,
|
return OrchestratorEventPublisherProviderFactory.KEYCLOAK_ENDPOINT != null
|
||||||
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_ID,
|
? new HTTPWithUMAAuthEventSender(OrchestratorEventPublisherProviderFactory.ORCHESTRATOR_ENDPOINT,
|
||||||
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_SECRET,
|
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_ID,
|
||||||
OrchestratorEventPublisherProviderFactory.KEYCLOAK_ENDPOINT,
|
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_SECRET,
|
||||||
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_ID);
|
OrchestratorEventPublisherProviderFactory.KEYCLOAK_ENDPOINT,
|
||||||
|
OrchestratorEventPublisherProviderFactory.KEYCLOAK_CLIENT_ID)
|
||||||
|
: new HTTPWithUMAAuthEventSender(OrchestratorEventPublisherProviderFactory.ORCHESTRATOR_ENDPOINT, null,
|
||||||
|
null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,36 +47,48 @@ public class OrchestratorEventPublisherProviderFactory implements EventListenerP
|
||||||
if (oepp == null || elapsed > CHECK_DELAY) {
|
if (oepp == null || elapsed > CHECK_DELAY) {
|
||||||
lastEndpointCheck = now;
|
lastEndpointCheck = now;
|
||||||
ClientModel orchestratorClient = getClientInActualOrMasterRealm(keycloakSession, ORCHESTRATOR_CLIENT_ID);
|
ClientModel orchestratorClient = getClientInActualOrMasterRealm(keycloakSession, ORCHESTRATOR_CLIENT_ID);
|
||||||
ClientModel keycloakClient = getClientInActualOrMasterRealm(keycloakSession, KEYCLOAK_CLIENT_ID);
|
|
||||||
logger.debug("Getting configured orchestrator endpoint address from client's base URL");
|
|
||||||
String orchestratorAddress = orchestratorClient.getBaseUrl();
|
|
||||||
logger.debug("Getting configured keycloak endpoint address from client's base URL");
|
|
||||||
String keycloakAddress = keycloakClient.getBaseUrl();
|
|
||||||
logger.debug("Getting configured keycloak client client-secret from client");
|
|
||||||
String keycloakClientSecret = keycloakClient.getSecret();
|
|
||||||
URL newOrchestratorEndpoint;
|
URL newOrchestratorEndpoint;
|
||||||
|
if (orchestratorClient != null) {
|
||||||
|
logger.trace("Getting configured orchestrator endpoint address from client's base URL");
|
||||||
|
try {
|
||||||
|
newOrchestratorEndpoint = new URL(orchestratorClient.getBaseUrl());
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
logger.errorf("Can't create new orchestrator endpoint address: %s", orchestratorClient.getBaseUrl(),
|
||||||
|
e);
|
||||||
|
oepp = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.debugf("Can't go ahead without a configured '%f' client", ORCHESTRATOR_CLIENT_ID);
|
||||||
|
oepp = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ClientModel keycloakClient = getClientInActualOrMasterRealm(keycloakSession, KEYCLOAK_CLIENT_ID);
|
||||||
URL newKeycloakEndpoint;
|
URL newKeycloakEndpoint;
|
||||||
try {
|
String keycloakClientSecret;
|
||||||
newOrchestratorEndpoint = new URL(orchestratorAddress);
|
if (keycloakClient != null) {
|
||||||
} catch (MalformedURLException e) {
|
try {
|
||||||
logger.errorf("Can't create new orchestrator endpoint address: %s",
|
logger.debug("Getting configured keycloak endpoint address from client's base URL");
|
||||||
orchestratorAddress, e);
|
newKeycloakEndpoint = new URL(keycloakClient.getBaseUrl());
|
||||||
oepp = null;
|
// Only do it if URL has been configured properly
|
||||||
return null;
|
logger.debug("Getting configured keycloak client client-secret from client");
|
||||||
}
|
keycloakClientSecret = keycloakClient.getSecret();
|
||||||
try {
|
} catch (MalformedURLException e) {
|
||||||
newKeycloakEndpoint = new URL(keycloakAddress);
|
logger.errorf("Can't create new keycloak token address: %s", keycloakClient.getBaseUrl(), e);
|
||||||
} catch (MalformedURLException e) {
|
oepp = null;
|
||||||
logger.errorf("Can't create new keycloak token address: %s", keycloakAddress, e);
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.debugf("Can't go ahead without a configured '%f' client", KEYCLOAK_CLIENT_ID);
|
||||||
oepp = null;
|
oepp = null;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oepp == null || !newOrchestratorEndpoint.equals(ORCHESTRATOR_ENDPOINT)
|
if (oepp == null || !newOrchestratorEndpoint.equals(ORCHESTRATOR_ENDPOINT)
|
||||||
|| !newKeycloakEndpoint.equals(KEYCLOAK_ENDPOINT)
|
|| !newKeycloakEndpoint.equals(KEYCLOAK_ENDPOINT)
|
||||||
|| !keycloakClientSecret.equals(KEYCLOAK_CLIENT_SECRET)) {
|
|| !keycloakClientSecret.equals(KEYCLOAK_CLIENT_SECRET)) {
|
||||||
|
|
||||||
logger.infof("Creating new orchestrator event publisher provider for endpoint: %s",
|
logger.info("Creating new orchestrator event publisher provider");
|
||||||
orchestratorAddress);
|
|
||||||
// Address and other fileds will be then read from static fields in this class by
|
// Address and other fileds will be then read from static fields in this class by
|
||||||
// the createEventSender() called by the superclass' constructor, overridden in the impl.
|
// the createEventSender() called by the superclass' constructor, overridden in the impl.
|
||||||
ORCHESTRATOR_ENDPOINT = newOrchestratorEndpoint;
|
ORCHESTRATOR_ENDPOINT = newOrchestratorEndpoint;
|
||||||
|
@ -86,7 +98,7 @@ public class OrchestratorEventPublisherProviderFactory implements EventListenerP
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.debugf("Next check is in %d millis", CHECK_DELAY - elapsed);
|
logger.tracef("Next check is in %d millis", CHECK_DELAY - elapsed);
|
||||||
}
|
}
|
||||||
return oepp;
|
return oepp;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +119,7 @@ public class OrchestratorEventPublisherProviderFactory implements EventListenerP
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.debugf("Client '%f' found", clientId);
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue