use of org.platformlayer.federation.model.PlatformLayerConnectionConfiguration in project platformlayer by platformlayer.
the class FederatedPlatformLayerClient method buildFederationConfiguration.
// public static FederationMap buildFederationMap(HttpStrategy httpStrategy, TypedPlatformLayerClient localClient,
// TypedItemMapper mapper) throws OpsException {
// FederationConfiguration federationMapConfig = buildFederationConfiguration(localClient);
//
// FederationMap federationMap = new FederationMap(httpStrategy, mapper, federationMapConfig);
//
// if (localClient != null) {
// federationMap.addDefault(localClient);
// }
//
// return federationMap;
// }
public static FederationConfiguration buildFederationConfiguration(TypedPlatformLayerClient localClient) throws OpsException {
FederationConfiguration federationMapConfig = new FederationConfiguration();
String federationNamespace = "http://platformlayer.org/service/federation/v1.0";
boolean federationEnabled = isServiceEnabled(localClient, federationNamespace);
if (federationEnabled) {
for (FederatedService service : localClient.listItems(FederatedService.class)) {
PlatformLayerConnectionConfiguration config = new PlatformLayerConnectionConfiguration();
config.key = service.getKey();
config.secret = service.getSecret();
config.authenticationEndpoint = service.getServer();
config.tenant = service.getTenant();
config.username = service.getUsername();
config.platformlayerEndpoint = service.getServer();
federationMapConfig.systems.add(config);
}
for (FederatedServiceMap map : localClient.listItems(FederatedServiceMap.class)) {
FederationRule rule = new FederationRule();
rule.target = map.getTarget();
rule.serviceType = map.getServiceType();
federationMapConfig.rules.add(rule);
}
}
return federationMapConfig;
}
use of org.platformlayer.federation.model.PlatformLayerConnectionConfiguration in project platformlayer by platformlayer.
the class HttpPlatformLayerClient method buildUsingProperties.
public static HttpPlatformLayerClient buildUsingProperties(HttpStrategy httpStrategy, Properties properties) {
PlatformLayerConnectionConfiguration config = new PlatformLayerConnectionConfiguration();
config.tenant = properties.getProperty("platformlayer.tenant");
config.authenticationEndpoint = properties.getProperty("platformlayer.auth.url");
config.username = properties.getProperty("platformlayer.username");
config.secret = properties.getProperty("platformlayer.password");
config.platformlayerEndpoint = properties.getProperty("platformlayer.url");
String trustKeys = properties.getProperty("platformlayer.ssl.keys", null);
if (!Strings.isNullOrEmpty(trustKeys)) {
config.platformlayerTrustKeys = Lists.newArrayList(Splitter.on(',').trimResults().split(trustKeys));
}
String authTrustKeys = properties.getProperty("platformlayer.auth.ssl.keys", null);
if (!Strings.isNullOrEmpty(authTrustKeys)) {
config.authTrustKeys = Lists.newArrayList(Splitter.on(',').trimResults().split(authTrustKeys));
}
return buildUsingConfiguration(httpStrategy, config);
}
use of org.platformlayer.federation.model.PlatformLayerConnectionConfiguration in project platformlayer by platformlayer.
the class FederationMap method buildTargetMap.
private void buildTargetMap(FederationConfiguration config) {
for (PlatformLayerConnectionConfiguration child : config.systems) {
FederationKey host = FederationKey.build(child.authenticationEndpoint);
ProjectId project = new ProjectId(child.tenant);
FederationMapping key = new FederationMapping(host, project);
MappedTarget target = new MappedTarget();
target.configuration = child;
addMapping(key, target);
}
}
use of org.platformlayer.federation.model.PlatformLayerConnectionConfiguration in project platformlayer by platformlayer.
the class FederationMap method buildRules.
private void buildRules(FederationConfiguration config) {
for (FederationRule federationRule : config.rules) {
Rule rule = new Rule();
rule.mappedItems = PlatformLayerKey.fromServiceAndItem(federationRule.serviceType, null);
for (PlatformLayerConnectionConfiguration system : config.systems) {
if (Objects.equal(system.key, federationRule.target)) {
if (rule.targetKey != null) {
throw new IllegalStateException();
}
FederationKey host = FederationKey.build(system.authenticationEndpoint);
ProjectId project = new ProjectId(system.tenant);
rule.targetKey = new FederationMapping(host, project);
}
}
if (rule.targetKey == null) {
throw new IllegalStateException();
}
addRule(rule);
}
}
Aggregations