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 javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
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
|
||||
public static class GetAuthenticationResponse extends
|
||||
RetryOnTimeOutExceptionFunction<Credentials, AuthenticationResponse> {
|
||||
|
|
|
@ -25,10 +25,8 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
|
@ -81,14 +79,7 @@ public class AuthenticationServiceModule extends AbstractModule {
|
|||
protected ServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
|
||||
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
|
||||
public static class GetAuth extends RetryOnTimeOutExceptionFunction<Credentials, Auth> {
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.concurrent.TimeoutException;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
|
@ -79,6 +78,9 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* service is needed to locate endpoints and such
|
||||
*/
|
||||
@Provides
|
||||
@Singleton
|
||||
protected ServiceAsyncClient provideServiceClient(AsyncClientFactory factory) {
|
||||
|
@ -122,18 +124,11 @@ public class KeystoneAuthenticationModule extends AbstractModule {
|
|||
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
|
||||
// PROPERTY_SESSION_INTERVAL is default to 60 seconds, but we have this here at 23 hours for now.
|
||||
@Provides
|
||||
@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));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
@Singleton
|
||||
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.domain.Access;
|
||||
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.Splitter;
|
||||
|
@ -32,13 +31,11 @@ import com.google.common.base.Throwables;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
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
|
||||
public AuthenticateApiAccessKeyCredentials(AsyncClientFactory factory) {
|
||||
this.factory = factory;
|
||||
public AuthenticateApiAccessKeyCredentials(ServiceAsyncClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,7 +46,6 @@ public class AuthenticateApiAccessKeyCredentials implements Function<Credentials
|
|||
String usernameOrAccessKey = Iterables.get(tenantIdUsernameOrAccessKey, 1);
|
||||
String passwordOrSecretKey = input.credential;
|
||||
|
||||
ServiceAsyncClient client = factory.create(ServiceAsyncClient.class);
|
||||
try {
|
||||
ApiAccessKeyCredentials apiAccessKeyCredentials = ApiAccessKeyCredentials.createWithAccessKeyAndSecretKey(
|
||||
usernameOrAccessKey, passwordOrSecretKey);
|
||||
|
|
|
@ -91,13 +91,18 @@ public class CryptoStreams {
|
|||
/**
|
||||
* @see #md5Hex
|
||||
*/
|
||||
public static String md5Hex(final String in) throws IOException {
|
||||
return md5Hex(new InputSupplier<InputStream>() {
|
||||
@Override
|
||||
public InputStream getInput() throws IOException {
|
||||
return new ByteArrayInputStream(in.getBytes());
|
||||
}
|
||||
});
|
||||
public static String md5Hex(final String in) {
|
||||
try {
|
||||
return md5Hex(new InputSupplier<InputStream>() {
|
||||
@Override
|
||||
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.ExecutorServiceModule;
|
||||
import org.jclouds.config.ValueOfConfigurationKeyOrNull;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -200,6 +201,12 @@ public class RestContextBuilder<S, A> {
|
|||
return config.apply(PROPERTY_CREDENTIAL);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Provider
|
||||
protected Credentials bindProviderCredentials(@Identity String identity, @Nullable @Credential String credential){
|
||||
return new Credentials(identity, credential);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindConfigurations() {
|
||||
|
|
|
@ -23,8 +23,12 @@ import java.util.Map;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
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.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
@ -61,7 +65,7 @@ public class RestClientModule<S, A> extends AbstractModule {
|
|||
this(syncClientType, asyncClientType, ImmutableMap
|
||||
.<Class<?>, Class<?>> of(syncClientType, asyncClientType));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.features;
|
||||
package org.jclouds.openstack.nova.v1_1;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -25,6 +25,7 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
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.parse.ParseServerListTest;
|
||||
import org.testng.annotations.Test;
|
Loading…
Reference in New Issue