Skip to content

Commit

Permalink
Merge pull request #68 from AvanzaBank/tp-325-gs-security-support-fixes
Browse files Browse the repository at this point in the history
TP-325: Allow singleton CredentialsProvider during GS tests
  • Loading branch information
kbs4j authored Jul 8, 2020
2 parents 139946e + d90f742 commit 80521d8
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.avanza.astrix.modules.KeyLock;
import com.avanza.astrix.modules.ObjectCache;
import com.avanza.astrix.modules.ObjectCache.ObjectFactory;
import com.gigaspaces.security.directory.CredentialsProvider;
import com.j_spaces.core.IJSpace;
/**
* Manages lifecycle for each clustered-proxy created by Astrix.
Expand Down Expand Up @@ -127,7 +128,7 @@ public GigaSpaceInstance(String spaceUrl, DynamicConfig dynamicConfig, ServicePr
if (GsBinder.isAuthenticationRequired(serviceProperties)) {
final String spaceName = GsBinder.getSpaceName(serviceProperties);
log.debug("Connecting to space {} as a secured space.", spaceName);
urlSpaceConfigurer.credentialsProvider(gsSecurityProvider.getGsClientCredentialsProvider(spaceName));
urlSpaceConfigurer.credentialsProvider(getCredentialsProvider(spaceName));
}
IJSpace space = urlSpaceConfigurer.create();
this.proxy = new GigaSpaceConfigurer(space).create();
Expand Down Expand Up @@ -181,4 +182,11 @@ public void setConfig(DynamicConfig config) {
this.config = config;
}

private CredentialsProvider getCredentialsProvider(String spaceName) {
Object credentialsProvider = System.getProperties().get("com.gs.security.credentials-provider.class");
if (credentialsProvider instanceof CredentialsProvider) {
return (CredentialsProvider) credentialsProvider;
}
return gsSecurityProvider.getGsClientCredentialsProvider(spaceName);
}
}

0 comments on commit 80521d8

Please sign in to comment.