Fixed files before merge

This commit is contained in:
Jeremy Daggett 2012-02-01 22:39:29 -08:00
parent 676e153080
commit e4c32bc00b
5 changed files with 18 additions and 70 deletions

View File

@ -1,53 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
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;
/**
* Provides synchronous access to the KeyStone Service API.
* <p/>
*
* @see IdentityServiceAsyncClient
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* />
* @author Adrian Cole
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface IdentityServiceClient {
/**
* Authenticate to generate a token.
*
* @return access with token
*/
Access authenticateTenantWithCredentials(String tenantId, PasswordCredentials passwordCredentials);
/**
* Authenticate to generate a token.
*
* @return access with token
*/
Access authenticateTenantWithCredentials(String tenantId, ApiAccessKeyCredentials passwordCredentials);
}

View File

@ -44,16 +44,16 @@ import com.google.common.util.concurrent.ListenableFuture;
* Provides asynchronous access to Service via their REST API. * Provides asynchronous access to Service via their REST API.
* <p/> * <p/>
* *
* @see IdentityServiceClient * @see ServiceClient
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html" * @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* /> * />
* @author Adrian Cole * @author Adrian Cole
*/ */
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}") @Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
public interface IdentityServiceAsyncClient { public interface ServiceAsyncClient {
/** /**
* @see IdentityServiceClient#authenticateTenantWithCredentials(String,PasswordCredentials) * @see ServiceClient#authenticateTenantWithCredentials(String,PasswordCredentials)
*/ */
@POST @POST
@SelectJson("access") @SelectJson("access")
@ -64,7 +64,7 @@ public interface IdentityServiceAsyncClient {
PasswordCredentials passwordCredentials); PasswordCredentials passwordCredentials);
/** /**
* @see IdentityServiceClient#authenticateTenantWithCredentials(String,ApiAccessKeyCredentials) * @see ServiceClient#authenticateTenantWithCredentials(String,ApiAccessKeyCredentials)
*/ */
@POST @POST
@SelectJson("access") @SelectJson("access")
@ -75,7 +75,7 @@ public interface IdentityServiceAsyncClient {
ApiAccessKeyCredentials apiAccessKeyCredentials); ApiAccessKeyCredentials apiAccessKeyCredentials);
/** /**
* @see IdentityServiceClient#getTenants() * @see ServiceClient#getTenants()
*/ */
@GET @GET
@SelectJson("tenants") @SelectJson("tenants")

View File

@ -35,6 +35,7 @@ import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.rest.binders.BindToJsonPayload;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
@ -55,12 +56,12 @@ public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinde
throw new IllegalStateException("BindAuthToJsonPayload needs parameters"); throw new IllegalStateException("BindAuthToJsonPayload needs parameters");
} }
protected void addCredentialsInArgsOrNull(GeneratedHttpRequest<?> gRequest, Builder<String, Object> builder, String tenantId) { protected void addCredentialsInArgsOrNull(GeneratedHttpRequest<?> gRequest, Builder<String, Object> builder) {
for (Object arg : gRequest.getArgs()) { for (Object arg : gRequest.getArgs()) {
if (arg instanceof PasswordCredentials) { if (arg instanceof PasswordCredentials) {
builder.put("auth", ImmutableMap.of("passwordCredentials", PasswordCredentials.class.cast(arg), "tenantId", tenantId)); builder.put("passwordCredentials", PasswordCredentials.class.cast(arg));
} else if (arg instanceof ApiAccessKeyCredentials) { } else if (arg instanceof ApiAccessKeyCredentials) {
builder.put("auth", ImmutableMap.of("apiAccessKeyCredentials", ApiAccessKeyCredentials.class.cast(arg))); builder.put("apiAccessKeyCredentials", ApiAccessKeyCredentials.class.cast(arg));
} }
} }
} }
@ -73,10 +74,10 @@ public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinde
checkState(gRequest.getArgs() != null, "args should be initialized at this point"); checkState(gRequest.getArgs() != null, "args should be initialized at this point");
Builder<String, Object> builder = ImmutableMap.<String, Object> builder(); Builder<String, Object> builder = ImmutableMap.<String, Object> builder();
//builder.put("tenantId", postParams.get("tenantId")); addCredentialsInArgsOrNull(gRequest, builder);
if (Strings.emptyToNull(postParams.get("tenantId")) != null)
addCredentialsInArgsOrNull(gRequest, builder, postParams.get("tenantId")); builder.put("tenantId", postParams.get("tenantId"));
return super.bindToRequest(request, builder.build()); return super.bindToRequest(request, ImmutableMap.of("auth", builder.build()));
} }
} }

View File

@ -34,7 +34,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.location.Provider; import org.jclouds.location.Provider;
import org.jclouds.openstack.Authentication; import org.jclouds.openstack.Authentication;
import org.jclouds.openstack.keystone.v2_0.IdentityServiceAsyncClient; import org.jclouds.openstack.keystone.v2_0.ServiceAsyncClient;
import org.jclouds.openstack.keystone.v2_0.domain.Access; 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.domain.PasswordCredentials;
import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.AsyncClientFactory;
@ -56,7 +56,7 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole * @author Adrian Cole
*/ */
@RequiresHttp @RequiresHttp
public class KeyStoneAuthenticationModule extends AbstractModule { public class KeystoneAuthenticationModule extends AbstractModule {
@Override @Override
protected void configure() { protected void configure() {
@ -81,8 +81,8 @@ public class KeyStoneAuthenticationModule extends AbstractModule {
@Provides @Provides
@Singleton @Singleton
protected IdentityServiceAsyncClient provideServiceClient(AsyncClientFactory factory) { protected ServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
return factory.create(IdentityServiceAsyncClient.class); return factory.create(ServiceAsyncClient.class);
} }
@Provides @Provides
@ -96,7 +96,7 @@ public class KeyStoneAuthenticationModule extends AbstractModule {
public static class GetAccess extends RetryOnTimeOutExceptionFunction<Credentials, Access> { public static class GetAccess extends RetryOnTimeOutExceptionFunction<Credentials, Access> {
@Inject @Inject
public GetAccess(final IdentityServiceAsyncClient client) { public GetAccess(final ServiceAsyncClient client) {
super(new Function<Credentials, Access>() { super(new Function<Credentials, Access>() {
@Override @Override