Skip to content

Commit 9d6b8a2

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 3675 b: refs/heads/pubsub-alpha c: c486452 h: refs/heads/master i: 3673: 340cfff 3671: 1243911
1 parent 506f586 commit 9d6b8a2

5 files changed

Lines changed: 49 additions & 7 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: 7eb957d29adba95dc310d5854899baef4f7d0583
5+
refs/heads/pubsub-alpha: c486452b4c81da7f077e2573b1f29dee3994bd86
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,33 @@ public RestorableState<AuthCredentials> capture() {
243243
}
244244
}
245245

246+
public static class NoAuthCredentials extends AuthCredentials {
247+
248+
private static final AuthCredentials INSTANCE = new NoAuthCredentials();
249+
private static final NoAuthCredentialsState STATE = new NoAuthCredentialsState();
250+
251+
private static class NoAuthCredentialsState
252+
implements RestorableState<AuthCredentials>, Serializable {
253+
254+
private static final long serialVersionUID = -4022100563954640465L;
255+
256+
@Override
257+
public AuthCredentials restore() {
258+
return INSTANCE;
259+
}
260+
}
261+
262+
@Override
263+
public GoogleCredentials credentials() {
264+
return null;
265+
}
266+
267+
@Override
268+
public RestorableState<AuthCredentials> capture() {
269+
return STATE;
270+
}
271+
}
272+
246273
public abstract GoogleCredentials credentials();
247274

248275
public static AuthCredentials createForAppEngine() {
@@ -281,6 +308,13 @@ public static ServiceAccountAuthCredentials createFor(String account, PrivateKey
281308
return new ServiceAccountAuthCredentials(account, privateKey);
282309
}
283310

311+
/**
312+
* Creates a placeholder denoting that no credentials should be used.
313+
*/
314+
public static AuthCredentials noAuth() {
315+
return NoAuthCredentials.INSTANCE;
316+
}
317+
284318
/**
285319
* Creates Service Account Credentials given a stream for credentials in JSON format.
286320
*

branches/pubsub-alpha/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ public RetryParams retryParams() {
523523
* options.
524524
*/
525525
public HttpRequestInitializer httpRequestInitializer() {
526-
final HttpRequestInitializer delegate = authCredentials() != null
527-
? new HttpCredentialsAdapter(authCredentials().credentials().createScoped(scopes()))
528-
: null;
526+
final HttpRequestInitializer delegate =
527+
authCredentials() != null && authCredentials.credentials() != null
528+
? new HttpCredentialsAdapter(authCredentials().credentials().createScoped(scopes()))
529+
: null;
529530
return new HttpRequestInitializer() {
530531
@Override
531532
public void initialize(HttpRequest httpRequest) throws IOException {

branches/pubsub-alpha/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.api.services.datastore.DatastoreV1.RunQueryResponse;
3333
import com.google.common.collect.Iterators;
3434
import com.google.common.collect.Lists;
35+
import com.google.gcloud.AuthCredentials;
3536
import com.google.gcloud.RetryParams;
3637
import com.google.gcloud.datastore.Query.ResultType;
3738
import com.google.gcloud.datastore.StructuredQuery.OrderBy;
@@ -128,6 +129,7 @@ public void setUp() {
128129
options = DatastoreOptions.builder()
129130
.projectId(PROJECT_ID)
130131
.host("http://localhost:" + PORT)
132+
.authCredentials(AuthCredentials.noAuth())
131133
.retryParams(RetryParams.noRetries())
132134
.build();
133135
datastore = options.service();

branches/pubsub-alpha/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.google.common.collect.ImmutableMap;
1313
import com.google.common.collect.ImmutableSet;
1414
import com.google.common.io.ByteStreams;
15+
import com.google.gcloud.AuthCredentials;
1516
import com.google.gcloud.resourcemanager.ResourceManagerOptions;
1617

1718
import com.sun.net.httpserver.Headers;
@@ -550,17 +551,21 @@ private LocalResourceManagerHelper() {
550551
}
551552

552553
/**
553-
* Creates a LocalResourceManagerHelper object that listens to requests on the local machine.
554+
* Creates a {@code LocalResourceManagerHelper} object that listens to requests on the local
555+
* machine.
554556
*/
555557
public static LocalResourceManagerHelper create() {
556558
return new LocalResourceManagerHelper();
557559
}
558560

559561
/**
560-
* Returns a ResourceManagerOptions instance that sets the host to use the mock server.
562+
* Returns a {@link ResourceManagerOptions} instance that sets the host to use the mock server.
561563
*/
562564
public ResourceManagerOptions options() {
563-
return ResourceManagerOptions.builder().host("http://localhost:" + port).build();
565+
return ResourceManagerOptions.builder()
566+
.host("http://localhost:" + port)
567+
.authCredentials(AuthCredentials.noAuth())
568+
.build();
564569
}
565570

566571
/**

0 commit comments

Comments
 (0)