Skip to content

Commit a91cc85

Browse files
authored
Revert "core/auth: Remove CallCredentials2 (#8464)"
This reverts commit 7cde473.
1 parent 62fafe7 commit a91cc85

4 files changed

Lines changed: 428 additions & 47 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2016 The gRPC Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.grpc;
18+
19+
import java.util.concurrent.Executor;
20+
21+
/**
22+
* The new interface for {@link CallCredentials}.
23+
*
24+
* <p>THIS CLASS NAME IS TEMPORARY and is part of a migration. This class will BE DELETED as it
25+
* replaces {@link CallCredentials} in short-term. THIS CLASS IS ONLY REFERENCED BY IMPLEMENTIONS.
26+
* All consumers should be always referencing {@link CallCredentials}.
27+
*
28+
* @deprecated the new interface has been promoted into {@link CallCredentials}. Implementations
29+
* should switch back to "{@code extends CallCredentials}".
30+
*/
31+
@Deprecated
32+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4901")
33+
public abstract class CallCredentials2 extends CallCredentials {
34+
/**
35+
* Pass the credential data to the given {@link MetadataApplier}, which will propagate it to the
36+
* request metadata.
37+
*
38+
* <p>It is called for each individual RPC, within the {@link Context} of the call, before the
39+
* stream is about to be created on a transport. Implementations should not block in this
40+
* method. If metadata is not immediately available, e.g., needs to be fetched from network, the
41+
* implementation may give the {@code applier} to an asynchronous task which will eventually call
42+
* the {@code applier}. The RPC proceeds only after the {@code applier} is called.
43+
*
44+
* @param requestInfo request-related information
45+
* @param appExecutor The application thread-pool. It is provided to the implementation in case it
46+
* needs to perform blocking operations.
47+
* @param applier The outlet of the produced headers. It can be called either before or after this
48+
* method returns.
49+
*/
50+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1914")
51+
public abstract void applyRequestMetadata(
52+
RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier);
53+
54+
@Override
55+
public final void applyRequestMetadata(
56+
RequestInfo requestInfo, Executor appExecutor,
57+
final CallCredentials.MetadataApplier applier) {
58+
applyRequestMetadata(requestInfo, appExecutor, new MetadataApplier() {
59+
@Override
60+
public void apply(Metadata headers) {
61+
applier.apply(headers);
62+
}
63+
64+
@Override
65+
public void fail(Status status) {
66+
applier.fail(status);
67+
}
68+
});
69+
}
70+
71+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1914")
72+
public abstract static class MetadataApplier extends CallCredentials.MetadataApplier {}
73+
}

auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
import javax.annotation.Nullable;
4343

4444
/**
45-
* Wraps {@link Credentials} as a {@link io.grpc.CallCredentials}.
45+
* Wraps {@link Credentials} as a {@link CallCredentials}.
4646
*/
47-
final class GoogleAuthLibraryCallCredentials extends io.grpc.CallCredentials {
47+
// TODO(zhangkun83): remove the suppression after we change the base class to CallCredential
48+
@SuppressWarnings("deprecation")
49+
final class GoogleAuthLibraryCallCredentials extends io.grpc.CallCredentials2 {
4850
private static final Logger log
4951
= Logger.getLogger(GoogleAuthLibraryCallCredentials.class.getName());
5052
private static final JwtHelper jwtHelper

0 commit comments

Comments
 (0)