mirror of https://github.com/apache/jclouds.git
Fixed files before merge
This commit is contained in:
parent
676e153080
commit
e4c32bc00b
|
@ -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);
|
||||
}
|
|
@ -44,16 +44,16 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* Provides asynchronous access to Service via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see IdentityServiceClient
|
||||
* @see ServiceClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
|
||||
public interface IdentityServiceAsyncClient {
|
||||
public interface ServiceAsyncClient {
|
||||
|
||||
/**
|
||||
* @see IdentityServiceClient#authenticateTenantWithCredentials(String,PasswordCredentials)
|
||||
* @see ServiceClient#authenticateTenantWithCredentials(String,PasswordCredentials)
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("access")
|
||||
|
@ -64,7 +64,7 @@ public interface IdentityServiceAsyncClient {
|
|||
PasswordCredentials passwordCredentials);
|
||||
|
||||
/**
|
||||
* @see IdentityServiceClient#authenticateTenantWithCredentials(String,ApiAccessKeyCredentials)
|
||||
* @see ServiceClient#authenticateTenantWithCredentials(String,ApiAccessKeyCredentials)
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("access")
|
||||
|
@ -75,7 +75,7 @@ public interface IdentityServiceAsyncClient {
|
|||
ApiAccessKeyCredentials apiAccessKeyCredentials);
|
||||
|
||||
/**
|
||||
* @see IdentityServiceClient#getTenants()
|
||||
* @see ServiceClient#getTenants()
|
||||
*/
|
||||
@GET
|
||||
@SelectJson("tenants")
|
|
@ -35,6 +35,7 @@ import org.jclouds.rest.MapBinder;
|
|||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
|
@ -55,12 +56,12 @@ public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinde
|
|||
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()) {
|
||||
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) {
|
||||
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");
|
||||
|
||||
Builder<String, Object> builder = ImmutableMap.<String, Object> builder();
|
||||
//builder.put("tenantId", postParams.get("tenantId"));
|
||||
|
||||
addCredentialsInArgsOrNull(gRequest, builder, postParams.get("tenantId"));
|
||||
return super.bindToRequest(request, builder.build());
|
||||
addCredentialsInArgsOrNull(gRequest, builder);
|
||||
if (Strings.emptyToNull(postParams.get("tenantId")) != null)
|
||||
builder.put("tenantId", postParams.get("tenantId"));
|
||||
return super.bindToRequest(request, ImmutableMap.of("auth", builder.build()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.domain.Credentials;
|
|||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.location.Provider;
|
||||
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.PasswordCredentials;
|
||||
import org.jclouds.rest.AsyncClientFactory;
|
||||
|
@ -56,7 +56,7 @@ import com.google.inject.TypeLiteral;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
public class KeyStoneAuthenticationModule extends AbstractModule {
|
||||
public class KeystoneAuthenticationModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@ -81,8 +81,8 @@ public class KeyStoneAuthenticationModule extends AbstractModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected IdentityServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
|
||||
return factory.create(IdentityServiceAsyncClient.class);
|
||||
protected ServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
|
||||
return factory.create(ServiceAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -96,7 +96,7 @@ public class KeyStoneAuthenticationModule extends AbstractModule {
|
|||
public static class GetAccess extends RetryOnTimeOutExceptionFunction<Credentials, Access> {
|
||||
|
||||
@Inject
|
||||
public GetAccess(final IdentityServiceAsyncClient client) {
|
||||
public GetAccess(final ServiceAsyncClient client) {
|
||||
super(new Function<Credentials, Access>() {
|
||||
|
||||
@Override
|
Loading…
Reference in New Issue