Skip to content

Commit

Permalink
s2a: Move s2a implementation to internal package
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta19 authored Oct 1, 2024
1 parent f9ff526 commit 927d215
Show file tree
Hide file tree
Showing 36 changed files with 101 additions and 101 deletions.
28 changes: 14 additions & 14 deletions s2a/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@rules_jvm_external//:defs.bzl", "artifact")
java_library(
name = "s2a_channel_pool",
srcs = glob([
"src/main/java/io/grpc/s2a/channel/*.java",
"src/main/java/io/grpc/s2a/internal/channel/*.java",
]),
deps = [
"//api",
Expand All @@ -23,7 +23,7 @@ java_library(

java_library(
name = "s2a_identity",
srcs = ["src/main/java/io/grpc/s2a/handshaker/S2AIdentity.java"],
srcs = ["src/main/java/io/grpc/s2a/internal/handshaker/S2AIdentity.java"],
deps = [
":common_java_proto",
artifact("com.google.errorprone:error_prone_annotations"),
Expand All @@ -33,7 +33,7 @@ java_library(

java_library(
name = "token_fetcher",
srcs = ["src/main/java/io/grpc/s2a/handshaker/tokenmanager/TokenFetcher.java"],
srcs = ["src/main/java/io/grpc/s2a/internal/handshaker/tokenmanager/TokenFetcher.java"],
deps = [
":s2a_identity",
],
Expand All @@ -42,7 +42,7 @@ java_library(
java_library(
name = "access_token_manager",
srcs = [
"src/main/java/io/grpc/s2a/handshaker/tokenmanager/AccessTokenManager.java",
"src/main/java/io/grpc/s2a/internal/handshaker/tokenmanager/AccessTokenManager.java",
],
deps = [
":s2a_identity",
Expand All @@ -54,7 +54,7 @@ java_library(
java_library(
name = "single_token_fetcher",
srcs = [
"src/main/java/io/grpc/s2a/handshaker/tokenmanager/SingleTokenFetcher.java",
"src/main/java/io/grpc/s2a/internal/handshaker/tokenmanager/SingleTokenFetcher.java",
],
deps = [
":s2a_identity",
Expand All @@ -66,15 +66,15 @@ java_library(
java_library(
name = "s2a_handshaker",
srcs = [
"src/main/java/io/grpc/s2a/handshaker/ConnectionClosedException.java",
"src/main/java/io/grpc/s2a/handshaker/GetAuthenticationMechanisms.java",
"src/main/java/io/grpc/s2a/handshaker/ProtoUtil.java",
"src/main/java/io/grpc/s2a/handshaker/S2AConnectionException.java",
"src/main/java/io/grpc/s2a/handshaker/S2APrivateKeyMethod.java",
"src/main/java/io/grpc/s2a/handshaker/S2AProtocolNegotiatorFactory.java",
"src/main/java/io/grpc/s2a/handshaker/S2AStub.java",
"src/main/java/io/grpc/s2a/handshaker/S2ATrustManager.java",
"src/main/java/io/grpc/s2a/handshaker/SslContextFactory.java",
"src/main/java/io/grpc/s2a/internal/handshaker/ConnectionClosedException.java",
"src/main/java/io/grpc/s2a/internal/handshaker/GetAuthenticationMechanisms.java",
"src/main/java/io/grpc/s2a/internal/handshaker/ProtoUtil.java",
"src/main/java/io/grpc/s2a/internal/handshaker/S2AConnectionException.java",
"src/main/java/io/grpc/s2a/internal/handshaker/S2APrivateKeyMethod.java",
"src/main/java/io/grpc/s2a/internal/handshaker/S2AProtocolNegotiatorFactory.java",
"src/main/java/io/grpc/s2a/internal/handshaker/S2AStub.java",
"src/main/java/io/grpc/s2a/internal/handshaker/S2ATrustManager.java",
"src/main/java/io/grpc/s2a/internal/handshaker/SslContextFactory.java",
],
deps = [
":access_token_manager",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static io.grpc.MethodDescriptor.generateFullMethodName;

Expand All @@ -15,29 +15,29 @@ private S2AServiceGrpc() {}
public static final java.lang.String SERVICE_NAME = "grpc.gcp.s2a.S2AService";

// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<io.grpc.s2a.handshaker.SessionReq,
io.grpc.s2a.handshaker.SessionResp> getSetUpSessionMethod;
private static volatile io.grpc.MethodDescriptor<io.grpc.s2a.internal.handshaker.SessionReq,
io.grpc.s2a.internal.handshaker.SessionResp> getSetUpSessionMethod;

@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "SetUpSession",
requestType = io.grpc.s2a.handshaker.SessionReq.class,
responseType = io.grpc.s2a.handshaker.SessionResp.class,
requestType = io.grpc.s2a.internal.handshaker.SessionReq.class,
responseType = io.grpc.s2a.internal.handshaker.SessionResp.class,
methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
public static io.grpc.MethodDescriptor<io.grpc.s2a.handshaker.SessionReq,
io.grpc.s2a.handshaker.SessionResp> getSetUpSessionMethod() {
io.grpc.MethodDescriptor<io.grpc.s2a.handshaker.SessionReq, io.grpc.s2a.handshaker.SessionResp> getSetUpSessionMethod;
public static io.grpc.MethodDescriptor<io.grpc.s2a.internal.handshaker.SessionReq,
io.grpc.s2a.internal.handshaker.SessionResp> getSetUpSessionMethod() {
io.grpc.MethodDescriptor<io.grpc.s2a.internal.handshaker.SessionReq, io.grpc.s2a.internal.handshaker.SessionResp> getSetUpSessionMethod;
if ((getSetUpSessionMethod = S2AServiceGrpc.getSetUpSessionMethod) == null) {
synchronized (S2AServiceGrpc.class) {
if ((getSetUpSessionMethod = S2AServiceGrpc.getSetUpSessionMethod) == null) {
S2AServiceGrpc.getSetUpSessionMethod = getSetUpSessionMethod =
io.grpc.MethodDescriptor.<io.grpc.s2a.handshaker.SessionReq, io.grpc.s2a.handshaker.SessionResp>newBuilder()
io.grpc.MethodDescriptor.<io.grpc.s2a.internal.handshaker.SessionReq, io.grpc.s2a.internal.handshaker.SessionResp>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "SetUpSession"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
io.grpc.s2a.handshaker.SessionReq.getDefaultInstance()))
io.grpc.s2a.internal.handshaker.SessionReq.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
io.grpc.s2a.handshaker.SessionResp.getDefaultInstance()))
io.grpc.s2a.internal.handshaker.SessionResp.getDefaultInstance()))
.setSchemaDescriptor(new S2AServiceMethodDescriptorSupplier("SetUpSession"))
.build();
}
Expand Down Expand Up @@ -100,8 +100,8 @@ public interface AsyncService {
* operations from the TLS handshake.
* </pre>
*/
default io.grpc.stub.StreamObserver<io.grpc.s2a.handshaker.SessionReq> setUpSession(
io.grpc.stub.StreamObserver<io.grpc.s2a.handshaker.SessionResp> responseObserver) {
default io.grpc.stub.StreamObserver<io.grpc.s2a.internal.handshaker.SessionReq> setUpSession(
io.grpc.stub.StreamObserver<io.grpc.s2a.internal.handshaker.SessionResp> responseObserver) {
return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(getSetUpSessionMethod(), responseObserver);
}
}
Expand Down Expand Up @@ -139,8 +139,8 @@ protected S2AServiceStub build(
* operations from the TLS handshake.
* </pre>
*/
public io.grpc.stub.StreamObserver<io.grpc.s2a.handshaker.SessionReq> setUpSession(
io.grpc.stub.StreamObserver<io.grpc.s2a.handshaker.SessionResp> responseObserver) {
public io.grpc.stub.StreamObserver<io.grpc.s2a.internal.handshaker.SessionReq> setUpSession(
io.grpc.stub.StreamObserver<io.grpc.s2a.internal.handshaker.SessionResp> responseObserver) {
return io.grpc.stub.ClientCalls.asyncBidiStreamingCall(
getChannel().newCall(getSetUpSessionMethod(), getCallOptions()), responseObserver);
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public io.grpc.stub.StreamObserver<Req> invoke(
switch (methodId) {
case METHODID_SET_UP_SESSION:
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.setUpSession(
(io.grpc.stub.StreamObserver<io.grpc.s2a.handshaker.SessionResp>) responseObserver);
(io.grpc.stub.StreamObserver<io.grpc.s2a.internal.handshaker.SessionResp>) responseObserver);
default:
throw new AssertionError();
}
Expand All @@ -224,8 +224,8 @@ public static final io.grpc.ServerServiceDefinition bindService(AsyncService ser
getSetUpSessionMethod(),
io.grpc.stub.ServerCalls.asyncBidiStreamingCall(
new MethodHandlers<
io.grpc.s2a.handshaker.SessionReq,
io.grpc.s2a.handshaker.SessionResp>(
io.grpc.s2a.internal.handshaker.SessionReq,
io.grpc.s2a.internal.handshaker.SessionResp>(
service, METHODID_SET_UP_SESSION)))
.build();
}
Expand All @@ -236,7 +236,7 @@ private static abstract class S2AServiceBaseDescriptorSupplier

@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return io.grpc.s2a.handshaker.S2AProto.getDescriptor();
return io.grpc.s2a.internal.handshaker.S2AProto.getDescriptor();
}

@java.lang.Override
Expand Down
6 changes: 3 additions & 3 deletions s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import io.grpc.internal.SharedResourcePool;
import io.grpc.netty.InternalNettyChannelCredentials;
import io.grpc.netty.InternalProtocolNegotiator;
import io.grpc.s2a.channel.S2AHandshakerServiceChannel;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.handshaker.S2AProtocolNegotiatorFactory;
import io.grpc.s2a.internal.channel.S2AHandshakerServiceChannel;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.S2AProtocolNegotiatorFactory;
import javax.annotation.concurrent.NotThreadSafe;
import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.channel;
package io.grpc.s2a.internal.channel;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.grpc.Channel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.channel;
package io.grpc.s2a.internal.channel;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.channel;
package io.grpc.s2a.internal.channel;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import com.google.errorprone.annotations.Immutable;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.handshaker.tokenmanager.AccessTokenManager;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.tokenmanager.AccessTokenManager;
import java.util.Optional;

/** Retrieves the authentication mechanism for a given local identity. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

/** Exception that denotes a runtime error that was encountered when talking to the S2A server. */
@SuppressWarnings("serial") // This class is never serialized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static com.google.common.base.Preconditions.checkNotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.protobuf.ByteString;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.netty.handler.ssl.OpenSslPrivateKeyMethod;
import java.io.IOException;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand All @@ -37,9 +37,9 @@
import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator;
import io.grpc.netty.InternalProtocolNegotiators;
import io.grpc.netty.InternalProtocolNegotiators.ProtocolNegotiationHandler;
import io.grpc.s2a.channel.S2AChannelPool;
import io.grpc.s2a.channel.S2AGrpcChannelPool;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.internal.channel.S2AChannelPool;
import io.grpc.s2a.internal.channel.S2AGrpcChannelPool;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.collect.ImmutableList;
import com.google.protobuf.ByteString;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.handshaker.ValidatePeerCertificateChainReq.VerificationMode;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.ValidatePeerCertificateChainReq.VerificationMode;
import java.io.IOException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker;
package io.grpc.s2a.internal.handshaker;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.collect.ImmutableSet;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import io.netty.handler.ssl.OpenSslContextOption;
import io.netty.handler.ssl.OpenSslSessionContext;
import io.netty.handler.ssl.OpenSslX509KeyManagerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker.tokenmanager;
package io.grpc.s2a.internal.handshaker.tokenmanager;

import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import java.lang.reflect.Method;
import java.util.Optional;
import javax.annotation.concurrent.ThreadSafe;
Expand All @@ -31,7 +31,7 @@ public static Optional<AccessTokenManager> create() {
Optional<?> tokenFetcher;
try {
Class<?> singleTokenFetcherClass =
Class.forName("io.grpc.s2a.handshaker.tokenmanager.SingleTokenFetcher");
Class.forName("io.grpc.s2a.internal.handshaker.tokenmanager.SingleTokenFetcher");
Method createTokenFetcher = singleTokenFetcherClass.getMethod("create");
tokenFetcher = (Optional) createTokenFetcher.invoke(null);
} catch (ClassNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker.tokenmanager;
package io.grpc.s2a.internal.handshaker.tokenmanager;

import com.google.common.annotations.VisibleForTesting;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.S2AIdentity;
import java.util.Optional;

/** Fetches a single access token via an environment variable. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

package io.grpc.s2a.handshaker.tokenmanager;
package io.grpc.s2a.internal.handshaker.tokenmanager;

import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.internal.handshaker.S2AIdentity;

/** Fetches tokens used to authenticate to S2A. */
interface TokenFetcher {
Expand Down
2 changes: 1 addition & 1 deletion s2a/src/main/proto/grpc/gcp/s2a/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package grpc.gcp.s2a;

option java_multiple_files = true;
option java_outer_classname = "CommonProto";
option java_package = "io.grpc.s2a.handshaker";
option java_package = "io.grpc.s2a.internal.handshaker";

// The TLS 1.0-1.2 ciphersuites that the application can negotiate when using
// S2A.
Expand Down
Loading

0 comments on commit 927d215

Please sign in to comment.