diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java index fc9ac76a47..3e372350e2 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java @@ -16,8 +16,8 @@ */ package org.jclouds.openstack.cinder.v1; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; import java.util.Properties; @@ -25,10 +25,11 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.openstack.cinder.v1.config.CinderHttpApiModule; import org.jclouds.openstack.cinder.v1.config.CinderParserModule; -import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.internal.BaseHttpApiMetadata; @@ -58,6 +59,7 @@ public class CinderApiMetadata extends BaseHttpApiMetadata { public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.BLOCK_STORAGE); + properties.setProperty(KeystoneProperties.KEYSTONE_VERSION, "2"); properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); return properties; } @@ -75,8 +77,8 @@ public class CinderApiMetadata extends BaseHttpApiMetadata { .defaultEndpoint("http://localhost:5000/v2.0/") .defaultProperties(CinderApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.>builder() - .add(AuthenticationApiModule.class) - .add(KeystoneAuthenticationModule.class) + .add(AuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(CinderParserModule.class) .add(CinderHttpApiModule.class) diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/extensions/AvailabilityZoneApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/extensions/AvailabilityZoneApi.java index 4b2abdb08b..1594419b9c 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/extensions/AvailabilityZoneApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/extensions/AvailabilityZoneApi.java @@ -21,7 +21,7 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; import org.jclouds.Fallbacks; import org.jclouds.openstack.cinder.v1.domain.AvailabilityZone; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/QuotaApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/QuotaApi.java index e8c39f9bd7..14fa57c6df 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/QuotaApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/QuotaApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.cinder.v1.domain.VolumeQuota; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java index 4c5be5b72e..28c3e8bfe5 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java @@ -32,7 +32,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.cinder.v1.domain.Snapshot; import org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PayloadParam; diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java index c6d4d54370..c9f98202b9 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java @@ -32,7 +32,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.cinder.v1.domain.Volume; import org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PayloadParam; diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java index da59d8ba5b..2ee062ec4f 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java @@ -27,7 +27,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.cinder.v1.domain.VolumeType; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/internal/BaseCinderApiLiveTest.java b/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/internal/BaseCinderApiLiveTest.java index 23c4702614..88397bcfc0 100644 --- a/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/internal/BaseCinderApiLiveTest.java +++ b/apis/openstack-cinder/src/test/java/org/jclouds/openstack/cinder/v1/internal/BaseCinderApiLiveTest.java @@ -20,7 +20,7 @@ import java.util.Properties; import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.openstack.cinder.v1.CinderApi; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; /** * Tests behavior of CinderApi diff --git a/apis/openstack-keystone/pom.xml b/apis/openstack-keystone/pom.xml index a4a2e7a0d9..36d7a112c2 100644 --- a/apis/openstack-keystone/pom.xml +++ b/apis/openstack-keystone/pom.xml @@ -32,13 +32,18 @@ bundle - + http://localhost:5000/v${jclouds.api-version}/ - 2.0 - FIXME_IDENTITY - FIXME_CREDENTIALS + FIXME_TENANT:FIXME_USER + FIXME_PASSWORD + + http://localhost/identity/v3 + 3 + + FIXME_DOMAIN:FIXME_USER + FIXME_PASSWORD passwordCredentials org.jclouds.openstack*;version="${project.version}" @@ -69,6 +74,13 @@ ${project.version} test + + + org.apache.jclouds.driver + jclouds-okhttp + ${project.version} + test + ch.qos.logback logback-classic @@ -84,7 +96,28 @@ auto-service true + + com.google.auto.value + auto-value + provided + + + + + + + maven-compiler-plugin + false + + ${maven.compile.source} + ${maven.compile.target} + ${project.build.sourceEncoding} + + + + @@ -102,6 +135,13 @@ test + + none + + + **/keystone/v2_0/**/*IntegrationTest.java + **/keystone/v2_0/**/*LiveTest.java + ${test.openstack-keystone.endpoint} ${test.openstack-keystone.api-version} @@ -117,6 +157,43 @@ + + live-v3 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + none + + + **/keystone/v3/**/*IntegrationTest.java + **/keystone/v3/**/*LiveTest.java + + + ${test.openstack-keystone.endpoint} + ${test.openstack-keystone.api-version} + ${test.openstack-keystone.build-version} + ${test.openstack-keystone-3.identity} + ${test.openstack-keystone-3.credential} + ${test.jclouds.keystone.credential-type} + + + + + + + + diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/AuthHeaders.java similarity index 96% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/AuthHeaders.java index 88ea817383..c6d6b27b3e 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/AuthHeaders.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.v2_0.reference; +package org.jclouds.openstack.keystone.auth; public final class AuthHeaders { diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/AuthenticationApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/AuthenticationApi.java new file mode 100644 index 0000000000..cc6053ea0f --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/AuthenticationApi.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth; + +import org.jclouds.openstack.keystone.auth.domain.ApiAccessKeyCredentials; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.TokenCredentials; + +/** + * Authentication methods to be implemented to all Keystone authentication APIs. + */ +public interface AuthenticationApi { + + AuthInfo authenticatePassword(TenantOrDomainAndCredentials credentials); + + AuthInfo authenticateAccessKey(TenantOrDomainAndCredentials credentials); + + AuthInfo authenticateToken(TenantOrDomainAndCredentials credentials); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/Authentication.java similarity index 95% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/Authentication.java index d6e5381f82..b4d59f5cda 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/Authentication.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.auth.config; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/AuthenticationModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/AuthenticationModule.java new file mode 100644 index 0000000000..6731fe826c --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/AuthenticationModule.java @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.config; + +import static com.google.common.base.Preconditions.checkArgument; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; + +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.domain.Credentials; +import org.jclouds.http.HttpRetryHandler; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.location.Provider; +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.functions.AuthenticateApiAccessKeyCredentials; +import org.jclouds.openstack.keystone.auth.functions.AuthenticatePasswordCredentials; +import org.jclouds.openstack.keystone.auth.functions.AuthenticateTokenCredentials; +import org.jclouds.openstack.keystone.auth.handlers.RetryOnRenew; +import org.jclouds.openstack.keystone.config.KeystoneProperties; +import org.jclouds.openstack.keystone.v2_0.auth.V2AuthenticationApi; +import org.jclouds.openstack.keystone.v3.auth.V3AuthenticationApi; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; +import com.google.common.collect.Maps; +import com.google.inject.AbstractModule; +import com.google.inject.Injector; +import com.google.inject.Provides; + +public class AuthenticationModule extends AbstractModule { + + @Override + protected void configure() { + bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class); + bindHttpApi(binder(), V2AuthenticationApi.class); + bindHttpApi(binder(), V3AuthenticationApi.class); + } + + @Provides + @Singleton + protected final AuthenticationApi provideAuthenticationApi(Injector i, + @Named(KeystoneProperties.KEYSTONE_VERSION) String keystoneVersion) { + return authenticationApis(i).get(keystoneVersion); + } + + protected Map authenticationApis(Injector i) { + Map authenticationApis = Maps.newHashMap(); + authenticationApis.put("2", i.getInstance(V2AuthenticationApi.class)); + authenticationApis.put("3", i.getInstance(V3AuthenticationApi.class)); + return authenticationApis; + } + + /** + * borrowing concurrency code to ensure that caching takes place properly + */ + @Provides + @Singleton + @Authentication + protected final Supplier provideAuthenticationTokenCache(final Supplier supplier) + throws InterruptedException, ExecutionException, TimeoutException { + return new Supplier() { + @Override + public String get() { + return supplier.get().getAuthToken(); + } + }; + } + + @Provides + @Singleton + protected final Map> provideAuthenticationMethods(Injector i) { + return authenticationMethods(i); + } + + protected Map> authenticationMethods(Injector i) { + Builder> fns = ImmutableSet.builder(); + fns.add(i.getInstance(AuthenticatePasswordCredentials.class)); + fns.add(i.getInstance(AuthenticateApiAccessKeyCredentials.class)); + fns.add(i.getInstance(AuthenticateTokenCredentials.class)); + return CredentialTypes.indexByCredentialType(fns.build()); + } + + @Provides + @Singleton + protected final Function authenticationMethodForCredentialType( + @Named(KeystoneProperties.CREDENTIAL_TYPE) String credentialType, + Map> authenticationMethods) { + checkArgument(authenticationMethods.containsKey(credentialType), "credential type %s not in supported list: %s", + credentialType, authenticationMethods.keySet()); + return authenticationMethods.get(credentialType); + } + + // TODO: what is the timeout of the session token? modify default accordingly + // PROPERTY_SESSION_INTERVAL is default to 60 seconds, but we have this here + // at 11 hours for now. + @Provides + @Singleton + public final LoadingCache provideAuthInfoCache(Function getAccess) { + return CacheBuilder.newBuilder().expireAfterWrite(11, TimeUnit.HOURS).build(CacheLoader.from(getAccess)); + } + + // Temporary conversion of a cache to a supplier until there is a + // single-element cache + // http://code.google.com/p/guava-libraries/issues/detail?id=872 + @Provides + @Singleton + protected final Supplier provideAuthInfoSupplier(final LoadingCache cache, + @Provider final Supplier creds) { + return new Supplier() { + @Override + public AuthInfo get() { + return cache.getUnchecked(creds.get()); + } + }; + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/CredentialType.java similarity index 95% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/CredentialType.java index b0d67ccbd4..d3952962aa 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/CredentialType.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.auth.config; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,7 +32,6 @@ import javax.inject.Qualifier; public @interface CredentialType { /** * @see CredentialTypes - * */ String value(); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/CredentialTypes.java similarity index 66% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/CredentialTypes.java index c774ae190d..7cfb6d7f38 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/config/CredentialTypes.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.auth.config; import static com.google.common.base.Preconditions.checkArgument; @@ -32,21 +32,33 @@ public class CredentialTypes { public static final String PASSWORD_CREDENTIALS = "passwordCredentials"; + public static final String TOKEN_CREDENTIALS = "tokenCredentials"; + public static String credentialTypeOf(T input) { Class authenticationType = input.getClass(); - checkArgument(authenticationType.isAnnotationPresent(CredentialType.class), - "programming error: %s should have annotation %s", authenticationType, CredentialType.class.getName()); - return authenticationType.getAnnotation(CredentialType.class).value(); + CredentialType credentialType = findCredentialType(authenticationType); + checkArgument(credentialType != null, "programming error: %s should have annotation %s", authenticationType, + CredentialType.class.getName()); + return credentialType.value(); } public static Map indexByCredentialType(Iterable iterable) { return Maps.uniqueIndex(iterable, new Function() { - @Override public String apply(T input) { return credentialTypeOf(input); } - }); } + + /** + * Find an annotation in teh given class or their parents. We need this since + * AutoValue classes inherit the classes we define. + */ + public static CredentialType findCredentialType(Class input) { + if (input == null) + return null; + CredentialType ann = input.getAnnotation(CredentialType.class); + return ann != null ? ann : findCredentialType(input.getSuperclass()); + } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/ApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/ApiAccessKeyCredentials.java new file mode 100644 index 0000000000..75ccf8841e --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/ApiAccessKeyCredentials.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.domain; + +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.API_ACCESS_KEY_CREDENTIALS; + +import org.jclouds.openstack.keystone.auth.config.CredentialType; + +import com.google.auto.value.AutoValue; + +@CredentialType(API_ACCESS_KEY_CREDENTIALS) +@AutoValue +public abstract class ApiAccessKeyCredentials { + + public abstract String accessKey(); + public abstract String secretKey(); + + public static ApiAccessKeyCredentials create(String accessKey, String secretKey) { + return builder().accessKey(accessKey).secretKey(secretKey).build(); + } + + ApiAccessKeyCredentials() { + + } + + public static Builder builder() { + return new AutoValue_ApiAccessKeyCredentials.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder accessKey(String accessKey); + public abstract Builder secretKey(String secretKey); + + public abstract ApiAccessKeyCredentials build(); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/AuthInfo.java similarity index 79% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/AuthInfo.java index 6bf6e11d0c..98e62efe31 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/AuthInfo.java @@ -14,10 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.auth.domain; -import com.google.inject.ImplementedBy; +/** + * Common interface for authentication objects. + */ +public interface AuthInfo { -@ImplementedBy(AdminURL.class) -public interface EndpointToSupplierAdminURI extends EndpointToSupplierURI { + String getAuthToken(); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/PasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/PasswordCredentials.java new file mode 100644 index 0000000000..2e1fee9b50 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/PasswordCredentials.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.domain; + +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.PASSWORD_CREDENTIALS; + +import org.jclouds.openstack.keystone.auth.config.CredentialType; + +import com.google.auto.value.AutoValue; +import com.google.common.base.MoreObjects; + +@CredentialType(PASSWORD_CREDENTIALS) +@AutoValue +public abstract class PasswordCredentials { + + public abstract String username(); + public abstract String password(); + + public static PasswordCredentials create(String username, String password) { + return builder().username(username).password(password).build(); + } + + PasswordCredentials() { + + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("username", username()) + .add("password", password() == null ? null : "*****").toString(); + } + + public static Builder builder() { + return new AutoValue_PasswordCredentials.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder username(String username); + public abstract Builder password(String password); + + public abstract PasswordCredentials build(); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/TenantOrDomainAndCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/TenantOrDomainAndCredentials.java new file mode 100644 index 0000000000..b30f3fc290 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/TenantOrDomainAndCredentials.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.domain; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.auto.value.AutoValue; + +/** + * Keystone credentials with tenant. Configure the tenant properties to the + * configured context credentials. + */ +@AutoValue +public abstract class TenantOrDomainAndCredentials { + + @Nullable public abstract String tenantOrDomainId(); + @Nullable public abstract String tenantOrDomainName(); + @Nullable public abstract String scope(); + public abstract T credentials(); + + TenantOrDomainAndCredentials() { + + } + + public static Builder builder() { + return new AutoValue_TenantOrDomainAndCredentials.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder tenantOrDomainId(String tenantId); + public abstract Builder tenantOrDomainName(String tenantName); + public abstract Builder scope(String scope); + public abstract Builder credentials(T credentials); + + public abstract TenantOrDomainAndCredentials build(); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/TokenCredentials.java similarity index 52% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/TokenCredentials.java index 01d81bd826..7f5d0b2f66 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/domain/TokenCredentials.java @@ -14,26 +14,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.auth.domain; -import java.net.URI; +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.TOKEN_CREDENTIALS; -import javax.inject.Singleton; +import org.jclouds.openstack.keystone.auth.config.CredentialType; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import com.google.auto.value.AutoValue; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; +@CredentialType(TOKEN_CREDENTIALS) +@AutoValue +public abstract class TokenCredentials { -@Singleton -public class PublicURLOrInternalIfNull implements EndpointToSupplierURI { - // TODO: check accessibility and prioritize private first - @Override - public Supplier apply(Endpoint input) { - return Suppliers.ofInstance(input.getPublicURL() != null ? input.getPublicURL() : input.getInternalURL()); + public abstract String id(); + + public static TokenCredentials create(String id) { + return builder().id(id).build(); } - public String toString() { - return "supplyPublicURL()"; + TokenCredentials() { + } + + public static Builder builder() { + return new AutoValue_TokenCredentials.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + + public abstract TokenCredentials build(); + } + } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/filters/AuthenticateRequest.java similarity index 85% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/filters/AuthenticateRequest.java index b46899ce16..6ee125c33f 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/filters/AuthenticateRequest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.filters; +package org.jclouds.openstack.keystone.auth.filters; import javax.inject.Inject; import javax.inject.Singleton; @@ -22,8 +22,8 @@ import javax.inject.Singleton; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; -import org.jclouds.openstack.keystone.v2_0.config.Authentication; -import org.jclouds.openstack.v2_0.reference.AuthHeaders; +import org.jclouds.openstack.keystone.auth.AuthHeaders; +import org.jclouds.openstack.keystone.auth.config.Authentication; import com.google.common.base.Supplier; @@ -36,7 +36,7 @@ public class AuthenticateRequest implements HttpRequestFilter { private final Supplier authTokenProvider; @Inject - public AuthenticateRequest(@Authentication Supplier authTokenProvider) { + AuthenticateRequest(@Authentication Supplier authTokenProvider) { this.authTokenProvider = authTokenProvider; } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticateApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticateApiAccessKeyCredentials.java new file mode 100644 index 0000000000..47c2fccaef --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticateApiAccessKeyCredentials.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.functions; + +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.API_ACCESS_KEY_CREDENTIALS; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.config.CredentialType; +import org.jclouds.openstack.keystone.auth.domain.ApiAccessKeyCredentials; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; + +@CredentialType(API_ACCESS_KEY_CREDENTIALS) +@Singleton +public class AuthenticateApiAccessKeyCredentials extends BaseAuthenticator { + + private final AuthenticationApi auth; + + @Inject + AuthenticateApiAccessKeyCredentials(AuthenticationApi auth) { + this.auth = auth; + } + + @Override + public ApiAccessKeyCredentials createCredentials(String identity, String credential) { + return ApiAccessKeyCredentials.builder().accessKey(identity).secretKey(credential).build(); + } + + @Override + public AuthInfo authenticate(TenantOrDomainAndCredentials credentials) { + return auth.authenticateAccessKey(credentials); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticatePasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticatePasswordCredentials.java new file mode 100644 index 0000000000..2513bd2760 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticatePasswordCredentials.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.functions; + +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.PASSWORD_CREDENTIALS; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.config.CredentialType; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; + +@CredentialType(PASSWORD_CREDENTIALS) +@Singleton +public class AuthenticatePasswordCredentials extends BaseAuthenticator { + + private final AuthenticationApi auth; + + @Inject + AuthenticatePasswordCredentials(AuthenticationApi auth) { + this.auth = auth; + } + + @Override + public PasswordCredentials createCredentials(String identity, String credential) { + return PasswordCredentials.builder().username(identity).password(credential).build(); + } + + @Override + public AuthInfo authenticate(TenantOrDomainAndCredentials credentials) { + return auth.authenticatePassword(credentials); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticateTokenCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticateTokenCredentials.java new file mode 100644 index 0000000000..fac0289d7d --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/AuthenticateTokenCredentials.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.functions; + +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.TOKEN_CREDENTIALS; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.config.CredentialType; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.TokenCredentials; + +@CredentialType(TOKEN_CREDENTIALS) +@Singleton +public class AuthenticateTokenCredentials extends BaseAuthenticator { + + private final AuthenticationApi auth; + + @Inject + AuthenticateTokenCredentials(AuthenticationApi auth) { + this.auth = auth; + } + + @Override + public TokenCredentials createCredentials(String identity, String credential) { + return TokenCredentials.builder().id(credential).build(); + } + + @Override + public AuthInfo authenticate(TenantOrDomainAndCredentials credentials) { + return auth.authenticateToken(credentials); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/BaseAuthenticator.java similarity index 61% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/BaseAuthenticator.java index 3e4216a233..d49204c91a 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/functions/BaseAuthenticator.java @@ -14,26 +14,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions.internal; +package org.jclouds.openstack.keystone.auth.functions; import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.REQUIRES_TENANT; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.TENANT_ID; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.TENANT_NAME; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.REQUIRES_TENANT; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SCOPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.TENANT_ID; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.TENANT_NAME; import javax.annotation.PostConstruct; import javax.annotation.Resource; import org.jclouds.domain.Credentials; import org.jclouds.logging.Logger; -import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.v3.domain.Auth.Scope; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.inject.Inject; import com.google.inject.name.Named; -public abstract class BaseAuthenticator implements Function { +public abstract class BaseAuthenticator implements Function { @Resource protected Logger logger = Logger.NULL; @@ -49,6 +51,10 @@ public abstract class BaseAuthenticator implements Function implements Function tenantName = Optional.fromNullable(defaultTenantName); - Optional tenantId = Optional.fromNullable(defaultTenantId); - + public AuthInfo apply(Credentials input) { + String tenantName = defaultTenantName; String usernameOrAccessKey = input.identity; + String passwordOrSecretKeyOrToken = input.credential; - if (!tenantName.isPresent() && input.identity.indexOf(':') != -1) { - tenantName = Optional.of(input.identity.substring(0, input.identity.lastIndexOf(':'))); + if (defaultTenantName == null && input.identity.indexOf(':') != -1) { + tenantName = input.identity.substring(0, input.identity.lastIndexOf(':')); usernameOrAccessKey = input.identity.substring(input.identity.lastIndexOf(':') + 1); } - String passwordOrSecretKey = input.credential; - - C creds = createCredentials(usernameOrAccessKey, passwordOrSecretKey); - - Access access; - if (tenantId.isPresent()) { - access = authenticateWithTenantId(tenantId, creds); - } else if (tenantName.isPresent()) { - access = authenticateWithTenantName(tenantName, creds); - } else if (!requiresTenant) { - access = authenticateWithTenantName(tenantName, creds); - } else { + if (defaultTenantId == null && tenantName == null && requiresTenant) { throw new IllegalArgumentException( String.format( "current configuration is set to [%s]. Unless you set [%s] or [%s], you must prefix your identity with 'tenantName:'", REQUIRES_TENANT, TENANT_NAME, TENANT_ID)); } - return access; + + C creds = createCredentials(usernameOrAccessKey, passwordOrSecretKeyOrToken); + TenantOrDomainAndCredentials credsWithTenant = TenantOrDomainAndCredentials. builder().tenantOrDomainId(defaultTenantId) + .tenantOrDomainName(tenantName).scope(scope).credentials(creds).build(); + + return authenticate(credsWithTenant); } public abstract C createCredentials(String identity, String credential); - - protected abstract Access authenticateWithTenantId(Optional tenantId, C apiAccessKeyCredentials); - - protected abstract Access authenticateWithTenantName(Optional tenantId, C apiAccessKeyCredentials); + + public abstract AuthInfo authenticate(TenantOrDomainAndCredentials credentials); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/handlers/RetryOnRenew.java similarity index 93% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/handlers/RetryOnRenew.java index 5cedc8081b..23ef7a10aa 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/auth/handlers/RetryOnRenew.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.handlers; +package org.jclouds.openstack.keystone.auth.handlers; import java.util.concurrent.TimeUnit; @@ -28,8 +28,8 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.logging.Logger; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.v2_0.reference.AuthHeaders; +import org.jclouds.openstack.keystone.auth.AuthHeaders; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; import com.google.common.annotations.VisibleForTesting; import com.google.common.cache.Cache; @@ -53,12 +53,12 @@ public class RetryOnRenew implements HttpRetryHandler { @Named(Constants.PROPERTY_MAX_RETRIES) static int NUM_RETRIES = 5; - private final LoadingCache authenticationResponseCache; + private final LoadingCache authenticationResponseCache; private final BackoffLimitedRetryHandler backoffHandler; @Inject - protected RetryOnRenew(LoadingCache authenticationResponseCache, + RetryOnRenew(LoadingCache authenticationResponseCache, BackoffLimitedRetryHandler backoffHandler) { this.authenticationResponseCache = authenticationResponseCache; this.backoffHandler = backoffHandler; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/ServiceEndpoint.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/ServiceEndpoint.java new file mode 100644 index 0000000000..08477c091c --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/ServiceEndpoint.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog; + +import java.net.URI; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.auto.value.AutoValue; +import com.google.common.base.Enums; + +/** + * Common properties for OpenStack service endpoints. + *

+ * This class provides a common view on the service catalog endpoints so it can + * be parsed in a generic way for Keystone v2 and v3. + */ +@AutoValue +public abstract class ServiceEndpoint { + + public enum Interface { + PUBLIC, ADMIN, INTERNAL, UNRECOGNIZED; + + public static Interface fromValue(String iface) { + return Enums.getIfPresent(Interface.class, iface.toUpperCase()).or(UNRECOGNIZED); + } + } + + @Nullable public abstract String id(); + @Nullable public abstract String regionId(); + public abstract URI url(); + public abstract Interface iface(); + public abstract String type(); + @Nullable public abstract String version(); + + ServiceEndpoint() { + + } + + public static Builder builder() { + return new AutoValue_ServiceEndpoint.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder regionId(String regionId); + public abstract Builder url(URI url); + public abstract Builder iface(Interface iface); + public abstract Builder type(String type); + public abstract Builder version(String version); + + public Builder iface(String iface) { + return iface(Interface.fromValue(iface)); + } + + public abstract ServiceEndpoint build(); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/config/InternalUrlModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/InternalUrlModule.java similarity index 79% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/config/InternalUrlModule.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/InternalUrlModule.java index 71b36cb4e2..bda2bed267 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/config/InternalUrlModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/InternalUrlModule.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.v2_0.config; +package org.jclouds.openstack.keystone.catalog.config; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierURI; -import org.jclouds.openstack.keystone.v2_0.functions.InternalURL; +import org.jclouds.openstack.keystone.catalog.functions.InternalURL; +import org.jclouds.openstack.keystone.catalog.functions.ServiceEndpointResolutionStrategy; import com.google.inject.AbstractModule; import com.google.inject.Singleton; @@ -30,6 +30,6 @@ import com.google.inject.Singleton; public class InternalUrlModule extends AbstractModule { @Override protected void configure() { - bind(EndpointToSupplierURI.class).to(InternalURL.class); + bind(ServiceEndpointResolutionStrategy.class).to(InternalURL.class); } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/KeystoneAdminURLModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/KeystoneAdminURLModule.java new file mode 100644 index 0000000000..a70a2223fb --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/KeystoneAdminURLModule.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.config; + +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.util.Suppliers2.getLastValueInMap; + +import java.net.URI; +import java.util.NoSuchElementException; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.location.Provider; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToAdminURISupplier; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Identity; +import org.jclouds.rest.annotations.ApiVersion; +import org.jclouds.util.Suppliers2; + +import com.google.common.base.Supplier; +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.assistedinject.FactoryModuleBuilder; + +public class KeystoneAdminURLModule extends AbstractModule { + + @Override + protected void configure() { + install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, + RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + } + + /** + * in some cases, there is no {@link ServiceType#IDENTITY} entry in the service catalog. In + * other cases, there's no adminURL entry present. Fallback to the provider in this case. + */ + @Provides + @Singleton + @Identity + protected final Supplier provideIdentityAdminUrl(final RegionIdToAdminURISupplier.Factory factory, + @ApiVersion final String version, @Named(KEYSTONE_VERSION) String keystoneVersion, + @Provider final Supplier providerURI) { + // There is a convention to use service types such as "identityv3" for specific endpoints. let's look first for + // those endpoints, and fallback to the default "identity" one or the project URL. + Supplier identityServiceForSpecificVersionInType = getLastValueInMap(factory.createForApiTypeAndVersion( + ServiceType.IDENTITY + "v" + keystoneVersion, version)); + Supplier identityServiceForVersion = Suppliers2.onThrowable(identityServiceForSpecificVersionInType, + NoSuchElementException.class, + getLastValueInMap(factory.createForApiTypeAndVersion(ServiceType.IDENTITY, version))); + Supplier whenIdentityServiceIsntListedFallbackToProviderURI = Suppliers2.onThrowable( + identityServiceForVersion, NoSuchElementException.class, providerURI); + Supplier whenIdentityServiceHasNoAdminURLFallbackToProviderURI = Suppliers2.or( + whenIdentityServiceIsntListedFallbackToProviderURI, providerURI); + return whenIdentityServiceHasNoAdminURLFallbackToProviderURI; + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/ServiceCatalogModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/ServiceCatalogModule.java new file mode 100644 index 0000000000..9019c7c5a0 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/config/ServiceCatalogModule.java @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.config; + +import static org.jclouds.util.Suppliers2.getLastValueInMap; + +import java.net.URI; +import java.util.List; +import java.util.Map; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.location.Provider; +import org.jclouds.location.suppliers.ImplicitLocationSupplier; +import org.jclouds.location.suppliers.LocationsSupplier; +import org.jclouds.location.suppliers.RegionIdToURISupplier; +import org.jclouds.location.suppliers.RegionIdsSupplier; +import org.jclouds.location.suppliers.all.RegionToProvider; +import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet; +import org.jclouds.location.suppliers.implicit.FirstRegion; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.suppliers.LocationIdToURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToAdminURISupplier; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.config.KeystoneProperties; +import org.jclouds.openstack.keystone.v2_0.catalog.V2ServiceCatalog; +import org.jclouds.openstack.keystone.v3.catalog.V3ServiceCatalog; +import org.jclouds.rest.annotations.ApiVersion; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.Maps; +import com.google.inject.AbstractModule; +import com.google.inject.Injector; +import com.google.inject.Provides; +import com.google.inject.Scopes; +import com.google.inject.assistedinject.FactoryModuleBuilder; + +public class ServiceCatalogModule extends AbstractModule { + + @Override + protected void configure() { + + } + + @Provides + @Singleton + protected final Supplier> provideServiceCatalog(Injector i, + @Named(KeystoneProperties.KEYSTONE_VERSION) String keystoneVersion) { + Map>> serviceCatalogs = Maps.newHashMap(); + serviceCatalogs.put("2", i.getInstance(V2ServiceCatalog.class)); + serviceCatalogs.put("3", i.getInstance(V3ServiceCatalog.class)); + return serviceCatalogs.get(keystoneVersion); + } + + /** + * For global services who have no regions, such as DNS. To use, do the following + *

    + *
  1. add this module to your {@link org.jclouds.apis.ApiMetadata#getDefaultModules()}
  2. + *
  3. create a service-specific annotation, such as {@code @CloudDNS}, and make sure that has the meta-annotation + * {@link javax.inject.Qualifier}
  4. + *
  5. add the above annotation to any {@code Api} classes by placing it on the type. ex. + * {@code @Endpoint(CloudDNS.class)}
  6. + *
  7. add the following to your {@link org.jclouds.rest.config.RestClientModule}
  8. + * + *
    +    * bind(new TypeLiteral<Supplier<URI>>() {
    +    * }).annotatedWith(CloudDNS.class).to(new TypeLiteral<Supplier<URI>>() {
    +    * });
    +    * 
    + */ + public static class ProviderModule extends AbstractModule { + @Override + protected void configure() { + install(new FactoryModuleBuilder().build(LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory.class)); + } + + @Provides + @Singleton + protected final Supplier provideZoneIdToURISupplierForApiVersion( + @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, + LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory factory) { + return getLastValueInMap(factory.createForApiTypeAndVersion(serviceType, apiVersion)); + } + + @Provides + @Singleton + final Function provideProvider(@Provider final String provider) { + return new Function() { + @Override + public String apply(ServiceEndpoint in) { + return provider; + } + }; + } + } + + public static class RegionModule extends AbstractModule { + @Override + protected void configure() { + install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, + RegionIdToURIFromServiceEndpointsForTypeAndVersion.class).build(RegionIdToURISupplier.Factory.class)); + install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, + RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + // Dynamically build the region list as opposed to from properties + bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class); + bind(ImplicitLocationSupplier.class).to(FirstRegion.class).in(Scopes.SINGLETON); + bind(LocationsSupplier.class).to(RegionToProvider.class).in(Scopes.SINGLETON); + } + + @Provides + @Singleton + protected final RegionIdToURISupplier guiceProvideRegionIdToURISupplierForApiVersion( + @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, + RegionIdToURISupplier.Factory factory) { + return provideRegionIdToURISupplierForApiVersion(serviceType, apiVersion, factory); + } + + // Supply the region to id map from keystone, based on the servicetype and + // api version in config + protected RegionIdToURISupplier provideRegionIdToURISupplierForApiVersion( + @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, + RegionIdToURISupplier.Factory factory) { + return factory.createForApiTypeAndVersion(serviceType, apiVersion); + } + + @Provides + @Singleton + protected final RegionIdToAdminURISupplier guiceProvideRegionIdToAdminURISupplierForApiVersion( + @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, + RegionIdToAdminURISupplier.Factory factory) { + return provideRegionIdToAdminURISupplierForApiVersion(serviceType, apiVersion, factory); + } + + // Supply the region to id to AdminURL map from keystone, based on the + // servicetype and api version in config + protected RegionIdToAdminURISupplier provideRegionIdToAdminURISupplierForApiVersion( + @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, + RegionIdToAdminURISupplier.Factory factory) { + return factory.createForApiTypeAndVersion(serviceType, apiVersion); + } + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/AdminEndpointResolutionStrategy.java similarity index 70% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/AdminEndpointResolutionStrategy.java index 8b424f7cb2..3ee1d78268 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/AdminEndpointResolutionStrategy.java @@ -14,16 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.catalog.functions; -import java.net.URI; - -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; import com.google.inject.ImplementedBy; -@ImplementedBy(PublicURLOrInternalIfNull.class) -public interface EndpointToSupplierURI extends Function> { +/** + * Given a sets of endpoints for a particular service and version, return the + * URL of the admin endpoint to be used to connect to the service. + */ +@ImplementedBy(AdminURL.class) +public interface AdminEndpointResolutionStrategy extends ServiceEndpointResolutionStrategy { } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/AdminURL.java similarity index 65% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/AdminURL.java index 2669965048..b727ca1837 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/AdminURL.java @@ -14,25 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.catalog.functions; -import java.net.URI; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.ADMIN; import javax.inject.Singleton; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; +import com.google.common.base.Predicate; @Singleton -public class AdminURL implements EndpointToSupplierAdminURI { - @Override - public Supplier apply(Endpoint input) { - return Suppliers.ofInstance(input.getAdminURL()); - } +public class AdminURL extends BaseEndpointResolutionStrategy implements AdminEndpointResolutionStrategy { - public String toString() { - return "supplyAdminURL()"; + @Override + protected Predicate filter() { + return withIface(ADMIN); } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/BaseEndpointResolutionStrategy.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/BaseEndpointResolutionStrategy.java new file mode 100644 index 0000000000..23fe16d75b --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/BaseEndpointResolutionStrategy.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.functions; + +import static com.google.common.collect.Iterables.tryFind; + +import java.net.URI; +import java.util.Collection; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface; + +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; + +/** + * Resolves the endpoint to be used to connect to a service based on a given + * predicate. + */ +public abstract class BaseEndpointResolutionStrategy implements ServiceEndpointResolutionStrategy { + + protected abstract Predicate filter(); + + @Nullable + @Override + public Supplier apply(Collection input) { + Predicate filter = filter(); + Optional serviceEndpoint = tryFind(input, filter); + return Suppliers.ofInstance(serviceEndpoint.isPresent() ? serviceEndpoint.get().url() : null); + } + + protected static Predicate withIface(final Interface iface) { + return new Predicate() { + @Override + public boolean apply(ServiceEndpoint input) { + return input.iface().equals(iface); + } + + @Override + public String toString() { + return "interface(" + iface.name().toLowerCase() + ")"; + } + }; + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/AuthenticationApiModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/InternalURL.java similarity index 63% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/AuthenticationApiModule.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/InternalURL.java index 2537d63305..dfe44e3d3f 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/AuthenticationApiModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/InternalURL.java @@ -14,20 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.catalog.functions; -import static org.jclouds.rest.config.BinderUtils.bindHttpApi; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.INTERNAL; -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; +import javax.inject.Singleton; -import com.google.inject.AbstractModule; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; -public class AuthenticationApiModule extends AbstractModule { +import com.google.common.base.Predicate; + +@Singleton +public class InternalURL extends BaseEndpointResolutionStrategy { @Override - protected void configure() { - // AuthenticationApi is used directly for filters and retry handlers, so let's bind it explicitly - bindHttpApi(binder(), AuthenticationApi.class); + protected Predicate filter() { + return withIface(INTERNAL); } - } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/PublicURLOrInternal.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/PublicURLOrInternal.java new file mode 100644 index 0000000000..cbf01f967d --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/PublicURLOrInternal.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.functions; + +import static com.google.common.base.Predicates.or; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.INTERNAL; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.PUBLIC; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import javax.inject.Singleton; + +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; + +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; + +@Singleton +public class PublicURLOrInternal extends BaseEndpointResolutionStrategy { + + @Override + public Supplier apply(Collection input) { + List publicEndpointsFirst = new ArrayList(input); + Collections.sort(publicEndpointsFirst, PublicInterfacesFirst); + return super.apply(publicEndpointsFirst); + } + + @Override + protected Predicate filter() { + return or(withIface(PUBLIC), withIface(INTERNAL)); + } + + private static final Comparator PublicInterfacesFirst = new Comparator() { + @Override + public int compare(ServiceEndpoint left, ServiceEndpoint right) { + // We only care about public interfaces, since the collection will be + // filtered only by public or internal ones + if (PUBLIC.equals(left.iface())) { + return -1; + } else if (PUBLIC.equals(right.iface())) { + return 1; + } else { + return 0; + } + }; + }; +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProvider.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ReturnRegionOrProvider.java similarity index 69% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProvider.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ReturnRegionOrProvider.java index 2dfc32ed09..db1d314996 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProvider.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ReturnRegionOrProvider.java @@ -14,27 +14,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; - -import static com.google.common.base.Preconditions.checkNotNull; +package org.jclouds.openstack.keystone.catalog.functions; import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.location.Provider; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; @Singleton -public class ReturnRegionOrProvider implements EndpointToRegion { - private String provider; +public class ReturnRegionOrProvider implements ServiceEndpointToRegion { + private final String provider; @Inject ReturnRegionOrProvider(@Provider String provider) { - this.provider = checkNotNull(provider, "provider"); + this.provider = provider; } @Override - public String apply(Endpoint input) { - return input.getRegion() != null ? input.getRegion() : provider; + public String apply(ServiceEndpoint input) { + return input.regionId() != null ? input.regionId() : provider; } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/InternalURL.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ServiceEndpointResolutionStrategy.java similarity index 63% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/InternalURL.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ServiceEndpointResolutionStrategy.java index fbd23d2ea2..da8b654893 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/InternalURL.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ServiceEndpointResolutionStrategy.java @@ -14,30 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.catalog.functions; import java.net.URI; +import java.util.Collection; -import javax.inject.Singleton; - -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import com.google.common.base.Function; import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; +import com.google.inject.ImplementedBy; /** - * Select internal URL endpoints services - * + * Given a sets of endpoints for a particular service and version, return the + * URL to be used to connect to the service. */ -@Singleton -public class InternalURL implements EndpointToSupplierURI { - @Override - public Supplier apply(Endpoint input) { - return Suppliers.ofInstance(input.getInternalURL()); - } - - @Override - public String toString() { - return "supplyInternalURL()"; - } +@ImplementedBy(PublicURLOrInternal.class) +public interface ServiceEndpointResolutionStrategy extends Function, Supplier> { + } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ServiceEndpointToRegion.java similarity index 81% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ServiceEndpointToRegion.java index d3ec6d6c36..c1ed3f11ec 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/functions/ServiceEndpointToRegion.java @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.catalog.functions; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; import com.google.common.base.Function; import com.google.inject.ImplementedBy; @ImplementedBy(ReturnRegionOrProvider.class) -public interface EndpointToRegion extends Function { +public interface ServiceEndpointToRegion extends Function { } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/LocationIdToURIFromServiceEndpointsForTypeAndVersion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/LocationIdToURIFromServiceEndpointsForTypeAndVersion.java new file mode 100644 index 0000000000..aabfec2e83 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/LocationIdToURIFromServiceEndpointsForTypeAndVersion.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.suppliers; + +import static com.google.common.collect.Iterables.any; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.isEmpty; +import static com.google.common.collect.Maps.transformValues; +import static com.google.common.collect.Multimaps.asMap; +import static com.google.common.collect.Multimaps.index; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import javax.annotation.Resource; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.logging.Logger; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.functions.ServiceEndpointResolutionStrategy; +import org.jclouds.openstack.keystone.catalog.functions.ServiceEndpointToRegion; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.base.Supplier; +import com.google.common.collect.Multimap; +import com.google.inject.Inject; +import com.google.inject.assistedinject.Assisted; + +public class LocationIdToURIFromServiceEndpointsForTypeAndVersion implements Supplier>> { + + public interface Factory { + + LocationIdToURIFromServiceEndpointsForTypeAndVersion createForApiTypeAndVersion(@Assisted("apiType") String apiType, + @Nullable @Assisted("apiVersion") String apiVersion) throws NoSuchElementException; + } + + @Resource + protected Logger logger = Logger.NULL; + + protected final Supplier> serviceEndpoints; + protected final ServiceEndpointResolutionStrategy resolveServiceEndpointURI; + protected final ServiceEndpointToRegion serviceEndpointToRegion; + protected final String apiType; + protected final String apiVersion; + + @Inject + LocationIdToURIFromServiceEndpointsForTypeAndVersion(Supplier> serviceEndpoints, + ServiceEndpointResolutionStrategy resolveServiceEndpointURI, ServiceEndpointToRegion serviceEndpointToRegion, + @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { + this.serviceEndpoints = serviceEndpoints; + this.resolveServiceEndpointURI = resolveServiceEndpointURI; + this.serviceEndpointToRegion = serviceEndpointToRegion; + this.apiType = apiType; + this.apiVersion = apiVersion; + } + + @Override + public Map> get() { + List endpoints = serviceEndpoints.get(); + if (endpoints.isEmpty()) { + throw new NoSuchElementException( + "No endpoints were found in the service catalog. Make sure your authentication token has the right scopes and permissions"); + } + + // Filter endpoints by service type + Iterable endpointsForType = filter(endpoints, apiTypeEquals); + if (isEmpty(endpointsForType)) { + throw new NoSuchElementException(String.format("no endpoints for apiType %s in service endpoints %s", apiType, + endpoints)); + } + + // Check if there are endpoints for a particular version, if specified and + // there are versioned endpoints + boolean checkVersionId = apiVersion != null && any(endpointsForType, versionAware); + Predicate versionFilter = checkVersionId ? apiVersionEqualsVersionId : Predicates. alwaysTrue(); + Iterable endpointsForTypeAndVersion = filter(endpointsForType, versionFilter); + if (isEmpty(endpointsForTypeAndVersion)) { + throw new NoSuchElementException(String.format( + "no service endpoints for apiType %s are of version %s, or version agnostic: %s", apiType, apiVersion, + endpointsForType)); + } + + logger.debug("service endpoints for apiType %s and version %s: %s", apiType, apiVersion, + endpointsForTypeAndVersion); + + Multimap locationToServiceEndpoints = index(endpointsForTypeAndVersion, + serviceEndpointToRegion); + return transformValues(asMap(locationToServiceEndpoints), resolveServiceEndpointURI); + } + + private final Predicate apiVersionEqualsVersionId = new Predicate() { + @Override + public boolean apply(ServiceEndpoint input) { + return input.version().equals(apiVersion); + } + }; + + private final Predicate versionAware = new Predicate() { + @Override + public boolean apply(ServiceEndpoint input) { + return input.version() != null; + } + }; + + private final Predicate apiTypeEquals = new Predicate() { + @Override + public boolean apply(ServiceEndpoint input) { + return input.type().equals(apiType); + } + }; + + @Override + public String toString() { + return "locationIdToURIFromServiceEndpointsForTypeAndVersion(" + apiType + ", " + apiVersion + ")"; + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.java new file mode 100644 index 0000000000..742d4403a0 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.suppliers; + +import java.util.List; + +import javax.inject.Inject; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.functions.AdminEndpointResolutionStrategy; +import org.jclouds.openstack.keystone.catalog.functions.ServiceEndpointToRegion; + +import com.google.common.base.Supplier; +import com.google.inject.assistedinject.Assisted; + +public class RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion extends LocationIdToURIFromServiceEndpointsForTypeAndVersion implements + RegionIdToAdminURISupplier { + @Inject + public RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion(Supplier> serviceEndpoints, + AdminEndpointResolutionStrategy resolveServiceEndpointURI, ServiceEndpointToRegion serviceEndpointToRegion, + @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { + super(serviceEndpoints, resolveServiceEndpointURI, serviceEndpointToRegion, apiType, apiVersion); + } + + @Override + public String toString() { + return "regionIdToAdminURIFromServiceEndpointsForTypeAndVersion(" + apiType + ", " + apiVersion + ")"; + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToAdminURISupplier.java similarity index 72% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToAdminURISupplier.java index 759c2b9c5b..07f1773f6c 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToAdminURISupplier.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.suppliers; +package org.jclouds.openstack.keystone.catalog.suppliers; import java.net.URI; import java.util.Map; @@ -26,19 +26,11 @@ import com.google.common.base.Supplier; import com.google.inject.ImplementedBy; import com.google.inject.assistedinject.Assisted; -@ImplementedBy(RegionIdToAdminURIFromAccessForTypeAndVersion.class) +@ImplementedBy(RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.class) public interface RegionIdToAdminURISupplier extends Supplier>> { + interface Factory { - /** - * - * @param apiType - * type of the api, according to the provider. ex. {@code compute} - * {@code object-store} - * @param apiVersion - * version of the api, or null - * @return regions mapped to default uri - * @throws NoSuchElementException if the {@code apiType} is not present in the catalog - */ + RegionIdToAdminURISupplier createForApiTypeAndVersion(@Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) throws NoSuchElementException; } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToURIFromServiceEndpointsForTypeAndVersion.java similarity index 53% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersion.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToURIFromServiceEndpointsForTypeAndVersion.java index aff2814120..7065ee59e4 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersion.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/catalog/suppliers/RegionIdToURIFromServiceEndpointsForTypeAndVersion.java @@ -14,27 +14,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.suppliers; +package org.jclouds.openstack.keystone.catalog.suppliers; + +import java.util.List; import javax.inject.Inject; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierURI; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.functions.ServiceEndpointResolutionStrategy; +import org.jclouds.openstack.keystone.catalog.functions.ServiceEndpointToRegion; import com.google.common.base.Supplier; import com.google.inject.assistedinject.Assisted; -public class RegionIdToURIFromAccessForTypeAndVersion extends LocationIdToURIFromAccessForTypeAndVersion implements - RegionIdToURISupplier { +public class RegionIdToURIFromServiceEndpointsForTypeAndVersion extends LocationIdToURIFromServiceEndpointsForTypeAndVersion implements + RegionIdToURISupplier { @Inject - public RegionIdToURIFromAccessForTypeAndVersion(Supplier access, - EndpointToSupplierURI endpointToSupplierURI, EndpointToRegion endpointToRegion, - @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { - super(access, endpointToSupplierURI, endpointToRegion, apiType, apiVersion); + public RegionIdToURIFromServiceEndpointsForTypeAndVersion(Supplier> serviceEndpoints, + ServiceEndpointResolutionStrategy resolveServiceEndpointURI, ServiceEndpointToRegion serviceEndpointToRegion, + @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { + super(serviceEndpoints, resolveServiceEndpointURI, serviceEndpointToRegion, apiType, apiVersion); } @Override diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/config/KeystoneProperties.java similarity index 78% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/config/KeystoneProperties.java index dcb83cff7b..bab41a47d4 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/config/KeystoneProperties.java @@ -14,7 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.config; + +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.rest.annotations.SinceApiVersion; /** * Configuration properties and constants used in Keystone connections. @@ -28,6 +31,7 @@ public final class KeystoneProperties { *
      *
    • apiAccessKeyCredentials
    • *
    • passwordCredentials
    • + *
    • tokenCredentials
    • *
    * * @see CredentialTypes @@ -61,6 +65,20 @@ public final class KeystoneProperties { * @see openstack docs */ public static final String REQUIRES_TENANT = "jclouds.keystone.requires-tenant"; + + /** + * set this property to specify for scoped authentication. + *

    + * The format is one of the following: + *

      + *
    • project:
    • + *
    • domain:
    • + *
    • + *
    + * For example: project:457841231597451534 + */ + @SinceApiVersion("3") + public static final String SCOPE = "jclouds.keystone.scope"; /** * type of the keystone service. ex. {@code compute} @@ -68,6 +86,11 @@ public final class KeystoneProperties { * @see ServiceType */ public static final String SERVICE_TYPE = "jclouds.keystone.service-type"; + + /** + * Version of keystone to be used by services. Default: 3. + */ + public static final String KEYSTONE_VERSION = "jclouds.keystone.version"; private KeystoneProperties() { throw new AssertionError("intentionally unimplemented"); diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java index a06ea13be9..b8dbbcf91a 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java @@ -16,18 +16,19 @@ */ package org.jclouds.openstack.keystone.v2_0; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.catalog.config.KeystoneAdminURLModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule.KeystoneAdminURLModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.internal.BaseHttpApiMetadata; @@ -59,6 +60,7 @@ public class KeystoneApiMetadata extends BaseHttpApiMetadata { Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); properties.setProperty(SERVICE_TYPE, ServiceType.IDENTITY); + properties.setProperty(KEYSTONE_VERSION, "2"); return properties; } @@ -75,8 +77,8 @@ public class KeystoneApiMetadata extends BaseHttpApiMetadata { .defaultEndpoint("http://localhost:5000/v${jclouds.api-version}/") .defaultProperties(KeystoneApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.>builder() - .add(AuthenticationApiModule.class) - .add(KeystoneAuthenticationModule.class) + .add(AuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(KeystoneAdminURLModule.class) .add(KeystoneParserModule.class) .add(KeystoneHttpApiModule.class).build()); diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/auth/V2AuthenticationApi.java similarity index 56% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationApi.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/auth/V2AuthenticationApi.java index 0ac8a6c977..a5c222007e 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/auth/V2AuthenticationApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.auth; import java.io.Closeable; @@ -23,13 +23,13 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; -import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.domain.ApiAccessKeyCredentials; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; import org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload; import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; -import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.SelectJson; import com.google.inject.name.Named; @@ -39,7 +39,7 @@ import com.google.inject.name.Named; */ @Consumes(MediaType.APPLICATION_JSON) @Path("/tokens") -public interface AuthenticationApi extends Closeable { +public interface V2AuthenticationApi extends AuthenticationApi, Closeable { /** * Authenticate to generate a token. @@ -50,8 +50,8 @@ public interface AuthenticationApi extends Closeable { @POST @SelectJson("access") @MapBinder(BindAuthToJsonPayload.class) - Access authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, - PasswordCredentials passwordCredentials); + @Override + Access authenticatePassword(TenantOrDomainAndCredentials credentials); /** * Authenticate to generate a token. @@ -62,30 +62,7 @@ public interface AuthenticationApi extends Closeable { @POST @SelectJson("access") @MapBinder(BindAuthToJsonPayload.class) - Access authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, - PasswordCredentials passwordCredentials); + @Override + Access authenticateAccessKey(TenantOrDomainAndCredentials credentials); - /** - * Authenticate to generate a token. - * - * @return access with token - */ - @Named("authenticate") - @POST - @SelectJson("access") - @MapBinder(BindAuthToJsonPayload.class) - Access authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, - ApiAccessKeyCredentials apiAccessKeyCredentials); - - /** - * Authenticate to generate a token. - * - * @return access with token - */ - @Named("authenticate") - @POST - @SelectJson("access") - @MapBinder(BindAuthToJsonPayload.class) - Access authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, - ApiAccessKeyCredentials apiAccessKeyCredentials); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java index 71ef63d8b0..9980830cdd 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java @@ -16,24 +16,29 @@ */ package org.jclouds.openstack.keystone.v2_0.binders; -import com.google.common.base.Predicates; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.Iterables; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.collect.Iterables.tryFind; +import static org.jclouds.openstack.keystone.auth.config.CredentialTypes.findCredentialType; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.jclouds.http.HttpRequest; import org.jclouds.json.Json; -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; +import org.jclouds.openstack.keystone.auth.config.CredentialType; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; import org.jclouds.rest.MapBinder; import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Optional; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; @Singleton public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinder { @@ -42,28 +47,35 @@ public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinde super(jsonBinder); } - protected void addCredentialsInArgsOrNull(GeneratedHttpRequest gRequest, Builder builder) { - for (Object arg : Iterables.filter(gRequest.getInvocation().getArgs(), Predicates.notNull())) { - if (arg.getClass().isAnnotationPresent(CredentialType.class)) { - builder.put(arg.getClass().getAnnotation(CredentialType.class).value(), arg); - } - } + protected TenantOrDomainAndCredentials findCredentialsInArgs(GeneratedHttpRequest gRequest) { + Optional credentials = tryFind(gRequest.getInvocation().getArgs(), instanceOf(TenantOrDomainAndCredentials.class)); + return credentials.isPresent() ? (TenantOrDomainAndCredentials) credentials.get() : null; } @Override public R bindToRequest(R request, Map postParams) { checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); + "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - Builder builder = ImmutableMap.builder(); - addCredentialsInArgsOrNull(gRequest, builder); - // TODO: is tenantName permanent? or should we switch to tenantId at some point. seems most tools - // still use tenantName - if (!Strings.isNullOrEmpty((String) postParams.get("tenantName"))) - builder.put("tenantName", postParams.get("tenantName")); - else if (!Strings.isNullOrEmpty((String) postParams.get("tenantId"))) - builder.put("tenantId", postParams.get("tenantId")); + + TenantOrDomainAndCredentials credentials = findCredentialsInArgs(gRequest); + if (credentials != null) { + CredentialType credentialType = findCredentialType(credentials.credentials().getClass()); + checkArgument(credentialType != null, "the given credentials must be annotated with @CredentialType"); + + builder.put(credentialType.value(), credentials.credentials()); + + // TODO: is tenantName permanent? or should we switch to tenantId at + // some point. seems most tools still use tenantName + if (credentials != null) { + if (!Strings.isNullOrEmpty(credentials.tenantOrDomainId())) + builder.put("tenantId", credentials.tenantOrDomainId()); + else if (!Strings.isNullOrEmpty(credentials.tenantOrDomainName())) + builder.put("tenantName", credentials.tenantOrDomainName()); + } + } + R authRequest = super.bindToRequest(request, ImmutableMap.of("auth", builder.build())); authRequest.getPayload().setSensitive(true); return authRequest; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/catalog/V2ServiceCatalog.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/catalog/V2ServiceCatalog.java new file mode 100644 index 0000000000..913b0b5cd5 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/catalog/V2ServiceCatalog.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v2_0.catalog; + +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.ADMIN; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.INTERNAL; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.PUBLIC; + +import java.net.URI; +import java.util.List; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface; +import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.v2_0.domain.Service; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableList; + +@Singleton +public class V2ServiceCatalog implements Supplier> { + + @Resource + private Logger logger = Logger.NULL; + + private final Supplier authInfo; + + @Inject + V2ServiceCatalog(Supplier authInfo) { + this.authInfo = authInfo; + } + + @Override + public List get() { + Access access = (Access) authInfo.get(); + ImmutableList.Builder serviceEndpoints = ImmutableList.builder(); + for (Service service : access) { + for (Endpoint endpoint : service) { + if (endpoint.getAdminURL() != null) { + serviceEndpoints.add(toServiceEndpoint(service.getType(), ADMIN).apply(endpoint)); + } + if (endpoint.getInternalURL() != null) { + serviceEndpoints.add(toServiceEndpoint(service.getType(), INTERNAL).apply(endpoint)); + } + if (endpoint.getPublicURL() != null) { + serviceEndpoints.add(toServiceEndpoint(service.getType(), PUBLIC).apply(endpoint)); + } + } + } + + return serviceEndpoints.build(); + } + + private Function toServiceEndpoint(final String type, final Interface iface) { + return new Function() { + @Override + public ServiceEndpoint apply(Endpoint input) { + ServiceEndpoint.Builder builder = ServiceEndpoint.builder().id(input.getId()).iface(iface) + .regionId(input.getRegion()).type(type).version(input.getVersionId()); + + switch (iface) { + case ADMIN: + builder.url(input.getAdminURL()); + break; + case INTERNAL: + builder.url(input.getInternalURL()); + break; + case PUBLIC: + builder.url(input.getPublicURL()); + break; + case UNRECOGNIZED: + URI url = input.getPublicURL() != null ? input.getPublicURL() : input.getInternalURL(); + logger.warn("Unrecognized endpoint interface for %s. Using URL: %s", input, url); + builder.url(url); + break; + } + + return builder.build(); + } + }; + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java deleted file mode 100644 index 4d540fd37c..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.config; - -import static com.google.common.base.Preconditions.checkArgument; -import static org.jclouds.util.Suppliers2.getLastValueInMap; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.location.Provider; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.LocationsSupplier; -import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.location.suppliers.RegionIdsSupplier; -import org.jclouds.location.suppliers.ZoneIdToURISupplier; -import org.jclouds.location.suppliers.ZoneIdsSupplier; -import org.jclouds.location.suppliers.all.RegionToProvider; -import org.jclouds.location.suppliers.all.ZoneToProvider; -import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet; -import org.jclouds.location.suppliers.derived.ZoneIdsFromZoneIdToURIKeySet; -import org.jclouds.location.suppliers.implicit.FirstRegion; -import org.jclouds.location.suppliers.implicit.FirstZone; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.functions.AuthenticateApiAccessKeyCredentials; -import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials; -import org.jclouds.openstack.keystone.v2_0.handlers.RetryOnRenew; -import org.jclouds.openstack.keystone.v2_0.suppliers.LocationIdToURIFromAccessForTypeAndVersion; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersion; -import org.jclouds.openstack.keystone.v2_0.suppliers.ZoneIdToURIFromAccessForTypeAndVersion; -import org.jclouds.rest.annotations.ApiVersion; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.AbstractModule; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.assistedinject.FactoryModuleBuilder; - -public class KeystoneAuthenticationModule extends AbstractModule { - - /** - * For global services who have no regions, such as DNS. To use, do the following - *
      - *
    1. add this module to your {@link org.jclouds.apis.ApiMetadata#getDefaultModules()}
    2. - *
    3. create a service-specific annotation, such as {@code @CloudDNS}, and make sure that has the meta-annotation - * {@link javax.inject.Qualifier}
    4. - *
    5. add the above annotation to any {@code Api} classes by placing it on the type. ex. - * {@code @Endpoint(CloudDNS.class)}
    6. - *
    7. add the following to your {@link org.jclouds.rest.config.RestClientModule}
    8. - * - *
      -    * bind(new TypeLiteral<Supplier<URI>>() {
      -    * }).annotatedWith(CloudDNS.class).to(new TypeLiteral<Supplier<URI>>() {
      -    * });
      -    * 
      - */ - public static class ProviderModule extends AbstractModule { - @Override - protected void configure() { - install(new FactoryModuleBuilder().build(LocationIdToURIFromAccessForTypeAndVersion.Factory.class)); - } - - @Provides - @Singleton - protected final Supplier provideZoneIdToURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - LocationIdToURIFromAccessForTypeAndVersion.Factory factory) { - return getLastValueInMap(factory.createForApiTypeAndVersion(serviceType, apiVersion)); - } - - @Provides - @Singleton - final Function provideProvider(@Provider final String provider) { - return new Function() { - @Override - public String apply(Endpoint in) { - return provider; - } - }; - } - } - - public static class RegionModule extends AbstractModule { - @Override - protected void configure() { - install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, - RegionIdToURIFromAccessForTypeAndVersion.class).build(RegionIdToURISupplier.Factory.class)); - install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); - // dynamically build the region list as opposed to from properties - bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class); - bind(ImplicitLocationSupplier.class).to(FirstRegion.class).in(Scopes.SINGLETON); - bind(LocationsSupplier.class).to(RegionToProvider.class).in(Scopes.SINGLETON); - } - - @Provides - @Singleton - protected final RegionIdToURISupplier guiceProvideRegionIdToURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - RegionIdToURISupplier.Factory factory) { - return provideRegionIdToURISupplierForApiVersion(serviceType, apiVersion, factory); - } - - // supply the region to id map from keystone, based on the servicetype and api version in - // config - protected RegionIdToURISupplier provideRegionIdToURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - RegionIdToURISupplier.Factory factory) { - return factory.createForApiTypeAndVersion(serviceType, apiVersion); - } - - @Provides - @Singleton - protected final RegionIdToAdminURISupplier guiceProvideRegionIdToAdminURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - RegionIdToAdminURISupplier.Factory factory) { - return provideRegionIdToAdminURISupplierForApiVersion(serviceType, apiVersion, factory); - } - - // supply the region to id to AdminURL map from keystone, based on the servicetype and api - // version in - // config - protected RegionIdToAdminURISupplier provideRegionIdToAdminURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - RegionIdToAdminURISupplier.Factory factory) { - return factory.createForApiTypeAndVersion(serviceType, apiVersion); - } - - } - - /** - * @deprecated All OpenStack APIs rely on regions in jclouds 2.0. To be removed in jclouds 2.0. - */ - @Deprecated - public static class ZoneModule extends AbstractModule { - @Override - protected void configure() { - install(new FactoryModuleBuilder().implement(ZoneIdToURISupplier.class, - ZoneIdToURIFromAccessForTypeAndVersion.class).build(ZoneIdToURISupplier.Factory.class)); - // dynamically build the zone list as opposed to from properties - bind(ZoneIdsSupplier.class).to(ZoneIdsFromZoneIdToURIKeySet.class); - bind(ImplicitLocationSupplier.class).to(FirstZone.class).in(Scopes.SINGLETON); - bind(LocationsSupplier.class).to(ZoneToProvider.class).in(Scopes.SINGLETON); - } - - // supply the zone to id map from keystone, based on the servicetype and api version in - // config - @Provides - @Singleton - protected final ZoneIdToURISupplier provideZoneIdToURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - ZoneIdToURISupplier.Factory factory) { - return factory.createForApiTypeAndVersion(serviceType, apiVersion); - } - - } - - @Override - protected void configure() { - bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class); - } - - /** - * borrowing concurrency code to ensure that caching takes place properly - */ - @Provides - @Singleton - @Authentication - protected final Supplier provideAuthenticationTokenCache(final Supplier supplier) - throws InterruptedException, ExecutionException, TimeoutException { - return new Supplier() { - @Override - public String get() { - return supplier.get().getToken().getId(); - } - }; - } - - @Provides - @Singleton - protected final Map> provideAuthenticationMethods(Injector i) { - return authenticationMethods(i); - } - - protected Map> authenticationMethods(Injector i) { - Builder> fns = ImmutableSet.> builder(); - fns.add(i.getInstance(AuthenticatePasswordCredentials.class)); - fns.add(i.getInstance(AuthenticateApiAccessKeyCredentials.class)); - return CredentialTypes.indexByCredentialType(fns.build()); - } - - @Provides - @Singleton - protected final Function authenticationMethodForCredentialType( - @Named(KeystoneProperties.CREDENTIAL_TYPE) String credentialType, - Map> authenticationMethods) { - checkArgument(authenticationMethods.containsKey(credentialType), "credential type %s not in supported list: %s", - credentialType, authenticationMethods.keySet()); - return authenticationMethods.get(credentialType); - } - - // TODO: what is the timeout of the session token? modify default accordingly - // PROPERTY_SESSION_INTERVAL is default to 60 seconds, but we have this here at 11 hours for now. - @Provides - @Singleton - public final LoadingCache provideAccessCache(Function getAccess) { - return CacheBuilder.newBuilder().expireAfterWrite(11, TimeUnit.HOURS).build(CacheLoader.from(getAccess)); - } - - // Temporary conversion of a cache to a supplier until there is a single-element cache - // http://code.google.com/p/guava-libraries/issues/detail?id=872 - @Provides - @Singleton - protected final Supplier provideAccessSupplier(final LoadingCache cache, - @Provider final Supplier creds) { - return new Supplier() { - @Override - public Access get() { - return cache.getUnchecked(creds.get()); - } - }; - } - -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneHttpApiModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneHttpApiModule.java index fc8aca3973..34c23585f6 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneHttpApiModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneHttpApiModule.java @@ -16,10 +16,7 @@ */ package org.jclouds.openstack.keystone.v2_0.config; -import static org.jclouds.util.Suppliers2.getLastValueInMap; - import java.net.URI; -import java.util.NoSuchElementException; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -29,30 +26,21 @@ import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; -import org.jclouds.location.Provider; import org.jclouds.openstack.keystone.v2_0.KeystoneApi; import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier; -import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.domain.Extension; import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationMatchesExtensionSet; -import org.jclouds.openstack.v2_0.services.Identity; import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.rest.config.HttpApiModule; import org.jclouds.rest.functions.ImplicitOptionalConverter; -import org.jclouds.util.Suppliers2; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -import com.google.inject.AbstractModule; import com.google.inject.Binder; import com.google.inject.Provides; -import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.inject.multibindings.MapBinder; /** @@ -64,33 +52,6 @@ public class KeystoneHttpApiModule extends HttpApiModule { public KeystoneHttpApiModule() { } - public static class KeystoneAdminURLModule extends AbstractModule { - - @Override - protected void configure() { - install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); - } - - /** - * in some cases, there is no {@link ServiceType#IDENTITY} entry in the service catalog. In - * other cases, there's no adminURL entry present. Fallback to the provider in this case. - */ - @Provides - @Singleton - @Identity - protected final Supplier provideStorageUrl(final RegionIdToAdminURISupplier.Factory factory, - @ApiVersion final String version, @Provider final Supplier providerURI) { - Supplier identityServiceForVersion = getLastValueInMap(factory.createForApiTypeAndVersion( - ServiceType.IDENTITY, version)); - Supplier whenIdentityServiceIsntListedFallbackToProviderURI = Suppliers2.onThrowable( - identityServiceForVersion, NoSuchElementException.class, providerURI); - Supplier whenIdentityServiceHasNoAdminURLFallbackToProviderURI = Suppliers2.or( - whenIdentityServiceIsntListedFallbackToProviderURI, providerURI); - return whenIdentityServiceHasNoAdminURLFallbackToProviderURI; - } - } - // Allow providers to cleanly contribute their own aliases public static MapBinder namespaceAliasBinder(Binder binder) { return MapBinder.newMapBinder(binder, URI.class, URI.class, NamespaceAliases.class).permitDuplicates(); diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java index eb63a31fa9..58dac280dc 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java @@ -22,6 +22,7 @@ import java.beans.ConstructorProperties; import java.util.Set; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; import com.google.common.base.MoreObjects; import com.google.common.base.Objects; @@ -36,7 +37,7 @@ import com.google.common.collect.ImmutableSet; * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html" * /> */ -public class Access extends ForwardingSet implements Comparable { +public class Access extends ForwardingSet implements Comparable, AuthInfo { public static Builder builder() { return new ConcreteBuilder(); @@ -166,4 +167,9 @@ public class Access extends ForwardingSet implements Comparable return serviceCatalog; } + @Override + public String getAuthToken() { + return token.getId(); + } + } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java deleted file mode 100644 index b189a2ffe4..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; - -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.MoreObjects.ToStringHelper; - -/** - * Api AccessKey Credentials - * - * @see - */ -@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS) -public class ApiAccessKeyCredentials { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromApiAccessKeyCredentials(this); - } - - public static ApiAccessKeyCredentials createWithAccessKeyAndSecretKey(String accessKey, String secretKey) { - return new ApiAccessKeyCredentials(accessKey, secretKey); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected String accessKey; - protected String secretKey; - - /** - * @see ApiAccessKeyCredentials#getAccessKey() - */ - public T accessKey(String accessKey) { - this.accessKey = accessKey; - return self(); - } - - /** - * @see ApiAccessKeyCredentials#getSecretKey() - */ - public T secretKey(String secretKey) { - this.secretKey = secretKey; - return self(); - } - - public ApiAccessKeyCredentials build() { - return new ApiAccessKeyCredentials(accessKey, secretKey); - } - - public T fromApiAccessKeyCredentials(ApiAccessKeyCredentials in) { - return this - .accessKey(in.getAccessKey()) - .secretKey(in.getSecretKey()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String accessKey; - private final String secretKey; - - @ConstructorProperties({ - "accessKey", "secretKey" - }) - protected ApiAccessKeyCredentials(String accessKey, String secretKey) { - this.accessKey = checkNotNull(accessKey, "accessKey"); - this.secretKey = checkNotNull(secretKey, "secretKey"); - } - - /** - * @return the accessKey - */ - public String getAccessKey() { - return this.accessKey; - } - - /** - * @return the secretKey - */ - public String getSecretKey() { - return this.secretKey; - } - - @Override - public int hashCode() { - return Objects.hashCode(accessKey, secretKey); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ApiAccessKeyCredentials that = ApiAccessKeyCredentials.class.cast(obj); - return Objects.equal(this.accessKey, that.accessKey) - && Objects.equal(this.secretKey, that.secretKey); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("accessKey", accessKey).add("secretKey", secretKey); - } - - @Override - public String toString() { - return string().toString(); - } - -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java index f5424bd7f2..0080b2e6a1 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java @@ -22,8 +22,8 @@ import java.net.URI; import org.jclouds.javax.annotation.Nullable; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; /** * An network-accessible address, usually described by URL, where a service may diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java deleted file mode 100644 index 68b5f9950a..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; - -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.MoreObjects.ToStringHelper; - -/** - * Password Credentials - * - * @see - */ -@CredentialType("passwordCredentials") -public class PasswordCredentials { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromPasswordCredentials(this); - } - - public static PasswordCredentials createWithUsernameAndPassword(String username, String password) { - return new PasswordCredentials(username, password); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected String username; - protected String password; - - /** - * @see PasswordCredentials#getUsername() - */ - public T username(String username) { - this.username = username; - return self(); - } - - /** - * @see PasswordCredentials#getPassword() - */ - public T password(String password) { - this.password = password; - return self(); - } - - public PasswordCredentials build() { - return new PasswordCredentials(username, password); - } - - public T fromPasswordCredentials(PasswordCredentials in) { - return this - .username(in.getUsername()) - .password(in.getPassword()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String username; - private final String password; - - @ConstructorProperties({ - "username", "password" - }) - protected PasswordCredentials(String username, String password) { - this.username = checkNotNull(username, "username"); - this.password = checkNotNull(password, "password"); - } - - /** - * @return the username - */ - public String getUsername() { - return this.username; - } - - /** - * @return the password - */ - public String getPassword() { - return this.password; - } - - @Override - public int hashCode() { - return Objects.hashCode(username, password); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - PasswordCredentials that = PasswordCredentials.class.cast(obj); - return Objects.equal(this.username, that.username) - && Objects.equal(this.password, that.password); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("username", username) - .add("password", password == null ? null : "*****"); - } - - @Override - public String toString() { - return string().toString(); - } - -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java index 2d11b16178..f5ced864a9 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java @@ -30,8 +30,8 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.Role; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java index 8c9b8cf9ae..2bba9fab97 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java @@ -30,9 +30,9 @@ import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; import org.jclouds.openstack.keystone.v2_0.domain.Service; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseServices; import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseServices.ToPagedIterable; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java index 93489b39dc..f3dec87f17 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java @@ -28,8 +28,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.options.CreateTenantOptions; import org.jclouds.openstack.keystone.v2_0.options.UpdateTenantOptions; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java index 952b4a1d83..7102fca5a2 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.options.CreateUserOptions; import org.jclouds.openstack.keystone.v2_0.options.UpdateUserOptions; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceApi.java index dbf982db94..0836318b50 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceApi.java @@ -25,8 +25,8 @@ import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantApi.java index 85828bfe9f..1136a2f715 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantApi.java @@ -27,9 +27,9 @@ import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants; import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants.ToPagedIterable; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenApi.java index f61dc8be11..a6d39614e8 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenApi.java @@ -30,10 +30,10 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; import org.jclouds.openstack.keystone.v2_0.domain.Token; import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.services.Identity; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserApi.java index f7dd75e1e3..11d1ac0b5b 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserApi.java @@ -31,10 +31,10 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; import org.jclouds.openstack.keystone.v2_0.domain.Role; import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseUsers; import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseUsers.ToPagedIterable; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java deleted file mode 100644 index 7a42f336e9..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; -import org.jclouds.openstack.keystone.v2_0.functions.internal.BaseAuthenticator; - -import com.google.common.base.Optional; - -@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS) -@Singleton -public class AuthenticateApiAccessKeyCredentials extends BaseAuthenticator { - protected final AuthenticationApi api; - - @Inject - public AuthenticateApiAccessKeyCredentials(AuthenticationApi api) { - this.api = api; - } - - @Override - protected Access authenticateWithTenantName(Optional tenantName, ApiAccessKeyCredentials apiAccessKeyCredentials) { - return api.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials); - } - - @Override - protected Access authenticateWithTenantId(Optional tenantId, ApiAccessKeyCredentials apiAccessKeyCredentials) { - return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials); - } - - @Override - public ApiAccessKeyCredentials createCredentials(String identity, String credential) { - return ApiAccessKeyCredentials.createWithAccessKeyAndSecretKey(identity, credential); - } - - @Override - public String toString() { - return "authenticateApiAccessKeyCredentials()"; - } -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java deleted file mode 100644 index 15d1237102..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; -import org.jclouds.openstack.keystone.v2_0.functions.internal.BaseAuthenticator; - -import com.google.common.base.Optional; - -@CredentialType(CredentialTypes.PASSWORD_CREDENTIALS) -@Singleton -public class AuthenticatePasswordCredentials extends BaseAuthenticator { - protected final AuthenticationApi api; - - @Inject - public AuthenticatePasswordCredentials(AuthenticationApi api) { - this.api = api; - } - - @Override - protected Access authenticateWithTenantName(Optional tenantName, PasswordCredentials apiAccessKeyCredentials) { - return api.authenticateWithTenantNameAndCredentials(tenantName.orNull(), apiAccessKeyCredentials); - } - - @Override - protected Access authenticateWithTenantId(Optional tenantId, PasswordCredentials apiAccessKeyCredentials) { - return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiAccessKeyCredentials); - } - - @Override - public PasswordCredentials createCredentials(String identity, String credential) { - return PasswordCredentials.createWithUsernameAndPassword(identity, credential); - } - - @Override - public String toString() { - return "authenticatePasswordCredentials()"; - } -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java deleted file mode 100644 index c6c1a34f14..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -public final class RegionToAdminEndpointURI implements Function { - - private final RegionIdToAdminURISupplier regionToAdminEndpoints; - - @Inject - RegionToAdminEndpointURI(RegionIdToAdminURISupplier regionToAdminEndpoints) { - this.regionToAdminEndpoints = regionToAdminEndpoints; - } - - @Override - public URI apply(Object from) { - Map> regionToAdminEndpoint = regionToAdminEndpoints.get(); - checkState(!regionToAdminEndpoint.isEmpty(), "no region name to admin endpoint mappings in keystone!"); - checkArgument(regionToAdminEndpoint.containsKey(from), - "requested location %s, which is not in the keystone admin endpoints: %s", from, regionToAdminEndpoint); - return regionToAdminEndpoint.get(from).get(); - } -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersion.java deleted file mode 100644 index 063f4a6858..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersion.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.suppliers; - -import static com.google.common.collect.Iterables.any; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.isEmpty; -import static com.google.common.collect.Iterables.tryFind; -import static com.google.common.collect.Multimaps.index; - - -import java.net.URI; -import java.util.Collection; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.annotation.Resource; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.logging.Logger; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.domain.Service; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierURI; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; -import com.google.inject.Inject; -import com.google.inject.assistedinject.Assisted; - -public class LocationIdToURIFromAccessForTypeAndVersion implements Supplier>> { - - public interface Factory { - /** - * - * @param apiType - * type of the api, according to the provider. ex. - * {@code compute} {@code object-store} - * @param apiVersion - * version of the api, or null if not available - * @return locations mapped to default uri - * @throws NoSuchElementException - * if the {@code apiType} is not present in the catalog - */ - LocationIdToURIFromAccessForTypeAndVersion createForApiTypeAndVersion(@Assisted("apiType") String apiType, - @Nullable @Assisted("apiVersion") String apiVersion) throws NoSuchElementException; - } - - @Resource - protected Logger logger = Logger.NULL; - - protected final Supplier access; - protected final EndpointToSupplierURI endpointToSupplierURI; - protected final Function endpointToLocationId; - protected final String apiType; - protected final String apiVersion; - - @Inject - public LocationIdToURIFromAccessForTypeAndVersion(Supplier access, - EndpointToSupplierURI endpointToSupplierURI, Function endpointToLocationId, - @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { - this.access = access; - this.endpointToSupplierURI = endpointToSupplierURI; - this.endpointToLocationId = endpointToLocationId; - this.apiType = apiType; - this.apiVersion = apiVersion; - } - - @Override - public Map> get() { - FluentIterable services = FluentIterable.from(access.get()).filter(apiTypeEquals); - if (services.isEmpty()) - throw new NoSuchElementException(String.format("apiType %s not found in catalog %s", apiType, services)); - - Iterable endpoints = concat(services); - - if (isEmpty(endpoints)) - throw new NoSuchElementException( - String.format("no endpoints for apiType %s in services %s", apiType, services)); - - boolean checkVersionId = any(endpoints, versionAware); - - Multimap locationToEndpoints = index(endpoints, endpointToLocationId); - Map locationToEndpoint; - if (checkVersionId && apiVersion != null) { - locationToEndpoint = refineToVersionSpecificEndpoint(locationToEndpoints); - if (locationToEndpoint.size() == 0) - throw new NoSuchElementException(String.format( - "no endpoints for apiType %s are of version %s, or version agnostic: %s", apiType, apiVersion, - locationToEndpoints)); - } else { - locationToEndpoint = firstEndpointInLocation(locationToEndpoints); - } - - logger.debug("endpoints for apiType %s and version %s: %s", apiType, apiVersion, locationToEndpoints); - return Maps.transformValues(locationToEndpoint, endpointToSupplierURI); - } - - @VisibleForTesting - Map firstEndpointInLocation(Multimap locationToEndpoints) { - Builder locationToEndpointBuilder = ImmutableMap. builder(); - for (Map.Entry> entry : locationToEndpoints.asMap().entrySet()) { - String locationId = entry.getKey(); - Collection endpoints = entry.getValue(); - switch (endpoints.size()) { - case 0: - logNoEndpointsInLocation(locationId); - break; - default: - locationToEndpointBuilder.put(locationId, Iterables.get(endpoints, 0)); - } - } - return locationToEndpointBuilder.build(); - } - - @VisibleForTesting - Map refineToVersionSpecificEndpoint(Multimap locationToEndpoints) { - Builder locationToEndpointBuilder = ImmutableMap. builder(); - for (Map.Entry> entry : locationToEndpoints.asMap().entrySet()) { - String locationId = entry.getKey(); - Collection endpoints = entry.getValue(); - switch (endpoints.size()) { - case 0: - logNoEndpointsInLocation(locationId); - break; - default: - putIfPresent(locationId, strictMatchEndpointVersion(endpoints, locationId), locationToEndpointBuilder); - } - - } - return locationToEndpointBuilder.build(); - } - - /** - * Prioritizes endpoint.versionId over endpoint.id when matching - */ - private Optional strictMatchEndpointVersion(Iterable endpoints, String locationId) { - Optional endpointOfVersion = tryFind(endpoints, apiVersionEqualsVersionId); - if (!endpointOfVersion.isPresent()) - logger.debug("no endpoints of apiType %s matched expected version %s in location %s: %s", apiType, apiVersion, - locationId, endpoints); - return endpointOfVersion; - } - - private void logNoEndpointsInLocation(String locationId) { - logger.debug("no endpoints found for apiType %s in location %s", apiType, locationId); - } - - private final Predicate apiVersionEqualsVersionId = new Predicate() { - - @Override - public boolean apply(Endpoint input) { - return input.getVersionId().equals(apiVersion); - } - - }; - - private final Predicate versionAware = new Predicate() { - - @Override - public boolean apply(Endpoint input) { - return input.getVersionId() != null; - } - - }; - - private final Predicate apiTypeEquals = new Predicate() { - - @Override - public boolean apply(Service input) { - return input.getType().equals(apiType); - } - - }; - - private static void putIfPresent(K key, Optional value, Builder builder) { - if (value.isPresent()) - builder.put(key, value.get()); - } - - @Override - public String toString() { - return "locationIdToURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")"; - } -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersion.java deleted file mode 100644 index bd794d284a..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersion.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.suppliers; - -import javax.inject.Inject; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierAdminURI; - -import com.google.common.base.Supplier; -import com.google.inject.assistedinject.Assisted; - -public class RegionIdToAdminURIFromAccessForTypeAndVersion extends LocationIdToURIFromAccessForTypeAndVersion implements - RegionIdToAdminURISupplier { - @Inject - public RegionIdToAdminURIFromAccessForTypeAndVersion(Supplier access, - EndpointToSupplierAdminURI endpointToSupplierURI, EndpointToRegion endpointToRegion, - @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { - super(access, endpointToSupplierURI, endpointToRegion, apiType, apiVersion); - } - - @Override - public String toString() { - return "regionIdToAdminURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")"; - } -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersion.java deleted file mode 100644 index 41f936be5a..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersion.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.suppliers; - -import javax.inject.Inject; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.suppliers.ZoneIdToURISupplier; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierURI; - -import com.google.common.base.Supplier; -import com.google.inject.assistedinject.Assisted; - -public class ZoneIdToURIFromAccessForTypeAndVersion extends LocationIdToURIFromAccessForTypeAndVersion implements - ZoneIdToURISupplier { - - @Inject - public ZoneIdToURIFromAccessForTypeAndVersion( - Supplier access, - // NOTE that in some services, the region is in fact the zone. temporarily, we need - // to use the region field, in this case. - EndpointToSupplierURI endpointToSupplierURI, EndpointToRegion endpointToZone, - @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { - super(access, endpointToSupplierURI, endpointToZone, apiType, apiVersion); - } - - @Override - public String toString() { - return "zoneIdToURIFromAccessForTypeAndVersion(" + apiType + ", " + apiVersion + ")"; - } -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApi.java new file mode 100644 index 0000000000..05cd91d665 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApi.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3; + +import java.io.Closeable; + +import org.jclouds.openstack.keystone.v3.features.AuthApi; +import org.jclouds.openstack.keystone.v3.features.CatalogApi; +import org.jclouds.openstack.keystone.v3.features.ProjectApi; +import org.jclouds.openstack.keystone.v3.features.RegionApi; +import org.jclouds.openstack.keystone.v3.features.UserApi; +import org.jclouds.rest.annotations.Delegate; + +/** + * Provides access to the OpenStack Identity (Keystone) REST API. + */ +public interface KeystoneApi extends Closeable { + + /** + * Provides access to authentication and token management features. + */ + @Delegate + AuthApi getAuthApi(); + + /** + * Provides access to service catalog features. + */ + @Delegate + CatalogApi getCatalogApi(); + + /** + * Provides access to region features. + */ + @Delegate + RegionApi getRegionApi(); + + /** + * Provides access to project features. + */ + @Delegate + ProjectApi getProjectApi(); + + /** + * Provides access to user features. + */ + @Delegate + UserApi getUserApi(); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java new file mode 100644 index 0000000000..14fe19af96 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3; + +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.catalog.config.KeystoneAdminURLModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.v3.config.KeystoneHttpApiModule; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.rest.internal.BaseHttpApiMetadata; + +import com.google.auto.service.AutoService; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * Implementation of {@link ApiMetadata} for Keystone 3.0 API + */ +@AutoService(ApiMetadata.class) +public class KeystoneApiMetadata extends BaseHttpApiMetadata { + + @Override + public Builder toBuilder() { + return new ConcreteBuilder().fromApiMetadata(this); + } + + public KeystoneApiMetadata() { + this(new ConcreteBuilder()); + } + + protected KeystoneApiMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = BaseHttpApiMetadata.defaultProperties(); + properties.setProperty(CREDENTIAL_TYPE, org.jclouds.openstack.keystone.auth.config.CredentialTypes.PASSWORD_CREDENTIALS); + properties.setProperty(SERVICE_TYPE, ServiceType.IDENTITY); + properties.setProperty(KEYSTONE_VERSION, "3"); + return properties; + } + + public abstract static class Builder> extends BaseHttpApiMetadata.Builder { + + protected Builder() { + id("openstack-keystone-3") + .name("OpenStack Keystone 3.x API") + .identityName("${domain}:${userName} or ${userName}, if your keystone supports a default project") + .credentialName("${password}") + .endpointName("Keystone V3 base URL") + .documentation(URI.create("http://api.openstack.org/")) + .version("3") + .defaultEndpoint("http://localhost/identity/v3") + .defaultProperties(KeystoneApiMetadata.defaultProperties()) + .defaultModules(ImmutableSet.>builder() + .add(AuthenticationModule.class) + .add(ServiceCatalogModule.class) + .add(KeystoneAdminURLModule.class) + .add(KeystoneHttpApiModule.class) + .build()); + } + + @Override + public KeystoneApiMetadata build() { + return new KeystoneApiMetadata(this); + } + } + + private static class ConcreteBuilder extends Builder { + @Override + protected ConcreteBuilder self() { + return this; + } + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java new file mode 100644 index 0000000000..0902f659a6 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.auth; + +import java.io.Closeable; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; + +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.TokenCredentials; +import org.jclouds.openstack.keystone.v3.binders.BindPasswordAuthToJsonPayload; +import org.jclouds.openstack.keystone.v3.binders.BindTokenAuthToJsonPayload; +import org.jclouds.openstack.keystone.v3.domain.Token; +import org.jclouds.openstack.keystone.v3.parsers.ParseTokenFromHttpResponse; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.ResponseParser; + +import com.google.inject.name.Named; + +/** + * Provides access to the OpenStack Keystone Authentication API. + */ +@Consumes(MediaType.APPLICATION_JSON) +@Path("/auth/tokens") +public interface V3AuthenticationApi extends AuthenticationApi, Closeable { + + @Named("token:create") + @POST + @ResponseParser(ParseTokenFromHttpResponse.class) + @MapBinder(BindPasswordAuthToJsonPayload.class) + @Override + Token authenticatePassword(TenantOrDomainAndCredentials credentials); + + @Named("token:create") + @POST + @ResponseParser(ParseTokenFromHttpResponse.class) + @MapBinder(BindTokenAuthToJsonPayload.class) + @Override + Token authenticateToken(TenantOrDomainAndCredentials credentials); + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindAuthToJsonPayload.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindAuthToJsonPayload.java new file mode 100644 index 0000000000..a27ae12d12 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindAuthToJsonPayload.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.binders; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.collect.Iterables.tryFind; +import static org.jclouds.openstack.keystone.v3.domain.Auth.Scope.DOMAIN; +import static org.jclouds.openstack.keystone.v3.domain.Auth.Scope.DOMAIN_ID; +import static org.jclouds.openstack.keystone.v3.domain.Auth.Scope.PROJECT; +import static org.jclouds.openstack.keystone.v3.domain.Auth.Scope.PROJECT_ID; +import static org.jclouds.openstack.keystone.v3.domain.Auth.Scope.UNSCOPED; + +import java.util.Map; +import java.util.Set; + +import org.jclouds.http.HttpRequest; +import org.jclouds.json.Json; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.v3.domain.Auth; +import org.jclouds.openstack.keystone.v3.domain.Auth.DomainIdScope; +import org.jclouds.openstack.keystone.v3.domain.Auth.DomainScope; +import org.jclouds.openstack.keystone.v3.domain.Auth.Id; +import org.jclouds.openstack.keystone.v3.domain.Auth.Name; +import org.jclouds.openstack.keystone.v3.domain.Auth.ProjectIdScope; +import org.jclouds.openstack.keystone.v3.domain.Auth.ProjectScope; +import org.jclouds.openstack.keystone.v3.domain.Auth.ProjectScope.ProjectName; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToJsonPayload; +import org.jclouds.rest.internal.GeneratedHttpRequest; + +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +public abstract class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinder { + + private static final Set SCOPE_PREFIXES = ImmutableSet + .of(PROJECT, PROJECT_ID, DOMAIN, DOMAIN_ID); + + protected BindAuthToJsonPayload(Json jsonBinder) { + super(jsonBinder); + } + + protected abstract Auth buildAuth(TenantOrDomainAndCredentials credentials, Object scope); + + @Override + public R bindToRequest(R request, Map postParams) { + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + "this binder is only valid for GeneratedHttpRequests!"); + GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; + + Optional authentication = tryFind(gRequest.getInvocation().getArgs(), + instanceOf(TenantOrDomainAndCredentials.class)); + checkArgument(authentication.isPresent(), "no credentials found in the api call arguments"); + + @SuppressWarnings("unchecked") + TenantOrDomainAndCredentials credentials = (TenantOrDomainAndCredentials) authentication.get(); + Object scope = parseScope(credentials); + Auth auth = buildAuth(credentials, scope); + + R authRequest = super.bindToRequest(request, ImmutableMap.of("auth", auth)); + authRequest.getPayload().setSensitive(true); + + return authRequest; + } + + private Object parseScope(TenantOrDomainAndCredentials credentials) { + String scope = credentials.scope(); + // If there is no prefix, assume an unscoped authentication + if (!scope.contains(":")) { + checkArgument(scope.equals(UNSCOPED), "Invalid scope: %s", scope); + return UNSCOPED; + } + // Otherwise, parse if it is a project or domain scope + String[] parts = scope.split(":"); + checkArgument(parts.length == 2, "Invalid scope: %s", scope); + checkArgument(SCOPE_PREFIXES.contains(parts[0]), "Scope prefix should be: %s", SCOPE_PREFIXES); + + if (PROJECT.equals(parts[0])) { + Object domainScope = credentials.tenantOrDomainId() != null ? Id.create(credentials.tenantOrDomainId()) : Name + .create(credentials.tenantOrDomainName()); + return ProjectScope.create(ProjectName.create(parts[1], domainScope)); + } else if (PROJECT_ID.equals(parts[0])) { + return ProjectIdScope.create(Id.create(parts[1])); + } else if (DOMAIN.equals(parts[0])) { + return DomainScope.create(Name.create(parts[1])); + } else { + return DomainIdScope.create(Id.create(parts[1])); + } + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindPasswordAuthToJsonPayload.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindPasswordAuthToJsonPayload.java new file mode 100644 index 0000000000..40c94f89ec --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindPasswordAuthToJsonPayload.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.binders; + +import static java.util.Collections.singletonList; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.json.Json; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.v3.domain.Auth; +import org.jclouds.openstack.keystone.v3.domain.Auth.Identity; +import org.jclouds.openstack.keystone.v3.domain.Auth.Identity.PasswordAuth; +import org.jclouds.openstack.keystone.v3.domain.Auth.Identity.PasswordAuth.UserAuth; +import org.jclouds.openstack.keystone.v3.domain.Auth.Identity.PasswordAuth.UserAuth.DomainAuth; + +@Singleton +public class BindPasswordAuthToJsonPayload extends BindAuthToJsonPayload { + + @Inject + BindPasswordAuthToJsonPayload(Json jsonBinder) { + super(jsonBinder); + } + + @Override + protected Auth buildAuth(TenantOrDomainAndCredentials credentials, Object scope) { + PasswordCredentials creds = credentials.credentials(); + DomainAuth domain = DomainAuth.create(credentials.tenantOrDomainName()); + UserAuth user = UserAuth.create(creds.username(), domain, creds.password()); + + return Auth.create(Identity.create(singletonList("password"), null, PasswordAuth.create(user)), scope); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindTokenAuthToJsonPayload.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindTokenAuthToJsonPayload.java new file mode 100644 index 0000000000..439baa29eb --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/binders/BindTokenAuthToJsonPayload.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.binders; + +import static java.util.Collections.singletonList; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.json.Json; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.TokenCredentials; +import org.jclouds.openstack.keystone.v3.domain.Auth; +import org.jclouds.openstack.keystone.v3.domain.Auth.Id; +import org.jclouds.openstack.keystone.v3.domain.Auth.Identity; + +@Singleton +public class BindTokenAuthToJsonPayload extends BindAuthToJsonPayload { + + @Inject + BindTokenAuthToJsonPayload(Json jsonBinder) { + super(jsonBinder); + } + + @Override + protected Auth buildAuth(TenantOrDomainAndCredentials credentials, Object scope) { + Id token = Id.create(credentials.credentials().id()); + return Auth.create(Identity.create(singletonList("token"), token, null), scope); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/catalog/V3ServiceCatalog.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/catalog/V3ServiceCatalog.java new file mode 100644 index 0000000000..0e86f2bc25 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/catalog/V3ServiceCatalog.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.catalog; + +import java.util.List; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.v3.domain.Catalog; +import org.jclouds.openstack.keystone.v3.domain.Endpoint; +import org.jclouds.openstack.keystone.v3.domain.Token; + +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableList; + +@Singleton +public class V3ServiceCatalog implements Supplier> { + + @Resource + private Logger logger = Logger.NULL; + + private final Supplier authInfo; + + @Inject + V3ServiceCatalog(Supplier authInfo) { + this.authInfo = authInfo; + } + + @Override + public List get() { + Token token = (Token) authInfo.get(); + + ImmutableList.Builder serviceEndpoints = ImmutableList.builder(); + for (Catalog catalog : token.catalog()) { + for (Endpoint endpoint : catalog.endpoints()) { + serviceEndpoints.add(ServiceEndpoint.builder().id(endpoint.id()).iface(endpoint.iface()) + .regionId(endpoint.regionId()).type(catalog.type()).url(endpoint.url()).build()); + } + } + + return serviceEndpoints.build(); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java new file mode 100644 index 0000000000..121268019b --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.config; + +import org.jclouds.json.config.GsonModule; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.openstack.keystone.v3.KeystoneApi; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.config.HttpApiModule; + +/** + * Configures the Keystone API. + */ +@ConfiguresHttpApi +public class KeystoneHttpApiModule extends HttpApiModule { + + @Override + protected void configure() { + super.configure(); + bind(DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java new file mode 100644 index 0000000000..58c9ee62f1 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class Auth { + public abstract Identity identity(); + @Nullable public abstract Object scope(); + + @SerializedNames({ "identity", "scope" }) + public static Auth create(Identity identity, Object scope) { + return new AutoValue_Auth(identity, scope); + } + + @AutoValue + public abstract static class Identity { + public abstract List methods(); + @Nullable public abstract Id token(); + @Nullable public abstract PasswordAuth password(); + + @SerializedNames({ "methods", "token", "password" }) + public static Identity create(List methods, Id token, PasswordAuth password) { + return new AutoValue_Auth_Identity(methods, token, password); + } + + @AutoValue + public abstract static class PasswordAuth { + public abstract UserAuth user(); + + @SerializedNames({ "user" }) + public static PasswordAuth create(UserAuth user) { + return new AutoValue_Auth_Identity_PasswordAuth(user); + } + + @AutoValue + public abstract static class UserAuth { + public abstract String name(); + public abstract DomainAuth domain(); + public abstract String password(); + + @SerializedNames({ "name", "domain", "password" }) + public static UserAuth create(String name, DomainAuth domain, String password) { + return new AutoValue_Auth_Identity_PasswordAuth_UserAuth(name, domain, password); + } + + @AutoValue + public abstract static class DomainAuth { + @Nullable public abstract String name(); + + @SerializedNames({ "name" }) + public static DomainAuth create(String name) { + return new AutoValue_Auth_Identity_PasswordAuth_UserAuth_DomainAuth(name); + } + } + } + } + } + + @AutoValue + public abstract static class Id { + public abstract String id(); + + @SerializedNames({ "id" }) + public static Id create(String id) { + return new AutoValue_Auth_Id(id); + } + } + + @AutoValue + public abstract static class Name { + @Nullable public abstract String name(); + + @SerializedNames({ "name" }) + public static Name create(String name) { + return new AutoValue_Auth_Name(name); + } + } + + public static class Scope { + public static final String PROJECT = "project"; + public static final String PROJECT_ID = "projectId"; + public static final String DOMAIN = "domain"; + public static final String DOMAIN_ID = "domainId"; + public static final String UNSCOPED = "unscoped"; + } + + @AutoValue + public abstract static class ProjectScope { + public abstract ProjectName project(); + + @SerializedNames({ Scope.PROJECT }) + public static ProjectScope create(ProjectName project) { + return new AutoValue_Auth_ProjectScope(project); + } + + @AutoValue + public abstract static class ProjectName { + public abstract String name(); + @Nullable public abstract Object domain(); + + @SerializedNames({ "name", Scope.DOMAIN }) + public static ProjectName create(String name, Object domain) { + return new AutoValue_Auth_ProjectScope_ProjectName(name, domain); + } + + public static ProjectName create(String name, Name domain) { + return new AutoValue_Auth_ProjectScope_ProjectName(name, domain); + } + + public static ProjectName create(String name, Id domain) { + return new AutoValue_Auth_ProjectScope_ProjectName(name, domain); + } + } + } + + @AutoValue + public abstract static class ProjectIdScope { + public abstract Id project(); + + @SerializedNames({ Scope.PROJECT }) + public static ProjectIdScope create(Id id) { + return new AutoValue_Auth_ProjectIdScope(id); + } + } + + @AutoValue + public abstract static class DomainIdScope { + public abstract Id domain(); + + @SerializedNames({ Scope.DOMAIN }) + public static DomainIdScope create(Id id) { + return new AutoValue_Auth_DomainIdScope(id); + } + } + + @AutoValue + public abstract static class DomainScope { + public abstract Name domain(); + + @SerializedNames({ Scope.DOMAIN }) + public static DomainScope create(Name name) { + return new AutoValue_Auth_DomainScope(name); + } + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Catalog.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Catalog.java new file mode 100644 index 0000000000..8fa6b7d0ef --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Catalog.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class Catalog { + + public abstract String id(); + @Nullable public abstract String name(); + public abstract String type(); + public abstract List endpoints(); + + @SerializedNames({ "id", "name", "type", "endpoints" }) + public static Catalog create(String id, String name, String type, List endpoints) { + return builder().id(id).name(name).type(type).endpoints(endpoints).build(); + } + + Catalog() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Catalog.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder type(String type); + public abstract Builder endpoints(List endpoints); + + abstract List endpoints(); + abstract Catalog autoBuild(); + + public Catalog build() { + endpoints(endpoints() == null ? ImmutableList. of() : ImmutableList.copyOf(endpoints())); + return autoBuild(); + } + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Endpoint.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Endpoint.java new file mode 100644 index 0000000000..0c6b919c3b --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Endpoint.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import java.net.URI; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class Endpoint { + + @Nullable public abstract String id(); + @Nullable public abstract String region(); + @Nullable public abstract String regionId(); + @Nullable public abstract String serviceId(); + public abstract URI url(); + @Nullable public abstract Boolean enabled(); + public abstract String iface(); + + @SerializedNames({ "id", "region", "region_id", "service_id", "url", "enabled", "interface" }) + public static Endpoint create(String id, String region, String regionId, String serviceId, URI url, Boolean enabled, + String iface) { + return builder().id(serviceId).region(region).regionId(regionId).serviceId(serviceId).url(url).enabled(enabled) + .iface(iface).build(); + } + + Endpoint() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Endpoint.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder region(String region); + public abstract Builder regionId(String regionId); + public abstract Builder serviceId(String serviceId); + public abstract Builder url(URI url); + public abstract Builder enabled(Boolean enabled); + public abstract Builder iface(String iface); + public abstract Endpoint build(); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Group.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Group.java new file mode 100644 index 0000000000..ee2738ae58 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Group.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class Group { + + public abstract String id(); + public abstract String name(); + @Nullable public abstract String description(); + @Nullable public abstract String domainId(); + @Nullable public abstract Link link(); + + @SerializedNames({ "id", "name", "description", "domain_id", "links" }) + public static Group create(String id, String name, String description, String domainId, Link link) { + return builder().id(id).name(name).description(description).domainId(domainId).link(link).build(); + } + + Group() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Group.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder name(String String); + public abstract Builder description(String description); + public abstract Builder domainId(String domainId); + public abstract Builder link(Link link); + public abstract Group build(); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Link.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Link.java new file mode 100644 index 0000000000..0d86069cdf --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Link.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class Link { + + public abstract String self(); + + @SerializedNames({"self"}) + public static Link create(String self) { + return new AutoValue_Link(self); + } + + Link() { + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Project.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Project.java new file mode 100644 index 0000000000..00ae34a544 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Project.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class Project { + + public abstract boolean isDomain(); + @Nullable public abstract String description(); + @Nullable public abstract String domainId(); + @Nullable public abstract String domainName(); + public abstract boolean enabled(); + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String parentId(); + @Nullable public abstract List tags(); + @Nullable public abstract Link link(); + + @SerializedNames({ "is_domain", "description", "domain_id", "domain_name", "enabled", "id", "name", "parent_id", + "tags", "links" }) + public static Project create(boolean isDomain, String description, String domainId, String domainName, + boolean enabled, String id, String name, String parentId, List tags, Link link) { + return builder().isDomain(isDomain).description(description).domainId(domainId).domainName(domainName) + .enabled(enabled).id(id).name(name).parentId(parentId).tags(tags).link(link).build(); + } + + Project() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Project.Builder().isDomain(false).enabled(true); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder isDomain(boolean isDomain); + public abstract Builder description(String description); + public abstract Builder domainId(String domainId); + public abstract Builder domainName(String domainName); + public abstract Builder enabled(boolean enabled); + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder parentId(String parentId); + public abstract Builder tags(List tags); + public abstract Builder link(Link link); + + abstract List tags(); + abstract Project autoBuild(); + + public Project build() { + tags(tags() == null ? null : ImmutableList.copyOf(tags())); + return autoBuild(); + } + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Region.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Region.java new file mode 100644 index 0000000000..70598fed98 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Region.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class Region { + + public abstract String id(); + public abstract String description(); + @Nullable public abstract Link link(); + @Nullable public abstract String parentRegionId(); + + @SerializedNames({ "id", "description", "links", "parent_region_id" }) + public static Region create(String id, String description, Link link, String parentRegionId) { + return builder().id(id).description(description).link(link).parentRegionId(parentRegionId).build(); + } + + Region() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Region.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder description(String name); + public abstract Builder link(Link link); + public abstract Builder parentRegionId(String parentRegionId); + public abstract Region build(); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Token.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Token.java new file mode 100644 index 0000000000..8fc20a82b2 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Token.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import java.util.Date; +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class Token implements AuthInfo { + + @Nullable public abstract String id(); + public abstract List methods(); + @Nullable public abstract Date expiresAt(); + @Nullable public abstract Object extras(); + @Nullable public abstract List catalog(); + @Nullable public abstract List auditIds(); + public abstract User user(); + public abstract Date issuedAt(); + + @Override + public String getAuthToken() { + return id(); + } + + @SerializedNames({ "id", "methods", "expires_at", "extras", "catalog", "audit_ids", "user", "issued_at" }) + private static Token create(String id, List methods, Date expiresAt, Object extras, List catalog, + List auditIds, User user, Date issuedAt) { + return builder().id(id).methods(methods).expiresAt(expiresAt).extras(extras).catalog(catalog).auditIds(auditIds) + .user(user).issuedAt(issuedAt).build(); + } + + Token() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_Token.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder id(String id); + public abstract Builder methods(List methods); + public abstract Builder expiresAt(Date expiresAt); + public abstract Builder extras(Object extras); + public abstract Builder catalog(List catalog); + public abstract Builder auditIds(List auditIds); + public abstract Builder user(User user); + public abstract Builder issuedAt(Date issuedAt); + + abstract List catalog(); + abstract List methods(); + abstract List auditIds(); + + abstract Token autoBuild(); + + public Token build() { + return catalog(catalog() != null ? ImmutableList.copyOf(catalog()) : ImmutableList.of()) + .methods(methods() != null ? ImmutableList.copyOf(methods()) : ImmutableList.of()) + .auditIds(auditIds() != null ? ImmutableList.copyOf(auditIds()) : ImmutableList.of()) + .autoBuild(); + } + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/User.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/User.java new file mode 100644 index 0000000000..bda64112f1 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/User.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.domain; + +import java.util.Date; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class User { + + @AutoValue + public abstract static class Domain { + public abstract String id(); + public abstract String name(); + + @SerializedNames({ "id", "name" }) + public static Domain create(String id, String name) { + return new AutoValue_User_Domain(id, name); + } + } + + public abstract String id(); + public abstract String name(); + @Nullable public abstract Date passwordExpiresAt(); + @Nullable public abstract Domain domain(); + @Nullable public abstract String domainId(); + @Nullable public abstract String defaultProjectId(); + @Nullable public abstract Boolean enabled(); + @Nullable public abstract Link link(); + + @SerializedNames({ "id", "name", "password_expires_at", "domain", "domain_id", "default_project_id", "enabled", "links" }) + public static User create(String id, String name, Date passwordExpiresAt, Domain domain, String domainId, + String defaultProjectId, Boolean enabled, Link link) { + return builder().id(id).name(name).passwordExpiresAt(passwordExpiresAt).domain(domain).domainId(domainId) + .defaultProjectId(defaultProjectId).enabled(enabled).link(link).build(); + } + + User() { + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_User.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder passwordExpiresAt(Date passwordExpiresAt); + public abstract Builder domain(Domain domain); + public abstract Builder domainId(String domainId); + public abstract Builder defaultProjectId(String defaultProjectId); + public abstract Builder enabled(Boolean enabled); + public abstract Builder link(Link link); + public abstract User build(); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/AuthApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/AuthApi.java new file mode 100644 index 0000000000..845c738c01 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/AuthApi.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v3.domain.Token; +import org.jclouds.openstack.keystone.v3.domain.User; +import org.jclouds.openstack.v2_0.services.Identity; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides access to the Keystone Authentication API. + */ +@Consumes(MediaType.APPLICATION_JSON) +@RequestFilters(AuthenticateRequest.class) +@Endpoint(Identity.class) +@Path("/auth") +public interface AuthApi { + + /** + * Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog). + */ + @Named("token:get") + @GET + @SelectJson("token") + @Path("/tokens") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + @Headers(keys = "X-Subject-Token", values = "{token}") + Token get(@PathParam("token") String token); + + /** + * Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog). + */ + @Named("token:getuser") + @GET + @SelectJson("user") + @Path("/tokens") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + @Headers(keys = "X-Subject-Token", values = "{token}") + User getUserOfToken(@PathParam("token") String token); + + /** + * Validate a token. This is a high-performance variant of the #getToken() call that does not return any further + * information. + */ + @Named("token:check") + @HEAD + @Path("/tokens") + @Headers(keys = "X-Subject-Token", values = "{token}") + @Fallback(FalseOnNotFoundOr404.class) + boolean isValid(@PathParam("token") String token); + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/CatalogApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/CatalogApi.java new file mode 100644 index 0000000000..c29f29933e --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/CatalogApi.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import java.util.List; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v3.domain.Endpoint; +import org.jclouds.openstack.v2_0.services.Identity; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides access to the Keystone Admin API. + */ +@Consumes(MediaType.APPLICATION_JSON) +@RequestFilters(AuthenticateRequest.class) +@org.jclouds.rest.annotations.Endpoint(Identity.class) +public interface CatalogApi { + + /** + * List all endpoints for a token. + *

      + * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/988672 ) + */ + @Named("endpoints:list") + @GET + @SelectJson("endpoints") + @Path("/endpoints") + @Fallback(EmptyListOnNotFoundOr404.class) + List endpoints(); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/ProjectApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/ProjectApi.java new file mode 100644 index 0000000000..494e851793 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/ProjectApi.java @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import java.util.List; +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v3.domain.Project; +import org.jclouds.openstack.v2_0.services.Identity; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PATCH; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.WrapWith; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * Provides access to the Keystone Projects API. + */ +@Consumes(MediaType.APPLICATION_JSON) +@RequestFilters(AuthenticateRequest.class) +@Endpoint(Identity.class) +@Path("/projects") +public interface ProjectApi { + + @Named("projects:list") + @GET + @SelectJson("projects") + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + @Named("projects:get") + @GET + @Path("/{id}") + @SelectJson("project") + @Fallback(NullOnNotFoundOr404.class) + Project get(@PathParam("id") String id); + + @Named("projects:create") + @POST + @SelectJson("project") + @WrapWith("project") + Project create(@PayloadParam("name") String name, @Nullable @PayloadParam("description") String description, + @PayloadParam("enabled") boolean enabled, @PayloadParam("is_domain") boolean isDomain, + @Nullable @PayloadParam("domain_id") String domainId, @Nullable @PayloadParam("parent_id") String parentId); + + @Named("projects:update") + @PATCH + @Path("/{id}") + @SelectJson("project") + Project update(@PathParam("id") String id, @WrapWith("project") Project project); + + @Named("projects:delete") + @DELETE + @Path("/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); + + @Named("projects:listTags") + @GET + @Path("/{projectId}/tags") + @SelectJson("tags") + Set listTags(@PathParam("projectId") String projectId); + + @Named("projects:hasTag") + @HEAD + @Path("/{projectId}/tags/{tag}") + @Fallback(FalseOnNotFoundOr404.class) + boolean hasTag(@PathParam("projectId") String projectId, @PathParam("tag") String tag); + + @Named("projects:addTag") + @PUT + @Path("/{projectId}/tags/{tag}") + void addTag(@PathParam("projectId") String projectId, @PathParam("tag") String tag); + + @Named("projects:removeTag") + @DELETE + @Path("/{projectId}/tags/{tag}") + void removeTag(@PathParam("projectId") String projectId, @PathParam("tag") String tag); + + @Named("projects:setTags") + @PUT + @Path("/{projectId}/tags") + @MapBinder(BindToJsonPayload.class) + void setTags(@PathParam("projectId") String projectId, @PayloadParam("tags") Set tags); + + @Named("projects:removeTags") + @DELETE + @Path("/{projectId}/tags") + void removeAllTags(@PathParam("projectId") String projectId); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/RegionApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/RegionApi.java new file mode 100644 index 0000000000..c21716f3f4 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/RegionApi.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import java.util.List; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v3.domain.Region; +import org.jclouds.openstack.v2_0.services.Identity; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.PATCH; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.WrapWith; + +/** + * Provides access to the Keystone Region API. + */ +@Consumes(MediaType.APPLICATION_JSON) +@RequestFilters(AuthenticateRequest.class) +@Endpoint(Identity.class) +@Path("/regions") +public interface RegionApi { + + @Named("regions:list") + @GET + @SelectJson("regions") + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + @Named("regions:get") + @GET + @Path("/{id}") + @SelectJson("region") + @Fallback(NullOnNotFoundOr404.class) + Region get(@PathParam("id") String id); + + @Named("regions:create") + @POST + @SelectJson("region") + @WrapWith("region") + Region create(@PayloadParam("id") String id, @Nullable @PayloadParam("description") String description, + @Nullable @PayloadParam("parent_region_id") String parentId); + + @Named("regions:update") + @PATCH + @Path("/{id}") + @SelectJson("region") + @WrapWith("region") + Region update(@PathParam("id") String id, @Nullable @PayloadParam("description") String description, + @Nullable @PayloadParam("parent_region_id") String parentId); + + @Named("regions:delete") + @DELETE + @Path("/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/UserApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/UserApi.java new file mode 100644 index 0000000000..1617b51c9f --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/UserApi.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import java.util.List; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v3.domain.Group; +import org.jclouds.openstack.keystone.v3.domain.Project; +import org.jclouds.openstack.keystone.v3.domain.User; +import org.jclouds.openstack.v2_0.services.Identity; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.PATCH; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.WrapWith; + +/** + * Provides access to the Keystone User API. + */ +@Consumes(MediaType.APPLICATION_JSON) +@RequestFilters(AuthenticateRequest.class) +@Endpoint(Identity.class) +@Path("/users") +public interface UserApi { + + @Named("users:list") + @GET + @SelectJson("users") + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + @Named("users:get") + @GET + @Path("/{id}") + @SelectJson("user") + @Fallback(NullOnNotFoundOr404.class) + User get(@PathParam("id") String id); + + @Named("users:create") + @POST + @SelectJson("user") + @WrapWith("user") + User create(@PayloadParam("name") String name, @Nullable @PayloadParam("password") String password, + @Nullable @PayloadParam("enabled") Boolean enabled, @Nullable @PayloadParam("domain_id") String domainId, + @Nullable @PayloadParam("default_project_id") String defaultProjectId); + + @Named("users:update") + @PATCH + @Path("/{id}") + @SelectJson("user") + @WrapWith("user") + User update(@PathParam("id") String id, @PayloadParam("name") String name, + @Nullable @PayloadParam("password") String password, @Nullable @PayloadParam("enabled") Boolean enabled, + @Nullable @PayloadParam("domain_id") String domainId, + @Nullable @PayloadParam("default_project_id") String defaultProjectId); + + @Named("users:delete") + @DELETE + @Path("/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); + + @Named("users:groups") + @GET + @Path("/{id}/groups") + @SelectJson("groups") + List listGroups(@PathParam("id") String id); + + @Named("users:projects") + @GET + @Path("/{id}/projects") + @SelectJson("projects") + List listProjects(@PathParam("id") String id); + + @Named("users:password") + @POST + @Path("/{id}/password") + @WrapWith("user") + void changePassword(@PathParam("id") String id, @PayloadParam("original_password") String originalPassword, + @PayloadParam("password") String newPassword); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/parsers/ParseTokenFromHttpResponse.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/parsers/ParseTokenFromHttpResponse.java new file mode 100644 index 0000000000..0f0ca70f13 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/parsers/ParseTokenFromHttpResponse.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.parsers; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Singleton; + +import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.json.internal.GsonWrapper; +import org.jclouds.openstack.keystone.v3.domain.Token; + +import com.google.common.base.Function; +import com.google.inject.Inject; +import com.google.inject.TypeLiteral; + +@Singleton +public class ParseTokenFromHttpResponse implements Function { + private final ParseFirstJsonValueNamed parser; + + @Inject + ParseTokenFromHttpResponse(GsonWrapper gsonView) { + this.parser = new ParseFirstJsonValueNamed(gsonView, TypeLiteral.get(Token.class), "token"); + } + + public Token apply(HttpResponse response) { + checkNotNull(response, "response"); + Token toParse = parser.apply(response); + checkNotNull(toParse, "parsed result from %s", response); + String xSubjectToken = response.getFirstHeaderOrNull("X-Subject-Token"); + return toParse.toBuilder().id(xSubjectToken).build(); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/features/ExtensionApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/features/ExtensionApi.java index 633b32722b..466bcc97c8 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/features/ExtensionApi.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/features/ExtensionApi.java @@ -28,7 +28,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.domain.Extension; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/config/CredentialTypesTest.java similarity index 72% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/config/CredentialTypesTest.java index a609630263..93af93cc6d 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/config/CredentialTypesTest.java @@ -14,11 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.auth.config; import static org.testng.Assert.assertEquals; -import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -27,8 +27,9 @@ import com.google.common.collect.ImmutableSet; public class CredentialTypesTest { public void testCredentialTypeOfWhenValid() { - assertEquals(CredentialTypes.credentialTypeOf(PasswordCredentials.createWithUsernameAndPassword("username", - "password")), CredentialTypes.PASSWORD_CREDENTIALS); + assertEquals( + CredentialTypes.credentialTypeOf(PasswordCredentials.builder().username("username").password("password") + .build()), CredentialTypes.PASSWORD_CREDENTIALS); } @Test(expectedExceptions = IllegalArgumentException.class) @@ -37,9 +38,10 @@ public class CredentialTypesTest { } public void testIndexByCredentialTypeWhenValid() { - assertEquals(CredentialTypes.indexByCredentialType( - ImmutableSet.of(PasswordCredentials.createWithUsernameAndPassword("username", "password"))).keySet(), - ImmutableSet.of(CredentialTypes.PASSWORD_CREDENTIALS)); + assertEquals( + CredentialTypes.indexByCredentialType( + ImmutableSet.of(PasswordCredentials.builder().username("username").password("password").build())) + .keySet(), ImmutableSet.of(CredentialTypes.PASSWORD_CREDENTIALS)); } @Test(expectedExceptions = IllegalArgumentException.class) diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/ProviderModuleExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/config/ProviderModuleExpectTest.java similarity index 88% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/ProviderModuleExpectTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/config/ProviderModuleExpectTest.java index b40fcbf9a3..a11c7de08a 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/ProviderModuleExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/config/ProviderModuleExpectTest.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.config; +package org.jclouds.openstack.keystone.auth.config; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.util.Suppliers2.getLastValueInMap; import static org.testng.Assert.assertTrue; @@ -42,8 +43,10 @@ import org.jclouds.http.HttpResponse; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; import org.jclouds.location.suppliers.RegionIdToURISupplier; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.ProviderModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.keystone.v2_0.KeystoneApi; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestApiExpectTest; import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.annotations.ApiVersion; @@ -124,6 +127,7 @@ public class ProviderModuleExpectTest extends BaseRestApiExpectTest>builder() - .add(AuthenticationApiModule.class) - .add(KeystoneAuthenticationModule.class) + .add(AuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(DNSHttpApiModule.class).build()); } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/handlers/RetryOnRenewTest.java similarity index 92% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/handlers/RetryOnRenewTest.java index 840cda3d3e..01611ffebd 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/handlers/RetryOnRenewTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.handlers; +package org.jclouds.openstack.keystone.auth.handlers; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; @@ -30,7 +30,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.io.Payloads; -import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; import org.testng.annotations.Test; import com.google.common.cache.LoadingCache; @@ -46,7 +46,7 @@ public class RetryOnRenewTest { HttpRequest request = createMock(HttpRequest.class); HttpResponse response = createMock(HttpResponse.class); @SuppressWarnings("unchecked") - LoadingCache cache = createMock(LoadingCache.class); + LoadingCache cache = createMock(LoadingCache.class); BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class); expect(command.getCurrentRequest()).andReturn(request); @@ -78,7 +78,7 @@ public class RetryOnRenewTest { HttpResponse response = createMock(HttpResponse.class); @SuppressWarnings("unchecked") - LoadingCache cache = createMock(LoadingCache.class); + LoadingCache cache = createMock(LoadingCache.class); BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class); expect(command.getCurrentRequest()).andReturn(request).anyTimes(); @@ -108,7 +108,7 @@ public class RetryOnRenewTest { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = createMock(HttpResponse.class); @SuppressWarnings("unchecked") - LoadingCache cache = createMock(LoadingCache.class); + LoadingCache cache = createMock(LoadingCache.class); BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class); expect(backoffHandler.shouldRetryRequest(command, response)).andReturn(true).once(); diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/LocationIdToURIFromAccessForTypeAndVersionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/LocationIdToURIFromAccessForTypeAndVersionTest.java new file mode 100644 index 0000000000..0b1c8901f6 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/LocationIdToURIFromAccessForTypeAndVersionTest.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.auth.suppliers; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import javax.inject.Singleton; + +import org.jclouds.location.Provider; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.suppliers.LocationIdToURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.v2_0.catalog.V2ServiceCatalog; +import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; +import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; +import org.testng.annotations.Test; + +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Provides; +import com.google.inject.Scopes; +import com.google.inject.TypeLiteral; +import com.google.inject.assistedinject.FactoryModuleBuilder; + +@Test(groups = "unit", testName = "LocationIdToURIFromAccessForTypeAndVersionTest") +public class LocationIdToURIFromAccessForTypeAndVersionTest { + private final LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory factory = Guice.createInjector( + new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Provider.class).to("openstack-keystone"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); + install(new FactoryModuleBuilder().implement(LocationIdToURIFromServiceEndpointsForTypeAndVersion.class, + LocationIdToURIFromServiceEndpointsForTypeAndVersion.class).build( + LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory.class)); + // We test against a 2.0 service catalog but it is OK for the purpose of this test + bind(new TypeLiteral>>() { + }).to(V2ServiceCatalog.class).in(Scopes.SINGLETON); + } + + @Provides + @Singleton + public Supplier provide() { + return Suppliers. ofInstance(new ParseAccessTest().expected()); + } + + }).getInstance(LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory.class); + + public void testRegionUnmatchesOkWhenNoVersionIdSet() { + assertEquals( + Maps.transformValues(factory.createForApiTypeAndVersion("compute", "2").get(), + Suppliers. supplierFunction()), + ImmutableMap.of("az-1.region-a.geo-1", + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-2.region-a.geo-1", + URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-3.region-a.geo-1", + URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"))); + } + + public void testRegionMatches() { + assertEquals( + Maps.transformValues(factory.createForApiTypeAndVersion("compute", "2").get(), + Suppliers. supplierFunction()), + ImmutableMap.of("az-1.region-a.geo-1", + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-2.region-a.geo-1", + URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-3.region-a.geo-1", + URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"))); + } + + private final LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory raxFactory = Guice.createInjector( + new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Provider.class).to("rackspace"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); + install(new FactoryModuleBuilder().implement(LocationIdToURIFromServiceEndpointsForTypeAndVersion.class, + LocationIdToURIFromServiceEndpointsForTypeAndVersion.class).build( + LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory.class)); + // We test against a 2.0 service catalog but it is OK for the purpose of this test + bind(new TypeLiteral>>() { + }).to(V2ServiceCatalog.class).in(Scopes.SINGLETON); + } + + @Provides + @Singleton + public Supplier provide() { + return Suppliers. ofInstance(new ParseRackspaceAccessTest().expected()); + } + }).getInstance(LocationIdToURIFromServiceEndpointsForTypeAndVersion.Factory.class); + + @Test(expectedExceptions = NoSuchElementException.class) + public void testWhenNotInList() { + assertEquals( + Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), + Suppliers. supplierFunction()), + ImmutableMap.of("rackspace", URI.create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testProviderWhenNoRegions() { + Map withNoRegions = Maps.transformValues(raxFactory.createForApiTypeAndVersion("compute", "1.0") + .get(), Suppliers. supplierFunction()); + assertEquals(withNoRegions, + ImmutableMap.of("rackspace", URI.create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testOkWithNoVersions() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("rax:database", null).get(), + Suppliers. supplierFunction()), ImmutableMap.of("DFW", + URI.create("https://dfw.databases.api.rackspacecloud.com/v1.0/40806637803162"), "ORD", + URI.create("https://ord.databases.api.rackspacecloud.com/v1.0/40806637803162"))); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java similarity index 75% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java index 91ebb61623..3a632e23db 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java @@ -14,18 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.suppliers; +package org.jclouds.openstack.keystone.auth.suppliers; import static org.testng.Assert.assertEquals; import java.net.URI; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import javax.inject.Singleton; import org.jclouds.location.Provider; -import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToAdminURISupplier; +import org.jclouds.openstack.keystone.v2_0.catalog.V2ServiceCatalog; import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; import org.testng.annotations.Test; @@ -37,6 +42,7 @@ import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; +import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.FactoryModuleBuilder; @@ -50,13 +56,16 @@ public class RegionIdToAdminURIFromAccessForTypeAndVersionTest { bind(new TypeLiteral>() { }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + // We test against a 2.0 service catalog but it is OK for the purpose of this test + bind(new TypeLiteral>>() { + }).to(V2ServiceCatalog.class).in(Scopes.SINGLETON); } @Provides @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseAccessTest().expected()); + public Supplier provide() { + return Suppliers. ofInstance(new ParseAccessTest().expected()); } }).getInstance(RegionIdToAdminURISupplier.Factory.class); @@ -79,13 +88,16 @@ public class RegionIdToAdminURIFromAccessForTypeAndVersionTest { bind(new TypeLiteral>() { }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + RegionIdToAdminURIFromServiceEndpointsForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + // We test against a 2.0 service catalog but it is OK for the purpose of this test + bind(new TypeLiteral>>() { + }).to(V2ServiceCatalog.class).in(Scopes.SINGLETON); } @Provides @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); + public Supplier provide() { + return Suppliers. ofInstance(new ParseRackspaceAccessTest().expected()); } }).getInstance(RegionIdToAdminURISupplier.Factory.class); diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java similarity index 79% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java index 0b48360655..65b820dc47 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/auth/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java @@ -14,18 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.suppliers; +package org.jclouds.openstack.keystone.auth.suppliers; import static org.testng.Assert.assertEquals; import java.net.URI; +import java.util.List; import java.util.NoSuchElementException; import javax.inject.Singleton; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.jclouds.openstack.keystone.catalog.suppliers.RegionIdToURIFromServiceEndpointsForTypeAndVersion; +import org.jclouds.openstack.keystone.v2_0.catalog.V2ServiceCatalog; import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; import org.testng.annotations.Test; @@ -37,6 +41,7 @@ import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; +import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.FactoryModuleBuilder; @@ -50,18 +55,20 @@ public class RegionIdToURIFromAccessForTypeAndVersionTest { bind(new TypeLiteral>() { }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, - RegionIdToURIFromAccessForTypeAndVersion.class).build( + RegionIdToURIFromServiceEndpointsForTypeAndVersion.class).build( RegionIdToURISupplier.Factory.class)); + // We test against a 2.0 service catalog but it is OK for the purpose of this test + bind(new TypeLiteral>>() { + }).to(V2ServiceCatalog.class).in(Scopes.SINGLETON); } @Provides @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseAccessTest().expected()); + public Supplier provide() { + return Suppliers. ofInstance(new ParseAccessTest().expected()); } }).getInstance(RegionIdToURISupplier.Factory.class); - @SuppressWarnings("CheckReturnValue") @Test(expectedExceptions = NoSuchElementException.class) public void testRegionUnmatches() { Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.0").get(), @@ -84,14 +91,17 @@ public class RegionIdToURIFromAccessForTypeAndVersionTest { bind(new TypeLiteral>() { }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, - RegionIdToURIFromAccessForTypeAndVersion.class).build( + RegionIdToURIFromServiceEndpointsForTypeAndVersion.class).build( RegionIdToURISupplier.Factory.class)); + // We test against a 2.0 service catalog but it is OK for the purpose of this test + bind(new TypeLiteral>>() { + }).to(V2ServiceCatalog.class).in(Scopes.SINGLETON); } @Provides @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); + public Supplier provide() { + return Suppliers. ofInstance(new ParseRackspaceAccessTest().expected()); } }).getInstance(RegionIdToURISupplier.Factory.class); diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/AdminURLTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/AdminURLTest.java new file mode 100644 index 0000000000..ed5280e4d9 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/AdminURLTest.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.functions; + +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.ADMIN; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.PUBLIC; +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.Collections; + +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "AdminURLTest") +public class AdminURLTest { + private final AdminURL fn = new AdminURL(); + + public void testAdminURL() { + assertEquals( + fn.apply( + Collections.singletonList(ServiceEndpoint + .builder() + .type("cdn") + .regionId("LON") + .version("1.0") + .url(URI + .create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) + .iface(ADMIN).build())).get(), + URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")); + } + + public void testReturnsNullIfNotAdminURI() { + assertEquals( + fn.apply( + Collections.singletonList(ServiceEndpoint.builder().type("cdn").regionId("LON").version("1.0") + .url(URI.create("https://192.168.1.1")).iface(PUBLIC).build())).get(), null); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/InternalURLTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/InternalURLTest.java similarity index 64% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/InternalURLTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/InternalURLTest.java index 3f3782542d..fec5dd8c4b 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/InternalURLTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/InternalURLTest.java @@ -14,13 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.catalog.functions; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.INTERNAL; import static org.testng.Assert.assertEquals; import java.net.URI; +import java.util.Collections; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; import org.testng.annotations.Test; /** @@ -31,9 +33,10 @@ public class InternalURLTest { public void testInternalURL() { assertEquals( - fn.apply( - Endpoint.builder().region("regionOne").versionId("2.0") - .internalURL(URI.create("https://ericsson.com/v2/1900e98b-7272-4cbd-8e95-0b8c2a9266c0")) - .build()).get(), URI.create("https://ericsson.com/v2/1900e98b-7272-4cbd-8e95-0b8c2a9266c0")); + fn.apply(Collections.singletonList(ServiceEndpoint.builder().type("cdn").regionId("regionOne") + .version("2.0") + .url(URI.create("https://ericsson.com/v2/1900e98b-7272-4cbd-8e95-0b8c2a9266c0")) + .iface(INTERNAL).build())).get(), + URI.create("https://ericsson.com/v2/1900e98b-7272-4cbd-8e95-0b8c2a9266c0")); } } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/PublicURLOrInternalTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/PublicURLOrInternalTest.java new file mode 100644 index 0000000000..477236b4ec --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/PublicURLOrInternalTest.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.catalog.functions; + +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.INTERNAL; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.PUBLIC; +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.Collections; + +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "PublicURLOrInternalTest") +public class PublicURLOrInternalTest { + private final PublicURLOrInternal fn = new PublicURLOrInternal(); + + public void testPublicURLNotNullReturnsPublicURL() { + assertEquals( + fn.apply( + Collections.singletonList(ServiceEndpoint + .builder() + .type("cdn") + .regionId("LON") + .version("1.0") + .url(URI + .create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) + .iface(PUBLIC).build())).get(), + URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")); + } + + public void testPublicURLNullReturnsInternalURL() { + assertEquals( + fn.apply( + Collections.singletonList(ServiceEndpoint.builder().type("cdn").regionId("LON").version("1.0") + .url(URI.create("https://192.168.1.1")).iface(INTERNAL).build())).get(), + URI.create("https://192.168.1.1")); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProviderTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/ReturnRegionOrProviderTest.java similarity index 63% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProviderTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/ReturnRegionOrProviderTest.java index c606edd976..bc25ad3f4d 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProviderTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/catalog/functions/ReturnRegionOrProviderTest.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.keystone.v2_0.functions; +package org.jclouds.openstack.keystone.catalog.functions; +import static org.jclouds.openstack.keystone.catalog.ServiceEndpoint.Interface.PUBLIC; import static org.testng.Assert.assertEquals; import java.net.URI; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.catalog.ServiceEndpoint; import org.testng.annotations.Test; @Test(groups = "unit", testName = "ReturnRegionOrProviderTest") @@ -29,16 +30,16 @@ public class ReturnRegionOrProviderTest { public void testRegionNotNullReturnsRegion() { assertEquals( - fn.apply(Endpoint.builder().region("LON").versionId("1.0").publicURL( - URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) - .build()), "LON"); + fn.apply(ServiceEndpoint.builder().type("cdn").regionId("LON").version("1.0") + .url(URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) + .iface(PUBLIC).build()), "LON"); } public void testRegionNullReturnsProvider() { assertEquals( - fn.apply(Endpoint.builder().versionId("1.0").publicURL( - URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) - .build()), "openstack-keystone"); + fn.apply(ServiceEndpoint.builder().type("cdn").version("1.0") + .url(URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) + .iface(PUBLIC).build()), "openstack-keystone"); } } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApiLiveTest.java index accdf9b052..01b7f8ddef 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApiLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApiLiveTest.java @@ -59,7 +59,7 @@ public class RoleAdminApiLiveTest extends BaseKeystoneApiLiveTest { protected void tearDown() { if (testRole != null) { final String roleId = testRole.getId(); - boolean success = roleAdminOption.get().delete(roleId); + assertTrue(roleAdminOption.get().delete(roleId)); assertTrue(retry(new Predicate() { public boolean apply(RoleAdminApi roleApi) { return roleApi.get(roleId) == null; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApiLiveTest.java index e999816a5b..a83bed1c8c 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApiLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApiLiveTest.java @@ -59,7 +59,7 @@ public class ServiceAdminApiLiveTest extends BaseKeystoneApiLiveTest { protected void tearDown() { if (testService != null) { final String serviceId = testService.getId(); - boolean success = serviceAdminOption.get().delete(serviceId); + assertTrue(serviceAdminOption.get().delete(serviceId)); assertTrue(retry(new Predicate() { public boolean apply(ServiceAdminApi serviceApi) { return serviceApi.get(serviceId) == null; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApiLiveTest.java index b679579f20..cc7f8ebdfa 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApiLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApiLiveTest.java @@ -61,7 +61,7 @@ public class TenantAdminApiLiveTest extends BaseKeystoneApiLiveTest { protected void tearDown() { if (testTenant != null) { final String tenantId = testTenant.getId(); - boolean success = tenantAdminOption.get().delete(tenantId); + assertTrue(tenantAdminOption.get().delete(tenantId)); assertTrue(retry(new Predicate() { public boolean apply(TenantApi tenantApi) { return tenantApi.get(tenantId) == null; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApiLiveTest.java index 152cc924e9..3859bdf253 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApiLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApiLiveTest.java @@ -60,7 +60,7 @@ public class UserAdminApiLiveTest extends BaseKeystoneApiLiveTest { protected void tearDown() { if (testUser != null) { final String userId = testUser.getId(); - boolean success = userAdminOption.get().delete(userId); + assertTrue(userAdminOption.get().delete(userId)); assertTrue(retry(new Predicate() { public boolean apply(UserApi userApi) { return userApi.get(userId) == null; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenApiLiveTest.java index af9e2d5fa8..8cc3c69382 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenApiLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenApiLiveTest.java @@ -26,11 +26,11 @@ import java.util.Properties; import java.util.Set; import org.jclouds.http.HttpRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneApi; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; import org.jclouds.openstack.keystone.v2_0.domain.Token; import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest; import org.testng.annotations.Test; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java deleted file mode 100644 index 310d41be3e..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "AdminURLTest") -public class AdminURLTest { - private final AdminURL fn = new AdminURL(); - - public void testAdminURL() { - assertEquals(fn.apply( - Endpoint.builder().region("LON").versionId("1.0").adminURL( - URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) - .build()).get(), URI - .create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")); - } - - public void testPublicURLNullReturnsInternalURL() { - assertEquals(fn - .apply( - Endpoint.builder().region("lon").versionId("1.0") - .internalURL(URI.create("https://192.168.1.1")).build()).get(), null); - } - -} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java deleted file mode 100644 index 7e169acd04..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "PublicURLOrInternalIfNullTest") -public class PublicURLOrInternalIfNullTest { - private final PublicURLOrInternalIfNull fn = new PublicURLOrInternalIfNull(); - - public void testPublicURLNotNullReturnsPublicURL() { - assertEquals(fn.apply( - Endpoint.builder().region("LON").versionId("1.0").publicURL( - URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) - .build()).get(), URI - .create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")); - } - - public void testPublicURLNullReturnsInternalURL() { - assertEquals(fn - .apply( - Endpoint.builder().region("lon").versionId("1.0") - .internalURL(URI.create("https://192.168.1.1")).build()).get(), URI - .create("https://192.168.1.1")); - } - -} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneApiLiveTest.java index ee85a5e1bc..004d813aff 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneApiLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneApiLiveTest.java @@ -19,8 +19,8 @@ package org.jclouds.openstack.keystone.v2_0.internal; import java.util.Properties; import org.jclouds.apis.BaseApiLiveTest; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.keystone.v2_0.KeystoneApi; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.testng.annotations.Test; /** diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestApiExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestApiExpectTest.java index 01fc644fb8..1f19d96197 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestApiExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestApiExpectTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.keystone.v2_0.internal; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import java.util.Properties; diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionTest.java deleted file mode 100644 index f530329062..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.suppliers; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Singleton; - -import org.jclouds.location.Provider; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion; -import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; -import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; -import com.google.inject.assistedinject.FactoryModuleBuilder; - -@Test(groups = "unit", testName = "LocationIdToURIFromAccessForTypeAndVersionTest") -public class LocationIdToURIFromAccessForTypeAndVersionTest { - private final LocationIdToURIFromAccessForTypeAndVersion.Factory factory = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bindConstant().annotatedWith(Provider.class).to("openstack-keystone"); - bind(new TypeLiteral>() { - }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); - bind(new TypeLiteral>(){}).to(EndpointToRegion.class); - install(new FactoryModuleBuilder().implement(LocationIdToURIFromAccessForTypeAndVersion.class, - LocationIdToURIFromAccessForTypeAndVersion.class).build( - LocationIdToURIFromAccessForTypeAndVersion.Factory.class)); - } - - @Provides - @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseAccessTest().expected()); - } - - }).getInstance(LocationIdToURIFromAccessForTypeAndVersion.Factory.class); - - public void testRegionUnmatchesOkWhenNoVersionIdSet() { - assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "2").get(), Suppliers - . supplierFunction()), ImmutableMap.of("az-1.region-a.geo-1", URI - .create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-2.region-a.geo-1", URI - .create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-3.region-a.geo-1", URI - .create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"))); - } - - public void testRegionMatches() { - assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "2").get(), Suppliers - . supplierFunction()), ImmutableMap.of("az-1.region-a.geo-1", URI - .create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-2.region-a.geo-1", URI - .create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), "az-3.region-a.geo-1", URI - .create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"))); - } - - private final LocationIdToURIFromAccessForTypeAndVersion.Factory raxFactory = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bindConstant().annotatedWith(Provider.class).to("rackspace"); - bind(new TypeLiteral>() { - }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); - bind(new TypeLiteral>(){}).to(EndpointToRegion.class); - install(new FactoryModuleBuilder().implement(LocationIdToURIFromAccessForTypeAndVersion.class, - LocationIdToURIFromAccessForTypeAndVersion.class).build( - LocationIdToURIFromAccessForTypeAndVersion.Factory.class)); - } - - @Provides - @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); - } - }).getInstance(LocationIdToURIFromAccessForTypeAndVersion.Factory.class); - - @Test(expectedExceptions = NoSuchElementException.class) - public void testWhenNotInList() { - assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), Suppliers - . supplierFunction()), ImmutableMap.of("rackspace", URI - .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); - } - - public void testProviderWhenNoRegions() { - Map withNoRegions = Maps.transformValues(raxFactory.createForApiTypeAndVersion("compute", "1.0") - .get(), Suppliers. supplierFunction()); - assertEquals(withNoRegions, ImmutableMap.of("rackspace", URI - .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); - } - - public void testOkWithNoVersions() { - assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("rax:database", null).get(), Suppliers - . supplierFunction()), ImmutableMap.of("DFW", URI - .create("https://dfw.databases.api.rackspacecloud.com/v1.0/40806637803162"), "ORD", URI - .create("https://ord.databases.api.rackspacecloud.com/v1.0/40806637803162"))); - } - -} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionTest.java deleted file mode 100644 index b716bbc763..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.openstack.keystone.v2_0.suppliers; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.NoSuchElementException; - -import javax.inject.Singleton; - -import org.jclouds.location.Provider; -import org.jclouds.location.suppliers.ZoneIdToURISupplier; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; -import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; -import com.google.inject.assistedinject.FactoryModuleBuilder; - -@Test(groups = "unit", testName = "ZoneIdToURIFromAccessForTypeAndVersionSupplierTest") -public class ZoneIdToURIFromAccessForTypeAndVersionTest { - private final ZoneIdToURISupplier.Factory factory = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bindConstant().annotatedWith(Provider.class).to("rackspace"); - bind(new TypeLiteral>() { - }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); - install(new FactoryModuleBuilder().implement(ZoneIdToURISupplier.class, - ZoneIdToURIFromAccessForTypeAndVersion.class).build(ZoneIdToURISupplier.Factory.class)); - } - - @Provides - @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseAccessTest().expected()); - } - }).getInstance(ZoneIdToURISupplier.Factory.class); - - - @SuppressWarnings("CheckReturnValue") - @Test(expectedExceptions = NoSuchElementException.class) - public void testZoneUnmatches() { - Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.0").get(), - Suppliers. supplierFunction()); - } - - public void testZoneMatches() { - assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "2").get(), Suppliers - . supplierFunction()), ImmutableMap.of("az-1.region-a.geo-1", URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), - "az-2.region-a.geo-1", URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"), - "az-3.region-a.geo-1", URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v2/3456"))); - } - - private final ZoneIdToURISupplier.Factory raxFactory = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bindConstant().annotatedWith(Provider.class).to("rackspace"); - bind(new TypeLiteral>() { - }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); - install(new FactoryModuleBuilder().implement(ZoneIdToURISupplier.class, - ZoneIdToURIFromAccessForTypeAndVersion.class).build(ZoneIdToURISupplier.Factory.class)); - } - - @Provides - @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); - } - }).getInstance(ZoneIdToURISupplier.Factory.class); - - @Test(expectedExceptions = NoSuchElementException.class) - public void testWhenNotInList() { - assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), Suppliers - . supplierFunction()), ImmutableMap.of("rackspace", URI - .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); - } - - public void testProviderWhenNoZones() { - assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("compute", "1.0").get(), Suppliers - . supplierFunction()), ImmutableMap.of("rackspace", URI.create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); - } - - public void testOkWithNoVersions() { - assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("rax:database", null).get(), Suppliers - . supplierFunction()), ImmutableMap.of("DFW", URI.create("https://dfw.databases.api.rackspacecloud.com/v1.0/40806637803162"), - "ORD", URI.create("https://ord.databases.api.rackspacecloud.com/v1.0/40806637803162"))); - } -} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java new file mode 100644 index 0000000000..3b8a3b48c3 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.auth; + +import static org.testng.Assert.assertNotNull; + +import java.util.Properties; + +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.TokenCredentials; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest; +import org.testng.annotations.Test; + +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; + +@Test(groups = "live", testName = "V3AuthenticationApiLiveTest") +public class V3AuthenticationApiLiveTest extends BaseV3KeystoneApiLiveTest { + + private String tenant; + private String user; + + @Override + protected Properties setupProperties() { + Properties properties = super.setupProperties(); + tenant = Iterables.get(Splitter.on(":").split(identity), 0); + user = Iterables.get(Splitter.on(":").split(identity), 1); + return properties; + } + + public void testAuthenticatePassword() { + assertNotNull(authenticationApi.authenticatePassword(TenantOrDomainAndCredentials. builder() + .tenantOrDomainName(tenant).scope("unscoped") + .credentials(PasswordCredentials.builder().username(user).password(credential).build()).build())); + } + + public void testAuthenticateToken() { + assertNotNull(authenticationApi.authenticateToken(TenantOrDomainAndCredentials. builder() + .tenantOrDomainName(tenant).scope("unscoped") + .credentials(TokenCredentials.builder().id(token.get()).build()).build())); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiMockTest.java new file mode 100644 index 0000000000..d6019132ad --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiMockTest.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.auth; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.domain.TokenCredentials; +import org.jclouds.openstack.keystone.v3.domain.Token; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "V3AuthenticationApiMockTest", singleThreaded = true) +public class V3AuthenticationApiMockTest extends BaseV3KeystoneApiMockTest { + + public void testAuthenticatePassword() throws InterruptedException { + server.enqueue(jsonResponse("/v3/token.json")); + + TenantOrDomainAndCredentials credentials = TenantOrDomainAndCredentials. builder() + .tenantOrDomainName("domain") + .scope("unscoped") + .credentials(PasswordCredentials.builder().username("identity").password("credential").build()).build(); + + AuthInfo authInfo = authenticationApi.authenticatePassword(credentials); + + assertTrue(authInfo instanceof Token); + assertEquals(authInfo, tokenFromResource("/v3/token.json")); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "POST", "/auth/tokens", stringFromResource("/v3/auth-password.json")); + } + + public void testAuthenticatePasswordScoped() throws InterruptedException { + server.enqueue(jsonResponse("/v3/token.json")); + + TenantOrDomainAndCredentials credentials = TenantOrDomainAndCredentials. builder() + .tenantOrDomainName("domain") + .scope("projectId:1234567890") + .credentials(PasswordCredentials.builder().username("identity").password("credential").build()).build(); + + AuthInfo authInfo = authenticationApi.authenticatePassword(credentials); + + assertTrue(authInfo instanceof Token); + assertEquals(authInfo, tokenFromResource("/v3/token.json")); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "POST", "/auth/tokens", stringFromResource("/v3/auth-password-scoped.json")); + } + + public void testAuthenticateToken() throws InterruptedException { + server.enqueue(jsonResponse("/v3/token.json")); + + TenantOrDomainAndCredentials credentials = TenantOrDomainAndCredentials. builder() + .tenantOrDomainName("domain") + .scope("unscoped") + .credentials(TokenCredentials.builder().id("token").build()).build(); + + AuthInfo authInfo = authenticationApi.authenticateToken(credentials); + + assertTrue(authInfo instanceof Token); + assertEquals(authInfo, tokenFromResource("/v3/token.json")); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "POST", "/auth/tokens", stringFromResource("/v3/auth-token.json")); + } + + public void testAuthenticateTokenScoped() throws InterruptedException { + server.enqueue(jsonResponse("/v3/token.json")); + + TenantOrDomainAndCredentials credentials = TenantOrDomainAndCredentials. builder() + .tenantOrDomainName("domain") + .scope("domain:mydomain") + .credentials(TokenCredentials.builder().id("token").build()).build(); + + AuthInfo authInfo = authenticationApi.authenticateToken(credentials); + + assertTrue(authInfo instanceof Token); + assertEquals(authInfo, tokenFromResource("/v3/token.json")); + + assertEquals(server.getRequestCount(), 1); + assertSent(server, "POST", "/auth/tokens", stringFromResource("/v3/auth-token-scoped.json")); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java new file mode 100644 index 0000000000..2cfef5129c --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "AuthApiLiveTest") +public class AuthApiLiveTest extends BaseV3KeystoneApiLiveTest { + + public void testIsTokenValid() { + assertTrue(api().isValid(token.get())); + } + + public void testGetToken() { + assertNotNull(api().get(token.get())); + } + + private AuthApi api() { + return api.getAuthApi(); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java new file mode 100644 index 0000000000..a156fad845 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.keystone.v3.domain.Token; +import org.jclouds.openstack.keystone.v3.domain.User; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest; +import org.testng.annotations.Test; + +import com.squareup.okhttp.mockwebserver.RecordedRequest; + +@Test(groups = "unit", testName = "AuthApiMockTest", singleThreaded = true) +public class AuthApiMockTest extends BaseV3KeystoneApiMockTest { + + public void testGetToken() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/token.json")); + + Token token = api.getAuthApi().get(authToken); + + assertEquals(token, tokenFromResource("/v3/token.json")); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + RecordedRequest request = assertSent(server, "GET", "/auth/tokens"); + assertEquals(request.getHeader("X-Subject-Token"), authToken); + } + + public void testGetTokenReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + Token token = api.getAuthApi().get("foo"); + assertNull(token); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + RecordedRequest request = assertSent(server, "GET", "/auth/tokens"); + assertEquals(request.getHeader("X-Subject-Token"), "foo"); + } + + public void testIsValidToken() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + boolean valid = api.getAuthApi().isValid(authToken); + assertTrue(valid); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + RecordedRequest request = assertSent(server, "HEAD", "/auth/tokens"); + assertEquals(request.getHeader("X-Subject-Token"), authToken); + } + + public void testIsValidTokenReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + boolean valid = api.getAuthApi().isValid("foo"); + assertFalse(valid); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + RecordedRequest request = assertSent(server, "HEAD", "/auth/tokens"); + assertEquals(request.getHeader("X-Subject-Token"), "foo"); + } + + public void testGetUserOfToken() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/token.json")); + + User user = api.getAuthApi().getUserOfToken(authToken); + + assertEquals(user, tokenFromResource("/v3/token.json").user()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + RecordedRequest request = assertSent(server, "GET", "/auth/tokens"); + assertEquals(request.getHeader("X-Subject-Token"), authToken); + } + + public void testGetUserOfTokenReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + User user = api.getAuthApi().getUserOfToken("foo"); + assertNull(user); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + RecordedRequest request = assertSent(server, "GET", "/auth/tokens"); + assertEquals(request.getHeader("X-Subject-Token"), "foo"); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.java new file mode 100644 index 0000000000..3044c130bb --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; + +import java.util.List; + +import org.jclouds.openstack.keystone.v3.domain.Endpoint; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "CatalogApiLiveTest") +public class CatalogApiLiveTest extends BaseV3KeystoneApiLiveTest { + + @Test + public void testTenants() { + List result = api.getCatalogApi().endpoints(); + assertNotNull(result); + assertFalse(result.isEmpty()); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java new file mode 100644 index 0000000000..d7f7639b71 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.util.List; + +import org.jclouds.openstack.keystone.v3.domain.Endpoint; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "CatalogApiMockTest", singleThreaded = true) +public class CatalogApiMockTest extends BaseV3KeystoneApiMockTest { + + public void testListEndpoints() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/endpoints.json")); + + List endpoints = api.getCatalogApi().endpoints(); + assertFalse(endpoints.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/endpoints"); + } + + public void testListEndpointsReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + List endpoints = api.getCatalogApi().endpoints(); + assertTrue(endpoints.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/endpoints"); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/ProjectApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/ProjectApiLiveTest.java new file mode 100644 index 0000000000..df0c0dd69c --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/ProjectApiLiveTest.java @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static com.google.common.collect.Iterables.any; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.jclouds.openstack.keystone.v3.domain.Project; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; + +@Test(groups = "live", testName = "ProjectApiLiveTest", singleThreaded = true) +public class ProjectApiLiveTest extends BaseV3KeystoneApiLiveTest { + + private Project project; + + @BeforeClass + public void createTestProject() { + project = api().create(getClass().getSimpleName(), null, true, false, null, null); + assertNotNull(project.id()); + } + + @Test + public void testListProjects() { + assertTrue(any(api().list(), new Predicate() { + @Override + public boolean apply(Project input) { + return input.id().equals(project.id()); + } + })); + } + + @Test + public void testGetProject() { + assertNotNull(api().get(project.id())); + } + + @Test + public void testUpdateProject() { + Project updated = api().get(project.id()); + api().update(project.id(), updated.toBuilder().description("Updated").build()); + project = api().get(project.id()); + assertEquals(project.description(), "Updated"); + } + + @Test + public void testSetAndListTags() { + api().setTags(project.id(), ImmutableSet.of("foo", "bar")); + Set projectTags = api().listTags(project.id()); + assertEquals(projectTags, ImmutableSet.of("foo", "bar")); + } + + @Test(dependsOnMethods = "testSetAndListTags") + public void testHasTag() { + assertTrue(api().hasTag(project.id(), "foo")); + } + + @Test(dependsOnMethods = "testSetAndListTags") + public void testAddTag() { + api().addTag(project.id(), "three"); + assertTrue(api().hasTag(project.id(), "three")); + } + + @Test(dependsOnMethods = "testSetAndListTags") + public void testRemoveTag() { + api().removeTag(project.id(), "bar"); + assertFalse(api().hasTag(project.id(), "bar")); + } + + @Test(dependsOnMethods = "testRemoveTag") + public void testRemoveAllTags() { + api().removeAllTags(project.id()); + assertTrue(api().listTags(project.id()).isEmpty()); + } + + @AfterClass(alwaysRun = true) + public void deleteProject() { + assertTrue(api().delete(project.id())); + } + + private ProjectApi api() { + return api.getProjectApi(); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/ProjectApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/ProjectApiMockTest.java new file mode 100644 index 0000000000..b8a45425b2 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/ProjectApiMockTest.java @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.util.List; +import java.util.Set; + +import org.jclouds.openstack.keystone.v3.domain.Project; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.squareup.okhttp.mockwebserver.MockResponse; + +@Test(groups = "unit", testName = "ProjectApiMockTest", singleThreaded = true) +public class ProjectApiMockTest extends BaseV3KeystoneApiMockTest { + + public void testListProjects() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/projects.json").setResponseCode(201)); + + List projects = api.getProjectApi().list(); + assertFalse(projects.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/projects"); + } + + public void testListProjectsReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + List projects = api.getProjectApi().list(); + assertTrue(projects.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/projects"); + } + + public void testGetProject() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/project.json")); + + Project project = api.getProjectApi().get("2f9b30f706bc45d7923e055567be2e98"); + assertNotNull(project); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/projects/2f9b30f706bc45d7923e055567be2e98"); + } + + public void testGetProjectReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + Project project = api.getProjectApi().get("2f9b30f706bc45d7923e055567be2e98"); + assertNull(project); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/projects/2f9b30f706bc45d7923e055567be2e98"); + } + + public void testCreateProject() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/project.json")); + + Project project = api.getProjectApi().create("foo", null, true, false, null, null); + assertNotNull(project); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "POST", "/projects", "{\"project\":{\"is_domain\":false,\"enabled\":true,\"name\":\"foo\"}}"); + } + + public void testUpdateProject() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/project.json")); + + Project project = api.getProjectApi().update("2f9b30f706bc45d7923e055567be2e98", + Project.builder().name("foo").build()); + assertNotNull(project); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "PATCH", "/projects/2f9b30f706bc45d7923e055567be2e98", + "{\"project\":{\"is_domain\":false,\"enabled\":true,\"name\":\"foo\"}}"); + } + + public void testDeleteProject() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + boolean deleted = api.getProjectApi().delete("2f9b30f706bc45d7923e055567be2e98"); + assertTrue(deleted); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/projects/2f9b30f706bc45d7923e055567be2e98"); + } + + public void testDeleteProjectReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + boolean deleted = api.getProjectApi().delete("2f9b30f706bc45d7923e055567be2e98"); + assertFalse(deleted); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/projects/2f9b30f706bc45d7923e055567be2e98"); + } + + public void testListTags() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(new MockResponse().setBody("{\"tags\":[\"foo\",\"bar\"]}")); + + Set tags = api.getProjectApi().listTags("2f9b30f706bc45d7923e055567be2e98"); + assertEquals(tags, ImmutableSet.of("foo", "bar")); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/projects/2f9b30f706bc45d7923e055567be2e98/tags"); + } + + public void testHasTag() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + boolean hasTag = api.getProjectApi().hasTag("2f9b30f706bc45d7923e055567be2e98", "foo"); + assertTrue(hasTag); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "HEAD", "/projects/2f9b30f706bc45d7923e055567be2e98/tags/foo"); + } + + public void testAddTag() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response201()); + + api.getProjectApi().addTag("2f9b30f706bc45d7923e055567be2e98", "foo"); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "PUT", "/projects/2f9b30f706bc45d7923e055567be2e98/tags/foo"); + } + + public void testRemoveTag() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + api.getProjectApi().removeTag("2f9b30f706bc45d7923e055567be2e98", "foo"); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/projects/2f9b30f706bc45d7923e055567be2e98/tags/foo"); + } + + public void testSetTags() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(new MockResponse().setBody("{\"tags\":[\"foo\",\"bar\"]}")); + + api.getProjectApi().setTags("2f9b30f706bc45d7923e055567be2e98", ImmutableSet.of("foo", "bar")); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "PUT", "/projects/2f9b30f706bc45d7923e055567be2e98/tags", "{\"tags\":[\"foo\",\"bar\"]}"); + } + + public void testRemoveAllTags() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + api.getProjectApi().removeAllTags("2f9b30f706bc45d7923e055567be2e98"); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/projects/2f9b30f706bc45d7923e055567be2e98/tags"); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/RegionApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/RegionApiLiveTest.java new file mode 100644 index 0000000000..0e5bcfb636 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/RegionApiLiveTest.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static com.google.common.collect.Iterables.any; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.keystone.v3.domain.Region; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; + +@Test(groups = "live", testName = "RegionApiLiveTest", singleThreaded = true) +public class RegionApiLiveTest extends BaseV3KeystoneApiLiveTest { + + private Region region; + + @BeforeClass + public void createTestRegion() { + region = api().create(getClass().getSimpleName(), null, null); + assertEquals(region.id(), getClass().getSimpleName()); + } + + @Test + public void testListRegions() { + assertTrue(any(api().list(), new Predicate() { + @Override + public boolean apply(Region input) { + return input.id().equals(region.id()); + } + })); + } + + @Test + public void testGetRegion() { + assertNotNull(api().get(region.id())); + } + + @Test + public void testUpdateRegion() { + api().update(region.id(), "Updated", null); + region = api().get(region.id()); + assertEquals(region.description(), "Updated"); + } + + @AfterClass(alwaysRun = true) + public void deleteRegion() { + assertTrue(api().delete(region.id())); + } + + private RegionApi api() { + return api.getRegionApi(); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/RegionApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/RegionApiMockTest.java new file mode 100644 index 0000000000..bc7b1e0020 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/RegionApiMockTest.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.util.List; + +import org.jclouds.openstack.keystone.v3.domain.Region; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "RegionApiMockTest", singleThreaded = true) +public class RegionApiMockTest extends BaseV3KeystoneApiMockTest { + + public void testListRegions() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/regions.json")); + + List regions = api.getRegionApi().list(); + assertFalse(regions.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/regions"); + } + + public void testListRegionsReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + List regions = api.getRegionApi().list(); + assertTrue(regions.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/regions"); + } + + public void testGetRegion() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/region.json")); + + Region region = api.getRegionApi().get("RegionOne"); + assertNotNull(region); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/regions/RegionOne"); + } + + public void testGetRegionReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + Region region = api.getRegionApi().get("RegionOne"); + assertNull(region); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/regions/RegionOne"); + } + + public void testCreateRegion() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/region.json")); + + Region region = api.getRegionApi().create("RegionOne", "Description", "12345"); + assertNotNull(region); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "POST", "/regions", + "{\"region\":{\"id\":\"RegionOne\",\"description\":\"Description\",\"parent_region_id\":\"12345\"}}"); + } + + public void testUpdateRegion() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/region.json")); + + Region region = api.getRegionApi().update("RegionOne", "Updated", null); + assertNotNull(region); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "PATCH", "/regions/RegionOne", "{\"region\":{\"description\":\"Updated\"}}"); + } + + public void testDeleteRegion() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + boolean deleted = api.getRegionApi().delete("RegionOne"); + assertTrue(deleted); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/regions/RegionOne"); + } + + public void testDeleteRegionReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + boolean deleted = api.getRegionApi().delete("RegionOne"); + assertFalse(deleted); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/regions/RegionOne"); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/UserApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/UserApiLiveTest.java new file mode 100644 index 0000000000..addcf39c01 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/UserApiLiveTest.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static com.google.common.collect.Iterables.any; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.keystone.v3.domain.User; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; + +@Test(groups = "live", testName = "UserApiLiveTest", singleThreaded = true) +public class UserApiLiveTest extends BaseV3KeystoneApiLiveTest { + + private User user; + + @BeforeClass + public void createTestUser() { + user = api().create(getClass().getSimpleName(), "p4ssw0rd", true, null, null); + assertNotNull(user); + } + + @Test + public void testListUsers() { + assertTrue(any(api().list(), new Predicate() { + @Override + public boolean apply(User input) { + return input.id().equals(user.id()); + } + })); + } + + @Test + public void testGetUser() { + assertNotNull(api().get(user.id())); + } + + @Test + public void testUpdateUser() { + api().update(user.id(), "Updated", null, null, null, null); + user = api().get(user.id()); + assertEquals(user.name(), "Updated"); + } + + @Test + public void testListGroups() { + assertNotNull(api().listGroups(user.id())); + } + + @Test + public void testListProjects() { + assertNotNull(api().listProjects(user.id())); + } + + @Test + public void testChangePassword() { + api().changePassword(user.id(), "p4ssw0rd", "Newp4ssw0rd"); + } + + @AfterClass(alwaysRun = true) + public void deleteUser() { + assertTrue(api().delete(user.id())); + } + + private UserApi api() { + return api.getUserApi(); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/UserApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/UserApiMockTest.java new file mode 100644 index 0000000000..f31ae62bb9 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/UserApiMockTest.java @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.util.List; + +import org.jclouds.openstack.keystone.v3.domain.Group; +import org.jclouds.openstack.keystone.v3.domain.Project; +import org.jclouds.openstack.keystone.v3.domain.User; +import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "UserApiMockTest", singleThreaded = true) +public class UserApiMockTest extends BaseV3KeystoneApiMockTest { + + public void testListUsers() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/users.json")); + + List users = api.getUserApi().list(); + assertFalse(users.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/users"); + } + + public void testListUsersReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + List users = api.getUserApi().list(); + assertTrue(users.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/users"); + } + + public void testGetUser() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/user.json")); + + User user = api.getUserApi().get("0bedc61110fd4e94a251260a47f18f29"); + assertNotNull(user); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/users/0bedc61110fd4e94a251260a47f18f29"); + } + + public void testGetUserReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + User user = api.getUserApi().get("0bedc61110fd4e94a251260a47f18f29"); + assertNull(user); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/users/0bedc61110fd4e94a251260a47f18f29"); + } + + public void testCreateUser() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/user.json")); + + User user = api.getUserApi().create("user", "p4ssw0rd", true, "123", "789"); + assertNotNull(user); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "POST", "/users", "{\"user\":{\"name\":\"user\",\"password\":\"p4ssw0rd\",\"enabled\":true," + + "\"domain_id\":\"123\",\"default_project_id\":\"789\"}}"); + } + + public void testUpdateUser() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/user.json")); + + User user = api.getUserApi().update("0bedc61110fd4e94a251260a47f18f29", "foo", null, null, null, null); + assertNotNull(user); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "PATCH", "/users/0bedc61110fd4e94a251260a47f18f29", "{\"user\":{\"name\":\"foo\"}}"); + } + + public void testDeleteUser() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + boolean deleted = api.getUserApi().delete("0bedc61110fd4e94a251260a47f18f29"); + assertTrue(deleted); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/users/0bedc61110fd4e94a251260a47f18f29"); + } + + public void testDeleteUserReturns404() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response404()); + + boolean deleted = api.getUserApi().delete("0bedc61110fd4e94a251260a47f18f29"); + assertFalse(deleted); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "DELETE", "/users/0bedc61110fd4e94a251260a47f18f29"); + } + + public void testListGroups() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/groups.json")); + + List groups = api.getUserApi().listGroups("0bedc61110fd4e94a251260a47f18f29"); + assertFalse(groups.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/users/0bedc61110fd4e94a251260a47f18f29/groups"); + } + + public void testListProjects() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(jsonResponse("/v3/projects.json")); + + List projects = api.getUserApi().listProjects("0bedc61110fd4e94a251260a47f18f29"); + assertFalse(projects.isEmpty()); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "GET", "/users/0bedc61110fd4e94a251260a47f18f29/projects"); + } + + public void testChangePassword() throws InterruptedException { + enqueueAuthentication(server); + server.enqueue(response204()); + + api.getUserApi().changePassword("0bedc61110fd4e94a251260a47f18f29", "foo", "bar"); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertSent(server, "POST", "/users/0bedc61110fd4e94a251260a47f18f29/password", + "{\"user\":{\"original_password\":\"foo\",\"password\":\"bar\"}}"); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java new file mode 100644 index 0000000000..6d08b465ee --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.internal; + +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SCOPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; + +import java.util.Properties; + +import org.jclouds.apis.BaseApiLiveTest; +import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule; +import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.config.Authentication; +import org.jclouds.openstack.keystone.v3.KeystoneApi; +import org.jclouds.rest.ApiContext; + +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Key; +import com.google.inject.Module; +import com.google.inject.TypeLiteral; + +public class BaseV3KeystoneApiLiveTest extends BaseApiLiveTest { + + protected Supplier token; + protected AuthenticationApi authenticationApi; + + public BaseV3KeystoneApiLiveTest() { + provider = "openstack-keystone-3"; + } + + @Override + protected KeystoneApi create(Properties props, Iterable modules) { + ApiContext ctx = newBuilder().modules(modules).overrides(props).build(); + authenticationApi = ctx.utils().injector().getInstance(AuthenticationApi.class); + token = ctx.utils().injector().getInstance(Key.get(new TypeLiteral>() { + }, Authentication.class)); + return ctx.getApi(); + } + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + setIfTestSystemPropertyPresent(props, CREDENTIAL_TYPE); + setIfTestSystemPropertyPresent(props, SCOPE); + String customServiceType = setIfTestSystemPropertyPresent(props, SERVICE_TYPE); + if (customServiceType == null) { + props.setProperty(SERVICE_TYPE, "identityv3"); + } + return props; + } + + @Override + protected Iterable setupModules() { + ImmutableSet.Builder modules = ImmutableSet.builder(); + modules.add(new OkHttpCommandExecutorServiceModule()); + modules.add(new SLF4JLoggingModule()); + return modules.build(); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java new file mode 100644 index 0000000000..ec3f7ba509 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.keystone.v3.internal; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.collect.Iterables.getOnlyElement; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.UUID; + +import org.jclouds.ContextBuilder; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule; +import org.jclouds.json.Json; +import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.config.KeystoneProperties; +import org.jclouds.openstack.keystone.v3.KeystoneApi; +import org.jclouds.openstack.keystone.v3.KeystoneApiMetadata; +import org.jclouds.openstack.keystone.v3.domain.Token; +import org.jclouds.rest.ApiContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +import com.google.common.base.Charsets; +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSet; +import com.google.common.io.Resources; +import com.google.common.reflect.TypeToken; +import com.google.gson.JsonParser; +import com.google.inject.Module; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import com.squareup.okhttp.mockwebserver.RecordedRequest; + +public class BaseV3KeystoneApiMockTest { + + private static final String DEFAULT_ENDPOINT = new KeystoneApiMetadata().getDefaultEndpoint().orNull(); + + protected MockWebServer server; + protected KeystoneApi api; + protected AuthenticationApi authenticationApi; + protected String authToken; + private Json json; + + // So that we can ignore formatting. + private final JsonParser parser = new JsonParser(); + + @BeforeMethod + public void start() throws IOException { + server = new MockWebServer(); + server.play(); + + ApiContext ctx = ContextBuilder.newBuilder("openstack-keystone-3") + .credentials("domain:identity", "credential") + .endpoint(url("")) + .modules(modules()) + .overrides(overrides()) + .build(); + json = ctx.utils().injector().getInstance(Json.class); + authenticationApi = ctx.utils().injector().getInstance(AuthenticationApi.class); + api = ctx.getApi(); + } + + @AfterMethod(alwaysRun = true) + public void stop() throws IOException { + server.shutdown(); + api.close(); + } + + protected Properties overrides() { + Properties overrides = new Properties(); + overrides.setProperty(KeystoneProperties.SCOPE, "projectId:1234567890"); + overrides.setProperty(KeystoneProperties.SERVICE_TYPE, "identityv3"); + return overrides; + } + + protected Set modules() { + ImmutableSet.Builder modules = ImmutableSet.builder(); + modules.add(new ExecutorServiceModule(newDirectExecutorService())); + modules.add(new OkHttpCommandExecutorServiceModule()); + modules.add(new SLF4JLoggingModule()); + return modules.build(); + } + + protected String url(String path) { + return server.getUrl(path).toString(); + } + + protected void enqueueAuthentication(MockWebServer server) { + authToken = UUID.randomUUID().toString(); + server.enqueue(jsonResponse("/v3/token.json").addHeader("X-Subject-Token", authToken)); + } + + protected MockResponse jsonResponse(String resource) { + return new MockResponse().addHeader("Content-Type", "application/json").setBody(stringFromResource(resource)); + } + + protected MockResponse response404() { + return new MockResponse().setStatus("HTTP/1.1 404 Not Found"); + } + + protected MockResponse response201() { + return new MockResponse().setStatus("HTTP/1.1 201 Created"); + } + + protected MockResponse response204() { + return new MockResponse().setStatus("HTTP/1.1 204 No Content"); + } + + protected String stringFromResource(String resourceName) { + try { + return Resources.toString(getClass().getResource(resourceName), Charsets.UTF_8) + .replace(DEFAULT_ENDPOINT, url("")); + } catch (IOException e) { + throw Throwables.propagate(e); + } + } + + protected T onlyObjectFromResource(String resourceName, TypeToken> type) { + // Assume JSON objects passed here will be in the form: { "entity": { ... } } + String text = stringFromResource(resourceName); + Map object = json.fromJson(text, type.getType()); + checkArgument(!object.isEmpty(), "The given json does not contain any object: %s", text); + checkArgument(object.keySet().size() == 1, "The given json does not contain more than one object: %s", text); + return object.get(getOnlyElement(object.keySet())); + } + + protected T objectFromResource(String resourceName, Class type) { + String text = stringFromResource(resourceName); + return json.fromJson(text, type); + } + + protected void assertAuthentication(MockWebServer server) throws InterruptedException { + RecordedRequest request = assertSentNoAuth(server, "POST", "/auth/tokens"); + assertBody(request, stringFromResource("/v3/auth-password-scoped.json")); + } + + private RecordedRequest assertSentNoAuth(MockWebServer server, String method, String path) throws InterruptedException { + RecordedRequest request = server.takeRequest(); + assertEquals(request.getMethod(), method); + assertEquals(request.getPath(), path); + assertEquals(request.getHeader("Accept"), "application/json"); + return request; + } + + protected RecordedRequest assertSent(MockWebServer server, String method, String path) throws InterruptedException { + RecordedRequest request = assertSentNoAuth(server, method, path); + assertEquals(request.getHeader("X-Auth-Token"), authToken); + return request; + } + + protected RecordedRequest assertSent(MockWebServer server, String method, String path, String json) + throws InterruptedException { + RecordedRequest request = assertSent(server, method, path); + assertBody(request, json); + return request; + } + + private void assertBody(RecordedRequest request, String body) { + assertEquals(request.getHeader("Content-Type"), "application/json"); + assertEquals(parser.parse(new String(request.getBody(), Charsets.UTF_8)), parser.parse(body)); + } + + protected Token tokenFromResource(String resource) { + return onlyObjectFromResource(resource, new TypeToken>() { + private static final long serialVersionUID = 1L; + }); + } +} diff --git a/apis/openstack-keystone/src/test/resources/logback.xml b/apis/openstack-keystone/src/test/resources/logback.xml index 98b1ea9c88..5c373558a8 100644 --- a/apis/openstack-keystone/src/test/resources/logback.xml +++ b/apis/openstack-keystone/src/test/resources/logback.xml @@ -2,63 +2,41 @@ target/test-data/jclouds.log - %d %-5p [%c] [%thread] %m%n - target/test-data/jclouds-wire.log - %d %-5p [%c] [%thread] %m%n - target/test-data/jclouds-compute.log - %d %-5p [%c] [%thread] %m%n - - - target/test-data/jclouds-ssh.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - + + + + - - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/v3/auth-password-scoped.json b/apis/openstack-keystone/src/test/resources/v3/auth-password-scoped.json new file mode 100644 index 0000000000..993e0362a0 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/auth-password-scoped.json @@ -0,0 +1,23 @@ +{ + "auth": { + "identity": { + "methods": [ + "password" + ], + "password": { + "user": { + "name": "identity", + "domain": { + "name": "domain" + }, + "password": "credential" + } + } + }, + "scope": { + "project": { + "id": "1234567890" + } + } + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/auth-password.json b/apis/openstack-keystone/src/test/resources/v3/auth-password.json new file mode 100644 index 0000000000..2c2e8bd312 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/auth-password.json @@ -0,0 +1,19 @@ +{ + "auth": { + "identity": { + "methods": [ + "password" + ], + "password": { + "user": { + "name": "identity", + "domain": { + "name": "domain" + }, + "password": "credential" + } + } + }, + "scope": "unscoped" + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/auth-token-scoped.json b/apis/openstack-keystone/src/test/resources/v3/auth-token-scoped.json new file mode 100644 index 0000000000..a1938a79b9 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/auth-token-scoped.json @@ -0,0 +1,17 @@ +{ + "auth": { + "identity": { + "methods": [ + "token" + ], + "token": { + "id": "token" + } + }, + "scope": { + "domain": { + "name": "mydomain" + } + } + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/auth-token.json b/apis/openstack-keystone/src/test/resources/v3/auth-token.json new file mode 100644 index 0000000000..9ddd70fa39 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/auth-token.json @@ -0,0 +1,13 @@ +{ + "auth": { + "identity": { + "methods": [ + "token" + ], + "token": { + "id": "token" + } + }, + "scope": "unscoped" + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/endpoints.json b/apis/openstack-keystone/src/test/resources/v3/endpoints.json new file mode 100644 index 0000000000..0a097e0f98 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/endpoints.json @@ -0,0 +1,153 @@ +{ + "endpoints": [ + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/151d1dd2c86b4af783143ab1aa9d9a39" + }, + "url": "http://localhost/compute/v2/$(project_id)s", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "a14c47dc13194bf2a2195e861db9f906", + "id": "151d1dd2c86b4af783143ab1aa9d9a39" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/1a9f6c6bea0e4ff5bb8b17e3647a706e" + }, + "url": "http://localhost/volume/v2/$(project_id)s", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "238841bcff5f4f2b9ee2f7973c19e22a", + "id": "1a9f6c6bea0e4ff5bb8b17e3647a706e" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/206d6d831dbf44ccad854ffb419b4f02" + }, + "url": "http://localhost/volume/v1/$(project_id)s", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "a222e99e3d24476baa7762858dc34006", + "id": "206d6d831dbf44ccad854ffb419b4f02" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/23f60684390f4376aca5d828f2381e6e" + }, + "url": "http://localhost:8080", + "region": "RegionOne", + "enabled": true, + "interface": "admin", + "service_id": "2774503aa5354d70a801df09a813db46", + "id": "23f60684390f4376aca5d828f2381e6e" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/572671cba1d34bd29fdd160eac891971" + }, + "url": "http://localhost/volume/v3/$(project_id)s", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "be984bfb8b5f447d8a0ea3fa075054fc", + "id": "572671cba1d34bd29fdd160eac891971" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/882c0c04727744ee8d20839f5f9eec9a" + }, + "url": "http://localhost/compute/v2.1", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "fcc6a934957545bbb5fee29a217530ef", + "id": "882c0c04727744ee8d20839f5f9eec9a" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/9f1b314e3bc5403a8dcdef14c9eb044c" + }, + "url": "http://localhost/identity/v3", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "6b73ec12f7754a8696d758561a1cf5f1", + "id": "9f1b314e3bc5403a8dcdef14c9eb044c" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/bb2aa713d1154809aeb414e6fd71ba95" + }, + "url": "http://localhost/image", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "5dbcb1098b2e41e083c05c9006bd9830", + "id": "bb2aa713d1154809aeb414e6fd71ba95" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/dcf25870430f468d8f8dfd9d3acb95cc" + }, + "url": "http://localhost:9696/", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "d12688144a6e4d9db17ead14f4670d5b", + "id": "dcf25870430f468d8f8dfd9d3acb95cc" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/eb1517fb194a4df09109aa4606c245b9" + }, + "url": "http://localhost/identity/v3", + "region": "RegionOne", + "enabled": true, + "interface": "admin", + "service_id": "6b73ec12f7754a8696d758561a1cf5f1", + "id": "eb1517fb194a4df09109aa4606c245b9" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/edd066392b3549508739e18d5e69dbb7" + }, + "url": "http://localhost/placement", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "74efa863cb264dcbba922ff254a19876", + "id": "edd066392b3549508739e18d5e69dbb7" + }, + { + "region_id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/endpoints/ef84daa849894b8ebda274615a083139" + }, + "url": "http://localhost:8080/v1/AUTH_$(project_id)s", + "region": "RegionOne", + "enabled": true, + "interface": "public", + "service_id": "2774503aa5354d70a801df09a813db46", + "id": "ef84daa849894b8ebda274615a083139" + } + ], + "links": { + "self": "http://localhost/identity/v3/endpoints", + "previous": null, + "next": null + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/groups.json b/apis/openstack-keystone/src/test/resources/v3/groups.json new file mode 100644 index 0000000000..17f061cf7d --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/groups.json @@ -0,0 +1,27 @@ +{ + "groups": [ + { + "description": "Developers cleared for work on all general projects", + "domain_id": "1789d1", + "id": "ea167b", + "links": { + "self": "https://example.com/identity/v3/groups/ea167b" + }, + "name": "Developers" + }, + { + "description": "Developers cleared for work on secret projects", + "domain_id": "1789d1", + "id": "a62db1", + "links": { + "self": "https://example.com/identity/v3/groups/a62db1" + }, + "name": "Secure Developers" + } + ], + "links": { + "self": "http://example.com/identity/v3/users/9fe1d3/groups", + "previous": null, + "next": null + } +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/v3/project.json b/apis/openstack-keystone/src/test/resources/v3/project.json new file mode 100644 index 0000000000..0a47ffa3d6 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/project.json @@ -0,0 +1,15 @@ +{ + "project": { + "is_domain": false, + "description": "Updated", + "links": { + "self": "http://localhost/identity/v3/projects/2f9b30f706bc45d7923e055567be2e98" + }, + "tags": [], + "enabled": true, + "id": "2f9b30f706bc45d7923e055567be2e98", + "parent_id": "default", + "domain_id": "default", + "name": "ProjectApiLiveTest" + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/projects.json b/apis/openstack-keystone/src/test/resources/v3/projects.json new file mode 100644 index 0000000000..2f9faa0fa2 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/projects.json @@ -0,0 +1,74 @@ +{ + "links": { + "self": "http://localhost/identity/v3/projects", + "previous": null, + "next": null + }, + "projects": [ + { + "is_domain": false, + "description": "Updated", + "links": { + "self": "http://localhost/identity/v3/projects/2f9b30f706bc45d7923e055567be2e98" + }, + "tags": [], + "enabled": true, + "id": "2f9b30f706bc45d7923e055567be2e98", + "parent_id": "default", + "domain_id": "default", + "name": "ProjectApiLiveTest" + }, + { + "is_domain": false, + "description": "", + "links": { + "self": "http://localhost/identity/v3/projects/2fa489f9b84541b8a614c8c9df0d7596" + }, + "tags": [], + "enabled": true, + "id": "2fa489f9b84541b8a614c8c9df0d7596", + "parent_id": "default", + "domain_id": "default", + "name": "service" + }, + { + "is_domain": false, + "description": "", + "links": { + "self": "http://localhost/identity/v3/projects/43de288ea0ce4d2b8b811055b10f156b" + }, + "tags": [], + "enabled": true, + "id": "43de288ea0ce4d2b8b811055b10f156b", + "parent_id": "default", + "domain_id": "default", + "name": "jclouds" + }, + { + "is_domain": false, + "description": "Bootstrap project for initializing the cloud.", + "links": { + "self": "http://localhost/identity/v3/projects/90131053e7384f8a9e970544e0845913" + }, + "tags": [], + "enabled": true, + "id": "90131053e7384f8a9e970544e0845913", + "parent_id": "default", + "domain_id": "default", + "name": "admin" + }, + { + "is_domain": false, + "description": "", + "links": { + "self": "http://localhost/identity/v3/projects/d91b807dc87d477381500e8c920b10c7" + }, + "tags": [], + "enabled": true, + "id": "d91b807dc87d477381500e8c920b10c7", + "parent_id": "default", + "domain_id": "default", + "name": "demo" + } + ] +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/v3/region.json b/apis/openstack-keystone/src/test/resources/v3/region.json new file mode 100644 index 0000000000..ee5eee80ca --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/region.json @@ -0,0 +1,10 @@ +{ + "region": { + "parent_region_id": null, + "id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/regions/RegionApiLiveTest" + }, + "description": "Updated" + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/regions.json b/apis/openstack-keystone/src/test/resources/v3/regions.json new file mode 100644 index 0000000000..326a6fe990 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/regions.json @@ -0,0 +1,18 @@ +{ + "regions": [ + { + "parent_region_id": null, + "id": "RegionOne", + "links": { + "self": "http://localhost/identity/v3/regions/RegionOne" + }, + "description": "" + } + ], + "links": { + "self": "http://localhost/identity/v3/regions", + "previous": null, + "next": null + } +} + diff --git a/apis/openstack-keystone/src/test/resources/v3/token.json b/apis/openstack-keystone/src/test/resources/v3/token.json new file mode 100644 index 0000000000..b7fa6773e1 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/token.json @@ -0,0 +1,518 @@ +{ + "token": { + "methods": [ + "password" + ], + "roles": [ + { + "id": "9fe2ff9ee4384b1894a90878d3e92bab", + "name": "_member_" + }, + { + "id": "df7d043a09d34a7c9e2bad15926ee097", + "name": "cpf_org_manager" + }, + { + "id": "3af119c426a742999e7890f6d1f70b36", + "name": "cpf_admin" + } + ], + "expires_at": "2017-12-10T11:48:46.546830Z", + "project": { + "domain": { + "id": "2347b158dcaf488496b44cc4edfd2bd8", + "name": "0kjFQF29" + }, + "id": "2233c4d7d5c044b1b48e1bef25c1f305", + "name": "0kjFQF29-prj" + }, + "catalog": [ + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://objectstorage.myprovider.com/v1/AUTH_2233c4d7d5c044b1b48e1bef25c1f305", + "region": "uk-1", + "interface": "public", + "id": "b506af0e016a4b5fb592f196da569a41", + "name": "objectstorage" + } + ], + "type": "object-store", + "id": "024329e4fde148e58ecd90b7d9872438", + "name": "objectstorage" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://keymanagement.myprovider.com/v1", + "region": "uk-1", + "interface": "public", + "id": "0419c448001845af8f6828cf49745e72", + "name": "keymanagement" + } + ], + "type": "keystore", + "id": "07f309b0ef9d42758ea4de47bdca9c32", + "name": "keymanagement" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://certificate.myprovider.com/v1", + "region": "uk-1", + "interface": "public", + "id": "e1cc93936fb94cdbadc20f17c4ad3140", + "name": "certificate" + } + ], + "type": "certificate", + "id": "0bd9a971e97d4c15af6b94311e4e9c15", + "name": "certificate" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://orchestration.myprovider.com/v1/2233c4d7d5c044b1b48e1bef25c1f305", + "region": "uk-1", + "interface": "public", + "id": "c3ee708a6ae24ddf92c078526c36a446", + "name": "orchestration" + } + ], + "type": "orchestration", + "id": "0dafa2a9240c41268c37818979769c88", + "name": "orchestration" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://blockstorage.myprovider.com/v1/2233c4d7d5c044b1b48e1bef25c1f305", + "region": "uk-1", + "interface": "public", + "id": "ba9061d324954b1a9f6b1c1f5d4a5c5e", + "name": "blockstorage" + } + ], + "type": "volume", + "id": "0ec640e57e4d4374841d2ab7b292f2c2", + "name": "blockstorage" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://loadbalancing.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "169bcb3f92384f709232864f4d5304eb", + "name": "loadbalancing" + } + ], + "type": "loadbalancing", + "id": "15ef761fa00a438985213aec7b6fb18a", + "name": "loadbalancing" + }, + { + "endpoints": [], + "type": "dwh", + "id": "1a53a2e82370422d90174c4acf585ea9", + "name": "dwh" + }, + { + "endpoints": [], + "type": "contract", + "id": "1b35fa74ae0e46ebbc2014f976fec0e1", + "name": "contract" + }, + { + "endpoints": [], + "type": "appplatform", + "id": "253096ed430c49c48c9f3549e867b538", + "name": "appplatform" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://compute-w.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "e26ad89a682d4c8f8a71c9e76cd785b4", + "name": "compute-w" + } + ], + "type": "compute-w", + "id": "327c11710f184555b43bc6fdfc47626b", + "name": "compute-w" + }, + { + "endpoints": [], + "type": "notification", + "id": "3435ad7a1da04b1cb2e249665529eb51", + "name": "notification" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://compute.myprovider.com/v2/2233c4d7d5c044b1b48e1bef25c1f305", + "region": "uk-1", + "interface": "public", + "id": "f70e51b9a6a74a87a4c7055b8df8bedf", + "name": "compute" + } + ], + "type": "compute", + "id": "3e19093f50cc4590973c8953e2c327f9", + "name": "compute" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://queue.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "c46b5ec51ab04402a9ffd8177743ba6f", + "name": "queue" + } + ], + "type": "queue", + "id": "4a9ab69b74ec4948a0a6958177d30387", + "name": "queue" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://autoscale.myprovider.com/autoscale_schedulers", + "region": "uk-1", + "interface": "public", + "id": "071ee50be4b341558e37f84abac47d02", + "name": "autoscale" + } + ], + "type": "autoscale", + "id": "4f158b2836434c7ca6ee47e40a3ee56c", + "name": "autoscale" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://telemetry.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "6ac15657fbc548d7ab2ed986b8d94192", + "name": "telemetry" + } + ], + "type": "metering", + "id": "54ee7596f0e1433cb8db6201be2cf772", + "name": "telemetry" + }, + { + "endpoints": [], + "type": "cdn", + "id": "5954129d136e4a76b7cd6f3d1f3808b5", + "name": "cdn" + }, + { + "endpoints": [], + "type": "oss", + "id": "5a252878ffd7402498b6b74b575a899a", + "name": "oss" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://rolemanagement.myprovider.com/v1", + "region": "uk-1", + "interface": "public", + "id": "2d600a5de6ec42c6a5eab7b519832d87", + "name": "rolemanagement" + } + ], + "type": "rolemanagement", + "id": "5bc90099f0ad490c811239a6a3a8f853", + "name": "rolemanagement" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://compute-b.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "768450282d5546409395d2cb35502dad", + "name": "compute-b" + } + ], + "type": "compute-b", + "id": "65f754202b6049578e9a292a801e28f7", + "name": "compute-b" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://networking.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "675910513a7e466c84c39c5ca9445b81", + "name": "networking" + } + ], + "type": "network", + "id": "6cf37e33dc7140b9b032faabfa53a53e", + "name": "networking" + }, + { + "endpoints": [], + "type": "dns", + "id": "7426c97af5174c1abdb8b84ba02227ce", + "name": "dns" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://database.myprovider.com/v1.0/2233c4d7d5c044b1b48e1bef25c1f305", + "region": "uk-1", + "interface": "public", + "id": "6976cbeed14c464da15c13e949b41607", + "name": "database" + } + ], + "type": "database", + "id": "75c0280f15844d7a9eb22b1ad5a978e8", + "name": "database" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "http://localhost/identity/v3", + "region": "uk-1", + "interface": "admin", + "id": "db15a7126d4a4f1f81903bb4d56be32b", + "name": "identity" + } + ], + "type": "identity", + "id": "79066fe949064550930a61b33a49eb53", + "name": "identity" + }, + { + "endpoints": [], + "type": "intdns", + "id": "804190a423804019aab8fd934db0086e", + "name": "intdns" + }, + { + "endpoints": [], + "type": "invoicing", + "id": "8d364df08cbc4d7188f0cf83744b0336", + "name": "invoicing" + }, + { + "endpoints": [], + "type": "catalog", + "id": "9674ae5917af401397071c028ff33b68", + "name": "catalog" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://software.myprovider.com/v1.0", + "region": "uk-1", + "interface": "public", + "id": "fd6g35fgknrzumut7bx6p6bwzehkfhrz", + "name": "software" + } + ], + "type": "software", + "id": "9760973e49b04b00b41e60c180a80562", + "name": "software" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://blockstorage.myprovider.com/v2/2233c4d7d5c044b1b48e1bef25c1f305", + "region": "uk-1", + "interface": "public", + "id": "8c4ace3bbbd44883b5762a9ad8432a46", + "name": "blockstoragev2" + } + ], + "type": "volumev2", + "id": "9bf82d0466714eee86e304ab3301aec9", + "name": "blockstorage" + }, + { + "endpoints": [], + "type": "dnsadmin", + "id": "a2b90094346c48deabb9ca645bacf588", + "name": "dnsadmin" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://vmimport.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "225257ec50ef47668185587cc6edb95d", + "name": "vmimport" + } + ], + "type": "vmimport", + "id": "c73fa07c3b604b4f89d5a2b9c4621cf2", + "name": "vmimport" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "http://localhost/identity/v3", + "region": "uk-1", + "interface": "public", + "id": "27dc2bba1c5d4a14b68657fc8fdd4e3e", + "name": "identityv3" + }, + { + "region_id": "uk-1", + "url": "http://localhost/identity/v3", + "region": "uk-1", + "interface": "admin", + "id": "27dc2bba1c5d4a14b68657fc8fdd4e3e", + "name": "identityv3" + } + ], + "type": "identityv3", + "id": "cc6f50d496884ef0a751acb2e1eceedd", + "name": "identityv3" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://applicationmanagement.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "06fbcf8235434f23a08faed03b4af9ac", + "name": "appmanagement" + } + ], + "type": "appmanagement", + "id": "ce2f6bbe7a9f446b82d63725bd7bb484", + "name": "appmanagement" + }, + { + "endpoints": [], + "type": "nosql", + "id": "d07aa581c0734b6bb85cd496115b5110", + "name": "nosql" + }, + { + "endpoints": [], + "type": "baremetal", + "id": "d2f57dcae4c84466ac357220ff3d8900", + "name": "baremetal" + }, + { + "endpoints": [], + "type": "mail", + "id": "d4601f51af8f43f3b0e3409e4cbac690", + "name": "mail" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://networking-ex.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "bf356065e45349a5bde5e043c95a1923", + "name": "networking-ex" + } + ], + "type": "networking-ex", + "id": "d4937aa1275c41378bf2ae1dbe829c68", + "name": "networking-ex" + }, + { + "endpoints": [ + { + "region_id": "jp-east-1", + "url": "https://identity.gls.cloud.global.fujitsu.com/v3", + "region": "jp-east-1", + "interface": "public", + "id": "dc2ebf9d6fc04f1facc263a733cf754d", + "name": "global-identity" + } + ], + "type": "global-identity", + "id": "e74b9c29d6504f10a8fb8e1495f3f5c6", + "name": "global-identity" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://image.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "a832d640886b4ef89027339a2edf8fcd", + "name": "image" + } + ], + "type": "image", + "id": "ea850dab0e964e12a9f66787ee8623ae", + "name": "image" + }, + { + "endpoints": [], + "type": "billing", + "id": "f1302a2477bf492bb3e867952175974a", + "name": "billing" + }, + { + "endpoints": [ + { + "region_id": "uk-1", + "url": "https://import-export.myprovider.com", + "region": "uk-1", + "interface": "public", + "id": "e8bde8fe61a14a88b414e5568fc17201", + "name": "import-export" + } + ], + "type": "import-export", + "id": "fc302725919645199373077fa299fc6e", + "name": "import-export" + } + ], + "extras": {}, + "user": { + "domain": { + "id": "2347b158dcaf488496b44cc4edfd2bd8", + "name": "0kjFQF29" + }, + "id": "f1f24aea666542eeb58dc129c29734f0", + "name": "cloudsoft" + }, + "audit_ids": [ + "kr9Qqe-1QFOOlrt2XP6AqA" + ], + "issued_at": "2017-12-10T08:48:46.546877Z" + } +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/v3/user.json b/apis/openstack-keystone/src/test/resources/v3/user.json new file mode 100644 index 0000000000..1c64db934f --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/user.json @@ -0,0 +1,13 @@ +{ + "user": { + "password_expires_at": null, + "links": { + "self": "http://localhost/identity/v3/users/0bedc61110fd4e94a251260a47f18f29" + }, + "enabled": true, + "id": "0bedc61110fd4e94a251260a47f18f29", + "options": {}, + "domain_id": "default", + "name": "User" + } +} diff --git a/apis/openstack-keystone/src/test/resources/v3/users.json b/apis/openstack-keystone/src/test/resources/v3/users.json new file mode 100644 index 0000000000..48302204f8 --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/v3/users.json @@ -0,0 +1,132 @@ +{ + "users": [ + { + "password_expires_at": null, + "name": "UserApiLiveTest", + "links": { + "self": "http://localhost/identity/v3/users/0bedc61110fd4e94a251260a47f18f29" + }, + "domain_id": "default", + "enabled": true, + "id": "0bedc61110fd4e94a251260a47f18f29", + "options": {} + }, + { + "password_expires_at": null, + "name": "glance-swift", + "links": { + "self": "http://localhost/identity/v3/users/1194933d3f1147a3b0824848bb7ec5e2" + }, + "domain_id": "default", + "enabled": true, + "id": "1194933d3f1147a3b0824848bb7ec5e2", + "options": {} + }, + { + "password_expires_at": null, + "name": "nova", + "links": { + "self": "http://localhost/identity/v3/users/290999fc41fb48e397feef465d014fb6" + }, + "domain_id": "default", + "enabled": true, + "id": "290999fc41fb48e397feef465d014fb6", + "options": {} + }, + { + "password_expires_at": null, + "name": "placement", + "links": { + "self": "http://localhost/identity/v3/users/34e6ac0dd9bb4601bac4971785abd7f5" + }, + "domain_id": "default", + "enabled": true, + "id": "34e6ac0dd9bb4601bac4971785abd7f5", + "options": {} + }, + { + "name": "jclouds", + "links": { + "self": "http://localhost/identity/v3/users/6c3b325a28264f00865b38442429fd77" + }, + "domain_id": "default", + "enabled": true, + "options": {}, + "default_project_id": "43de288ea0ce4d2b8b811055b10f156b", + "id": "6c3b325a28264f00865b38442429fd77", + "password_expires_at": null + }, + { + "password_expires_at": null, + "name": "cinder", + "links": { + "self": "http://localhost/identity/v3/users/6e705bff20794de5955acf0936f02b3f" + }, + "domain_id": "default", + "enabled": true, + "id": "6e705bff20794de5955acf0936f02b3f", + "options": {} + }, + { + "name": "demo", + "links": { + "self": "http://localhost/identity/v3/users/84910c7070144530a6b9627fe0e1743f" + }, + "domain_id": "default", + "enabled": true, + "options": {}, + "id": "84910c7070144530a6b9627fe0e1743f", + "email": "demo@example.com", + "password_expires_at": null + }, + { + "password_expires_at": null, + "name": "swift", + "links": { + "self": "http://localhost/identity/v3/users/87306cb2f0954ca8919f0fbaf29a780f" + }, + "domain_id": "default", + "enabled": true, + "id": "87306cb2f0954ca8919f0fbaf29a780f", + "options": {} + }, + { + "password_expires_at": null, + "name": "glance", + "links": { + "self": "http://localhost/identity/v3/users/94c9f0f5e056489ebfef25870e8944fe" + }, + "domain_id": "default", + "enabled": true, + "id": "94c9f0f5e056489ebfef25870e8944fe", + "options": {} + }, + { + "password_expires_at": null, + "name": "admin", + "links": { + "self": "http://localhost/identity/v3/users/ab7bd6c2dd394fce8318e7562115d3f8" + }, + "domain_id": "default", + "enabled": true, + "id": "ab7bd6c2dd394fce8318e7562115d3f8", + "options": {} + }, + { + "password_expires_at": null, + "name": "neutron", + "links": { + "self": "http://localhost/identity/v3/users/d3607e141e334823978eec2e1ccca8de" + }, + "domain_id": "default", + "enabled": true, + "id": "d3607e141e334823978eec2e1ccca8de", + "options": {} + } + ], + "links": { + "self": "http://localhost/identity/v3/users", + "previous": null, + "next": null + } +} diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java index d73a1daa9b..a330afa4c9 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java @@ -17,8 +17,9 @@ package org.jclouds.openstack.nova.v2_0; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT; @@ -29,10 +30,10 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule; import org.jclouds.openstack.nova.v2_0.config.NovaHttpApiModule; import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; @@ -69,6 +70,7 @@ public class NovaApiMetadata extends BaseHttpApiMetadata { properties.setProperty("jclouds.ssh.retry-auth", "true"); properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE); properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false"); properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false"); properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500"); @@ -93,8 +95,8 @@ public class NovaApiMetadata extends BaseHttpApiMetadata { .defaultProperties(NovaApiMetadata.defaultProperties()) .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>builder() - .add(AuthenticationApiModule.class) - .add(KeystoneAuthenticationModule.class) + .add(AuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(NovaParserModule.class) .add(NovaHttpApiModule.class) diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AttachInterfaceApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AttachInterfaceApi.java index 65bd198f3c..119b08aa00 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AttachInterfaceApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AttachInterfaceApi.java @@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.InterfaceAttachment; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java index 9aa9b21d73..e3abe74d64 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java @@ -23,7 +23,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone; import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZoneDetails; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java index 7aa1f603fc..a4d4127c9b 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java @@ -25,7 +25,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindConsoleToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.Console; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java index 0db8cee02c..d935763dd1 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java @@ -33,7 +33,7 @@ import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java index 626ee2d282..003e66bfb9 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java @@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.FloatingIP; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPPoolApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPPoolApi.java index ead37abbcf..5bf56255f9 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPPoolApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPPoolApi.java @@ -22,7 +22,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.FloatingIPPool; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java index 8a07d3f77c..5eadc486cd 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Host; import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage; import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.MaintenanceModeDisabledResponseParser; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java index 889bb4f85a..18ad082f95 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java @@ -32,7 +32,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.HostAggregate; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HypervisorApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HypervisorApi.java index 8da914cab2..9e443f6166 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HypervisorApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HypervisorApi.java @@ -23,7 +23,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.regionscoped.Hypervisor; import org.jclouds.openstack.nova.v2_0.domain.regionscoped.HypervisorDetails; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java index d9f87d3a41..34074d1e08 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java @@ -30,7 +30,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindKeyPairToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.KeyPair; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseKeyPairs; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java index 5790620a87..59a5dd5ab3 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Quota; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java index 7e2b5030d5..9d3ed0ff3e 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java @@ -30,7 +30,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindSecurityGroupRuleToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.Ingress; import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java index e054bd9d97..b489b2a525 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java @@ -25,7 +25,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.BackupType; import org.jclouds.openstack.nova.v2_0.functions.ParseImageIdFromLocationHeader; import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java index 3d1ecba80b..e17ca690a4 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java @@ -25,7 +25,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java index 269059bbd5..f88b48068a 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java index eff19a05ea..f484cff574 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java @@ -24,7 +24,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.VirtualInterface; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java index eeaa99282f..185c8077e7 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java @@ -30,7 +30,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Volume; import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java index 4445b3ed62..8d329f1b94 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java @@ -30,7 +30,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java index 1204066e1e..05dafac0fa 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java @@ -34,7 +34,7 @@ import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.VolumeType; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions; import org.jclouds.openstack.v2_0.ServiceType; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java index d9e1498a9d..98d1d9f7ad 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java @@ -31,8 +31,8 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Flavor; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java index 1258c796db..3dc9907210 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java @@ -36,8 +36,8 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.Image; import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java index 42ab1c7a2d..33bf09a2a3 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java @@ -41,8 +41,8 @@ import org.jclouds.collect.PagedIterable; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.RebootType; import org.jclouds.openstack.nova.v2_0.domain.Server; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java index a19dc754c0..8c18292ea5 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java @@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableSet; /** * - * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE + * @see org.jclouds.openstack.keystone.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest") public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseNovaApiExpectTest { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java index bd3f714a2b..54aba7641d 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java @@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableSet; /** * - * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE + * @see org.jclouds.openstack.keystone.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest") public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiExpectTest { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java index 55f1a21b49..dac895e5bb 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java @@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableSet; /** * - * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE + * @see org.jclouds.openstack.keystone.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "PasswordAuthenticationExpectTest") public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java index 87d3f379b8..4761a6e91c 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java @@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableSet; /** * - * @see org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE + * @see org.jclouds.openstack.keystone.config.KeystoneProperties#CREDENTIAL_TYPE */ @Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest") public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiExpectTest { diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java index f5e33ddb12..d4aac073e3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java @@ -21,7 +21,7 @@ import static java.util.logging.Logger.getAnonymousLogger; import java.util.Properties; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.nova.v2_0.config.NovaProperties; import org.jclouds.rest.AuthorizationException; import org.jclouds.sshj.config.SshjSshClientModule; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java index 602831c416..713c1b9edc 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java @@ -21,8 +21,8 @@ import static org.testng.Assert.assertNotNull; import java.util.Properties; +import org.jclouds.openstack.keystone.catalog.config.InternalUrlModule; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; -import org.jclouds.openstack.v2_0.config.InternalUrlModule; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java index 614fad2f5c..13b34d1108 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java @@ -20,7 +20,7 @@ import java.util.Properties; import java.util.Set; import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.config.NovaProperties; import org.jclouds.openstack.nova.v2_0.domain.Flavor; diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java index 7351f68f23..3de0853599 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java @@ -17,21 +17,22 @@ package org.jclouds.openstack.swift.v1; import static org.jclouds.Constants.PROPERTY_IDEMPOTENT_METHODS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; -import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.TEMP_AUTH_HEADER_USER; -import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.TEMP_AUTH_HEADER_PASS; -import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.DEFAULT_HEADER_USER; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.DEFAULT_HEADER_PASS; +import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.DEFAULT_HEADER_USER; +import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.TEMP_AUTH_HEADER_PASS; +import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.TEMP_AUTH_HEADER_USER; import static org.jclouds.reflect.Reflection2.typeToken; - import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; import org.jclouds.openstack.swift.v1.blobstore.config.SignUsingTemporaryUrls; import org.jclouds.openstack.swift.v1.blobstore.config.SwiftBlobStoreContextModule; @@ -64,6 +65,7 @@ public class SwiftApiMetadata extends BaseHttpApiMetadata { public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_IDEMPOTENT_METHODS, "DELETE,GET,HEAD,OPTIONS,POST,PUT"); // Can alternatively be set to "tempAuthCredentials" properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); @@ -87,6 +89,7 @@ public class SwiftApiMetadata extends BaseHttpApiMetadata { .view(typeToken(RegionScopedBlobStoreContext.class)) .defaultModules(ImmutableSet.>builder() .add(SwiftAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(SwiftTypeAdapters.class) .add(SwiftHttpApiModule.class) diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftAuthenticationModule.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftAuthenticationModule.java index 90f1255197..a32276a94c 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftAuthenticationModule.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftAuthenticationModule.java @@ -18,11 +18,11 @@ package org.jclouds.openstack.swift.v1.config; import static org.jclouds.http.HttpUtils.releasePayload; import static org.jclouds.http.Uris.uriBuilder; -import static org.jclouds.openstack.v2_0.ServiceType.OBJECT_STORE; -import static org.jclouds.openstack.v2_0.reference.AuthHeaders.AUTH_TOKEN; -import static org.jclouds.rest.config.BinderUtils.bindHttpApi; +import static org.jclouds.openstack.keystone.auth.AuthHeaders.AUTH_TOKEN; import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.STORAGE_URL; import static org.jclouds.openstack.swift.v1.reference.TempAuthHeaders.TEMP_AUTH_HEADER_USER; +import static org.jclouds.openstack.v2_0.ServiceType.OBJECT_STORE; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; import java.io.Closeable; import java.net.URI; @@ -38,8 +38,8 @@ import org.jclouds.ContextBuilder; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; import org.jclouds.openstack.keystone.v2_0.domain.Service; @@ -59,33 +59,34 @@ import com.google.inject.Injector; import com.google.inject.name.Named; /** - * When {@link org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties#CREDENTIAL_TYPE} is set to {@code + * When {@link org.jclouds.openstack.keystone.config.KeystoneProperties#CREDENTIAL_TYPE} is set to {@code * tempAuthCredentials}, do not use Keystone. Instead, bridge TempAuth to Keystone by faking a service catalog out of * the storage url. The {@link ContextBuilder#endpoint(String) endpoint} must be set to the TempAuth url, usually ending * in {@code auth/v1.0/}. */ -public final class SwiftAuthenticationModule extends KeystoneAuthenticationModule { +public final class SwiftAuthenticationModule extends AuthenticationModule { @Override protected void configure() { super.configure(); - bindHttpApi(binder(), AuthenticationApi.class); bindHttpApi(binder(), TempAuthApi.class); } - @Override protected Map> authenticationMethods(Injector i) { - return ImmutableMap.>builder() - .putAll(super.authenticationMethods(i)) - .put("tempAuthCredentials", i.getInstance(TempAuth.class)).build(); + @Override + protected Map> authenticationMethods(Injector i) { + return ImmutableMap.> builder() + .putAll(super.authenticationMethods(i)) + .put("tempAuthCredentials", i.getInstance(TempAuth.class)) + .build(); } - static final class TempAuth implements Function { + static final class TempAuth implements Function { private final TempAuthApi delegate; @Inject TempAuth(TempAuthApi delegate) { this.delegate = delegate; } - @Override public Access apply(Credentials input) { + @Override public AuthInfo apply(Credentials input) { return delegate.auth(input); } } diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountApi.java index 63911db967..6db8d7b7e9 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountApi.java @@ -28,7 +28,7 @@ import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindAccountMetadataToHeaders; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindRemoveAccountMetadataToHeaders; import org.jclouds.openstack.swift.v1.domain.Account; diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/BulkApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/BulkApi.java index b62322fedf..ebf1e5b68a 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/BulkApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/BulkApi.java @@ -32,7 +32,7 @@ import javax.ws.rs.QueryParam; import org.jclouds.http.HttpRequest; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.binders.SetPayload; import org.jclouds.openstack.swift.v1.domain.BulkDeleteResponse; import org.jclouds.openstack.swift.v1.domain.ExtractArchiveResponse; diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerApi.java index 7a28fbc969..e942e716ec 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerApi.java @@ -34,7 +34,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.SwiftFallbacks.TrueOn404FalseOn409; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindContainerMetadataToHeaders; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindRemoveContainerMetadataToHeaders; diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApi.java index 044e457393..de4c61d437 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/DynamicLargeObjectApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindObjectMetadataToHeaders; import org.jclouds.openstack.swift.v1.binders.BindToHeaders; import org.jclouds.openstack.swift.v1.domain.SwiftObject; diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java index 24d845023a..41cbeb6025 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectApi.java @@ -18,8 +18,8 @@ package org.jclouds.openstack.swift.v1.features; import static com.google.common.net.HttpHeaders.EXPECT; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FROM; import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FRESH_METADATA; +import static org.jclouds.openstack.swift.v1.reference.SwiftHeaders.OBJECT_COPY_FROM; import java.util.Map; @@ -41,7 +41,7 @@ import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.http.options.GetOptions; import org.jclouds.io.Payload; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindObjectMetadataToHeaders; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindRemoveObjectMetadataToHeaders; import org.jclouds.openstack.swift.v1.binders.BindToHeaders; diff --git a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java index d5d490de7c..78cef14c1a 100644 --- a/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java +++ b/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/StaticLargeObjectApi.java @@ -31,11 +31,12 @@ import javax.ws.rs.PathParam; import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.binders.BindMetadataToHeaders.BindObjectMetadataToHeaders; import org.jclouds.openstack.swift.v1.binders.BindToHeaders; import org.jclouds.openstack.swift.v1.domain.DeleteStaticLargeObjectResponse; import org.jclouds.openstack.swift.v1.domain.Segment; +import org.jclouds.openstack.swift.v1.domain.SwiftObject; import org.jclouds.openstack.swift.v1.functions.ETagHeader; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java index 685a232214..6b9a865e4f 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java @@ -19,7 +19,7 @@ package org.jclouds.openstack.swift.v1; import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.assertj.core.api.Assertions.assertThat; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java index 97f544819a..5ae107534b 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.swift.v1.blobstore; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedSwiftBlobStoreParallelLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedSwiftBlobStoreParallelLiveTest.java index f2d0c8463c..a346d7bdf9 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedSwiftBlobStoreParallelLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedSwiftBlobStoreParallelLiveTest.java @@ -18,7 +18,7 @@ package org.jclouds.openstack.swift.v1.blobstore; import static org.assertj.core.util.Files.delete; import static org.jclouds.blobstore.options.PutOptions.Builder.multipart; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.testng.Assert.assertEquals; import java.io.File; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java index 3cb015e3a4..6995c81672 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobIntegrationLiveTest.java @@ -18,7 +18,7 @@ package org.jclouds.openstack.swift.v1.blobstore.integration; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import java.util.Properties; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java index d9996bf43f..402c09a475 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobLiveTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.swift.v1.blobstore.integration; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import java.util.Properties; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java index 9dd603f7c2..a54b3bfc0a 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftBlobSignerLiveTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.swift.v1.blobstore.integration; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import java.util.Properties; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java index fc8746b604..a0614cc2c7 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerIntegrationLiveTest.java @@ -16,14 +16,14 @@ */ package org.jclouds.openstack.swift.v1.blobstore.integration; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.testng.Assert.assertTrue; import java.util.Properties; import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest; -import org.testng.annotations.Test; import org.testng.SkipException; +import org.testng.annotations.Test; @Test(groups = "live", testName = "SwiftContainerIntegrationLiveTest") public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationTest { diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java index 9bd85d6f5f..608ddb66e2 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftContainerLiveTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.swift.v1.blobstore.integration; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import java.util.Properties; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java index 1da1a68d3e..3b7ec9d2b3 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/integration/SwiftServiceIntegrationLiveTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.swift.v1.blobstore.integration; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import java.util.Properties; diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java index 57d4b0a5ab..9beba1f28d 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/internal/BaseSwiftApiLiveTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.location.reference.LocationConstants; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.swift.v1.SwiftApi; import org.jclouds.openstack.swift.v1.domain.BulkDeleteResponse; import org.jclouds.openstack.swift.v1.domain.ObjectList; diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApi.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApi.java index 25869fbf61..579c635e17 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApi.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApi.java @@ -24,7 +24,6 @@ import javax.ws.rs.PathParam; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpoint; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; import org.jclouds.openstack.trove.v1.features.DatabaseApi; import org.jclouds.openstack.trove.v1.features.FlavorApi; import org.jclouds.openstack.trove.v1.features.InstanceApi; @@ -132,5 +131,5 @@ public interface TroveApi extends Closeable { * Provides the Tenant. */ @Provides - Optional getCurrentTenantId(); + Optional getCurrentTenantId(); } diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApiMetadata.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApiMetadata.java index 3d5e469395..034c53439b 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApiMetadata.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/TroveApiMetadata.java @@ -16,17 +16,18 @@ */ package org.jclouds.openstack.trove.v1; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.trove.v1.config.TroveHttpApiModule; import org.jclouds.openstack.trove.v1.config.TroveParserModule; import org.jclouds.openstack.v2_0.ServiceType; @@ -58,6 +59,7 @@ public class TroveApiMetadata extends BaseHttpApiMetadata { public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.DATABASE); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); return properties; } @@ -75,8 +77,8 @@ public class TroveApiMetadata extends BaseHttpApiMetadata { .defaultEndpoint("http://localhost:5000/v2.0/") .defaultProperties(TroveApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.>builder() - .add(AuthenticationApiModule.class) - .add(KeystoneAuthenticationModule.class) + .add(AuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(TroveParserModule.class) .add(TroveHttpApiModule.class) diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/config/TroveHttpApiModule.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/config/TroveHttpApiModule.java index 1bf6404046..1c127cc8e6 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/config/TroveHttpApiModule.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/config/TroveHttpApiModule.java @@ -26,8 +26,10 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v3.domain.Token; import org.jclouds.openstack.trove.v1.TroveApi; import org.jclouds.openstack.trove.v1.handlers.TroveErrorHandler; import org.jclouds.rest.ConfiguresHttpApi; @@ -67,14 +69,25 @@ public class TroveHttpApiModule extends HttpApiModule { } @Provides - final Supplier> supplyTenant(Supplier access) { + final Supplier> supplyTenant(Supplier access) { return Suppliers.compose(GetTenant.INSTANCE, access); } - private static enum GetTenant implements Function> { + private static enum GetTenant implements Function> { INSTANCE; - public Optional apply(Access in){ - return in.getToken().getTenant(); + public Optional apply(AuthInfo in) { + if (in instanceof Access) { + return Access.class.cast(in).getToken().getTenant().transform(new Function() { + @Override + public String apply(Tenant input) { + return input.getId(); + } + }); + } else if (in instanceof Token) { + // FIXME: What if user authenticated scoped to another project? + return Optional.of(Token.class.cast(in).user().defaultProjectId()); + } + return Optional.absent(); } } } diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/DatabaseApi.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/DatabaseApi.java index d640622a42..ef0fe27f57 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/DatabaseApi.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/DatabaseApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.trove.v1.binders.BindCreateDatabaseToJson; import org.jclouds.openstack.trove.v1.functions.ParseDatabaseListForUser; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/FlavorApi.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/FlavorApi.java index b71a5700a8..904f2a32bd 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/FlavorApi.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/FlavorApi.java @@ -25,7 +25,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.trove.v1.domain.Flavor; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/InstanceApi.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/InstanceApi.java index f64c75df13..443b02d96e 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/InstanceApi.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/InstanceApi.java @@ -29,7 +29,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.trove.v1.binders.BindCreateInstanceToJson; import org.jclouds.openstack.trove.v1.domain.Instance; import org.jclouds.openstack.trove.v1.functions.ParsePasswordFromRootedInstance; diff --git a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/UserApi.java b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/UserApi.java index 97449a4611..3753c54880 100644 --- a/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/UserApi.java +++ b/apis/openstack-trove/src/main/java/org/jclouds/openstack/trove/v1/features/UserApi.java @@ -18,6 +18,7 @@ package org.jclouds.openstack.trove.v1.features; import java.util.List; import java.util.Set; + import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -27,11 +28,12 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; + import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.trove.v1.binders.BindCreateUserToJson; import org.jclouds.openstack.trove.v1.binders.BindGrantUserToJson; import org.jclouds.openstack.trove.v1.domain.User; @@ -44,6 +46,7 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SkipEncoding; + import com.google.common.collect.FluentIterable; /** diff --git a/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiExpectTest.java b/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiExpectTest.java index df6b0bc7ce..3284038fca 100644 --- a/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiExpectTest.java +++ b/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiExpectTest.java @@ -72,7 +72,7 @@ public class FlavorApiExpectTest extends BaseTroveApiExpectTest { HttpResponse.builder().statusCode(200).payload(payloadFromResource("/flavor_list.json")).build() ); FlavorApi api = troveApi.getFlavorApi("RegionOne"); - Set flavors = api.list(troveApi.getCurrentTenantId().get().getId() ).toSet(); + Set flavors = api.list(troveApi.getCurrentTenantId().get()).toSet(); Flavor flavor = flavors.iterator().next(); assertEquals(flavor.getName(), "512MB Instance"); assertEquals(flavor.getId(), 1); diff --git a/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiLiveTest.java b/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiLiveTest.java index 2f2ec40aae..50201da216 100644 --- a/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiLiveTest.java +++ b/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/features/FlavorApiLiveTest.java @@ -45,7 +45,7 @@ public class FlavorApiLiveTest extends BaseTroveApiLiveTest { for (String region : api.getConfiguredRegions()) { FlavorApi flavorApi = api.getFlavorApi(region); - FluentIterable response = flavorApi.list( api.getCurrentTenantId().get().getId() ); // tenant id, but referred to as account id. + FluentIterable response = flavorApi.list( api.getCurrentTenantId().get()); // tenant id, but referred to as account id. for (Flavor flavor : response) { checkFlavor(flavor); } diff --git a/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/BaseTroveApiLiveTest.java b/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/BaseTroveApiLiveTest.java index 03df2194fb..d38e9733ad 100644 --- a/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/BaseTroveApiLiveTest.java +++ b/apis/openstack-trove/src/test/java/org/jclouds/openstack/trove/v1/internal/BaseTroveApiLiveTest.java @@ -19,7 +19,7 @@ package org.jclouds.openstack.trove.v1.internal; import java.util.Properties; import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.openstack.trove.v1.TroveApi; /** diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApi.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApi.java index 651d6b7560..e8b8f8f042 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApi.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApi.java @@ -28,7 +28,7 @@ import javax.ws.rs.PathParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.clouddns.v1.config.CloudDNS; import org.jclouds.rackspace.clouddns.v1.domain.Job; import org.jclouds.rackspace.clouddns.v1.features.DomainApi; @@ -36,6 +36,7 @@ import org.jclouds.rackspace.clouddns.v1.features.LimitApi; import org.jclouds.rackspace.clouddns.v1.features.RecordApi; import org.jclouds.rackspace.clouddns.v1.features.ReverseDNSApi; import org.jclouds.rackspace.clouddns.v1.functions.ParseJob; +import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApiMetadata.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApiMetadata.java index 55ea21d44b..c06aab885f 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApiMetadata.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/CloudDNSApiMetadata.java @@ -16,8 +16,9 @@ */ package org.jclouds.rackspace.clouddns.v1; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.rackspace.cloudidentity.v2_0.ServiceType.DNS; import static org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes.API_KEY_CREDENTIALS; @@ -25,9 +26,9 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ProviderModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.ProviderModule; import org.jclouds.rackspace.clouddns.v1.config.CloudDNSHttpApiModule; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; @@ -58,6 +59,7 @@ public class CloudDNSApiMetadata extends BaseHttpApiMetadata { Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, DNS); properties.setProperty(CREDENTIAL_TYPE, API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); return properties; } @@ -73,8 +75,8 @@ public class CloudDNSApiMetadata extends BaseHttpApiMetadata { .defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/") .defaultProperties(CloudDNSApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.> builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(ProviderModule.class) .add(CloudDNSHttpApiModule.class) .build()); diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/DomainApi.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/DomainApi.java index 7634e01133..7ae67f63d7 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/DomainApi.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/DomainApi.java @@ -37,10 +37,11 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rackspace.clouddns.v1.CloudDNSApi; import org.jclouds.rackspace.clouddns.v1.binders.FormatAndContentsToJSON; import org.jclouds.rackspace.clouddns.v1.binders.UpdateDomainsToJSON; import org.jclouds.rackspace.clouddns.v1.config.CloudDNS; @@ -56,8 +57,8 @@ import org.jclouds.rackspace.clouddns.v1.functions.ParseDomains; import org.jclouds.rackspace.clouddns.v1.functions.ParseJob; import org.jclouds.rackspace.clouddns.v1.functions.ParseSubdomains; import org.jclouds.rackspace.clouddns.v1.functions.SubdomainsToPagedIterable; +import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates; import org.jclouds.rackspace.cloudidentity.v2_0.functions.DateParser; - import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/LimitApi.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/LimitApi.java index 5160ce6a15..6e62054329 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/LimitApi.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/LimitApi.java @@ -22,7 +22,7 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.domain.Limits; import org.jclouds.rackspace.clouddns.v1.config.CloudDNS; import org.jclouds.rest.annotations.Endpoint; diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/RecordApi.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/RecordApi.java index bbc37a3b69..9752b96a67 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/RecordApi.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/RecordApi.java @@ -35,10 +35,11 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rackspace.clouddns.v1.CloudDNSApi; import org.jclouds.rackspace.clouddns.v1.binders.UpdateRecordsToJSON; import org.jclouds.rackspace.clouddns.v1.config.CloudDNS; import org.jclouds.rackspace.clouddns.v1.domain.Job; @@ -49,6 +50,7 @@ import org.jclouds.rackspace.clouddns.v1.functions.ParseOnlyRecord; import org.jclouds.rackspace.clouddns.v1.functions.ParseRecord; import org.jclouds.rackspace.clouddns.v1.functions.ParseRecords; import org.jclouds.rackspace.clouddns.v1.functions.RecordsToPagedIterable; +import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/ReverseDNSApi.java b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/ReverseDNSApi.java index df6860d79b..4b2aa09edb 100644 --- a/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/ReverseDNSApi.java +++ b/apis/rackspace-clouddns/src/main/java/org/jclouds/rackspace/clouddns/v1/features/ReverseDNSApi.java @@ -36,7 +36,8 @@ import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; +import org.jclouds.rackspace.clouddns.v1.CloudDNSApi; import org.jclouds.rackspace.clouddns.v1.binders.CreateReverseDNSToJSON; import org.jclouds.rackspace.clouddns.v1.binders.UpdateReverseDNSToJSON; import org.jclouds.rackspace.clouddns.v1.config.CloudDNS; @@ -47,6 +48,7 @@ import org.jclouds.rackspace.clouddns.v1.functions.ParseJob; import org.jclouds.rackspace.clouddns.v1.functions.ParseRecord; import org.jclouds.rackspace.clouddns.v1.functions.ParseRecords; import org.jclouds.rackspace.clouddns.v1.functions.RecordsToPagedIterable; +import org.jclouds.rackspace.clouddns.v1.predicates.JobPredicates; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.MapBinder; diff --git a/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/internal/BaseCloudDNSApiLiveTest.java b/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/internal/BaseCloudDNSApiLiveTest.java index e2ffd43905..58569b1a38 100644 --- a/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/internal/BaseCloudDNSApiLiveTest.java +++ b/apis/rackspace-clouddns/src/test/java/org/jclouds/rackspace/clouddns/v1/internal/BaseCloudDNSApiLiveTest.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.clouddns.v1.internal; import java.util.Properties; import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.rackspace.clouddns.v1.CloudDNSApi; public class BaseCloudDNSApiLiveTest extends BaseApiLiveTest { diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApiMetadata.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApiMetadata.java index 30556785b0..19a053246f 100644 --- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApiMetadata.java +++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/CloudFilesApiMetadata.java @@ -16,15 +16,17 @@ */ package org.jclouds.rackspace.cloudfiles.v1; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.swift.v1.SwiftApiMetadata; import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; import org.jclouds.openstack.swift.v1.blobstore.config.SignUsingTemporaryUrls; @@ -32,7 +34,6 @@ import org.jclouds.openstack.swift.v1.blobstore.config.SwiftBlobStoreContextModu import org.jclouds.openstack.swift.v1.config.SwiftTypeAdapters; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rackspace.cloudfiles.v1.config.CloudFilesHttpApiModule; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; import org.jclouds.rest.internal.BaseHttpApiMetadata; @@ -63,6 +64,7 @@ public class CloudFilesApiMetadata extends BaseHttpApiMetadata { public static Properties defaultProperties() { Properties properties = SwiftApiMetadata.defaultProperties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); return properties; } @@ -81,8 +83,8 @@ public class CloudFilesApiMetadata extends BaseHttpApiMetadata { .defaultProperties(CloudFilesApiMetadata.defaultProperties()) .view(typeToken(RegionScopedBlobStoreContext.class)) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(SwiftTypeAdapters.class) .add(CloudFilesHttpApiModule.class) diff --git a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java index e88626f57e..8dd7c6cf2d 100644 --- a/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java +++ b/apis/rackspace-cloudfiles/src/main/java/org/jclouds/rackspace/cloudfiles/v1/features/CDNApi.java @@ -38,7 +38,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudfiles.v1.binders.BindCDNPurgeEmailAddressesToHeaders; import org.jclouds.rackspace.cloudfiles.v1.domain.CDNContainer; import org.jclouds.rackspace.cloudfiles.v1.functions.ParseCDNContainerFromHeaders; diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityApiMetadata.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityApiMetadata.java index 3636a6c17b..9cca309536 100644 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityApiMetadata.java +++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityApiMetadata.java @@ -16,17 +16,17 @@ */ package org.jclouds.rackspace.cloudidentity.v2_0; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.openstack.keystone.catalog.config.KeystoneAdminURLModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata; import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule.KeystoneAdminURLModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -70,8 +70,8 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata { .defaultProperties(CloudIdentityApiMetadata.defaultProperties()) .documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-api-devguide/")) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(KeystoneAdminURLModule.class) .add(KeystoneParserModule.class) .add(KeystoneHttpApiModule.class).build()); diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityAuthenticationApi.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityAuthenticationApi.java index cb19a97607..db462b6976 100644 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityAuthenticationApi.java +++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/CloudIdentityAuthenticationApi.java @@ -22,13 +22,12 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; import org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.rackspace.cloudidentity.v2_0.domain.ApiKeyCredentials; import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.SelectJson; /** @@ -47,18 +46,6 @@ public interface CloudIdentityAuthenticationApi extends AuthenticationApi { @POST @SelectJson("access") @MapBinder(BindAuthToJsonPayload.class) - Access authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, - ApiKeyCredentials apiKeyCredentials); + Access authenticateApiKey(TenantOrDomainAndCredentials credentials); - /** - * Authenticate to generate a token. - * - * @return access with token - */ - @Named("authenticate") - @POST - @SelectJson("access") - @MapBinder(BindAuthToJsonPayload.class) - Access authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, - ApiKeyCredentials apiKeyCredentials); } diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationApiModule.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationApiModule.java deleted file mode 100644 index d3f0ec1dd8..0000000000 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationApiModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.rackspace.cloudidentity.v2_0.config; - -import static org.jclouds.rest.config.BinderUtils.bindHttpApi; - -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; -import org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityAuthenticationApi; - -import com.google.inject.AbstractModule; -import com.google.inject.Provides; - -public class CloudIdentityAuthenticationApiModule extends AbstractModule { - - @Override - protected void configure() { - // AuthenticationApi is used directly for filters and retry handlers, so let's bind it explicitly - bindHttpApi(binder(), CloudIdentityAuthenticationApi.class); - } - - @Provides - private AuthenticationApi provideAuthenticationApi(CloudIdentityAuthenticationApi in){ - return in; - } -} diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java index 88a51fa099..655537d820 100644 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java +++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java @@ -16,25 +16,44 @@ */ package org.jclouds.rackspace.cloudidentity.v2_0.config; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; + import java.util.Map; import org.jclouds.domain.Credentials; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials; +import org.jclouds.openstack.keystone.auth.AuthenticationApi; +import org.jclouds.openstack.keystone.auth.config.AuthenticationModule; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.functions.AuthenticatePasswordCredentials; +import org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityAuthenticationApi; import org.jclouds.rackspace.cloudidentity.v2_0.functions.AuthenticateApiKeyCredentials; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; +import com.google.common.collect.Maps; import com.google.inject.Injector; -public class CloudIdentityAuthenticationModule extends KeystoneAuthenticationModule { +public class CloudIdentityAuthenticationModule extends AuthenticationModule { @Override - protected Map> authenticationMethods(Injector i) { - Builder> fns = ImmutableSet.> builder(); + protected void configure() { + super.configure(); + bindHttpApi(binder(), CloudIdentityAuthenticationApi.class); + } + + @Override + protected Map authenticationApis(Injector i) { + Map authenticationApis = Maps.newHashMap(); + authenticationApis.put("2", i.getInstance(CloudIdentityAuthenticationApi.class)); + authenticationApis.put("3", i.getInstance(CloudIdentityAuthenticationApi.class)); + return authenticationApis; + } + + @Override + protected Map> authenticationMethods(Injector i) { + Builder> fns = ImmutableSet.> builder(); fns.add(i.getInstance(AuthenticatePasswordCredentials.class)); fns.add(i.getInstance(AuthenticateApiKeyCredentials.class)); return CredentialTypes.indexByCredentialType(fns.build()); diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java index 8313567599..c96a192b73 100644 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java +++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java @@ -16,7 +16,7 @@ */ package org.jclouds.rackspace.cloudidentity.v2_0.config; -import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; +import org.jclouds.openstack.keystone.auth.config.CredentialTypes; public class CloudIdentityCredentialTypes extends CredentialTypes { diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/domain/ApiKeyCredentials.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/domain/ApiKeyCredentials.java index 4976ec2fc9..c8f74aff58 100644 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/domain/ApiKeyCredentials.java +++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/domain/ApiKeyCredentials.java @@ -16,11 +16,11 @@ */ package org.jclouds.rackspace.cloudidentity.v2_0.domain; -import static com.google.common.base.Objects.equal; import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; +import org.jclouds.openstack.keystone.auth.config.CredentialType; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; import com.google.common.base.Objects; diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java index b4070bb0c0..254a53b4f6 100644 --- a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java +++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java @@ -19,15 +19,14 @@ package org.jclouds.rackspace.cloudidentity.v2_0.functions; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.openstack.keystone.v2_0.config.CredentialType; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.functions.internal.BaseAuthenticator; +import org.jclouds.openstack.keystone.auth.config.CredentialType; +import org.jclouds.openstack.keystone.auth.domain.AuthInfo; +import org.jclouds.openstack.keystone.auth.domain.TenantOrDomainAndCredentials; +import org.jclouds.openstack.keystone.auth.functions.BaseAuthenticator; import org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityAuthenticationApi; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; import org.jclouds.rackspace.cloudidentity.v2_0.domain.ApiKeyCredentials; -import com.google.common.base.Optional; - /** * * @see tenantId, ApiKeyCredentials apiKeyCredentials) { - return api.authenticateWithTenantNameAndCredentials(tenantId.orNull(), apiKeyCredentials); - } - - @Override - protected Access authenticateWithTenantId(Optional tenantId, ApiKeyCredentials apiKeyCredentials) { - return api.authenticateWithTenantIdAndCredentials(tenantId.orNull(), apiKeyCredentials); - } - @Override public ApiKeyCredentials createCredentials(String identity, String credential) { return ApiKeyCredentials.createWithUsernameAndApiKey(identity, credential); @@ -62,4 +51,9 @@ public class AuthenticateApiKeyCredentials extends BaseAuthenticator credentials) { + return api.authenticateApiKey(credentials); + } } diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/CloudLoadBalancersApiMetadata.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/CloudLoadBalancersApiMetadata.java index 67e07957bc..0c92fa2e13 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/CloudLoadBalancersApiMetadata.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/CloudLoadBalancersApiMetadata.java @@ -16,8 +16,9 @@ */ package org.jclouds.rackspace.cloudloadbalancers.v1; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; @@ -25,9 +26,9 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.rackspace.cloudidentity.v2_0.ServiceType; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; import org.jclouds.rackspace.cloudloadbalancers.v1.config.CloudLoadBalancersHttpApiModule; @@ -61,6 +62,7 @@ public class CloudLoadBalancersApiMetadata extends BaseHttpApiMetadata>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(CloudLoadBalancersHttpApiModule.class) .add(CloudLoadBalancersLoadBalancerContextModule.class).build()); diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApi.java index 2617b222b5..f862cf139e 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApi.java @@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRule; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApi.java index 8901e9ebdb..318f56ccab 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApi.java @@ -29,7 +29,7 @@ import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr422; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.ConnectionThrottle; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNestedBoolean; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApi.java index 3c092f4b81..ad623f2557 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApi.java @@ -26,7 +26,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNestedBoolean; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.Payload; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApi.java index 07b37867a7..bcc749be45 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNestedString; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.Payload; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/HealthMonitorApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/HealthMonitorApi.java index 4d6fc95f61..5c4e095ee8 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/HealthMonitorApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/HealthMonitorApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr422; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HealthMonitor; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApi.java index 8945d6898a..37328139b9 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/LoadBalancerApi.java @@ -37,8 +37,8 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.PagedIterable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.rackspace.cloudloadbalancers.v1.binders.BindMetadataToJsonPayload; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApi.java index b64b363d82..ceedc48645 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApi.java @@ -38,8 +38,8 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.PagedIterable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.rackspace.cloudloadbalancers.v1.binders.BindMetadataToJsonPayload; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ReportApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ReportApi.java index 9508f12461..b3c363d86d 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ReportApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ReportApi.java @@ -29,8 +29,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.PagedIterable; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HistoricalUsage; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApi.java index 96f0a25895..cd7c1ff8a4 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr422; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SSLTermination; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApi.java index 1a57d62ef7..350bf209c1 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApi.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SessionPersistence; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseSessionPersistence; import org.jclouds.rest.annotations.Fallback; diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApi.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApi.java index 42b913520e..a85505d1a1 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApi.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApi.java @@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId; import org.jclouds.rest.annotations.BinderParam; diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancersApiLiveTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancersApiLiveTest.java index b4d69f389e..5bb2027c7a 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancersApiLiveTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancersApiLiveTest.java @@ -20,7 +20,7 @@ import java.util.Properties; import java.util.logging.Logger; import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.config.KeystoneProperties; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.testng.annotations.BeforeGroups; diff --git a/providers/digitalocean2/src/test/resources/token.json b/providers/digitalocean2/src/test/resources/token.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java b/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java index 51b532f29c..33b8321f6e 100644 --- a/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java +++ b/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java @@ -19,7 +19,8 @@ package org.jclouds.rackspace.cloudblockstorage.uk; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; import java.net.URI; import java.util.Properties; @@ -27,10 +28,10 @@ import java.util.Properties; import org.jclouds.openstack.cinder.v1.CinderApiMetadata; import org.jclouds.openstack.cinder.v1.config.CinderHttpApiModule; import org.jclouds.openstack.cinder.v1.config.CinderParserModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -64,6 +65,7 @@ public class CloudBlockStorageUKProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_REGIONS, "LON"); properties.setProperty(PROPERTY_REGION + ".LON." + ISO3166_CODES, "GB-SLG"); return properties; @@ -81,8 +83,8 @@ public class CloudBlockStorageUKProviderMetadata extends BaseProviderMetadata { .endpointName("identity service url ending in /v2.0/") .documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html")) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(CinderParserModule.class) .add(CinderHttpApiModule.class).build()) diff --git a/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java b/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java index 19675fa7e0..761ab04ab1 100644 --- a/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java +++ b/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java @@ -19,7 +19,8 @@ package org.jclouds.rackspace.cloudblockstorage.us; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; import java.net.URI; import java.util.Properties; @@ -27,10 +28,10 @@ import java.util.Properties; import org.jclouds.openstack.cinder.v1.CinderApiMetadata; import org.jclouds.openstack.cinder.v1.config.CinderHttpApiModule; import org.jclouds.openstack.cinder.v1.config.CinderParserModule; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -64,6 +65,7 @@ public class CloudBlockStorageUSProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_REGIONS, "ORD,DFW,IAD,SYD,HKG"); properties.setProperty(PROPERTY_REGION + ".ORD." + ISO3166_CODES, "US-IL"); properties.setProperty(PROPERTY_REGION + ".DFW." + ISO3166_CODES, "US-TX"); @@ -85,8 +87,8 @@ public class CloudBlockStorageUSProviderMetadata extends BaseProviderMetadata { .endpointName("identity service url ending in /v2.0/") .documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html")) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(CinderParserModule.class) .add(CinderHttpApiModule.class).build()) diff --git a/providers/rackspace-clouddatabases-uk/src/main/java/org/jclouds/rackspace/clouddatabases/uk/CloudDatabasesUKProviderMetadata.java b/providers/rackspace-clouddatabases-uk/src/main/java/org/jclouds/rackspace/clouddatabases/uk/CloudDatabasesUKProviderMetadata.java index 307e86f610..5291dc246e 100644 --- a/providers/rackspace-clouddatabases-uk/src/main/java/org/jclouds/rackspace/clouddatabases/uk/CloudDatabasesUKProviderMetadata.java +++ b/providers/rackspace-clouddatabases-uk/src/main/java/org/jclouds/rackspace/clouddatabases/uk/CloudDatabasesUKProviderMetadata.java @@ -19,20 +19,21 @@ package org.jclouds.rackspace.clouddatabases.uk; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; import java.util.Properties; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.trove.v1.TroveApiMetadata; import org.jclouds.openstack.trove.v1.config.TroveHttpApiModule; import org.jclouds.openstack.trove.v1.config.TroveParserModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.rackspace.cloudidentity.v2_0.ServiceType; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -67,6 +68,7 @@ public class CloudDatabasesUKProviderMetadata extends BaseProviderMetadata { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); properties.setProperty(SERVICE_TYPE, ServiceType.DATABASES); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_REGIONS, "LON"); properties.setProperty(PROPERTY_REGION + ".LON." + ISO3166_CODES, "GB-SLG"); return properties; @@ -84,8 +86,8 @@ public class CloudDatabasesUKProviderMetadata extends BaseProviderMetadata { .endpointName("identity service url ending in /v2.0/") .documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html")) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(TroveParserModule.class) .add(TroveHttpApiModule.class).build()) diff --git a/providers/rackspace-clouddatabases-us/src/main/java/org/jclouds/rackspace/clouddatabases/us/CloudDatabasesUSProviderMetadata.java b/providers/rackspace-clouddatabases-us/src/main/java/org/jclouds/rackspace/clouddatabases/us/CloudDatabasesUSProviderMetadata.java index 4d595a70e6..ec94a127ff 100644 --- a/providers/rackspace-clouddatabases-us/src/main/java/org/jclouds/rackspace/clouddatabases/us/CloudDatabasesUSProviderMetadata.java +++ b/providers/rackspace-clouddatabases-us/src/main/java/org/jclouds/rackspace/clouddatabases/us/CloudDatabasesUSProviderMetadata.java @@ -19,20 +19,21 @@ package org.jclouds.rackspace.clouddatabases.us; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; import java.util.Properties; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.trove.v1.TroveApiMetadata; import org.jclouds.openstack.trove.v1.config.TroveHttpApiModule; import org.jclouds.openstack.trove.v1.config.TroveParserModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.rackspace.cloudidentity.v2_0.ServiceType; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -66,6 +67,7 @@ public class CloudDatabasesUSProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(SERVICE_TYPE, ServiceType.DATABASES); properties.setProperty(PROPERTY_REGIONS, "ORD,DFW,IAD,SYD,HKG"); properties.setProperty(PROPERTY_REGION + ".ORD." + ISO3166_CODES, "US-IL"); @@ -88,8 +90,8 @@ public class CloudDatabasesUSProviderMetadata extends BaseProviderMetadata { .endpointName("identity service url ending in /v2.0/") .documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html")) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(TroveParserModule.class) .add(TroveHttpApiModule.class).build()) diff --git a/providers/rackspace-cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/uk/CloudFilesUKProviderMetadata.java b/providers/rackspace-cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/uk/CloudFilesUKProviderMetadata.java index bf4eefada2..7307f19b73 100644 --- a/providers/rackspace-cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/uk/CloudFilesUKProviderMetadata.java +++ b/providers/rackspace-cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/uk/CloudFilesUKProviderMetadata.java @@ -19,14 +19,16 @@ package org.jclouds.rackspace.cloudfiles.uk; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; import org.jclouds.openstack.swift.v1.blobstore.config.SignUsingTemporaryUrls; import org.jclouds.openstack.swift.v1.blobstore.config.SwiftBlobStoreContextModule; @@ -36,7 +38,6 @@ import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApiMetadata; import org.jclouds.rackspace.cloudfiles.v1.config.CloudFilesHttpApiModule; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -68,6 +69,7 @@ public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_REGIONS, "LON"); properties.setProperty(PROPERTY_REGION + ".LON." + ISO3166_CODES, "GB-SLG"); @@ -89,8 +91,8 @@ public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { .version("1.0") .view(typeToken(RegionScopedBlobStoreContext.class)) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(SwiftTypeAdapters.class) .add(CloudFilesHttpApiModule.class) diff --git a/providers/rackspace-cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/us/CloudFilesUSProviderMetadata.java b/providers/rackspace-cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/us/CloudFilesUSProviderMetadata.java index cea0ebdb1e..76c83eba17 100644 --- a/providers/rackspace-cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/us/CloudFilesUSProviderMetadata.java +++ b/providers/rackspace-cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/us/CloudFilesUSProviderMetadata.java @@ -19,14 +19,16 @@ package org.jclouds.rackspace.cloudfiles.us; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext; import org.jclouds.openstack.swift.v1.blobstore.config.SignUsingTemporaryUrls; import org.jclouds.openstack.swift.v1.blobstore.config.SwiftBlobStoreContextModule; @@ -36,7 +38,6 @@ import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApiMetadata; import org.jclouds.rackspace.cloudfiles.v1.config.CloudFilesHttpApiModule; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; @@ -82,7 +83,8 @@ public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); - properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); + properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_REGIONS, "ORD,DFW,IAD,SYD,HKG"); properties.setProperty(PROPERTY_REGION + ".ORD." + ISO3166_CODES, "US-IL"); @@ -111,8 +113,8 @@ public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { .version("1.0") .view(typeToken(RegionScopedBlobStoreContext.class)) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(SwiftTypeAdapters.class) .add(CloudFilesHttpApiModule.class) diff --git a/providers/rackspace-cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/uk/CloudServersUKProviderMetadata.java b/providers/rackspace-cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/uk/CloudServersUKProviderMetadata.java index b03c59326e..adfe4bf5dc 100644 --- a/providers/rackspace-cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/uk/CloudServersUKProviderMetadata.java +++ b/providers/rackspace-cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/uk/CloudServersUKProviderMetadata.java @@ -20,17 +20,18 @@ import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; import java.net.URI; import java.util.Properties; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.nova.v2_0.NovaApiMetadata; import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; import org.jclouds.rackspace.cloudservers.uk.config.CloudServersUKComputeServiceContextModule; @@ -44,71 +45,83 @@ import com.google.inject.Module; * Implementation of {@link ProviderMetadata} for Rackspace Next Generation Cloud Servers. */ @AutoService(ProviderMetadata.class) -public class CloudServersUKProviderMetadata extends BaseProviderMetadata { +public class CloudServersUKProviderMetadata extends BaseProviderMetadata +{ - public static Builder builder() { - return new Builder(); - } + public static Builder builder() + { + return new Builder(); + } - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } + @Override + public Builder toBuilder() + { + return builder().fromProviderMetadata(this); + } - public CloudServersUKProviderMetadata() { - super(builder()); - } + public CloudServersUKProviderMetadata() + { + super(builder()); + } - public CloudServersUKProviderMetadata(Builder builder) { - super(builder); - } + public CloudServersUKProviderMetadata(final Builder builder) + { + super(builder); + } - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); - properties.setProperty(PROPERTY_REGIONS, "LON"); - properties.setProperty(PROPERTY_REGION + ".LON." + ISO3166_CODES, "GB-SLG"); - properties.setProperty(TEMPLATE, "imageNameMatches=.*Ubuntu.*"); - return properties; - } + public static Properties defaultProperties() + { + Properties properties = new Properties(); + properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); + properties.setProperty(PROPERTY_REGIONS, "LON"); + properties.setProperty(PROPERTY_REGION + ".LON." + ISO3166_CODES, "GB-SLG"); + properties.setProperty(TEMPLATE, "imageNameMatches=.*Ubuntu.*"); + return properties; + } - public static class Builder extends BaseProviderMetadata.Builder { + public static class Builder extends BaseProviderMetadata.Builder + { - protected Builder() { - id("rackspace-cloudservers-uk") - .name("Rackspace Next Generation Cloud Servers UK") - .apiMetadata(new NovaApiMetadata().toBuilder() - .identityName("${userName}") - .credentialName("${apiKey}") - .version("2") - .defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/") - .endpointName("identity service url ending in /v2.0/") - .documentation(URI.create("http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html#webhelp-currentid")) - .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) - .add(CloudIdentityAuthenticationModule.class) - .add(RegionModule.class) - .add(NovaParserModule.class) - .add(CloudServersUKHttpApiModule.class) - .add(CloudServersUKComputeServiceContextModule.class).build()) - .build()) - .homepage(URI.create("http://www.rackspace.co.uk/opencloud")) - .console(URI.create("https://mycloud.rackspace.co.uk/")) - .linkedServices("rackspace-cloudservers-uk", "cloudfiles-swift-uk") - .iso3166Codes("GB-SLG") - .endpoint("https://lon.identity.api.rackspacecloud.com/v2.0/") - .defaultProperties(CloudServersUKProviderMetadata.defaultProperties()); - } + protected Builder() + { + id("rackspace-cloudservers-uk") + .name("Rackspace Next Generation Cloud Servers UK") + .apiMetadata( + new NovaApiMetadata() + .toBuilder() + .identityName("${userName}") + .credentialName("${apiKey}") + .version("2") + .defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/") + .endpointName("identity service url ending in /v2.0/") + .documentation( + URI.create("http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html#webhelp-currentid")) + .defaultModules( + ImmutableSet.>builder() + .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class).add(RegionModule.class) + .add(NovaParserModule.class).add(CloudServersUKHttpApiModule.class) + .add(CloudServersUKComputeServiceContextModule.class).build()) + .build()).homepage(URI.create("http://www.rackspace.co.uk/opencloud")) + .console(URI.create("https://mycloud.rackspace.co.uk/")) + .linkedServices("rackspace-cloudservers-uk", "cloudfiles-swift-uk") + .iso3166Codes("GB-SLG") + .endpoint("https://lon.identity.api.rackspacecloud.com/v2.0/") + .defaultProperties(CloudServersUKProviderMetadata.defaultProperties()); + } - @Override - public CloudServersUKProviderMetadata build() { - return new CloudServersUKProviderMetadata(this); - } + @Override + public CloudServersUKProviderMetadata build() + { + return new CloudServersUKProviderMetadata(this); + } - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } + @Override + public Builder fromProviderMetadata(final ProviderMetadata in) + { + super.fromProviderMetadata(in); + return this; + } + } } diff --git a/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java b/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java index 2d247dca02..5262188e58 100644 --- a/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java +++ b/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java @@ -16,21 +16,22 @@ */ package org.jclouds.rackspace.cloudservers.us; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.keystone.config.KeystoneProperties.KEYSTONE_VERSION; import java.net.URI; import java.util.Properties; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule; +import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule.RegionModule; import org.jclouds.openstack.nova.v2_0.NovaApiMetadata; import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; import org.jclouds.rackspace.cloudservers.us.config.CloudServersUSComputeServiceContextModule; @@ -66,6 +67,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(KEYSTONE_VERSION, "2"); properties.setProperty(PROPERTY_REGIONS, "ORD,DFW,IAD,SYD,HKG"); properties.setProperty(PROPERTY_REGION + ".ORD." + ISO3166_CODES, "US-IL"); properties.setProperty(PROPERTY_REGION + ".DFW." + ISO3166_CODES, "US-TX"); @@ -94,8 +96,8 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata { .documentation( URI.create("http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/index.html")) .defaultModules(ImmutableSet.>builder() - .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) + .add(ServiceCatalogModule.class) .add(RegionModule.class) .add(NovaParserModule.class) .add(CloudServersUSHttpApiModule.class)