mirror of
https://github.com/apache/jclouds.git
synced 2025-02-06 10:09:35 +00:00
* Refactor OAuth so that it doesn't require private keys when we aren't signing anything.
* Rename constant serviceAccountCredentials to p12PrivateKeyCredentials as this better describes the credential value.
This commit is contained in:
parent
09df55e295
commit
aebc0c473a
@ -21,7 +21,7 @@ import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstan
|
||||
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.OPERATION_COMPLETE_INTERVAL;
|
||||
import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.OPERATION_COMPLETE_TIMEOUT;
|
||||
import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
|
||||
import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM;
|
||||
import static org.jclouds.oauth.v2.config.OAuthProperties.JWS_ALG;
|
||||
import static org.jclouds.reflect.Reflection2.typeToken;
|
||||
|
||||
import java.net.URI;
|
||||
@ -60,7 +60,7 @@ public class GoogleCloudStorageApiMetadata extends BaseHttpApiMetadata<GoogleClo
|
||||
Properties properties = BaseHttpApiMetadata.defaultProperties();
|
||||
properties.put("oauth.endpoint", "https://accounts.google.com/o/oauth2/token");
|
||||
properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token");
|
||||
properties.put(SIGNATURE_OR_MAC_ALGORITHM, "RS256");
|
||||
properties.put(JWS_ALG, "RS256");
|
||||
properties.put(PROPERTY_SESSION_INTERVAL, 3600);
|
||||
properties.put(OPERATION_COMPLETE_INTERVAL, 2000);
|
||||
properties.put(OPERATION_COMPLETE_TIMEOUT, 600000);
|
||||
|
@ -27,6 +27,8 @@ import static org.jclouds.crypto.Pems.privateKeySpec;
|
||||
import static org.jclouds.crypto.Pems.publicKeySpec;
|
||||
import static org.jclouds.crypto.PemsTest.PRIVATE_KEY;
|
||||
import static org.jclouds.crypto.PemsTest.PUBLIC_KEY;
|
||||
import static org.jclouds.oauth.v2.JWSAlgorithms.NONE;
|
||||
import static org.jclouds.oauth.v2.config.OAuthProperties.JWS_ALG;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@ -49,13 +51,13 @@ import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.io.payloads.ByteSourcePayload;
|
||||
import org.jclouds.oauth.v2.OAuthConstants;
|
||||
import org.jclouds.oauth.v2.config.OAuthProperties;
|
||||
import org.jclouds.oauth.v2.functions.BuildTokenRequest;
|
||||
import org.jclouds.oauth.v2.functions.BuildTokenRequest.TestBuildTokenRequest;
|
||||
import org.jclouds.rest.internal.BaseRestApiExpectTest;
|
||||
import org.jclouds.ssh.SshKeys;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.inject.Binder;
|
||||
@ -89,9 +91,8 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T
|
||||
return new Module() {
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
// Predicatable time
|
||||
binder.bind(new TypeLiteral<Supplier<Long>>() {
|
||||
}).toInstance(Suppliers.ofInstance(0L));
|
||||
// Predictable time
|
||||
binder.bind(BuildTokenRequest.class).to(TestBuildTokenRequest.class);
|
||||
try {
|
||||
KeyFactory keyfactory = KeyFactory.getInstance("RSA");
|
||||
PrivateKey privateKey = keyfactory.generatePrivate(privateKeySpec(ByteSource.wrap(PRIVATE_KEY
|
||||
@ -135,7 +136,7 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T
|
||||
protected Properties setupProperties() {
|
||||
Properties props = super.setupProperties();
|
||||
// use no sig algorithm for expect tests (means no credential is required either)
|
||||
props.put(OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM, OAuthConstants.NO_ALGORITHM);
|
||||
props.put(JWS_ALG, NONE);
|
||||
return props;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user