mirror of
https://github.com/apache/jclouds.git
synced 2026-09-05 18:59:40 +00:00
Allow configuration of session renewal.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
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.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
|
||||
@@ -82,6 +83,10 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
|
||||
properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false");
|
||||
properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false");
|
||||
properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500");
|
||||
// Keystone 1.1 expires tokens after 24 hours and allows renewal 1 hour
|
||||
// before expiry by default. We choose a value less than the latter
|
||||
// since the former persists between jclouds invocations.
|
||||
properties.setProperty(PROPERTY_SESSION_INTERVAL, 30 * 60 * 60 + "");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.jclouds.openstack.swift;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
@@ -67,6 +68,10 @@ public class SwiftApiMetadata extends BaseRestApiMetadata {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
|
||||
properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
|
||||
// Keystone 1.1 expires tokens after 24 hours and allows renewal 1 hour
|
||||
// before expiry by default. We choose a value less than the latter
|
||||
// since the former persists between jclouds invocations.
|
||||
properties.setProperty(PROPERTY_SESSION_INTERVAL, 30 * 60 * 60 + "");
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -100,4 +105,4 @@ public class SwiftApiMetadata extends BaseRestApiMetadata {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -20,6 +20,7 @@ package org.jclouds.openstack.keystone.v1_1.config;
|
||||
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -49,6 +50,7 @@ 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.name.Named;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
@@ -111,8 +113,9 @@ public class AuthenticationServiceModule extends AbstractModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public LoadingCache<Credentials, Auth> provideAuthCache(Function<Credentials, Auth> getAuth) {
|
||||
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS).build(CacheLoader.from(getAuth));
|
||||
protected LoadingCache<Credentials, Auth> provideAuthCache(GetAuth getAuth,
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long sessionInterval) {
|
||||
return CacheBuilder.newBuilder().expireAfterWrite(sessionInterval, TimeUnit.SECONDS).build(CacheLoader.from(getAuth));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
Reference in New Issue
Block a user