fixed factory

This commit is contained in:
Alfredo Oliviero 2024-05-14 11:19:49 +02:00
parent 4ea0762f7f
commit 8f00186a50
1 changed files with 12 additions and 3 deletions

View File

@ -50,7 +50,6 @@ public class KkClientFactory {
public void setSecret(Secret secret) {
this.secret = secret;
this.config = fetchIsConfig(this.secret);
}
// allows to configure the factory
@ -59,11 +58,17 @@ public class KkClientFactory {
config = configuration;
}
public Secret getSecretForInfrastructure(){
return InfrastrctureServiceClient.getSecretForInfrastructure();
}
public IsServerConfig fetchIsConfig(Secret secret) throws InternalServerErrorException {
try {
if (this.secret == null)
this.secret = InfrastrctureServiceClient.getSecretForInfrastructure();
if (secret == null){
throw new InternalServerErrorException("null secret for fetchIsConfig");
}
IsServerConfig cfg = InfrastrctureServiceClient.serviceConfigFromIS(RUNTIME_RESOURCE_NAME, CATEGORY,
END_POINT_NAME, IS_ROOT_SERVICE, secret);
@ -77,9 +82,13 @@ public class KkClientFactory {
}
public KeycloackApiClient createtKeycloakInstance(String context) {
if (this.secret == null) {
this.secret = getSecretForInfrastructure();
}
if (this.config == null) {
this.config = fetchIsConfig(this.secret);
}
return createtKeycloakInstance(this.config, context);
}