Search in sources :

Example 1 with PlatformLayerConnectionConfiguration

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;
}
Also used : FederationConfiguration(org.platformlayer.federation.model.FederationConfiguration) PlatformLayerConnectionConfiguration(org.platformlayer.federation.model.PlatformLayerConnectionConfiguration) FederatedServiceMap(org.platformlayer.service.federation.v1.FederatedServiceMap) FederationRule(org.platformlayer.federation.model.FederationRule) FederatedService(org.platformlayer.service.federation.v1.FederatedService)

Example 2 with PlatformLayerConnectionConfiguration

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);
}
Also used : PlatformLayerConnectionConfiguration(org.platformlayer.federation.model.PlatformLayerConnectionConfiguration)

Example 3 with PlatformLayerConnectionConfiguration

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);
    }
}
Also used : PlatformLayerConnectionConfiguration(org.platformlayer.federation.model.PlatformLayerConnectionConfiguration) ProjectId(org.platformlayer.ids.ProjectId) FederationKey(org.platformlayer.ids.FederationKey)

Example 4 with PlatformLayerConnectionConfiguration

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);
    }
}
Also used : FederationRule(org.platformlayer.federation.model.FederationRule) PlatformLayerConnectionConfiguration(org.platformlayer.federation.model.PlatformLayerConnectionConfiguration) ProjectId(org.platformlayer.ids.ProjectId) FederationRule(org.platformlayer.federation.model.FederationRule) FederationKey(org.platformlayer.ids.FederationKey)

Aggregations

PlatformLayerConnectionConfiguration (org.platformlayer.federation.model.PlatformLayerConnectionConfiguration)4 FederationRule (org.platformlayer.federation.model.FederationRule)2 FederationKey (org.platformlayer.ids.FederationKey)2 ProjectId (org.platformlayer.ids.ProjectId)2 FederationConfiguration (org.platformlayer.federation.model.FederationConfiguration)1 FederatedService (org.platformlayer.service.federation.v1.FederatedService)1 FederatedServiceMap (org.platformlayer.service.federation.v1.FederatedServiceMap)1