mirror of https://github.com/apache/jclouds.git
cruft removal
This commit is contained in:
parent
be453c6650
commit
5e23d34f91
|
@ -28,10 +28,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
@ -80,13 +78,6 @@ public class OpenStackAuthenticationModule extends AbstractModule {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Provider
|
|
||||||
protected Credentials provideAuthenticationCredentials(@Named(Constants.PROPERTY_IDENTITY) String user,
|
|
||||||
@Named(Constants.PROPERTY_CREDENTIAL) String key) {
|
|
||||||
return new Credentials(user, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class GetAuthenticationResponse extends
|
public static class GetAuthenticationResponse extends
|
||||||
RetryOnTimeOutExceptionFunction<Credentials, AuthenticationResponse> {
|
RetryOnTimeOutExceptionFunction<Credentials, AuthenticationResponse> {
|
||||||
|
|
|
@ -25,10 +25,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
@ -82,13 +80,6 @@ public class AuthenticationServiceModule extends AbstractModule {
|
||||||
return factory.create(ServiceAsyncClient.class);
|
return factory.create(ServiceAsyncClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Provider
|
|
||||||
protected Credentials provideAuthenticationCredentials(@Named(Constants.PROPERTY_IDENTITY) String user,
|
|
||||||
@Named(Constants.PROPERTY_CREDENTIAL) String key) {
|
|
||||||
return new Credentials(user, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class GetAuth extends RetryOnTimeOutExceptionFunction<Credentials, Auth> {
|
public static class GetAuth extends RetryOnTimeOutExceptionFunction<Credentials, Auth> {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.concurrent.TimeoutException;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.HttpRetryHandler;
|
import org.jclouds.http.HttpRetryHandler;
|
||||||
|
@ -79,6 +78,9 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* service is needed to locate endpoints and such
|
||||||
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected ServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
|
protected ServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
|
||||||
|
@ -122,18 +124,11 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
return new RetryOnTimeOutExceptionFunction<Credentials, Access>(authMethod);
|
return new RetryOnTimeOutExceptionFunction<Credentials, Access>(authMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Provider
|
|
||||||
protected Credentials provideAuthenticationCredentials(@Named(Constants.PROPERTY_IDENTITY) String userOrAccessKey,
|
|
||||||
@Named(Constants.PROPERTY_CREDENTIAL) String keyOrSecretKey) {
|
|
||||||
return new Credentials(userOrAccessKey, keyOrSecretKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: what is the timeout of the session token? modify default accordingly
|
// 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 23 hours for now.
|
// PROPERTY_SESSION_INTERVAL is default to 60 seconds, but we have this here at 23 hours for now.
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public LoadingCache<Credentials, Access> provideAccessCache2(Function<Credentials, Access> getAccess) {
|
public LoadingCache<Credentials, Access> provideAccessCache(Function<Credentials, Access> getAccess) {
|
||||||
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS).build(CacheLoader.from(getAccess));
|
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS).build(CacheLoader.from(getAccess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +150,10 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* currently, endpointParams are not configured to take their results from a supplier lazily, so
|
||||||
|
* we need to eagerly fetch.
|
||||||
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Access provideAccess(Supplier<Access> supplier) {
|
protected Access provideAccess(Supplier<Access> supplier) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.openstack.keystone.v2_0.ServiceAsyncClient;
|
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.ApiAccessKeyCredentials;
|
import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials;
|
||||||
import org.jclouds.rest.AsyncClientFactory;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -32,13 +31,11 @@ import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
public class AuthenticateApiAccessKeyCredentials implements Function<Credentials, Access> {
|
public class AuthenticateApiAccessKeyCredentials implements Function<Credentials, Access> {
|
||||||
private final AsyncClientFactory factory;
|
private final ServiceAsyncClient client;
|
||||||
|
|
||||||
// passing factory here to avoid a circular dependency on
|
|
||||||
// OpenStackAuthAsyncClient resolving ServiceAsyncClient
|
|
||||||
@Inject
|
@Inject
|
||||||
public AuthenticateApiAccessKeyCredentials(AsyncClientFactory factory) {
|
public AuthenticateApiAccessKeyCredentials(ServiceAsyncClient client) {
|
||||||
this.factory = factory;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +46,6 @@ public class AuthenticateApiAccessKeyCredentials implements Function<Credentials
|
||||||
String usernameOrAccessKey = Iterables.get(tenantIdUsernameOrAccessKey, 1);
|
String usernameOrAccessKey = Iterables.get(tenantIdUsernameOrAccessKey, 1);
|
||||||
String passwordOrSecretKey = input.credential;
|
String passwordOrSecretKey = input.credential;
|
||||||
|
|
||||||
ServiceAsyncClient client = factory.create(ServiceAsyncClient.class);
|
|
||||||
try {
|
try {
|
||||||
ApiAccessKeyCredentials apiAccessKeyCredentials = ApiAccessKeyCredentials.createWithAccessKeyAndSecretKey(
|
ApiAccessKeyCredentials apiAccessKeyCredentials = ApiAccessKeyCredentials.createWithAccessKeyAndSecretKey(
|
||||||
usernameOrAccessKey, passwordOrSecretKey);
|
usernameOrAccessKey, passwordOrSecretKey);
|
||||||
|
|
|
@ -91,13 +91,18 @@ public class CryptoStreams {
|
||||||
/**
|
/**
|
||||||
* @see #md5Hex
|
* @see #md5Hex
|
||||||
*/
|
*/
|
||||||
public static String md5Hex(final String in) throws IOException {
|
public static String md5Hex(final String in) {
|
||||||
return md5Hex(new InputSupplier<InputStream>() {
|
try {
|
||||||
@Override
|
return md5Hex(new InputSupplier<InputStream>() {
|
||||||
public InputStream getInput() throws IOException {
|
@Override
|
||||||
return new ByteArrayInputStream(in.getBytes());
|
public InputStream getInput() throws IOException {
|
||||||
}
|
return new ByteArrayInputStream(in.getBytes());
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
// risk is not here when reading from in.getBytes() so wrapping in runtime
|
||||||
|
throw Throwables.propagate(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.jclouds.concurrent.SingleThreaded;
|
||||||
import org.jclouds.concurrent.config.ConfiguresExecutorService;
|
import org.jclouds.concurrent.config.ConfiguresExecutorService;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.config.ValueOfConfigurationKeyOrNull;
|
import org.jclouds.config.ValueOfConfigurationKeyOrNull;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
|
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
|
@ -200,6 +201,12 @@ public class RestContextBuilder<S, A> {
|
||||||
return config.apply(PROPERTY_CREDENTIAL);
|
return config.apply(PROPERTY_CREDENTIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Provider
|
||||||
|
protected Credentials bindProviderCredentials(@Identity String identity, @Nullable @Credential String credential){
|
||||||
|
return new Credentials(identity, credential);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bindConfigurations() {
|
protected void bindConfigurations() {
|
||||||
|
|
|
@ -23,8 +23,12 @@ import java.util.Map;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.internal.ClassMethodArgs;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
import org.jclouds.rest.internal.RestContextImpl;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v1_1.features;
|
package org.jclouds.openstack.nova.v1_1;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.openstack.nova.v1_1.features.ServerClient;
|
||||||
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest;
|
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaRestClientExpectTest;
|
||||||
import org.jclouds.openstack.nova.v1_1.parse.ParseServerListTest;
|
import org.jclouds.openstack.nova.v1_1.parse.ParseServerListTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
Loading…
Reference in New Issue