diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 00000000000..53485cb9743 --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 diff --git a/.gemini/config.yaml b/.gemini/config.yaml new file mode 100644 index 00000000000..71adf793964 --- /dev/null +++ b/.gemini/config.yaml @@ -0,0 +1,13 @@ +have_fun: false +memory_config: + disabled: false +code_review: + disable: false + comment_severity_threshold: MEDIUM + max_review_comments: -1 + pull_request_opened: + help: false + summary: false + code_review: false + include_drafts: false +ignore_patterns: [] diff --git a/.gitattributes b/.gitattributes index d7df7b3f22b..4343b9bd8ec 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,4 @@ -TestService.java.txt binary -TestServiceLite.java.txt binary -TestServiceNano.java.txt binary -TestDeprecatedService.java.txt binary -TestDeprecatedServiceLite.java.txt binary -TestDeprecatedServiceNano.java.txt binary +TestService.java.txt -text +TestServiceLite.java.txt -text +TestDeprecatedService.java.txt -text +TestDeprecatedServiceLite.java.txt -text diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE deleted file mode 100644 index 431fcb1f09c..00000000000 --- a/.github/ISSUE_TEMPLATE +++ /dev/null @@ -1,8 +0,0 @@ -Please answer these questions before submitting your issue. - -### What version of gRPC are you using? - - -### What did you expect to see? - - diff --git a/.github/ISSUE_TEMPLATE/ask_question.md b/.github/ISSUE_TEMPLATE/ask_question.md new file mode 100644 index 00000000000..c384031e347 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ask_question.md @@ -0,0 +1,12 @@ +--- +name: Ask a question +about: Asking a question related gRPC-Java +labels: question +--- + + + + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..b6998dde7c2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,19 @@ +--- +name: Report a bug +about: Create a bug report to help us improve +--- + + + +### What version of gRPC-Java are you using? + +### What is your environment? + + +### What did you expect to see? + +### What did you see instead? + +### Steps to reproduce the bug + + diff --git a/.github/ISSUE_TEMPLATE/feature_report.md b/.github/ISSUE_TEMPLATE/feature_report.md new file mode 100644 index 00000000000..ddc60838148 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_report.md @@ -0,0 +1,19 @@ +--- +name: Request a feature +about: Suggest an enhancement for gRPC +labels: enhancement +--- + + + +### Is your feature request related to a problem? + + +### Describe the solution you'd like + + +### Describe alternatives you've considered + + +### Additional context + diff --git a/.github/lock.yml b/.github/lock.yml deleted file mode 100644 index 119e4840bee..00000000000 --- a/.github/lock.yml +++ /dev/null @@ -1,2 +0,0 @@ -daysUntilLock: 90 -lockComment: false diff --git a/.github/workflows/branch-testing.yml b/.github/workflows/branch-testing.yml new file mode 100644 index 00000000000..ece8ec4cd58 --- /dev/null +++ b/.github/workflows/branch-testing.yml @@ -0,0 +1,41 @@ +name: GitHub Actions Branch Testing + +on: + push: + branches: + - master + - 'v1.*' + schedule: + - cron: '54 19 * * SUN' # weekly at a "random" time + +permissions: + contents: read + +jobs: + arm64: + runs-on: ubuntu-24.04-arm + strategy: + matrix: + jre: [17] + fail-fast: false # Should swap to true if we grow a large matrix + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jre }} + distribution: 'temurin' + + - name: Gradle cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build + run: ./gradlew -Dorg.gradle.parallel=true -Dorg.gradle.jvmargs='-Xmx1g' -PskipAndroid=true -PskipCodegen=true -PerrorProne=false test + diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 00000000000..da1e2fed114 --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,13 @@ +name: "Validate Gradle Wrapper" +on: [push, pull_request] + +permissions: + contents: read + +jobs: + validation: + name: "Gradle wrapper validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v4 diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 00000000000..3070a1a2f7c --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,20 @@ +name: 'Lock Threads' + +on: + workflow_dispatch: + schedule: + - cron: '37 3 * * *' + +permissions: + issues: write + pull-requests: write + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v5 + with: + github-token: ${{ github.token }} + issue-inactive-days: 90 + pr-inactive-days: 90 diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000000..953edd12e04 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,114 @@ +name: GitHub Actions Linux Testing + +on: + push: + branches: + - master + - 'v1.*' + pull_request: + schedule: + - cron: '54 19 * * SUN' # weekly at a "random" time + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + jre: [8, 11, 17, 21] + fail-fast: false # Should swap to true if we grow a large matrix + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jre }} + distribution: 'temurin' + + - name: Gradle cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Maven cache + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository + !~/.m2/repository/io/grpc + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'build.gradle') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Protobuf cache + uses: actions/cache@v4 + with: + path: /tmp/protobuf-cache + key: ${{ runner.os }}-maven-${{ hashFiles('buildscripts/make_dependencies.sh') }} + + - name: Build + run: buildscripts/kokoro/unix.sh + - name: Post Failure Upload Test Reports to Artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: Test Reports (JRE ${{ matrix.jre }}) + path: | + ./*/build/reports/tests/** + ./*/*/build/reports/tests/** + retention-days: 14 + - name: Check for modified codegen + run: test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false) + + - name: Coveralls + if: matrix.jre == 8 # Upload once, instead of for each job in the matrix + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + run: ./gradlew :grpc-all:coveralls -PskipAndroid=true -x compileJava + - name: Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + bazel: + runs-on: ubuntu-latest + strategy: + matrix: + bzlmod: [true, false] + bazel_version: [8.7.0, 9.1.0] + exclude: + - bazel_version: 9.1.0 + bzlmod: false + env: + USE_BAZEL_VERSION: ${{ matrix.bazel_version }} + + steps: + - uses: actions/checkout@v4 + + - name: Check versions match in MODULE.bazel and repositories.bzl + run: | + diff -u <(sed -n '/GRPC_DEPS_START/,/GRPC_DEPS_END/ {/GRPC_DEPS_/! p}' MODULE.bazel) \ + <(sed -n '/GRPC_DEPS_START/,/GRPC_DEPS_END/ {/GRPC_DEPS_/! p}' repositories.bzl) + + - name: Bazel cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/bazel/*/cache + ~/.cache/bazelisk/downloads + key: ${{ runner.os }}-bazel-${{ env.USE_BAZEL_VERSION }}-${{ hashFiles('WORKSPACE', 'repositories.bzl') }} + + - name: Run bazel build + run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} + + - name: Run bazel test + run: bazelisk test //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} + + - name: Run example bazel build + run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} + working-directory: ./examples diff --git a/.gitignore b/.gitignore index e82cb67ccfc..b078d891adf 100644 --- a/.gitignore +++ b/.gitignore @@ -15,10 +15,14 @@ bazel-genfiles bazel-grpc-java bazel-out bazel-testlogs +MODULE.bazel.lock # IntelliJ IDEA .idea *.iml +*.ipr +*.iws +.ijwb # Eclipse .classpath @@ -27,9 +31,18 @@ bazel-testlogs .gitignore bin +# VsCode +.vscode + # OS X .DS_Store # Emacs *~ \#*\# + +# ARM tests +qemu-arm-static + +# Temporary output dir for artifacts +mvn-artifacts diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f494148c455..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -language: java - -env: - global: - - GRADLE_OPTS=-Xmx512m - - LDFLAGS=-L/tmp/protobuf/lib - - CXXFLAGS=-I/tmp/protobuf/include - - LD_LIBRARY_PATH=/tmp/protobuf/lib - -before_install: - - rm ~/.m2/settings.xml || true # Avoid repository.apache.org, which has QPS limits and is useless - - mkdir -p $HOME/.gradle/caches && - ln -s /tmp/gradle-caches-modules-2 $HOME/.gradle/caches/modules-2 - - mkdir -p $HOME/.gradle && - ln -s /tmp/gradle-wrapper $HOME/.gradle/wrapper - - buildscripts/make_dependencies.sh # build protoc into /tmp/protobuf - - mkdir -p $HOME/.gradle - - echo "checkstyle.ignoreFailures=false" >> $HOME/.gradle/gradle.properties - - echo "failOnWarnings=true" >> $HOME/.gradle/gradle.properties - - echo "errorProne=true" >> $HOME/.gradle/gradle.properties - -install: - - ./gradlew assemble generateTestProto install - - pushd examples && ./gradlew build && popd - - pushd examples && mvn verify && popd - - pushd examples/example-alts && ../gradlew build && popd - - pushd examples/example-tls && ../gradlew clean build && popd - - pushd examples/example-kotlin && ../gradlew build && popd - -before_script: - - test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false) - -script: - - ./gradlew check :grpc-all:jacocoTestReport - -after_success: - # Upload to coveralls once, instead of for each job in the matrix - - if [[ "$TRAVIS_JOB_NUMBER" == *.1 ]]; then ./gradlew :grpc-all:coveralls; fi - - bash <(curl -s https://codecov.io/bash) - -os: - - linux - -jdk: - - oraclejdk8 - - oraclejdk9 - - openjdk11 - -notifications: - email: false - -cache: - directories: - - /tmp/protobuf-cache - - /tmp/gradle-caches-modules-2 - - /tmp/gradle-wrapper - -before_cache: - # The lock changes based on folder name; normally $HOME/.gradle/caches/modules-2/modules-2.lock - - rm /tmp/gradle-caches-modules-2/gradle-caches-modules-2.lock - - find $HOME/.gradle/wrapper -not -name "*-all.zip" -and -not -name "*-bin.zip" -delete diff --git a/BUILD.bazel b/BUILD.bazel index e4175b0ecee..27a99fb62eb 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") +load("@rules_java//java:defs.bzl", "java_library", "java_plugin") +load("@rules_jvm_external//:defs.bzl", "artifact") load(":java_grpc_library.bzl", "java_grpc_library") java_proto_library( @@ -24,3 +27,45 @@ java_grpc_library( srcs = ["@com_google_protobuf//:api_proto"], deps = [":api_proto_java"], ) + +java_library( + name = "java_grpc_library_deps__do_not_reference", + visibility = ["//visibility:public"], + exports = [ + "//api", + "//protobuf", + "//stub", + "@com_google_protobuf//:protobuf_java", + artifact("com.google.code.findbugs:jsr305"), + artifact("com.google.guava:guava"), + ], +) + +java_library( + name = "java_lite_grpc_library_deps__do_not_reference", + visibility = ["//visibility:public"], + exports = [ + "//api", + "//protobuf-lite", + "//stub", + artifact("com.google.code.findbugs:jsr305"), + artifact("com.google.guava:guava"), + ], +) + +java_plugin( + name = "auto_value", + generates_api = 1, + processor_class = "com.google.auto.value.processor.AutoValueProcessor", + deps = [artifact("com.google.auto.value:auto-value")], +) + +java_library( + name = "auto_value_annotations", + exported_plugins = [":auto_value"], + neverlink = 1, + visibility = ["//:__subpackages__"], + exports = [ + artifact("com.google.auto.value:auto-value-annotations"), + ], +) diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md new file mode 100644 index 00000000000..9d4213ebca7 --- /dev/null +++ b/CODE-OF-CONDUCT.md @@ -0,0 +1,3 @@ +## Community Code of Conduct + +gRPC follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). diff --git a/COMPILING.md b/COMPILING.md index e23a2f425e9..b7df1319beb 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -11,6 +11,12 @@ developers don't have C compilers installed and don't need to run or modify the codegen, the build can skip it. To skip, create the file `/gradle.properties` and add `skipCodegen=true`. +Some parts of grpc-java depend on Android. Since many Java developers don't have +the Android SDK installed and don't need to run or modify the Android +components, the build can skip it. To skip, create the file +`/gradle.properties` and add `skipAndroid=true`. +Otherwise, create the file `/gradle.properties` and add `android.useAndroidX=true`. + Then, to build, run: ``` $ ./gradlew build @@ -19,11 +25,11 @@ $ ./gradlew build To install the artifacts to your Maven local repository for use in your own project, run: ``` -$ ./gradlew install +$ ./gradlew publishToMavenLocal ``` ### Notes for IntelliJ -Building in IntelliJ works best when you import the project as a Gradle project and delegate IDE +Building in IntelliJ works best when you import the project as a Gradle project and delegate IDE build/run actions to Gradle. You can find this setting at: @@ -38,23 +44,22 @@ This section is only necessary if you are making changes to the code generation. Most users only need to use `skipCodegen=true` as discussed above. ### Build Protobuf -The codegen plugin is C++ code and requires protobuf 3.0.0 or later. +The codegen plugin is C++ code and requires protobuf 22.5 or later. For Linux, Mac and MinGW: ``` -$ git clone https://github.com/google/protobuf.git -$ cd protobuf -$ git checkout v3.5.1 -$ ./autogen.sh -$ ./configure -$ make -$ make check +$ PROTOBUF_VERSION=22.5 +$ curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-all-$PROTOBUF_VERSION.tar.gz +$ tar xzf protobuf-all-$PROTOBUF_VERSION.tar.gz +$ cd protobuf-$PROTOBUF_VERSION +$ ./configure --disable-shared +$ make # You may want to pass -j to make this run faster; see make --help $ sudo make install ``` If you are comfortable with C++ compilation and autotools, you can specify a ``--prefix`` for Protobuf and use ``-I`` in ``CXXFLAGS``, ``-L`` in -``LDFLAGS``, ``LD_LIBRARY_PATH``, and ``PATH`` to reference it. The +``LDFLAGS`` to reference it. The environment variables will be used when building grpc-java. Protobuf installs to ``/usr/local`` by default. @@ -62,15 +67,8 @@ Protobuf installs to ``/usr/local`` by default. For Visual C++, please refer to the [Protobuf README](https://github.com/google/protobuf/blob/master/cmake/README.md) for how to compile Protobuf. gRPC-java assumes a Release build. -#### Linux and MinGW -If ``/usr/local/lib`` is not in your library search path, you can add it by running: -``` -$ sudo sh -c 'echo /usr/local/lib >> /etc/ld.so.conf' -$ sudo ldconfig -``` - #### Mac -Some versions of Mac OS X (e.g., 10.10) doesn't have ``/usr/local`` in the +Some versions of Mac OS X (e.g., 10.10) don't have ``/usr/local`` in the default search paths for header files and libraries. It will fail the build of the codegen. To work around this, you will need to set environment variables: ``` @@ -82,17 +80,17 @@ $ export CXXFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" When building on Windows and VC++, you need to specify project properties for Gradle to find protobuf: ``` -.\gradlew install ^ - -PvcProtobufInclude=C:\path\to\protobuf-3.5.1\src ^ - -PvcProtobufLibs=C:\path\to\protobuf-3.5.1\vsprojects\Release ^ +.\gradlew publishToMavenLocal ^ + -PvcProtobufInclude=C:\path\to\protobuf\src ^ + -PvcProtobufLibs=C:\path\to\protobuf\vsprojects\Release ^ -PtargetArch=x86_32 ``` Since specifying those properties every build is bothersome, you can instead create ``\gradle.properties`` with contents like: ``` -vcProtobufInclude=C:\\path\\to\\protobuf-3.5.1\\src -vcProtobufLibs=C:\\path\\to\\protobuf-3.5.1\\vsprojects\\Release +vcProtobufInclude=C:\\path\\to\\protobuf\\src +vcProtobufLibs=C:\\path\\to\\protobuf\\vsprojects\\Release targetArch=x86_32 ``` @@ -116,3 +114,39 @@ use the one that has been built by your own, by adding this property to ``` protoc=/path/to/protoc ``` + +How to install Android SDK +--------------------------- +This section is only necessary if you are building modules depending on Android +(e.g., `cronet`). Non-Android users only need to use `skipAndroid=true` as +discussed above. + +### Install via Android Studio (GUI) +Download and install Android Studio from [Android Developer site](https://developer.android.com/studio). +You can find the configuration for Android SDK at: +``` +Preferences -> System Settings -> Android SDK +``` +Select the version of Android SDK to be installed and click `apply`. The location +of Android SDK being installed is shown at `Android SDK Location` at the same panel. +The default is `$HOME/Library/Android/sdk` for Mac OS and `$HOME/Android/Sdk` for Linux. +You can change this to a custom location. + +### Install via Command line tools only +Go to [Android SDK](https://developer.android.com/studio#command-tools) and +download the commandlinetools package for your build machine OS. Decide where +you want the Android SDK to be stored. `$HOME/Library/Android/sdk` is typical on +Mac OS and `$HOME/Android/Sdk` for Linux. + +```sh +export ANDROID_HOME=$HOME/Android/Sdk # Adjust to your liking +mkdir $HOME/Android +mkdir $ANDROID_HOME +mkdir $ANDROID_HOME/cmdline-tools +unzip -d $ANDROID_HOME/cmdline-tools DOWNLOADS/commandlinetools-*.zip +mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest +# Android SDK is now ready. Now accept licenses so the build can auto-download packages +$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses + +# Add 'export ANDROID_HOME=$HOME/Android/Sdk' to your .bashrc or equivalent +``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9027b8f2c6f..646a7d986fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,17 @@ # How to contribute -We definitely welcome your patches and contributions to gRPC! +We definitely welcome your patches and contributions to gRPC! Please read the gRPC +organization's [governance rules](https://github.com/grpc/grpc-community/blob/master/governance.md) +and [contribution guidelines](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md) before proceeding. + If you are new to github, please start by reading [Pull Request howto](https://help.github.com/articles/about-pull-requests/) ## Legal requirements In order to protect both you and ourselves, you will need to sign the -[Contributor License Agreement](https://identity.linuxfoundation.org/projects/cncf). +[Contributor License Agreement](https://easycla.lfx.linuxfoundation.org/). When +you make a PR, a CLA bot will provide a link for the process. ## Compiling @@ -17,7 +21,7 @@ See [COMPILING.md](COMPILING.md). Specifically, you'll generally want to set ## Code style We follow the [Google Java Style -Guide](https://google-styleguide.googlecode.com/svn/trunk/javaguide.html). Our +Guide](https://google.github.io/styleguide/javaguide.html). Our build automatically will provide warnings for style issues. [Eclipse](https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml) and @@ -26,56 +30,36 @@ style configurations are commonly useful. For IntelliJ 14, copy the style to `~/.IdeaIC14/config/codestyles/`, start IntelliJ, go to File > Settings > Code Style, and set the Scheme to `GoogleStyle`. -## Maintaining clean commit history - -We have few conventions for keeping history clean and making code reviews easier -for reviewers: - -* First line of commit messages should be in format of - - `package-name: summary of change` - - where the summary finishes the sentence: `This commit improves gRPC to ____________.` - - for example: - - `core,netty,interop-testing: add capacitive duractance to turbo encabulators` - -* Every time you receive a feedback on your pull request, push changes that - address it as a separate one or multiple commits with a descriptive commit - message (try avoid using vauge `addressed pr feedback` type of messages). - - Project maintainers are obligated to squash those commits into one when - merging. - -## Running tests - -### Jetty ALPN setup for IntelliJ - -The tests in interop-testing project require jetty-alpn agent running in the background -otherwise they'll fail. Here are instructions on how to setup IntellJ IDEA to enable running -those tests in IDE: - -* Settings -> Build Tools -> Gradle -> Runner -> select Gradle Test Runner -* View -> Tool Windows -> Gradle -> Edit Run Configuration -> Defaults -> JUnit -> Before lauch -> + -> Run Gradle task, enter the task in the build.gradle that sets the javaagent. - -Step 1 must be taken, otherwise by the default JUnit Test Runner running a single test in IDE will trigger all the tests. - ## Guidelines for Pull Requests How to get your contributions merged smoothly and quickly. - Create **small PRs** that are narrowly focused on **addressing a single concern**. We often times receive PRs that are trying to fix several things at a time, but only one fix is considered acceptable, nothing gets merged and both author's & review's time is wasted. Create more PRs to address different concerns and everyone will be happy. -- For speculative changes, consider opening an issue and discussing it first. If you are suggesting a behavioral or API change, consider starting with a [gRFC proposal](https://github.com/grpc/proposal). - -- Provide a good **PR description** as a record of **what** change is being made and **why** it was made. Link to a github issue if it exists. - -- Don't fix code style and formatting unless you are already changing that line to address an issue. PRs with irrelevant changes won't be merged. If you do want to fix formatting or style, do that in a separate PR. - -- Unless your PR is trivial, you should expect there will be reviewer comments that you'll need to address before merging. We expect you to be reasonably responsive to those comments, otherwise the PR will be closed after 2-3 weeks of inactivity. - -- Maintain **clean commit history** and use **meaningful commit messages**. See [maintaining clean commit history](#maintaining-clean-commit-history) for details. - +- For speculative changes, consider opening an issue and discussing it to avoid + wasting time on an inappropriate approach. If you are suggesting a behavioral + or API change, consider starting with a [gRFC + proposal](https://github.com/grpc/proposal). + +- Follow [typical Git commit message](https://cbea.ms/git-commit/#seven-rules) + structure. Have a good **commit description** as a record of **what** and + **why** the change is being made. Link to a GitHub issue if it exists. The + commit description makes a good PR description and is auto-copied by GitHub if + you have a single commit when creating the PR. + + If your change is mostly for a single module (e.g., other module changes are + trivial), prefix your commit summary with the module name changed. Instead of + "Add HTTP/2 faster-than-light support to gRPC Netty" it is more terse as + "netty: Add faster-than-light support". + +- Don't fix code style and formatting unless you are already changing that line + to address an issue. If you do want to fix formatting or style, do that in a + separate PR. + +- Unless your PR is trivial, you should expect there will be reviewer comments + that you'll need to address before merging. Address comments with additional + commits so the reviewer can review just the changes; do not squash reviewed + commits unless the reviewer agrees. PRs are squashed when merging. + - Keep your PR up to date with upstream/master (if there are merge conflicts, we can't really merge your change). - **All tests need to be passing** before your change can be merged. We recommend you **run tests locally** before creating your PR to catch breakages early on. Also, `./gradlew build` (`gradlew build` on Windows) **must not introduce any new warnings**. diff --git a/GOVERNANCE.md b/GOVERNANCE.md new file mode 100644 index 00000000000..d6ff2674710 --- /dev/null +++ b/GOVERNANCE.md @@ -0,0 +1 @@ +This repository is governed by the gRPC organization's [governance rules](https://github.com/grpc/grpc-community/blob/master/governance.md). diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 00000000000..5048c7c5aca --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,35 @@ +This page lists all active maintainers of this repository. If you were a +maintainer and would like to add your name to the Emeritus list, please send us a +PR. + +See [GOVERNANCE.md](https://github.com/grpc/grpc-community/blob/master/governance.md) +for governance guidelines and how to become a maintainer. +See [CONTRIBUTING.md](https://github.com/grpc/grpc-community/blob/master/CONTRIBUTING.md) +for general contribution guidelines. + +## Maintainers (in alphabetical order) +- [ejona86](https://github.com/ejona86), Google LLC +- [jdcormie](https://github.com/jdcormie), Google LLC +- [kannanjgithub](https://github.com/kannanjgithub), Google LLC +- [ran-su](https://github.com/ran-su), Google LLC +- [sergiitk](https://github.com/sergiitk), Google LLC +- [temawi](https://github.com/temawi), Google LLC +- [YifeiZhuang](https://github.com/YifeiZhuang), Google LLC +- [zhangkun83](https://github.com/zhangkun83), Google LLC + +## Emeritus Maintainers (in alphabetical order) +- [carl-mastrangelo](https://github.com/carl-mastrangelo) +- [creamsoup](https://github.com/creamsoup) +- [dapengzhang0](https://github.com/dapengzhang0) +- [ericgribkoff](https://github.com/ericgribkoff) +- [jiangtaoli2016](https://github.com/jiangtaoli2016) +- [jtattermusch](https://github.com/jtattermusch) +- [larry-safran](https://github.com/larry-safran) +- [louiscryan](https://github.com/louiscryan) +- [markb74](https://github.com/markb74) +- [nicolasnoble](https://github.com/nicolasnoble) +- [nmittler](https://github.com/nmittler) +- [sanjaypujare](https://github.com/sanjaypujare) +- [srini100](https://github.com/srini100) +- [voidzcy](https://github.com/voidzcy) +- [zpencer](https://github.com/zpencer) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000000..e563857d8fe --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,163 @@ +module( + name = "grpc-java", + version = "1.82.0-SNAPSHOT", # CURRENT_GRPC_VERSION + repo_name = "io_grpc_grpc_java", +) + +# GRPC_DEPS_START +IO_GRPC_GRPC_JAVA_ARTIFACTS = [ + "com.google.android:annotations:4.1.1.4", + "com.google.api.grpc:proto-google-common-protos:2.64.1", + "com.google.auth:google-auth-library-credentials:1.42.1", + "com.google.auth:google-auth-library-oauth2-http:1.42.1", + "com.google.auto.value:auto-value-annotations:1.11.0", + "com.google.auto.value:auto-value:1.11.0", + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.code.gson:gson:2.13.2", + "com.google.errorprone:error_prone_annotations:2.48.0", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:guava:33.5.0-android", + "com.google.re2j:re2j:1.8", + "com.google.s2a.proto.v2:s2a-proto:0.1.3", + "com.google.truth:truth:1.4.5", + "dev.cel:runtime:0.12.0", + "dev.cel:protobuf:0.12.0", + "dev.cel:common:0.12.0", + "com.squareup.okhttp:okhttp:2.7.5", + "com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day + "io.netty:netty-buffer:4.1.133.Final", + "io.netty:netty-codec-http2:4.1.133.Final", + "io.netty:netty-codec-http:4.1.133.Final", + "io.netty:netty-codec-socks:4.1.133.Final", + "io.netty:netty-codec:4.1.133.Final", + "io.netty:netty-common:4.1.133.Final", + "io.netty:netty-handler-proxy:4.1.133.Final", + "io.netty:netty-handler:4.1.133.Final", + "io.netty:netty-resolver:4.1.133.Final", + "io.netty:netty-tcnative-boringssl-static:2.0.75.Final", + "io.netty:netty-tcnative-classes:2.0.75.Final", + "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.133.Final", + "io.netty:netty-transport-native-unix-common:4.1.133.Final", + "io.netty:netty-transport:4.1.133.Final", + "io.opencensus:opencensus-api:0.31.0", + "io.opencensus:opencensus-contrib-grpc-metrics:0.31.0", + "io.perfmark:perfmark-api:0.27.0", + "junit:junit:4.13.2", + "org.mockito:mockito-core:4.4.0", + "org.checkerframework:checker-qual:3.49.5", + "org.codehaus.mojo:animal-sniffer-annotations:1.27", +] +# GRPC_DEPS_END + +bazel_dep(name = "abseil-cpp", version = "20250512.1") +bazel_dep(name = "bazel_jar_jar", version = "0.1.11.bcr.1") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "googleapis", version = "0.0.0-20260514-1dbb1a14", repo_name = "com_google_googleapis") +bazel_dep(name = "grpc-proto", version = "0.0.0-20240627-ec30f58.bcr.1", repo_name = "io_grpc_grpc_proto") +bazel_dep(name = "protobuf", version = "33.4", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_java", version = "9.1.0") +bazel_dep(name = "rules_jvm_external", version = "6.0") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS, + repositories = [ + "https://repo.maven.apache.org/maven2/", + ], + strict_visibility = True, +) +use_repo(maven, "maven") + +maven.override( + coordinates = "com.google.protobuf:protobuf-java", + target = "@com_google_protobuf//:protobuf_java", +) +maven.override( + coordinates = "com.google.protobuf:protobuf-java-util", + target = "@com_google_protobuf//:protobuf_java_util", +) +maven.override( + coordinates = "com.google.protobuf:protobuf-javalite", + target = "@com_google_protobuf//:protobuf_javalite", +) +maven.override( + coordinates = "io.grpc:grpc-alts", + target = "@io_grpc_grpc_java//alts", +) +maven.override( + coordinates = "io.grpc:grpc-api", + target = "@io_grpc_grpc_java//api", +) +maven.override( + coordinates = "io.grpc:grpc-auth", + target = "@io_grpc_grpc_java//auth", +) +maven.override( + coordinates = "io.grpc:grpc-census", + target = "@io_grpc_grpc_java//census", +) +maven.override( + coordinates = "io.grpc:grpc-context", + target = "@io_grpc_grpc_java//context", +) +maven.override( + coordinates = "io.grpc:grpc-core", + target = "@io_grpc_grpc_java//core:core_maven", +) +maven.override( + coordinates = "io.grpc:grpc-googleapis", + target = "@io_grpc_grpc_java//googleapis", +) +maven.override( + coordinates = "io.grpc:grpc-grpclb", + target = "@io_grpc_grpc_java//grpclb", +) +maven.override( + coordinates = "io.grpc:grpc-inprocess", + target = "@io_grpc_grpc_java//inprocess", +) +maven.override( + coordinates = "io.grpc:grpc-netty", + target = "@io_grpc_grpc_java//netty", +) +maven.override( + coordinates = "io.grpc:grpc-netty-shaded", + target = "@io_grpc_grpc_java//netty:shaded_maven", +) +maven.override( + coordinates = "io.grpc:grpc-okhttp", + target = "@io_grpc_grpc_java//okhttp", +) +maven.override( + coordinates = "io.grpc:grpc-protobuf", + target = "@io_grpc_grpc_java//protobuf", +) +maven.override( + coordinates = "io.grpc:grpc-protobuf-lite", + target = "@io_grpc_grpc_java//protobuf-lite", +) +maven.override( + coordinates = "io.grpc:grpc-rls", + target = "@io_grpc_grpc_java//rls", +) +maven.override( + coordinates = "io.grpc:grpc-services", + target = "@io_grpc_grpc_java//services:services_maven", +) +maven.override( + coordinates = "io.grpc:grpc-stub", + target = "@io_grpc_grpc_java//stub", +) +maven.override( + coordinates = "io.grpc:grpc-testing", + target = "@io_grpc_grpc_java//testing", +) +maven.override( + coordinates = "io.grpc:grpc-xds", + target = "@io_grpc_grpc_java//xds:xds_maven", +) +maven.override( + coordinates = "io.grpc:grpc-util", + target = "@io_grpc_grpc_java//util", +) diff --git a/NOTICE.txt b/NOTICE.txt index 79a48ce2d71..f70c5620cf7 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -25,12 +25,38 @@ at: * LOCATION_IN_GRPC: * okhttp/third_party/okhttp -This product contains a modified portion of 'Netty', an open source -networking library, which can be obtained at: +This product contains a modified portion of 'Envoy', an open source +cloud-native high-performance edge/middle/service proxy, which can be +obtained at: * LICENSE: - * netty/third_party/netty/LICENSE.txt (Apache License 2.0) + * xds/third_party/envoy/LICENSE (Apache License 2.0) + * NOTICE: + * xds/third_party/envoy/NOTICE * HOMEPAGE: - * https://netty.io + * https://www.envoyproxy.io * LOCATION_IN_GRPC: - * netty/third_party/netty + * xds/third_party/envoy + +This product contains a modified portion of 'protoc-gen-validate (PGV)', +an open source protoc plugin to generate polyglot message validators, +which can be obtained at: + + * LICENSE: + * xds/third_party/protoc-gen-validate/LICENSE (Apache License 2.0) + * NOTICE: + * xds/third_party/protoc-gen-validate/NOTICE + * HOMEPAGE: + * https://github.com/envoyproxy/protoc-gen-validate + * LOCATION_IN_GRPC: + * xds/third_party/protoc-gen-validate + +This product contains a modified portion of 'udpa', +an open source universal data plane API, which can be obtained at: + + * LICENSE: + * xds/third_party/udpa/LICENSE (Apache License 2.0) + * HOMEPAGE: + * https://github.com/cncf/udpa + * LOCATION_IN_GRPC: + * xds/third_party/udpa diff --git a/README.md b/README.md index 8da0d0d3e37..8e6620c927e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,6 @@ gRPC-Java - An RPC library and framework ======================================== -gRPC-Java works with JDK 7. gRPC-Java clients are supported on Android API -levels 14 and up (Ice Cream Sandwich and later). Deploying gRPC servers on an -Android device is not supported. - -TLS usage typically requires using Java 8, or Play Services Dynamic Security -Provider on Android. Please see the [Security Readme](SECURITY.md). - @@ -20,18 +13,39 @@ Provider on Android. Please see the [Security Readme](SECURITY.md).
Homepage:
[![Join the chat at https://gitter.im/grpc/grpc](https://badges.gitter.im/grpc/grpc.svg)](https://gitter.im/grpc/grpc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build Status](https://travis-ci.org/grpc/grpc-java.svg?branch=master)](https://travis-ci.org/grpc/grpc-java) -[![Coverage Status](https://coveralls.io/repos/grpc/grpc-java/badge.svg?branch=master&service=github)](https://coveralls.io/github/grpc/grpc-java?branch=master) +[![GitHub Actions Linux Testing](https://github.com/grpc/grpc-java/actions/workflows/testing.yml/badge.svg?branch=master)](https://github.com/grpc/grpc-java/actions/workflows/testing.yml?branch=master) +[![Line Coverage Status](https://coveralls.io/repos/grpc/grpc-java/badge.svg?branch=master&service=github)](https://coveralls.io/github/grpc/grpc-java?branch=master) +[![Branch-adjusted Line Coverage Status](https://codecov.io/gh/grpc/grpc-java/branch/master/graph/badge.svg)](https://codecov.io/gh/grpc/grpc-java) + +Supported Platforms +------------------- + +gRPC-Java supports Java 8 and later. Android minSdkVersion 23 (Marshmallow) and +later are supported with [Java 8 language desugaring][android-java-8]. + +TLS usage on Android typically requires Play Services Dynamic Security Provider. +Please see the [Security Readme](SECURITY.md). + +Older Java versions are not directly supported, but a branch remains available +for fixes and releases. See [gRFC P5 JDK Version Support +Policy][P5-jdk-version-support]. + +Java version | gRPC Branch +------------ | ----------- +7 | 1.41.x + +[android-java-8]: https://developer.android.com/studio/write/java8-support#supported_features +[P5-jdk-version-support]: https://github.com/grpc/proposal/blob/master/P5-jdk-version-support.md#proposal Getting Started --------------- For a guided tour, take a look at the [quick start -guide](https://grpc.io/docs/quickstart/java.html) or the more explanatory [gRPC -basics](https://grpc.io/docs/tutorials/basic/java.html). +guide](https://grpc.io/docs/languages/java/quickstart) or the more explanatory [gRPC +basics](https://grpc.io/docs/languages/java/basics). -The [examples](https://github.com/grpc/grpc-java/tree/v1.17.1/examples) and the -[Android example](https://github.com/grpc/grpc-java/tree/v1.17.1/examples/android) +The [examples](https://github.com/grpc/grpc-java/tree/v1.81.0/examples) and the +[Android example](https://github.com/grpc/grpc-java/tree/v1.81.0/examples/android) are standalone projects that showcase the usage of gRPC. Download @@ -42,40 +56,45 @@ Download [the JARs][]. Or for Maven with non-Android, add to your `pom.xml`: io.grpc grpc-netty-shaded - 1.17.1 + 1.81.0 + runtime io.grpc grpc-protobuf - 1.17.1 + 1.81.0 io.grpc grpc-stub - 1.17.1 + 1.81.0 ``` Or for Gradle with non-Android, add to your dependencies: ```gradle -compile 'io.grpc:grpc-netty-shaded:1.17.1' -compile 'io.grpc:grpc-protobuf:1.17.1' -compile 'io.grpc:grpc-stub:1.17.1' +runtimeOnly 'io.grpc:grpc-netty-shaded:1.81.0' +implementation 'io.grpc:grpc-protobuf:1.81.0' +implementation 'io.grpc:grpc-stub:1.81.0' ``` For Android client, use `grpc-okhttp` instead of `grpc-netty-shaded` and `grpc-protobuf-lite` instead of `grpc-protobuf`: ```gradle -compile 'io.grpc:grpc-okhttp:1.17.1' -compile 'io.grpc:grpc-protobuf-lite:1.17.1' -compile 'io.grpc:grpc-stub:1.17.1' +implementation 'io.grpc:grpc-okhttp:1.81.0' +implementation 'io.grpc:grpc-protobuf-lite:1.81.0' +implementation 'io.grpc:grpc-stub:1.81.0' ``` +For [Bazel](https://bazel.build), you can either +[use Maven](https://github.com/bazelbuild/rules_jvm_external) +(with the GAVs from above), or use `@io_grpc_grpc_java//api` et al (see below). + [the JARs]: -https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.17.1 +https://search.maven.org/search?q=g:io.grpc%20AND%20v:1.81.0 Development snapshots are available in [Sonatypes's snapshot -repository](https://oss.sonatype.org/content/repositories/snapshots/). +repository](https://central.sonatype.com/repository/maven-snapshots/). Generated Code -------------- @@ -93,18 +112,18 @@ For protobuf-based codegen integrated with the Maven build system, you can use kr.motd.maven os-maven-plugin - 1.5.0.Final + 1.7.1 org.xolstice.maven.plugins protobuf-maven-plugin - 0.5.1 + 0.6.1 - com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier} + com.google.protobuf:protoc:3.25.8:exe:${os.detected.classifier} grpc-java - io.grpc:protoc-gen-grpc-java:1.17.1:exe:${os.detected.classifier} + io.grpc:protoc-gen-grpc-java:1.81.0:exe:${os.detected.classifier} @@ -121,27 +140,20 @@ For protobuf-based codegen integrated with the Maven build system, you can use [protobuf-maven-plugin]: https://www.xolstice.org/protobuf-maven-plugin/ -For protobuf-based codegen integrated with the Gradle build system, you can use -[protobuf-gradle-plugin][]: +For non-Android protobuf-based codegen integrated with the Gradle build system, +you can use [protobuf-gradle-plugin][]: ```gradle -apply plugin: 'com.google.protobuf' - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5' - } +plugins { + id 'com.google.protobuf' version '0.9.5' } protobuf { protoc { - artifact = "com.google.protobuf:protoc:3.5.1-1" + artifact = "com.google.protobuf:protoc:3.25.8" } plugins { grpc { - artifact = 'io.grpc:protoc-gen-grpc-java:1.17.1' + artifact = 'io.grpc:protoc-gen-grpc-java:1.81.0' } } generateProtoTasks { @@ -158,7 +170,43 @@ The prebuilt protoc-gen-grpc-java binary uses glibc on Linux. If you are compiling on Alpine Linux, you may want to use the [Alpine grpc-java package][] which uses musl instead. -[Alpine grpc-java package]: https://pkgs.alpinelinux.org/package/edge/testing/x86_64/grpc-java +[Alpine grpc-java package]: https://pkgs.alpinelinux.org/package/edge/community/x86_64/grpc-java + +For Android protobuf-based codegen integrated with the Gradle build system, also +use protobuf-gradle-plugin but specify the 'lite' options: + +```gradle +plugins { + id 'com.google.protobuf' version '0.9.5' +} + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:3.25.8" + } + plugins { + grpc { + artifact = 'io.grpc:protoc-gen-grpc-java:1.81.0' + } + } + generateProtoTasks { + all().each { task -> + task.builtins { + java { option 'lite' } + } + task.plugins { + grpc { option 'lite' } + } + } + } +} + +``` + +For [Bazel](https://bazel.build), use the [`proto_library`](https://github.com/bazelbuild/rules_proto) +and the [`java_proto_library`](https://bazel.build/reference/be/java#java_proto_library) (no `load()` required) +and `load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")` (from this project), as in +[this example `BUILD.bazel`](https://github.com/grpc/grpc-java/blob/master/examples/BUILD.bazel). API Stability ------------- @@ -172,7 +220,7 @@ We recommend using the [grpc-java-api-checker](https://github.com/grpc/grpc-java-api-checker) (an [Error Prone](https://github.com/google/error-prone) plugin) to check for usages of `@ExperimentalApi` and `@Internal` in any library code -that depends on gRPC. It may also be used to check for `@Internal` usage or +that depends on gRPC. It may also be used to check for `@Internal` usage or unintended `@ExperimentalApi` consumption in non-library code. How to Build @@ -209,12 +257,18 @@ wire. The interfaces to it are abstract just enough to allow plugging in of different implementations. Note the transport layer API is considered internal to gRPC and has weaker API guarantees than the core API under package `io.grpc`. -gRPC comes with three Transport implementations: +gRPC comes with multiple Transport implementations: -1. The Netty-based transport is the main transport implementation based on - [Netty](http://netty.io). It is for both the client and the server. -2. The OkHttp-based transport is a lightweight transport based on - [OkHttp](http://square.github.io/okhttp/). It is mainly for use on Android - and is for client only. +1. The Netty-based HTTP/2 transport is the main transport implementation based + on [Netty](https://netty.io). It is not officially supported on Android. + There is a "grpc-netty-shaded" version of this transport. It is generally + preferred over using the Netty-based transport directly as it requires less + dependency management and is easier to upgrade within many applications. +2. The OkHttp-based HTTP/2 transport is a lightweight transport based on + [Okio](https://square.github.io/okio/) and forked low-level parts of + [OkHttp](https://square.github.io/okhttp/). It is mainly for use on Android. 3. The in-process transport is for when a server is in the same process as the - client. It is useful for testing, while also being safe for production use. + client. It is used frequently for testing, while also being safe for + production use. +4. The Binder transport is for Android cross-process communication on a single + device. diff --git a/RELEASING.md b/RELEASING.md index f30354cc514..c57829b8c25 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,51 +4,32 @@ How to Create a Release of GRPC Java (for Maintainers Only) Build Environments ------------------ We deploy GRPC to Maven Central under the following systems: -- Ubuntu 14.04 with Docker 13.03.0 that runs CentOS 6.9 +- Ubuntu 14.04 with Docker 13.03.0 that runs CentOS 7 - Windows 7 64-bit with Visual Studio -- Mac OS X 10.12.6 +- Mac OS X 10.14.6 Other systems may also work, but we haven't verified them. -Prerequisites -------------- - -### Set Up OSSRH Account - -If you haven't deployed artifacts to Maven Central before, you need to setup -your OSSRH (OSS Repository Hosting) account. -- Follow the instructions on [this - page](http://central.sonatype.org/pages/ossrh-guide.html) to set up an - account with OSSRH. - - You only need to create the account, not set up a new project - - Contact a gRPC maintainer to add your account after you have created it. - Common Variables ---------------- Many of the following commands expect release-specific variables to be set. Set them before continuing, and set them again when resuming. ```bash -$ MAJOR=1 MINOR=7 PATCH=0 # Set appropriately for new release -$ VERSION_FILES=( +MAJOR=1 MINOR=7 PATCH=0 # Set appropriately for new release +VERSION_FILES=( + MODULE.bazel build.gradle - android/build.gradle - android-interop-testing/app/build.gradle core/src/main/java/io/grpc/internal/GrpcUtil.java - cronet/build.gradle - documentation/android-channel-builder.md + examples/MODULE.bazel examples/build.gradle examples/pom.xml examples/android/clientcache/app/build.gradle examples/android/helloworld/app/build.gradle examples/android/routeguide/app/build.gradle - examples/example-alts/build.gradle - examples/example-gauth/build.gradle - examples/example-gauth/pom.xml - examples/example-kotlin/build.gradle - examples/example-kotlin/android/helloworld/app/build.gradle - examples/example-tls/build.gradle - examples/example-tls/pom.xml + examples/android/strictmode/app/build.gradle + examples/example-*/build.gradle + examples/example-*/pom.xml ) ``` @@ -61,169 +42,211 @@ convention of `v..x`, while the tags include the patch version `v..`. For example, the same branch `v1.7.x` would be used to create all `v1.7` tags (e.g. `v1.7.0`, `v1.7.1`). -1. For `master`, change root build files to the next minor snapshot (e.g. +1. Review the issues in the current release [milestone](https://github.com/grpc/grpc-java/milestones) + for issues that won't make the cut. Check if any of them can be + closed. Be aware of the issues with the [TODO:release blocker][] label. + Consider reaching out to the assignee for the status update. +2. For `master`, change root build files to the next minor snapshot (e.g. ``1.8.0-SNAPSHOT``). ```bash - $ git checkout -b bump-version master + git checkout -b bump-version master # Change version to next minor (and keep -SNAPSHOT) - $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \ + sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \ "${VERSION_FILES[@]}" - $ sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$((MINOR+1)).0/ \ - compiler/src/test{,Lite,Nano}/golden/Test{,Deprecated}Service.java.txt - $ ./gradlew build - $ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle" + sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$((MINOR+1)).0/ \ + compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt + ./gradlew build + git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle" ``` -2. Go through PR review and submit. -3. Create the release branch starting just before your commit and push it to GitHub: +3. Go through PR review and submit. +4. Create the release branch starting just before your commit and push it to GitHub: ```bash - $ git fetch upstream - $ git checkout -b v$MAJOR.$MINOR.x \ - $(git log --pretty=format:%H --grep "^Start $MAJOR.$((MINOR+1)).0 development cycle$" upstream/master)^ - $ git push upstream v$MAJOR.$MINOR.x + git fetch upstream + git checkout -b v$MAJOR.$MINOR.x \ + $(git log --pretty=format:%H --grep "^Start $MAJOR.$((MINOR+1)).0 development cycle" upstream/master)^ + git push upstream v$MAJOR.$MINOR.x ``` -4. Go to [Travis CI settings](https://travis-ci.org/grpc/grpc-java/settings) and - add a _Cron Job_: - * Branch: `v$MAJOR.$MINOR.x` - * Interval: `weekly` - * Options: `Do not run if there has been a build in the last 24h` - * Click _Add_ button -5. Continue with Google-internal steps at go/grpc/java/releasing. +5. Continue with Google-internal steps at go/grpc-java/releasing, but stop + before `Auto releasing using kokoro`. 6. Create a milestone for the next release. 7. Move items out of the release milestone that didn't make the cut. Issues that may be backported should stay in the release milestone. Treat issues with the 'release blocker' label with special care. +8. Begin compiling release notes. This produces a starting point: + + ```bash + echo "## gRPC Java $MAJOR.$MINOR.0 Release Notes" && echo && \ + git shortlog -e --format='%s (%h)' "$(git merge-base upstream/v$MAJOR.$((MINOR-1)).x upstream/v$MAJOR.$MINOR.x)"..upstream/v$MAJOR.$MINOR.x | cat && \ + echo && echo && echo "Backported commits in previous release:" && \ + git log --oneline "$(git merge-base v$MAJOR.$((MINOR-1)).0 upstream/v$MAJOR.$MINOR.x)"..v$MAJOR.$((MINOR-1)).0^ + ``` + +[TODO:release blocker]: https://github.com/grpc/grpc-java/issues?q=label%3A%22TODO%3Arelease+blocker%22 +[TODO:backport]: https://github.com/grpc/grpc-java/issues?q=label%3ATODO%3Abackport Tagging the Release ------------------- 1. Verify there are no open issues in the release milestone. Open issues should - either be deferred or resolved and the fix backported. -2. For vMajor.Minor.x branch, change `README.md` to refer to the next release + either be deferred or resolved and the fix backported. Verify there are no + [TODO:release blocker][] nor [TODO:backport][] issues (open or closed), or + that they are tracking an issue for a different branch. +2. Ensure that the Google-internal steps + at go/grpc-java/releasing#before-tagging-a-release are completed. +3. For vMajor.Minor.x branch, change `README.md` to refer to the next release version. _Also_ update the version numbers for protoc if the protobuf library version was updated since the last release. ```bash - $ git checkout v$MAJOR.$MINOR.x - $ git pull upstream v$MAJOR.$MINOR.x - $ git checkout -b release - # Bump documented versions. Don't forget protobuf version - $ ${EDITOR:-nano -w} README.md - $ git commit -a -m "Update README to reference $MAJOR.$MINOR.$PATCH" + git checkout v$MAJOR.$MINOR.x + git pull upstream v$MAJOR.$MINOR.x + git checkout -b release-v$MAJOR.$MINOR.$PATCH + + # Bump documented gRPC versions. + # Also update protoc version to match protobuf version in gradle/libs.versions.toml. + ${EDITOR:-nano -w} README.md + + git commit -a -m "Update README etc to reference $MAJOR.$MINOR.$PATCH" ``` -3. Change root build files to remove "-SNAPSHOT" for the next release version +4. Change root build files to remove "-SNAPSHOT" for the next release version (e.g. `0.7.0`). Commit the result and make a tag: ```bash # Change version to remove -SNAPSHOT - $ sed -i 's/-SNAPSHOT\(.*CURRENT_GRPC_VERSION\)/\1/' "${VERSION_FILES[@]}" - $ sed -i s/-SNAPSHOT// compiler/src/test{,Lite,Nano}/golden/Test{,Deprecated}Service.java.txt - $ ./gradlew build - $ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH" - $ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH" + sed -i 's/-SNAPSHOT\(.*CURRENT_GRPC_VERSION\)/\1/' "${VERSION_FILES[@]}" + sed -i s/-SNAPSHOT// compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt + ./gradlew build + git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH" + git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH" ``` -4. Change root build files to the next snapshot version (e.g. `0.7.1-SNAPSHOT`). +5. Change root build files to the next snapshot version (e.g. `0.7.1-SNAPSHOT`). Commit the result: ```bash # Change version to next patch and add -SNAPSHOT - $ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \ + sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \ "${VERSION_FILES[@]}" - $ sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT/ \ - compiler/src/test{,Lite,Nano}/golden/Test{,Deprecated}Service.java.txt - $ ./gradlew build - $ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT" + sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT/ \ + compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt + ./gradlew build + git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT" + git push -u origin release-v$MAJOR.$MINOR.$PATCH ``` -5. Go through PR review and push the release tag and updated release branch to - GitHub: + Raise a PR and set the base branch of the PR to v$MAJOR.$MINOR.x of the upstream grpc-java repo. +6. Go through PR review and push the release tag and updated release branch to + GitHub (DO NOT click the merge button on the GitHub page): ```bash - $ git checkout v$MAJOR.$MINOR.x - $ git merge --ff-only release - $ git push upstream v$MAJOR.$MINOR.x - $ git push upstream v$MAJOR.$MINOR.$PATCH + git checkout v$MAJOR.$MINOR.x + git merge --ff-only release-v$MAJOR.$MINOR.$PATCH + git push upstream v$MAJOR.$MINOR.x + git push upstream v$MAJOR.$MINOR.$PATCH ``` -6. Close the release milestone. - -Build Artifacts ---------------- - -Trigger build as described in "Auto releasing using kokoro" at -go/grpc/java/releasing. - -It runs three jobs on Kokoro, one on each platform. See their scripts: -`linux_artifacts.sh`, `windows.bat`, and `unix.sh` (called directly for OS X; -called within the Docker environment on Linux). The mvn-artifacts/ outputs of -each script is combined into a single folder and then processed by -`upload_artifacts.sh`, which signs the files and uploads to Sonatype. - -Releasing on Maven Central --------------------------- - -Once all of the artifacts have been pushed to the staging repository, the -repository should have been closed by `upload_artifacts.sh`. Closing triggers -several sanity checks on the repository. If this completes successfully, the -repository can then be `released`, which will begin the process of pushing the -new artifacts to Maven Central (the staging repository will be destroyed in the -process). You can see the complete process for releasing to Maven Central on the -[OSSRH site](http://central.sonatype.org/pages/releasing-the-deployment.html). - -Build interop container image ------------------------------ - -We have containers for each release to detect compatibility regressions with old -releases. Generate one for the new release by following the -[GCR image generation instructions](https://github.com/grpc/grpc/blob/master/tools/interop_matrix/README.md#step-by-step-instructions-for-adding-a-gcr-image-for-a-new-release-for-compatibility-test). - -Update README.md ----------------- -After waiting ~1 day and verifying that the release appears on [Maven -Central](http://mvnrepository.com/), cherry-pick the commit that updated the -README into the master branch and go through review process. - -``` -$ git checkout -b bump-readme master -$ git cherry-pick v$MAJOR.$MINOR.$PATCH^ -``` - -Update version referenced by tutorials --------------------------------------- - -Update the `grpc_java_release_tag` in -[\_data/config.yml](https://github.com/grpc/grpc.github.io/blob/master/_data/config.yml) -of the grpc.github.io repository. - -Notify the Community --------------------- -Finally, document and publicize the release. - -1. Add [Release Notes](https://github.com/grpc/grpc-java/releases) for the new tag. - The description should include any major fixes or features since the last release. - You may choose to add links to bugs, PRs, or commits if appropriate. -2. Post a release announcement to [grpc-io](https://groups.google.com/forum/#!forum/grpc-io) - (`grpc-io@googlegroups.com`). The title should be something that clearly identifies - the release (e.g.`GRPC-Java Released`). - 1. Check if JCenter has picked up the new release (https://jcenter.bintray.com/io/grpc/) - and include its availability in the release announcement email. JCenter should mirror - everything on Maven Central, but users have reported delays. - -Update Hosted Javadoc +7. Close the release milestone. + +8. Trigger build as described in "Auto releasing using kokoro" at + go/grpc-java/releasing. + + It runs three jobs on Kokoro, one on each platform. See their scripts: + `linux_artifacts.sh`, `windows.bat`, and `macos.sh`. The mvn-artifacts/ + outputs of each script is combined into a single folder and then processed + by `upload_artifacts.sh`, which signs the files and uploads to Sonatype. + +9. Once all of the artifacts have been pushed to the staging repository, the + repository should have been closed by `upload_artifacts.sh`. Closing triggers + several sanity checks on the repository. If this completes successfully, the + repository can then be `released`, which will begin the process of pushing + the new artifacts to Maven Central (the staging repository will be destroyed + in the process). You can see the complete process for releasing to Maven + Central on the [OSSRH site](https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#deploying). + +10. We have containers for each release to detect compatibility regressions with + old releases. Generate one for the new release by following the [GCR image + generation instructions][gcr-image]. Summary: + ```bash + # If you haven't previously configured docker: + gcloud auth configure-docker us-docker.pkg.dev + + # In main grpc repo, add the new version to matrix + ${EDITOR:-nano -w} tools/interop_matrix/client_matrix.py + tools/interop_matrix/create_matrix_images.py --git_checkout --release=v$MAJOR.$MINOR.$PATCH \ + --upload_images --language java + docker pull us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_java:v$MAJOR.$MINOR.$PATCH + docker_image=us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_java:v$MAJOR.$MINOR.$PATCH \ + tools/interop_matrix/testcases/java__master + + # Commit the changes + git commit --all -m "[interop] Add grpc-java $MAJOR.$MINOR.$PATCH to client_matrix.py" + + # Create a PR with the `release notes: no` label and run ad-hoc test against your PR + ``` +[gcr-image]: https://github.com/grpc/grpc/blob/master/tools/interop_matrix/README.md#step-by-step-instructions-for-adding-a-gcr-image-for-a-new-release-for-compatibility-test + +11. Update gh-pages with the new Javadoc. Generally the file is on repo1 + 15 minutes after publishing: + + ```bash + git checkout gh-pages + git pull --ff-only upstream gh-pages + rm -r javadoc/ + wget -O grpc-all-javadoc.jar "https://repo1.maven.org/maven2/io/grpc/grpc-all/$MAJOR.$MINOR.$PATCH/grpc-all-$MAJOR.$MINOR.$PATCH-javadoc.jar" + unzip -d javadoc grpc-all-javadoc.jar + patch -p1 < ga.patch + rm grpc-all-javadoc.jar + rm -r javadoc/META-INF/ + git add -A javadoc + git commit -m "Javadoc for $MAJOR.$MINOR.$PATCH" + git push upstream gh-pages + ``` + + Verify the current version is [live on grpc.io](https://grpc.io/grpc-java/javadoc/). + +12. Add [Release Notes](https://github.com/grpc/grpc-java/releases) for the new tag. + *Make sure that any backports are reflected in the release notes.* + +13. Notify the Community. Post a release announcement to + [grpc-io](https://groups.google.com/forum/#!forum/grpc-io) + (`grpc-io@googlegroups.com`) with the title `gRPC-Java v$MAJOR.$MINOR.$PATCH + Released`. The email content should link to the GitHub release notes and + include a copy of them. + +14. Update README.md. Cherry-pick the commit that updated the README.md into the + master branch. + + ```bash + git checkout -b bump-readme master + git cherry-pick v$MAJOR.$MINOR.$PATCH^ + git push --set-upstream origin bump-readme + ``` + + Create a PR and go through the review process + +15. Update version referenced by tutorials. Update `params.grpc_vers.java` in + [config.yaml](https://github.com/grpc/grpc.io/blob/master/config.yaml) of + the grpc.io repository. Create a PR and go through the review process. + +Post-release upgrades --------------------- +Upgrade dependencies after the release so they can be well-tested before the +next release. + +Upgrade the Gradle plugins in `settings.gradle` and the Gradle version in +`gradle/wrapper/gradle-wrapper.properties`. Make sure to read the release notes +for each dependency upgraded. Test by doing a regular build. -Now we need to update gh-pages with the new Javadoc: +Upgrade the regular dependencies in `gradle/libs.versions.toml`, except for +Netty and netty-tcnative. To find available upgrades: ```bash -git checkout gh-pages -rm -r javadoc/ -wget -O grpc-all-javadoc.jar "http://search.maven.org/remotecontent?filepath=io/grpc/grpc-all/$MAJOR.$MINOR.$PATCH/grpc-all-$MAJOR.$MINOR.$PATCH-javadoc.jar" -unzip -d javadoc grpc-all-javadoc.jar -patch -p1 < ga.patch -rm grpc-all-javadoc.jar -rm -r javadoc/META-INF/ -git add -A javadoc -git commit -m "Javadoc for $MAJOR.$MINOR.$PATCH" +./gradlew checkForUpdates ``` -Push gh-pages to the main repository and verify the current version is [live -on grpc.io](https://grpc.io/grpc-java/javadoc/). +Test by doing a regular build. For each step, if a dependency cannot be +upgraded, add a comment. Create issues in other projects for breakages, and in +gRPC for things that will need a migration effort. + +When happy with the dependency upgrades, update the versions in `MODULE.bazel`, +`repositories.bzl`, and the various `pom.xml` and `build.gradle` files in +`examples/`. diff --git a/SECURITY.md b/SECURITY.md index 0b1c8f0b606..e710ceaabe1 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,35 +1,52 @@ +# Security Policy + +For information on gRPC Security Policy and reporting potentional security +issues, please see [gRPC CVE Process][]. + +[gRPC CVE Process]: https://github.com/grpc/proposal/blob/master/P4-grpc-cve-process.md + # Authentication -gRPC supports a number of different mechanisms for asserting identity between an client and server. This document provides code samples demonstrating how to provide SSL/TLS encryption support and identity assertions in Java, as well as passing OAuth2 tokens to services that support it. +gRPC supports a number of different mechanisms for asserting identity between an +client and server. This document provides code samples demonstrating how to +provide SSL/TLS encryption support and identity assertions in Java, as well as +passing OAuth2 tokens to services that support it. # Transport Security (TLS) -HTTP/2 over TLS mandates the use of [ALPN](https://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-05) to negotiate the use of the h2 protocol. ALPN is a fairly new standard and (where possible) gRPC also supports protocol negotiation via [NPN](https://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04) for systems that do not yet support ALPN. +HTTP/2 over TLS mandates the use of [ALPN](https://tools.ietf.org/html/rfc7301) +to negotiate the use of the h2 protocol and support for the GCM mode of AES. -On Android, use the [Play Services Provider](#tls-on-android). For non-Android systems, use [OpenSSL](#tls-with-openssl). +There are multiple options available, but on Android we recommend using the +[Play Services Provider](#tls-on-android) and for non-Android systems we +recommend [netty-tcnative with +BoringSSL](#tls-with-netty-tcnative-on-boringssl). ## TLS on Android On Android we recommend the use of the [Play Services Dynamic Security -Provider](https://www.appfoundry.be/blog/2014/11/18/Google-Play-Services-Dynamic-Security-Provider/) -to ensure your application has an up-to-date OpenSSL library with the necessary -ciper-suites and a reliable ALPN implementation. This requires [updating the -security provider at -runtime](https://developer.android.com/training/articles/security-gms-provider.html). +Provider][] to ensure your application has an up-to-date OpenSSL library with +the necessary cipher-suites and a reliable ALPN implementation. This requires +[updating the security provider at runtime][config-psdsp]. Although ALPN mostly works on newer Android releases (especially since 5.0), there are bugs and discovered security vulnerabilities that are only fixed by upgrading the security provider. Thus, we recommend using the Play Service Dynamic Security Provider for all Android versions. -*Note: The Dynamic Security Provider must be installed **before** creating a gRPC OkHttp channel. gRPC's OkHttpProtocolNegotiator statically initializes the security protocol(s) available to gRPC, which means that changes to the security provider after the first channel is created will not be picked up by gRPC.* +*Note: The Dynamic Security Provider must be installed **before** creating a +gRPC OkHttp channel. gRPC statically initializes the security protocol(s) +available, which means that changes to the security provider after the first +channel is created will not be noticed by gRPC.* + +[Play Services Dynamic Security Provider]: https://www.appfoundry.be/blog/2014/11/18/Google-Play-Services-Dynamic-Security-Provider/ +[config-psdsp]: https://developer.android.com/training/articles/security-gms-provider.html ### Bundling Conscrypt If depending on Play Services is not an option for your app, then you may bundle [Conscrypt](https://conscrypt.org) with your application. Binaries are available -on [Maven -Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.conscrypt%20a%3Aconscrypt-android). +on [Maven Central][conscrypt-maven]. Like the Play Services Dynamic Security Provider, you must still "install" Conscrypt before use. @@ -42,100 +59,98 @@ import java.security.Security; Security.insertProviderAt(Conscrypt.newProvider(), 1); ``` -## TLS with OpenSSL - -This is currently the recommended approach for using gRPC over TLS (on non-Android systems). +[conscrypt-maven]: https://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.conscrypt%20a%3Aconscrypt-android -The main benefits of using OpenSSL are: +## TLS on non-Android -1. **Speed**: In local testing, we've seen performance improvements of 3x over the JDK. GCM, which is used by the only cipher suite required by the HTTP/2 spec, is 10-500x faster. -2. **Ciphers**: OpenSSL has its own ciphers and is not dependent on the limitations of the JDK. This allows supporting GCM on Java 7. -3. **ALPN to NPN Fallback**: if the remote endpoint doesn't support ALPN. -4. **Version Independence**: does not require using a different library version depending on the JDK update. +OpenJDK versions prior to Java 8u252 do not support ALPN. Java 8 has 10% the +performance of OpenSSL. -Support for OpenSSL is only provided for the Netty transport via [netty-tcnative](https://github.com/netty/netty-tcnative), which is a fork of -[Apache Tomcat's tcnative](http://tomcat.apache.org/native-doc/), a JNI wrapper around OpenSSL. +We recommend most users use grpc-netty-shaded, which includes netty-tcnative on +BoringSSL. It includes pre-built libraries for 64 bit Windows, OS X, and 64 bit +Linux. For 32 bit Windows, Conscrypt is an option. For all other platforms, Java +9+ is required. -### OpenSSL: Dynamic vs Static (which to use?) +For users of xDS management protocol, the grpc-netty-shaded transport is +particularly appropriate since it is already used internally for the xDS +protocol and is a runtime dependency of grpc-xds. -As of version `1.1.33.Fork14`, netty-tcnative provides two options for usage: statically or dynamically linked. For simplification of initial setup, -we recommend that users first look at `netty-tcnative-boringssl-static`, which is statically linked against BoringSSL and Apache APR. Using this artifact requires no extra installation and guarantees that ALPN and the ciphers required for -HTTP/2 are available. In addition, starting with `1.1.33.Fork16` binaries for -all supported platforms can be included at compile time and the correct binary -for the platform can be selected at runtime. +For users of grpc-netty we recommend [netty-tcnative with +BoringSSL](#tls-with-netty-tcnative-on-boringssl), although using the built-in +JDK support in Java 9+, [Conscrypt](#tls-with-conscrypt), and [netty-tcnative +with OpenSSL](#tls-with-netty-tcnative-on-openssl) are other valid options. -Production systems, however, may require an easy upgrade path for OpenSSL security patches. In this case, relying on the statically linked artifact also implies waiting for the Netty team -to release the new artifact to Maven Central, which can take some time. A better solution in this case is to use the dynamically linked `netty-tcnative` artifact, which allows the site administrator -to easily upgrade OpenSSL in the standard way (e.g. apt-get) without relying on any new builds from Netty. +[Netty TCNative](https://github.com/netty/netty-tcnative) is a fork of +[Apache Tomcat's tcnative](https://tomcat.apache.org/native-doc/) and is a JNI +wrapper around OpenSSL/BoringSSL/LibreSSL. -### OpenSSL: Statically Linked (netty-tcnative-boringssl-static) +We recommend BoringSSL for its simplicity and low occurrence of security +vulnerabilities relative to OpenSSL. BoringSSL is used by Conscrypt as well. -This is the simplest way to configure the Netty transport for OpenSSL. You just need to add the appropriate `netty-tcnative-boringssl-static` artifact to your application's classpath. +### TLS with netty-tcnative on BoringSSL -Artifacts are available on [Maven Central](http://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/) for the following platforms: +Netty-tcnative with BoringSSL includes BoringSSL statically linked in the +binary. This means the system's pre-installed TLS libraries will not be used. +Production systems that have centralized upgrade agility in the face of +security vulnerabilities may want to use [netty-tcnative on +OpenSSL](#tls-with-netty-tcnative-on-openssl) instead. -Maven Classifier | Description ----------------- | ----------- -windows-x86_64 | Windows distribution -osx-x86_64 | Mac distribution -linux-x86_64 | Linux distribution +Users of grpc-netty-shaded will automatically use netty-tcnative with +BoringSSL. -##### Getting netty-tcnative-boringssl-static from Maven +grpc-netty users will need to add the appropriate +`netty-tcnative-boringssl-static` artifact to the application's classpath. +Artifacts are available for 64 bit Windows, OS X, and 64 bit Linux. -In Maven, you can use the [os-maven-plugin](https://github.com/trustin/os-maven-plugin) to help simplify the dependency. +Depending on netty-tcnative-boringssl-static will include binaries for all +supported platforms. For Maven: ```xml - io.netty netty-tcnative-boringssl-static - 2.0.20.Final + 2.0.20.Final + runtime - ``` -##### Getting netty-tcnative-boringssl-static from Gradle - -Gradle you can use the [osdetector-gradle-plugin](https://github.com/google/osdetector-gradle-plugin), which is a wrapper around the os-maven-plugin. +And for Gradle: ```gradle -buildscript { - repositories { - mavenCentral() - } -} - dependencies { - compile 'io.netty:netty-tcnative-boringssl-static:2.0.20.Final' + // See table for correct version + runtime 'io.netty:netty-tcnative-boringssl-static:2.0.20.Final' } ``` -### OpenSSL: Dynamically Linked (netty-tcnative) +For projects sensitive to binary size, specify the classifier for the precise +platform you need: `windows-x86_64`, `osx-x86_64`, `linux-x86_64`. You can also +use [os-maven-plugin](https://github.com/trustin/os-maven-plugin) or +[osdetector-gradle-plugin](https://github.com/google/osdetector-gradle-plugin), +to choose the classifier for the platform running the build. -If for any reason you need to dynamically link against OpenSSL (e.g. you need control over the version of OpenSSL), you can instead use the `netty-tcnative` artifact. - -Requirements: - -1. [OpenSSL](https://www.openssl.org/) version >= 1.0.2 for ALPN support, or version >= 1.0.1 for NPN. -2. [Apache APR library (libapr-1)](https://apr.apache.org/) version >= 1.5.2. -3. [netty-tcnative](https://github.com/netty/netty-tcnative) version >= 1.1.33.Fork7 must be on classpath. Prior versions only supported NPN and only Fedora-derivatives were supported for Linux. +### TLS with netty-tcnative on OpenSSL -Artifacts are available on [Maven Central](http://repo1.maven.org/maven2/io/netty/netty-tcnative/) for the following platforms: +Using OpenSSL can have more initial configuration issues, but can be useful if +your OS's OpenSSL version is recent and kept up-to-date with security fixes. +OpenSSL is not included with tcnative, but instead is dynamically linked using +your operating system's OpenSSL. -Classifier | Description ----------------- | ----------- -windows-x86_64 | Windows distribution -osx-x86_64 | Mac distribution -linux-x86_64 | Used for non-Fedora derivatives of Linux -linux-x86_64-fedora | Used for Fedora derivatives +To use OpenSSL you will use the `netty-tcnative` artifact. It requires: -On Linux it should be noted that OpenSSL uses a different soname for Fedora derivatives than other Linux releases. To work around this limitation, netty-tcnative deploys two separate versions for linux. +1. [OpenSSL](https://www.openssl.org/) version >= 1.0.2 for ALPN support. +2. [Apache APR library (libapr-1)](https://apr.apache.org/) version >= 1.5.2. -##### Getting netty-tcnative from Maven +You must specify a classifier for the correct netty-tcnative binary: +`windows-x86_64`, `osx-x86_64`, `linux-x86_64`, or `linux-x86_64-fedora`. +Fedora derivatives use a different soname from other Linux distributations, so +you must select the "fedora" version on those distributions. -In Maven, you can use the [os-maven-plugin](https://github.com/trustin/os-maven-plugin) to help simplify the dependency. +In Maven, you can use the +[os-maven-plugin](https://github.com/trustin/os-maven-plugin) to help simplify +the dependency. ```xml @@ -143,8 +158,9 @@ In Maven, you can use the [os-maven-plugin](https://github.com/trustin/os-maven- io.netty netty-tcnative - 2.0.20.Final + 2.0.20.Final ${tcnative.classifier} + runtime @@ -154,7 +170,7 @@ In Maven, you can use the [os-maven-plugin](https://github.com/trustin/os-maven- kr.motd.maven os-maven-plugin - 1.5.0.Final + 1.7.1 @@ -186,9 +202,8 @@ In Maven, you can use the [os-maven-plugin](https://github.com/trustin/os-maven- ``` -##### Getting netty-tcnative from Gradle - -Gradle you can use the [osdetector-gradle-plugin](https://github.com/google/osdetector-gradle-plugin), which is a wrapper around the os-maven-plugin. +And in Gradle you can use the +[osdetector-gradle-plugin](https://github.com/google/osdetector-gradle-plugin). ```gradle buildscript { @@ -211,58 +226,34 @@ if (osdetector.os == "linux" && osdetector.release.isLike("fedora")) { } dependencies { - compile 'io.netty:netty-tcnative:2.0.20.Final:' + tcnative_classifier + runtime 'io.netty:netty-tcnative:2.0.20.Final:' + tcnative_classifier } ``` -## TLS with JDK (Jetty ALPN/NPN) - -**WARNING: DON'T DO THIS!!** - -*For non-Android systems, the recommended approach is to use [OpenSSL](#tls-with-openssl). Using the JDK for ALPN is generally much slower and may not support the necessary ciphers for HTTP2.* - -*Jetty ALPN brings its own baggage in that the Java bootclasspath needs to be modified, which may not be an option for some environments. In addition, a specific version of Jetty ALPN has to be used for a given version of the JRE. If the versions don't match the negotiation will fail, but you won't really know why. And since there is such a tight coupling between Jetty ALPN and the JRE, there are no guarantees that Jetty ALPN will support every JRE out in the wild.* +### TLS with Conscrypt -*The moral of the story is: Don't use the JDK for ALPN! But if you absolutely have to, here's how you do it... :)* +[Conscrypt](https://conscrypt.org) provides an implementation of the JSSE +security APIs based on BoringSSL. Pre-built binaries are available for 32 and +64 bit Windows, OS X, and 64 bit Linux. ---- +Depend on `conscrypt-openjdk-uber` for binaries of all supported JRE platforms. +For projects sensitive to binary size, depend on `conscrypt-openjdk` and +specify the appropriate classifier. `os-maven-plugin` and +`osdetector-gradle-plugin` may also be used. See the documentation for +[netty-tcnative-boringssl-static](#tls-with-netty-tcnative-on-boringssl) for +example usage of the plugins. -If not using the Netty transport (or you are unable to use OpenSSL for some reason) another alternative is to use the JDK for TLS. +Generally you will "install" Conscrypt before use, for gRPC to find. -No standard Java release has built-in support for ALPN today ([there is a tracking issue](https://bugs.openjdk.java.net/browse/JDK-8051498) so go upvote it!) so we need to use the [Jetty-ALPN](https://github.com/jetty-project/jetty-alpn) (or [Jetty-NPN](https://github.com/jetty-project/jetty-npn) if on Java < 8) bootclasspath extension for OpenJDK. To do this, add an `Xbootclasspath` JVM option referencing the path to the Jetty `alpn-boot` jar. - -```sh -java -Xbootclasspath/p:/path/to/jetty/alpn/extension.jar ... -``` - -Note that you must use the [release of the Jetty-ALPN jar](http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) specific to the version of Java you are using. However, you can use the JVM agent [Jetty-ALPN-Agent](https://github.com/jetty-project/jetty-alpn-agent) to load the correct Jetty `alpn-boot` jar file for the current Java version. To do this, instead of adding an `Xbootclasspath` option, add a `javaagent` JVM option referencing the path to the Jetty `alpn-agent` jar. +```java +import org.conscrypt.Conscrypt; +import java.security.Security; +... -```sh -java -javaagent:/path/to/jetty-alpn-agent.jar ... +// Somewhere in main() +Security.insertProviderAt(Conscrypt.newProvider(), 1); ``` -### JDK Ciphers - -Java 7 does not support [the cipher suites recommended](https://tools.ietf.org/html/draft-ietf-httpbis-http2-17#section-9.2.2) by the HTTP2 specification. To address this we suggest servers use Java 8 where possible or use an alternative JCE implementation such as [Bouncy Castle](https://www.bouncycastle.org/java.html). If this is not practical it is possible to use other ciphers but you need to ensure that the services you intend to call have [allowed out-of-spec ciphers](https://github.com/grpc/grpc/issues/681) and have evaluated the security risks of doing so. - -Users should be aware that GCM is [_very_ slow (1 MB/s)](https://bugzilla.redhat.com/show_bug.cgi?id=1135504) before Java 8u60. With Java 8u60 GCM is 10x faster (10-20 MB/s), but that is still slow compared to OpenSSL (~200 MB/s), especially with AES-NI support (~1 GB/s). GCM cipher suites are the only suites available that comply with HTTP2's cipher requirements. - -### Configuring Jetty ALPN in Web Containers - -Some web containers, such as [Jetty](http://www.eclipse.org/jetty/documentation/current/jetty-classloading.html) restrict access to server classes for web applications. A gRPC client running within such a container must be properly configured to allow access to the ALPN classes. In Jetty, this is done by including a `WEB-INF/jetty-env.xml` file containing the following: - -```xml - - - - - - - - -org.eclipse.jetty.alpn. - - -``` ## Enabling TLS on a server To use TLS on the server, a certificate chain and private key need to be @@ -270,44 +261,50 @@ specified in PEM format. The standard TLS port is 443, but we use 8443 below to avoid needing extra permissions from the OS. ```java -Server server = ServerBuilder.forPort(8443) - // Enable TLS - .useTransportSecurity(certChainFile, privateKeyFile) +ServerCredentials creds = TlsServerCredentials.create(certChainFile, privateKeyFile); +Server server = Grpc.newServerBuilderForPort(8443, creds) .addService(serviceImplementation) - .build(); -server.start(); + .build() + .start(); ``` If the issuing certificate authority is not known to the client then a properly -configured SslContext or SSLSocketFactory should be provided to the -NettyChannelBuilder or OkHttpChannelBuilder, respectively. +configured trust manager should be provided to TlsChannelCredentials and used to +construct the channel. ## Mutual TLS [Mutual authentication][] (or "client-side authentication") configuration is similar to the server by providing truststores, a client certificate and private key to the client channel. The server must also be configured to request a certificate from clients, as well as truststores for which client certificates it should allow. ```java -Server server = NettyServerBuilder.forPort(8443) - .sslContext(GrpcSslContexts.forServer(certChainFile, privateKeyFile) - .trustManager(clientCAsFile) - .clientAuth(ClientAuth.REQUIRE) - .build()); +ServerCredentials creds = TlsServerCredentials.newBuilder() + .keyManager(certChainFile, privateKeyFile) + .trustManager(clientCAsFile) + .clientAuth(TlsServerCredentials.ClientAuth.REQUIRE) + .build(); ``` -Negotiated client certificates are available in the SSLSession, which is found in the `TRANSPORT_ATTR_SSL_SESSION` attribute of Grpc. A server interceptor can provide details in the current Context. +Negotiated client certificates are available in the SSLSession, which is found +in the `Grpc.TRANSPORT_ATTR_SSL_SESSION` attribute of the call. A server +interceptor can provide details in the current Context. ```java -public final static Context.Key SSL_SESSION_CONTEXT = Context.key("SSLSession"); +// The application uses this in its handlers. +public static final Context.Key SECURITY_INFO = Context.key("my.security.Info"); @Override -public ServerCall.Listener interceptCall(ServerCall call, +public ServerCall.Listener interceptCall(ServerCall call, Metadata headers, ServerCallHandler next) { - SSLSession sslSession = call.attributes().get(Grpc.TRANSPORT_ATTR_SSL_SESSION); + SSLSession sslSession = call.getAttributes().get(Grpc.TRANSPORT_ATTR_SSL_SESSION); if (sslSession == null) { - return next.startCall(call, headers) + return next.startCall(call, headers); } + // This interceptor can provide a centralized policy to process the client's + // certificate. Avoid exposing low-level details (like SSLSession) and + // instead provide a higher-level concept like "authenticated user." + MySecurityInfo info = process(sslSession); return Contexts.interceptCall( - Context.current().withValue(SSL_SESSION_CONTEXT, clientContext), call, headers, next); + Context.current().withValue(SECURITY_INFO, info), call, headers, next); } ``` @@ -319,23 +316,28 @@ If you received an error message "ALPN is not configured properly" or "Jetty ALP - ALPN related dependencies are either not present in the classpath - or that there is a classpath conflict - or that a wrong version is used due to dependency management - - or you are on an unsupported platform (e.g., 32-bit OS, Alpine with `musl` libc). See [Transport Security](#transport-security-tls) for supported platforms. + - or you are on an unsupported platform (e.g., 32-bit OS). See [Transport + Security](#transport-security-tls) for supported platforms. ### Netty If you aren't using gRPC on Android devices, you are most likely using `grpc-netty` transport. If you are developing for Android and have a dependency on `grpc-netty`, you should remove it as `grpc-netty` is unsupported on Android. Use `grpc-okhttp` instead. -If you are on a 32-bit operating system, or not on a [Transport Security supported platform](#transport-security-tls), you should use Jetty ALPN (and beware of potential issues), or you'll need to build your own 32-bit version of `netty-tcnative`. +If you are on a 32-bit operating system, using Java 11+ may be the easiest +solution, as ALPN was added to Java in Java 9. If on 32-bit Windows, [Conscrypt +is an option](#tls-with-conscrypt). Otherwise you need to [build your own 32-bit +version of +`netty-tcnative`](https://netty.io/wiki/forked-tomcat-native.html#wiki-h2-6). -If you are using `musl` libc (e.g., with Alpine Linux), then -`netty-tcnative-boringssl-static` won't work. There are several alternatives: - - Use [netty-tcnative-alpine](https://github.com/pires/netty-tcnative-alpine) - - Use a distribution with `glibc` +If on Alpine Linux, depending on your specific JDK you may see a crash in +netty_tcnative. This is generally caused by a missing symbol. Run `apk install +gcompat` and use the environment variable `LD_PRELOAD=/lib/libgcompat.so.0` when +executing Java. -If you are running inside of an embedded Tomcat runtime (e.g., Spring Boot), -then some versions of `netty-tcnative-boringssl-static` will have conflicts and -won't work. You must use gRPC 1.4.0 or later. +If on Fedora 30 or later and you see "libcrypt.so.1: cannot open shared object +file: No such file or directory". Run `dnf -y install libxcrypt-compat` to +install the necessary dependency. Most dependency versioning problems can be solved by using `io.grpc:grpc-netty-shaded` instead of `io.grpc:grpc-netty`, although this also @@ -362,7 +364,7 @@ If you are running in a runtime environment that also uses Netty (e.g., Hadoop, Below are known to work version combinations: grpc-netty version | netty-handler version | netty-tcnative-boringssl-static version ------------------- | --------------------- | --------------------------------------- +------------------ |-----------------------| --------------------------------------- 1.0.0-1.0.1 | 4.1.3.Final | 1.1.33.Fork19 1.0.2-1.0.3 | 4.1.6.Final | 1.1.33.Fork23 1.1.x-1.3.x | 4.1.8.Final | 1.1.33.Fork26 @@ -375,24 +377,40 @@ grpc-netty version | netty-handler version | netty-tcnative-boringssl-static ver 1.13.x | 4.1.25.Final | 2.0.8.Final 1.14.x-1.15.x | 4.1.27.Final | 2.0.12.Final 1.16.x-1.17.x | 4.1.30.Final | 2.0.17.Final -1.18.x- | 4.1.32.Final | 2.0.20.Final +1.18.x-1.19.x | 4.1.32.Final | 2.0.20.Final +1.20.x-1.21.x | 4.1.34.Final | 2.0.22.Final +1.22.x | 4.1.35.Final | 2.0.25.Final +1.23.x-1.24.x | 4.1.38.Final | 2.0.25.Final +1.25.x-1.27.x | 4.1.42.Final | 2.0.26.Final +1.28.x | 4.1.45.Final | 2.0.28.Final +1.29.x-1.31.x | 4.1.48.Final | 2.0.30.Final +1.32.x-1.34.x | 4.1.51.Final | 2.0.31.Final +1.35.x-1.41.x | 4.1.52.Final | 2.0.34.Final +1.42.x-1.43.x | 4.1.63.Final | 2.0.38.Final +1.44.x-1.47.x | 4.1.72.Final | 2.0.46.Final +1.48.x-1.49.x | 4.1.77.Final | 2.0.53.Final +1.50.x-1.53.x | 4.1.79.Final | 2.0.54.Final +1.54.x-1.55.x | 4.1.87.Final | 2.0.56.Final +1.56.x | 4.1.87.Final | 2.0.61.Final +1.57.x-1.58.x | 4.1.93.Final | 2.0.61.Final +1.59.x | 4.1.97.Final | 2.0.61.Final +1.60.x-1.66.x | 4.1.100.Final | 2.0.61.Final +1.67.x-1.70.x | 4.1.110.Final | 2.0.65.Final +1.71.x-1.74.x | 4.1.110.Final | 2.0.70.Final +1.75.x-1.76.x | 4.1.124.Final | 2.0.72.Final +1.77.x-1.78.x | 4.1.127.Final | 2.0.74.Final +1.79.x-1.80.x | 4.1.130.Final | 2.0.74.Final +1.81.x- | 4.1.132.Final | 2.0.75.Final _(grpc-netty-shaded avoids issues with keeping these versions in sync.)_ ### OkHttp -If you are using gRPC on Android devices, you are most likely using `grpc-okhttp` transport. - -Find the dependency tree (e.g., `mvn dependency:tree`), and look for versions of: - - `io.grpc:grpc-okhttp` - - `com.squareup.okhttp:okhttp` - -If you don't have `grpc-okhttp`, you should add it as a dependency. - -If you have both `io.grpc:grpc-netty` and `io.grpc:grpc-okhttp`, you may also have issues. Remove `grpc-netty` if you are on Android. - -If you have `okhttp` version below 2.5.0, then it may not work with gRPC. +If you are using gRPC on Android devices, you are most likely using +`grpc-okhttp` transport. -It is OK to have both `okhttp` 2.x and 3.x since they have different group name and under different packages. +Find the dependency tree (e.g., `mvn dependency:tree`), and look for +`io.grpc:grpc-okhttp`. If you don't have `grpc-okhttp`, you should add it as a +dependency. # gRPC over plaintext @@ -403,17 +421,12 @@ An option is provided to use gRPC over plaintext without TLS. While this is conv The following code snippet shows how you can call the Google Cloud PubSub API using gRPC with a service account. The credentials are loaded from a key stored in a well-known location or by detecting that the application is running in an environment that can provide one automatically, e.g. Google Compute Engine. While this example is specific to Google and it's services, similar patterns can be followed for other service providers. ```java -// Create a channel to the test service. -ManagedChannel channel = ManagedChannelBuilder.forTarget("pubsub.googleapis.com") +// Use the default credentials from the environment +ChannelCredentials creds = GoogleDefaultChannelCredentials.create(); +// Create a channel to the service +ManagedChannel channel = Grpc.newChannelBuilder("dns:///pubsub.googleapis.com", creds) .build(); -// Get the default credentials from the environment -GoogleCredentials creds = GoogleCredentials.getApplicationDefault(); -// Down-scope the credential to just the scopes required by the service -creds = creds.createScoped(Arrays.asList("https://www.googleapis.com/auth/pubsub")); -// Create an instance of {@link io.grpc.CallCredentials} -CallCredentials callCreds = MoreCallCredentials.from(creds); -// Create a stub with credential -PublisherGrpc.PublisherBlockingStub publisherStub = - PublisherGrpc.newBlockingStub(channel).withCallCredentials(callCreds); +// Create a stub and send an RPC +PublisherGrpc.PublisherBlockingStub publisherStub = PublisherGrpc.newBlockingStub(channel); publisherStub.publish(someMessage); ``` diff --git a/WORKSPACE b/WORKSPACE index 65bf26a8b25..1efdf2793a8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,5 +1,58 @@ workspace(name = "io_grpc_grpc_java") -load("//:repositories.bzl", "grpc_java_repositories") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories") grpc_java_repositories() + +http_archive( + name = "rules_java", + sha256 = "47632cc506c858011853073449801d648e10483d4b50e080ec2549a4b2398960", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/8.15.2/rules_java-8.15.2.tar.gz", + ], +) + +load("@com_google_protobuf//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps") + +protobuf_deps() + +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +load("@bazel_features//:deps.bzl", "bazel_features_deps") + +bazel_features_deps() + +load("@bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories") + +jar_jar_repositories() + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + +load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") + +switched_rules_by_language( + name = "com_google_googleapis_imports", +) + +http_archive( + name = "rules_jvm_external", + sha256 = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac", + strip_prefix = "rules_jvm_external-5.3", + url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/5.3/rules_jvm_external-5.3.tar.gz", +) + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_install( + artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS + PROTOBUF_MAVEN_ARTIFACTS, + override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS, + repositories = [ + "https://repo.maven.apache.org/maven2/", + ], + strict_visibility = True, +) diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 00000000000..4ecb9e5d985 --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1 @@ +# When using bzlmod this makes sure nothing from the legacy WORKSPACE is loaded diff --git a/all/build.gradle b/all/build.gradle index a20246cbc49..11eec4b7ff8 100644 --- a/all/build.gradle +++ b/all/build.gradle @@ -1,40 +1,48 @@ -apply plugin: 'com.github.kt3k.coveralls' +plugins { + id "java-library" + id "maven-publish" -description = "gRPC: All" - -buildscript { - repositories { - maven { // The google mirror is less flaky than mavenCentral() - url "https://maven-central.storage-download.googleapis.com/repos/central/data/" } - } - dependencies { classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1' } + id "com.github.kt3k.coveralls" } +description = "gRPC: All" + def subprojects = [ + project(':grpc-api'), project(':grpc-auth'), project(':grpc-core'), - project(':grpc-context'), + project(':grpc-grpclb'), + project(':grpc-gcp-csm-observability'), + project(':grpc-inprocess'), project(':grpc-netty'), project(':grpc-okhttp'), + project(':grpc-opentelemetry'), project(':grpc-protobuf'), project(':grpc-protobuf-lite'), - project(':grpc-protobuf-nano'), + project(':grpc-rls'), + project(':grpc-services'), + project(':grpc-servlet'), + project(':grpc-servlet-jakarta'), project(':grpc-stub'), project(':grpc-testing'), + project(':grpc-util'), + project(':grpc-xds'), ] -for (subproject in rootProject.subprojects) { +for (subproject in subprojects) { if (subproject == project) { continue } evaluationDependsOn(subproject.path) } +evaluationDependsOn(':grpc-interop-testing') dependencies { - compile subprojects.minus(project(':grpc-protobuf-lite')) + api subprojects.minus([project(':grpc-protobuf-lite')]) + implementation libraries.guava.jre // JRE required by transitive protobuf-java-util } -javadoc { +tasks.named("javadoc").configure { classpath = files(subprojects.collect { subproject -> subproject.javadoc.classpath }) @@ -43,40 +51,29 @@ javadoc { continue; } source subproject.javadoc.source - options.links subproject.javadoc.options.links.toArray(new String[0]) + options.linksOffline.addAll subproject.javadoc.options.linksOffline } } -task jacocoMerge(type: JacocoMerge) { - dependsOn(subprojects.jacocoTestReport.dependsOn) +tasks.named("jacocoTestReport").configure { mustRunAfter(subprojects.jacocoTestReport.mustRunAfter) - destinationFile = file("${buildDir}/jacoco/test.exec") - executionData = files(subprojects.jacocoTestReport.executionData) + mustRunAfter(project(':grpc-interop-testing').jacocoTestReport.mustRunAfter) + executionData.from files(subprojects.jacocoTestReport.executionData) .plus(project(':grpc-interop-testing').jacocoTestReport.executionData) - .filter { f -> f.exists() } -} - -jacocoTestReport { - dependsOn(jacocoMerge) reports { - xml.enabled = true - html.enabled = true + xml.required = true + html.required = true } - additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs) - sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs) - classDirectories = files(subprojects.sourceSets.main.output) - classDirectories = files(classDirectories.files.collect { - fileTree(dir: it, - exclude: [ - '**/io/grpc/internal/testing/**', - '**/io/grpc/okhttp/internal/**', - ]) - }) + subprojects.each { subproject -> + additionalSourceDirs.from(subproject.jacocoTestReport.additionalSourceDirs) + sourceDirectories.from(subproject.jacocoTestReport.sourceDirectories) + classDirectories.from(subproject.jacocoTestReport.classDirectories) + } } coveralls { sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten() } -tasks.coveralls { dependsOn(jacocoTestReport) } +tasks.named("coveralls").configure { dependsOn tasks.named("jacocoTestReport") } diff --git a/alts/BUILD.bazel b/alts/BUILD.bazel index 8924d7f1cc9..f29df303fbe 100644 --- a/alts/BUILD.bazel +++ b/alts/BUILD.bazel @@ -1,3 +1,7 @@ +load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") +load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") +load("@rules_java//java:defs.bzl", "java_library") +load("@rules_jvm_external//:defs.bzl", "artifact") load("//:java_grpc_library.bzl", "java_grpc_library") java_library( @@ -8,20 +12,20 @@ java_library( deps = [ ":handshaker_java_grpc", ":handshaker_java_proto", - "//core", + "//api", "//core:internal", "//netty", "//stub", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_guava_guava//jar", - "@com_google_j2objc_j2objc_annotations//jar", "@com_google_protobuf//:protobuf_java", "@com_google_protobuf//:protobuf_java_util", - "@io_netty_netty_buffer//jar", - "@io_netty_netty_codec//jar", - "@io_netty_netty_common//jar", - "@io_netty_netty_handler//jar", - "@io_netty_netty_transport//jar", + artifact("com.google.code.findbugs:jsr305"), + artifact("com.google.errorprone:error_prone_annotations"), + artifact("com.google.guava:guava"), + artifact("io.netty:netty-buffer"), + artifact("io.netty:netty-codec"), + artifact("io.netty:netty-common"), + artifact("io.netty:netty-handler"), + artifact("io.netty:netty-transport"), ], ) @@ -31,22 +35,20 @@ java_library( "src/main/java/io/grpc/alts/*.java", ]), visibility = ["//visibility:public"], - runtime_deps = ["//grpclb"], deps = [ ":alts_internal", ":handshaker_java_grpc", + ":handshaker_java_proto", + "//api", "//auth", - "//core", "//core:internal", "//netty", - "@com_google_auth_google_auth_library_oauth2_http//jar", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_guava_guava//jar", - "@com_google_j2objc_j2objc_annotations//jar", - "@io_netty_netty_common//jar", - "@io_netty_netty_handler//jar", - "@io_netty_netty_transport//jar", - "@org_apache_commons_commons_lang3//jar", + artifact("com.google.auth:google-auth-library-oauth2-http"), + artifact("com.google.code.findbugs:jsr305"), + artifact("com.google.guava:guava"), + artifact("io.netty:netty-common"), + artifact("io.netty:netty-handler"), + artifact("io.netty:netty-transport"), ], ) diff --git a/alts/build.gradle b/alts/build.gradle index 3b4f3b1ab6d..c206a37bcef 100644 --- a/alts/build.gradle +++ b/alts/build.gradle @@ -1,80 +1,79 @@ -buildscript { - repositories { jcenter() } - dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' } -} +plugins { + id "java-library" + id "maven-publish" -apply plugin: 'com.github.johnrengelman.shadow' + id "com.google.protobuf" + id "com.gradleup.shadow" + id "ru.vyarus.animalsniffer" +} description = "gRPC: ALTS" -sourceCompatibility = 1.7 -targetCompatibility = 1.7 - -buildscript { - repositories { - maven { // The google mirror is less flaky than mavenCentral() - url "https://maven-central.storage-download.googleapis.com/repos/central/data/" } - } - dependencies { classpath libraries.protobuf_plugin } -} - dependencies { - compile project(':grpc-auth'), + api project(':grpc-api') + implementation project(':grpc-auth'), project(':grpc-core'), - project(':grpc-netty'), + project(":grpc-context"), // Override google-auth dependency with our newer version project(':grpc-protobuf'), project(':grpc-stub'), - libraries.lang, - libraries.protobuf - compile (libraries.google_auth_oauth2_http) { - // prefer 3.0.2 from libraries instead of 1.3.9 - exclude group: 'com.google.code.findbugs', module: 'jsr305' - // prefer 20.0 from libraries instead of 19.0 - exclude group: 'com.google.guava', module: 'guava' - } - compileOnly libraries.javax_annotation - runtime project(':grpc-grpclb') - testCompile project(':grpc-testing'), + libraries.protobuf.java, + libraries.conscrypt, + libraries.google.auth.oauth2Http + def nettyDependency = implementation project(':grpc-netty') + + shadow configurations.implementation.getDependencies().minus(nettyDependency) + shadow project(path: ':grpc-netty-shaded', configuration: 'shadow') + + testImplementation project(':grpc-testing'), + testFixtures(project(':grpc-core')), + project(':grpc-inprocess'), project(':grpc-testing-proto'), libraries.guava, - libraries.guava_testlib, libraries.junit, - libraries.mockito, + libraries.mockito.core, libraries.truth - testRuntime libraries.netty_tcnative, - libraries.conscrypt - signature 'org.codehaus.mojo.signature:java17:1.0@signature' + + testImplementation libraries.guava.testlib + testRuntimeOnly libraries.netty.tcnative, + libraries.netty.tcnative.classes + testRuntimeOnly (libraries.netty.transport.epoll) { + artifact { + classifier = "linux-x86_64" + } + } + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() import net.ltgt.gradle.errorprone.CheckSeverity -[compileJava, compileTestJava].each() { - // protobuf calls valueof. Will be fixed in next release (google/protobuf#4046) - it.options.compilerArgs += [ - "-Xlint:-deprecation" - ] +[tasks.named("compileJava"), tasks.named("compileTestJava")]*.configure { // ALTS returns a lot of futures that we mostly don't care about. - it.options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF) + options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF) } -javadoc { exclude 'io/grpc/alts/internal/**' } - -artifacts { - archives shadowJar +tasks.named("javadoc").configure { + exclude 'io/grpc/alts/internal/**' + exclude 'io/grpc/alts/Internal*' } -jar { - // Must use a different classifier to avoid conflicting with shadowJar - classifier = 'original' +tasks.named("jar").configure { + // Must use a different archiveClassifier to avoid conflicting with shadowJar + archiveClassifier = 'original' + manifest { + attributes('Automatic-Module-Name': 'io.grpc.alts') + } } -configurations.archives.artifacts.removeAll { it.classifier == "original" } // We want to use grpc-netty-shaded instead of grpc-netty. But we also want our // source to work with Bazel, so we rewrite the code as part of the build. -shadowJar { - classifier = null +tasks.named("shadowJar").configure { + archiveClassifier = null dependencies { exclude(dependency {true}) } @@ -82,14 +81,24 @@ shadowJar { relocate 'io.netty', 'io.grpc.netty.shaded.io.netty' } -[ - install.repositories.mavenInstaller, - uploadArchives.repositories.mavenDeployer, -]*.pom*.whenConfigured { pom -> - def netty = pom.dependencies.find {dep -> dep.artifactId == 'grpc-netty'} - // Swap our dependency to grpc-netty-shaded. Projects depending on this via - // project(':grpc-alts') will still be using the non-shaded form. - netty.artifactId = "grpc-netty-shaded" - // Depend on specific version of grpc-netty-shaded because it is unstable API - netty.version = "[" + netty.version + "]" +publishing { + publications { + maven(MavenPublication) { + // We want this to throw an exception if it isn't working + def originalJar = artifacts.find { dep -> dep.classifier == 'original'} + artifacts.remove(originalJar) + + pom.withXml { + def dependenciesNode = new Node(null, 'dependencies') + project.configurations.shadow.allDependencies.each { dep -> + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', dep.group) + dependencyNode.appendNode('artifactId', dep.name) + dependencyNode.appendNode('version', dep.version) + dependencyNode.appendNode('scope', 'compile') + } + asNode().dependencies[0].replaceNode(dependenciesNode) + } + } + } } diff --git a/alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java b/alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java index 79643affaf0..07e4256eb75 100644 --- a/alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java +++ b/alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java @@ -1,30 +1,15 @@ package io.grpc.alts.internal; import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** */ -@javax.annotation.Generated( - value = "by gRPC proto compiler", - comments = "Source: grpc/gcp/handshaker.proto") +@io.grpc.stub.annotations.GrpcGenerated public final class HandshakerServiceGrpc { private HandshakerServiceGrpc() {} - public static final String SERVICE_NAME = "grpc.gcp.HandshakerService"; + public static final java.lang.String SERVICE_NAME = "grpc.gcp.HandshakerService"; // Static method descriptors that strictly reflect the proto. private static volatile io.grpc.MethodDescriptor getDoHandshakeMethod() { if ((getDoHandshakeMethod = HandshakerServiceGrpc.getDoHandshakeMethod) == null) { synchronized (HandshakerServiceGrpc.class) { if ((getDoHandshakeMethod = HandshakerServiceGrpc.getDoHandshakeMethod) == null) { - HandshakerServiceGrpc.getDoHandshakeMethod = getDoHandshakeMethod = + HandshakerServiceGrpc.getDoHandshakeMethod = getDoHandshakeMethod = io.grpc.MethodDescriptor.newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) - .setFullMethodName(generateFullMethodName( - "grpc.gcp.HandshakerService", "DoHandshake")) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DoHandshake")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( io.grpc.alts.internal.HandshakerReq.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( io.grpc.alts.internal.HandshakerResp.getDefaultInstance())) - .setSchemaDescriptor(new HandshakerServiceMethodDescriptorSupplier("DoHandshake")) - .build(); - } + .setSchemaDescriptor(new HandshakerServiceMethodDescriptorSupplier("DoHandshake")) + .build(); } - } - return getDoHandshakeMethod; + } + } + return getDoHandshakeMethod; } /** * Creates a new async stub that supports all call types for the service */ public static HandshakerServiceStub newStub(io.grpc.Channel channel) { - return new HandshakerServiceStub(channel); + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public HandshakerServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new HandshakerServiceStub(channel, callOptions); + } + }; + return HandshakerServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports all types of calls on the service + */ + public static HandshakerServiceBlockingV2Stub newBlockingV2Stub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public HandshakerServiceBlockingV2Stub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new HandshakerServiceBlockingV2Stub(channel, callOptions); + } + }; + return HandshakerServiceBlockingV2Stub.newStub(factory, channel); } /** @@ -71,7 +77,14 @@ public static HandshakerServiceStub newStub(io.grpc.Channel channel) { */ public static HandshakerServiceBlockingStub newBlockingStub( io.grpc.Channel channel) { - return new HandshakerServiceBlockingStub(channel); + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public HandshakerServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new HandshakerServiceBlockingStub(channel, callOptions); + } + }; + return HandshakerServiceBlockingStub.newStub(factory, channel); } /** @@ -79,12 +92,19 @@ public static HandshakerServiceBlockingStub newBlockingStub( */ public static HandshakerServiceFutureStub newFutureStub( io.grpc.Channel channel) { - return new HandshakerServiceFutureStub(channel); + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public HandshakerServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new HandshakerServiceFutureStub(channel, callOptions); + } + }; + return HandshakerServiceFutureStub.newStub(factory, channel); } /** */ - public static abstract class HandshakerServiceImplBase implements io.grpc.BindableService { + public interface AsyncService { /** *
@@ -96,39 +116,36 @@ public static abstract class HandshakerServiceImplBase implements io.grpc.Bindab
      * response before sending next request.
      * 
*/ - public io.grpc.stub.StreamObserver doHandshake( + default io.grpc.stub.StreamObserver doHandshake( io.grpc.stub.StreamObserver responseObserver) { - return asyncUnimplementedStreamingCall(getDoHandshakeMethod(), responseObserver); + return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(getDoHandshakeMethod(), responseObserver); } + } + + /** + * Base class for the server implementation of the service HandshakerService. + */ + public static abstract class HandshakerServiceImplBase + implements io.grpc.BindableService, AsyncService { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getDoHandshakeMethod(), - asyncBidiStreamingCall( - new MethodHandlers< - io.grpc.alts.internal.HandshakerReq, - io.grpc.alts.internal.HandshakerResp>( - this, METHODID_DO_HANDSHAKE))) - .build(); + return HandshakerServiceGrpc.bindService(this); } } /** + * A stub to allow clients to do asynchronous rpc calls to service HandshakerService. */ - public static final class HandshakerServiceStub extends io.grpc.stub.AbstractStub { - private HandshakerServiceStub(io.grpc.Channel channel) { - super(channel); - } - - private HandshakerServiceStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { + public static final class HandshakerServiceStub + extends io.grpc.stub.AbstractAsyncStub { + private HandshakerServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); } @java.lang.Override - protected HandshakerServiceStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { + protected HandshakerServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new HandshakerServiceStub(channel, callOptions); } @@ -144,45 +161,75 @@ protected HandshakerServiceStub build(io.grpc.Channel channel, */ public io.grpc.stub.StreamObserver doHandshake( io.grpc.stub.StreamObserver responseObserver) { - return asyncBidiStreamingCall( + return io.grpc.stub.ClientCalls.asyncBidiStreamingCall( getChannel().newCall(getDoHandshakeMethod(), getCallOptions()), responseObserver); } } /** + * A stub to allow clients to do synchronous rpc calls to service HandshakerService. */ - public static final class HandshakerServiceBlockingStub extends io.grpc.stub.AbstractStub { - private HandshakerServiceBlockingStub(io.grpc.Channel channel) { - super(channel); + public static final class HandshakerServiceBlockingV2Stub + extends io.grpc.stub.AbstractBlockingStub { + private HandshakerServiceBlockingV2Stub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected HandshakerServiceBlockingV2Stub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new HandshakerServiceBlockingV2Stub(channel, callOptions); } - private HandshakerServiceBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { + /** + *
+     * Handshaker service accepts a stream of handshaker request, returning a
+     * stream of handshaker response. Client is expected to send exactly one
+     * message with either client_start or server_start followed by one or more
+     * messages with next. Each time client sends a request, the handshaker
+     * service expects to respond. Client does not have to wait for service's
+     * response before sending next request.
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall + doHandshake() { + return io.grpc.stub.ClientCalls.blockingBidiStreamingCall( + getChannel(), getDoHandshakeMethod(), getCallOptions()); + } + } + + /** + * A stub to allow clients to do limited synchronous rpc calls to service HandshakerService. + */ + public static final class HandshakerServiceBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private HandshakerServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); } @java.lang.Override - protected HandshakerServiceBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { + protected HandshakerServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new HandshakerServiceBlockingStub(channel, callOptions); } } /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service HandshakerService. */ - public static final class HandshakerServiceFutureStub extends io.grpc.stub.AbstractStub { - private HandshakerServiceFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private HandshakerServiceFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { + public static final class HandshakerServiceFutureStub + extends io.grpc.stub.AbstractFutureStub { + private HandshakerServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { super(channel, callOptions); } @java.lang.Override - protected HandshakerServiceFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { + protected HandshakerServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new HandshakerServiceFutureStub(channel, callOptions); } } @@ -194,10 +241,10 @@ private static final class MethodHandlers implements io.grpc.stub.ServerCalls.ServerStreamingMethod, io.grpc.stub.ServerCalls.ClientStreamingMethod, io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final HandshakerServiceImplBase serviceImpl; + private final AsyncService serviceImpl; private final int methodId; - MethodHandlers(HandshakerServiceImplBase serviceImpl, int methodId) { + MethodHandlers(AsyncService serviceImpl, int methodId) { this.serviceImpl = serviceImpl; this.methodId = methodId; } @@ -225,6 +272,18 @@ public io.grpc.stub.StreamObserver invoke( } } + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getDoHandshakeMethod(), + io.grpc.stub.ServerCalls.asyncBidiStreamingCall( + new MethodHandlers< + io.grpc.alts.internal.HandshakerReq, + io.grpc.alts.internal.HandshakerResp>( + service, METHODID_DO_HANDSHAKE))) + .build(); + } + private static abstract class HandshakerServiceBaseDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { HandshakerServiceBaseDescriptorSupplier() {} @@ -248,9 +307,9 @@ private static final class HandshakerServiceFileDescriptorSupplier private static final class HandshakerServiceMethodDescriptorSupplier extends HandshakerServiceBaseDescriptorSupplier implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; + private final java.lang.String methodName; - HandshakerServiceMethodDescriptorSupplier(String methodName) { + HandshakerServiceMethodDescriptorSupplier(java.lang.String methodName) { this.methodName = methodName; } diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/AltsContext.java b/alts/src/generated/main/java/io/grpc/alts/internal/AltsContext.java deleted file mode 100644 index b8dbb7b1a55..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/AltsContext.java +++ /dev/null @@ -1,1670 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/altscontext.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.AltsContext} - */ -public final class AltsContext extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.AltsContext) - AltsContextOrBuilder { -private static final long serialVersionUID = 0L; - // Use AltsContext.newBuilder() to construct. - private AltsContext(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private AltsContext() { - applicationProtocol_ = ""; - recordProtocol_ = ""; - securityLevel_ = 0; - peerServiceAccount_ = ""; - localServiceAccount_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private AltsContext( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - applicationProtocol_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - recordProtocol_ = s; - break; - } - case 24: { - int rawValue = input.readEnum(); - - securityLevel_ = rawValue; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); - - peerServiceAccount_ = s; - break; - } - case 42: { - java.lang.String s = input.readStringRequireUtf8(); - - localServiceAccount_ = s; - break; - } - case 50: { - io.grpc.alts.internal.RpcProtocolVersions.Builder subBuilder = null; - if (peerRpcVersions_ != null) { - subBuilder = peerRpcVersions_.toBuilder(); - } - peerRpcVersions_ = input.readMessage(io.grpc.alts.internal.RpcProtocolVersions.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(peerRpcVersions_); - peerRpcVersions_ = subBuilder.buildPartial(); - } - - break; - } - case 58: { - if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - peerAttributes_ = com.google.protobuf.MapField.newMapField( - PeerAttributesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000040; - } - com.google.protobuf.MapEntry - peerAttributes__ = input.readMessage( - PeerAttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - peerAttributes_.getMutableMap().put( - peerAttributes__.getKey(), peerAttributes__.getValue()); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.AltsContextProto.internal_static_grpc_gcp_AltsContext_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 7: - return internalGetPeerAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.AltsContextProto.internal_static_grpc_gcp_AltsContext_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.AltsContext.class, io.grpc.alts.internal.AltsContext.Builder.class); - } - - private int bitField0_; - public static final int APPLICATION_PROTOCOL_FIELD_NUMBER = 1; - private volatile java.lang.Object applicationProtocol_; - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - public java.lang.String getApplicationProtocol() { - java.lang.Object ref = applicationProtocol_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - applicationProtocol_ = s; - return s; - } - } - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - public com.google.protobuf.ByteString - getApplicationProtocolBytes() { - java.lang.Object ref = applicationProtocol_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - applicationProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RECORD_PROTOCOL_FIELD_NUMBER = 2; - private volatile java.lang.Object recordProtocol_; - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - public java.lang.String getRecordProtocol() { - java.lang.Object ref = recordProtocol_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - recordProtocol_ = s; - return s; - } - } - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - public com.google.protobuf.ByteString - getRecordProtocolBytes() { - java.lang.Object ref = recordProtocol_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - recordProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SECURITY_LEVEL_FIELD_NUMBER = 3; - private int securityLevel_; - /** - *
-   * The security level of the created secure channel.
-   * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public int getSecurityLevelValue() { - return securityLevel_; - } - /** - *
-   * The security level of the created secure channel.
-   * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public io.grpc.alts.internal.SecurityLevel getSecurityLevel() { - io.grpc.alts.internal.SecurityLevel result = io.grpc.alts.internal.SecurityLevel.valueOf(securityLevel_); - return result == null ? io.grpc.alts.internal.SecurityLevel.UNRECOGNIZED : result; - } - - public static final int PEER_SERVICE_ACCOUNT_FIELD_NUMBER = 4; - private volatile java.lang.Object peerServiceAccount_; - /** - *
-   * The peer service account.
-   * 
- * - * string peer_service_account = 4; - */ - public java.lang.String getPeerServiceAccount() { - java.lang.Object ref = peerServiceAccount_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - peerServiceAccount_ = s; - return s; - } - } - /** - *
-   * The peer service account.
-   * 
- * - * string peer_service_account = 4; - */ - public com.google.protobuf.ByteString - getPeerServiceAccountBytes() { - java.lang.Object ref = peerServiceAccount_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - peerServiceAccount_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int LOCAL_SERVICE_ACCOUNT_FIELD_NUMBER = 5; - private volatile java.lang.Object localServiceAccount_; - /** - *
-   * The local service account.
-   * 
- * - * string local_service_account = 5; - */ - public java.lang.String getLocalServiceAccount() { - java.lang.Object ref = localServiceAccount_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - localServiceAccount_ = s; - return s; - } - } - /** - *
-   * The local service account.
-   * 
- * - * string local_service_account = 5; - */ - public com.google.protobuf.ByteString - getLocalServiceAccountBytes() { - java.lang.Object ref = localServiceAccount_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - localServiceAccount_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PEER_RPC_VERSIONS_FIELD_NUMBER = 6; - private io.grpc.alts.internal.RpcProtocolVersions peerRpcVersions_; - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public boolean hasPeerRpcVersions() { - return peerRpcVersions_ != null; - } - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersions getPeerRpcVersions() { - return peerRpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : peerRpcVersions_; - } - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getPeerRpcVersionsOrBuilder() { - return getPeerRpcVersions(); - } - - public static final int PEER_ATTRIBUTES_FIELD_NUMBER = 7; - private static final class PeerAttributesDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.String> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - io.grpc.alts.internal.AltsContextProto.internal_static_grpc_gcp_AltsContext_PeerAttributesEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> peerAttributes_; - private com.google.protobuf.MapField - internalGetPeerAttributes() { - if (peerAttributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - PeerAttributesDefaultEntryHolder.defaultEntry); - } - return peerAttributes_; - } - - public int getPeerAttributesCount() { - return internalGetPeerAttributes().getMap().size(); - } - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - - public boolean containsPeerAttributes( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetPeerAttributes().getMap().containsKey(key); - } - /** - * Use {@link #getPeerAttributesMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getPeerAttributes() { - return getPeerAttributesMap(); - } - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - - public java.util.Map getPeerAttributesMap() { - return internalGetPeerAttributes().getMap(); - } - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - - public java.lang.String getPeerAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetPeerAttributes().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - - public java.lang.String getPeerAttributesOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetPeerAttributes().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getApplicationProtocolBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, applicationProtocol_); - } - if (!getRecordProtocolBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, recordProtocol_); - } - if (securityLevel_ != io.grpc.alts.internal.SecurityLevel.SECURITY_NONE.getNumber()) { - output.writeEnum(3, securityLevel_); - } - if (!getPeerServiceAccountBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, peerServiceAccount_); - } - if (!getLocalServiceAccountBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, localServiceAccount_); - } - if (peerRpcVersions_ != null) { - output.writeMessage(6, getPeerRpcVersions()); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetPeerAttributes(), - PeerAttributesDefaultEntryHolder.defaultEntry, - 7); - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getApplicationProtocolBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, applicationProtocol_); - } - if (!getRecordProtocolBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, recordProtocol_); - } - if (securityLevel_ != io.grpc.alts.internal.SecurityLevel.SECURITY_NONE.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(3, securityLevel_); - } - if (!getPeerServiceAccountBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, peerServiceAccount_); - } - if (!getLocalServiceAccountBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, localServiceAccount_); - } - if (peerRpcVersions_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, getPeerRpcVersions()); - } - for (java.util.Map.Entry entry - : internalGetPeerAttributes().getMap().entrySet()) { - com.google.protobuf.MapEntry - peerAttributes__ = PeerAttributesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, peerAttributes__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.AltsContext)) { - return super.equals(obj); - } - io.grpc.alts.internal.AltsContext other = (io.grpc.alts.internal.AltsContext) obj; - - boolean result = true; - result = result && getApplicationProtocol() - .equals(other.getApplicationProtocol()); - result = result && getRecordProtocol() - .equals(other.getRecordProtocol()); - result = result && securityLevel_ == other.securityLevel_; - result = result && getPeerServiceAccount() - .equals(other.getPeerServiceAccount()); - result = result && getLocalServiceAccount() - .equals(other.getLocalServiceAccount()); - result = result && (hasPeerRpcVersions() == other.hasPeerRpcVersions()); - if (hasPeerRpcVersions()) { - result = result && getPeerRpcVersions() - .equals(other.getPeerRpcVersions()); - } - result = result && internalGetPeerAttributes().equals( - other.internalGetPeerAttributes()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + APPLICATION_PROTOCOL_FIELD_NUMBER; - hash = (53 * hash) + getApplicationProtocol().hashCode(); - hash = (37 * hash) + RECORD_PROTOCOL_FIELD_NUMBER; - hash = (53 * hash) + getRecordProtocol().hashCode(); - hash = (37 * hash) + SECURITY_LEVEL_FIELD_NUMBER; - hash = (53 * hash) + securityLevel_; - hash = (37 * hash) + PEER_SERVICE_ACCOUNT_FIELD_NUMBER; - hash = (53 * hash) + getPeerServiceAccount().hashCode(); - hash = (37 * hash) + LOCAL_SERVICE_ACCOUNT_FIELD_NUMBER; - hash = (53 * hash) + getLocalServiceAccount().hashCode(); - if (hasPeerRpcVersions()) { - hash = (37 * hash) + PEER_RPC_VERSIONS_FIELD_NUMBER; - hash = (53 * hash) + getPeerRpcVersions().hashCode(); - } - if (!internalGetPeerAttributes().getMap().isEmpty()) { - hash = (37 * hash) + PEER_ATTRIBUTES_FIELD_NUMBER; - hash = (53 * hash) + internalGetPeerAttributes().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.AltsContext parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.AltsContext parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.AltsContext parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.AltsContext parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.AltsContext parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.AltsContext parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.AltsContext prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.AltsContext} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.AltsContext) - io.grpc.alts.internal.AltsContextOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.AltsContextProto.internal_static_grpc_gcp_AltsContext_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 7: - return internalGetPeerAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 7: - return internalGetMutablePeerAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.AltsContextProto.internal_static_grpc_gcp_AltsContext_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.AltsContext.class, io.grpc.alts.internal.AltsContext.Builder.class); - } - - // Construct using io.grpc.alts.internal.AltsContext.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - applicationProtocol_ = ""; - - recordProtocol_ = ""; - - securityLevel_ = 0; - - peerServiceAccount_ = ""; - - localServiceAccount_ = ""; - - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersions_ = null; - } else { - peerRpcVersions_ = null; - peerRpcVersionsBuilder_ = null; - } - internalGetMutablePeerAttributes().clear(); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.AltsContextProto.internal_static_grpc_gcp_AltsContext_descriptor; - } - - public io.grpc.alts.internal.AltsContext getDefaultInstanceForType() { - return io.grpc.alts.internal.AltsContext.getDefaultInstance(); - } - - public io.grpc.alts.internal.AltsContext build() { - io.grpc.alts.internal.AltsContext result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.AltsContext buildPartial() { - io.grpc.alts.internal.AltsContext result = new io.grpc.alts.internal.AltsContext(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.applicationProtocol_ = applicationProtocol_; - result.recordProtocol_ = recordProtocol_; - result.securityLevel_ = securityLevel_; - result.peerServiceAccount_ = peerServiceAccount_; - result.localServiceAccount_ = localServiceAccount_; - if (peerRpcVersionsBuilder_ == null) { - result.peerRpcVersions_ = peerRpcVersions_; - } else { - result.peerRpcVersions_ = peerRpcVersionsBuilder_.build(); - } - result.peerAttributes_ = internalGetPeerAttributes(); - result.peerAttributes_.makeImmutable(); - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.AltsContext) { - return mergeFrom((io.grpc.alts.internal.AltsContext)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.AltsContext other) { - if (other == io.grpc.alts.internal.AltsContext.getDefaultInstance()) return this; - if (!other.getApplicationProtocol().isEmpty()) { - applicationProtocol_ = other.applicationProtocol_; - onChanged(); - } - if (!other.getRecordProtocol().isEmpty()) { - recordProtocol_ = other.recordProtocol_; - onChanged(); - } - if (other.securityLevel_ != 0) { - setSecurityLevelValue(other.getSecurityLevelValue()); - } - if (!other.getPeerServiceAccount().isEmpty()) { - peerServiceAccount_ = other.peerServiceAccount_; - onChanged(); - } - if (!other.getLocalServiceAccount().isEmpty()) { - localServiceAccount_ = other.localServiceAccount_; - onChanged(); - } - if (other.hasPeerRpcVersions()) { - mergePeerRpcVersions(other.getPeerRpcVersions()); - } - internalGetMutablePeerAttributes().mergeFrom( - other.internalGetPeerAttributes()); - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.AltsContext parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.AltsContext) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object applicationProtocol_ = ""; - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public java.lang.String getApplicationProtocol() { - java.lang.Object ref = applicationProtocol_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - applicationProtocol_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public com.google.protobuf.ByteString - getApplicationProtocolBytes() { - java.lang.Object ref = applicationProtocol_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - applicationProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public Builder setApplicationProtocol( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - applicationProtocol_ = value; - onChanged(); - return this; - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public Builder clearApplicationProtocol() { - - applicationProtocol_ = getDefaultInstance().getApplicationProtocol(); - onChanged(); - return this; - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public Builder setApplicationProtocolBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - applicationProtocol_ = value; - onChanged(); - return this; - } - - private java.lang.Object recordProtocol_ = ""; - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public java.lang.String getRecordProtocol() { - java.lang.Object ref = recordProtocol_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - recordProtocol_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public com.google.protobuf.ByteString - getRecordProtocolBytes() { - java.lang.Object ref = recordProtocol_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - recordProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public Builder setRecordProtocol( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - recordProtocol_ = value; - onChanged(); - return this; - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public Builder clearRecordProtocol() { - - recordProtocol_ = getDefaultInstance().getRecordProtocol(); - onChanged(); - return this; - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public Builder setRecordProtocolBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - recordProtocol_ = value; - onChanged(); - return this; - } - - private int securityLevel_ = 0; - /** - *
-     * The security level of the created secure channel.
-     * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public int getSecurityLevelValue() { - return securityLevel_; - } - /** - *
-     * The security level of the created secure channel.
-     * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public Builder setSecurityLevelValue(int value) { - securityLevel_ = value; - onChanged(); - return this; - } - /** - *
-     * The security level of the created secure channel.
-     * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public io.grpc.alts.internal.SecurityLevel getSecurityLevel() { - io.grpc.alts.internal.SecurityLevel result = io.grpc.alts.internal.SecurityLevel.valueOf(securityLevel_); - return result == null ? io.grpc.alts.internal.SecurityLevel.UNRECOGNIZED : result; - } - /** - *
-     * The security level of the created secure channel.
-     * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public Builder setSecurityLevel(io.grpc.alts.internal.SecurityLevel value) { - if (value == null) { - throw new NullPointerException(); - } - - securityLevel_ = value.getNumber(); - onChanged(); - return this; - } - /** - *
-     * The security level of the created secure channel.
-     * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - public Builder clearSecurityLevel() { - - securityLevel_ = 0; - onChanged(); - return this; - } - - private java.lang.Object peerServiceAccount_ = ""; - /** - *
-     * The peer service account.
-     * 
- * - * string peer_service_account = 4; - */ - public java.lang.String getPeerServiceAccount() { - java.lang.Object ref = peerServiceAccount_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - peerServiceAccount_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The peer service account.
-     * 
- * - * string peer_service_account = 4; - */ - public com.google.protobuf.ByteString - getPeerServiceAccountBytes() { - java.lang.Object ref = peerServiceAccount_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - peerServiceAccount_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The peer service account.
-     * 
- * - * string peer_service_account = 4; - */ - public Builder setPeerServiceAccount( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - peerServiceAccount_ = value; - onChanged(); - return this; - } - /** - *
-     * The peer service account.
-     * 
- * - * string peer_service_account = 4; - */ - public Builder clearPeerServiceAccount() { - - peerServiceAccount_ = getDefaultInstance().getPeerServiceAccount(); - onChanged(); - return this; - } - /** - *
-     * The peer service account.
-     * 
- * - * string peer_service_account = 4; - */ - public Builder setPeerServiceAccountBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - peerServiceAccount_ = value; - onChanged(); - return this; - } - - private java.lang.Object localServiceAccount_ = ""; - /** - *
-     * The local service account.
-     * 
- * - * string local_service_account = 5; - */ - public java.lang.String getLocalServiceAccount() { - java.lang.Object ref = localServiceAccount_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - localServiceAccount_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The local service account.
-     * 
- * - * string local_service_account = 5; - */ - public com.google.protobuf.ByteString - getLocalServiceAccountBytes() { - java.lang.Object ref = localServiceAccount_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - localServiceAccount_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The local service account.
-     * 
- * - * string local_service_account = 5; - */ - public Builder setLocalServiceAccount( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - localServiceAccount_ = value; - onChanged(); - return this; - } - /** - *
-     * The local service account.
-     * 
- * - * string local_service_account = 5; - */ - public Builder clearLocalServiceAccount() { - - localServiceAccount_ = getDefaultInstance().getLocalServiceAccount(); - onChanged(); - return this; - } - /** - *
-     * The local service account.
-     * 
- * - * string local_service_account = 5; - */ - public Builder setLocalServiceAccountBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - localServiceAccount_ = value; - onChanged(); - return this; - } - - private io.grpc.alts.internal.RpcProtocolVersions peerRpcVersions_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> peerRpcVersionsBuilder_; - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public boolean hasPeerRpcVersions() { - return peerRpcVersionsBuilder_ != null || peerRpcVersions_ != null; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersions getPeerRpcVersions() { - if (peerRpcVersionsBuilder_ == null) { - return peerRpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : peerRpcVersions_; - } else { - return peerRpcVersionsBuilder_.getMessage(); - } - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public Builder setPeerRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (peerRpcVersionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - peerRpcVersions_ = value; - onChanged(); - } else { - peerRpcVersionsBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public Builder setPeerRpcVersions( - io.grpc.alts.internal.RpcProtocolVersions.Builder builderForValue) { - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersions_ = builderForValue.build(); - onChanged(); - } else { - peerRpcVersionsBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public Builder mergePeerRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (peerRpcVersionsBuilder_ == null) { - if (peerRpcVersions_ != null) { - peerRpcVersions_ = - io.grpc.alts.internal.RpcProtocolVersions.newBuilder(peerRpcVersions_).mergeFrom(value).buildPartial(); - } else { - peerRpcVersions_ = value; - } - onChanged(); - } else { - peerRpcVersionsBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public Builder clearPeerRpcVersions() { - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersions_ = null; - onChanged(); - } else { - peerRpcVersions_ = null; - peerRpcVersionsBuilder_ = null; - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Builder getPeerRpcVersionsBuilder() { - - onChanged(); - return getPeerRpcVersionsFieldBuilder().getBuilder(); - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getPeerRpcVersionsOrBuilder() { - if (peerRpcVersionsBuilder_ != null) { - return peerRpcVersionsBuilder_.getMessageOrBuilder(); - } else { - return peerRpcVersions_ == null ? - io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : peerRpcVersions_; - } - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> - getPeerRpcVersionsFieldBuilder() { - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder>( - getPeerRpcVersions(), - getParentForChildren(), - isClean()); - peerRpcVersions_ = null; - } - return peerRpcVersionsBuilder_; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> peerAttributes_; - private com.google.protobuf.MapField - internalGetPeerAttributes() { - if (peerAttributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - PeerAttributesDefaultEntryHolder.defaultEntry); - } - return peerAttributes_; - } - private com.google.protobuf.MapField - internalGetMutablePeerAttributes() { - onChanged();; - if (peerAttributes_ == null) { - peerAttributes_ = com.google.protobuf.MapField.newMapField( - PeerAttributesDefaultEntryHolder.defaultEntry); - } - if (!peerAttributes_.isMutable()) { - peerAttributes_ = peerAttributes_.copy(); - } - return peerAttributes_; - } - - public int getPeerAttributesCount() { - return internalGetPeerAttributes().getMap().size(); - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - - public boolean containsPeerAttributes( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetPeerAttributes().getMap().containsKey(key); - } - /** - * Use {@link #getPeerAttributesMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getPeerAttributes() { - return getPeerAttributesMap(); - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - - public java.util.Map getPeerAttributesMap() { - return internalGetPeerAttributes().getMap(); - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - - public java.lang.String getPeerAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetPeerAttributes().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - - public java.lang.String getPeerAttributesOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetPeerAttributes().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearPeerAttributes() { - internalGetMutablePeerAttributes().getMutableMap() - .clear(); - return this; - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - - public Builder removePeerAttributes( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - internalGetMutablePeerAttributes().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutablePeerAttributes() { - return internalGetMutablePeerAttributes().getMutableMap(); - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - public Builder putPeerAttributes( - java.lang.String key, - java.lang.String value) { - if (key == null) { throw new java.lang.NullPointerException(); } - if (value == null) { throw new java.lang.NullPointerException(); } - internalGetMutablePeerAttributes().getMutableMap() - .put(key, value); - return this; - } - /** - *
-     * Additional attributes of the peer.
-     * 
- * - * map<string, string> peer_attributes = 7; - */ - - public Builder putAllPeerAttributes( - java.util.Map values) { - internalGetMutablePeerAttributes().getMutableMap() - .putAll(values); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.AltsContext) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.AltsContext) - private static final io.grpc.alts.internal.AltsContext DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.AltsContext(); - } - - public static io.grpc.alts.internal.AltsContext getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public AltsContext parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new AltsContext(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.AltsContext getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/AltsContextOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/AltsContextOrBuilder.java deleted file mode 100644 index ee8cfe13f37..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/AltsContextOrBuilder.java +++ /dev/null @@ -1,177 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/altscontext.proto - -package io.grpc.alts.internal; - -public interface AltsContextOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.AltsContext) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - java.lang.String getApplicationProtocol(); - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - com.google.protobuf.ByteString - getApplicationProtocolBytes(); - - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - java.lang.String getRecordProtocol(); - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - com.google.protobuf.ByteString - getRecordProtocolBytes(); - - /** - *
-   * The security level of the created secure channel.
-   * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - int getSecurityLevelValue(); - /** - *
-   * The security level of the created secure channel.
-   * 
- * - * .grpc.gcp.SecurityLevel security_level = 3; - */ - io.grpc.alts.internal.SecurityLevel getSecurityLevel(); - - /** - *
-   * The peer service account.
-   * 
- * - * string peer_service_account = 4; - */ - java.lang.String getPeerServiceAccount(); - /** - *
-   * The peer service account.
-   * 
- * - * string peer_service_account = 4; - */ - com.google.protobuf.ByteString - getPeerServiceAccountBytes(); - - /** - *
-   * The local service account.
-   * 
- * - * string local_service_account = 5; - */ - java.lang.String getLocalServiceAccount(); - /** - *
-   * The local service account.
-   * 
- * - * string local_service_account = 5; - */ - com.google.protobuf.ByteString - getLocalServiceAccountBytes(); - - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - boolean hasPeerRpcVersions(); - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - io.grpc.alts.internal.RpcProtocolVersions getPeerRpcVersions(); - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 6; - */ - io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getPeerRpcVersionsOrBuilder(); - - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - int getPeerAttributesCount(); - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - boolean containsPeerAttributes( - java.lang.String key); - /** - * Use {@link #getPeerAttributesMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getPeerAttributes(); - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - java.util.Map - getPeerAttributesMap(); - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - - java.lang.String getPeerAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue); - /** - *
-   * Additional attributes of the peer.
-   * 
- * - * map<string, string> peer_attributes = 7; - */ - - java.lang.String getPeerAttributesOrThrow( - java.lang.String key); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/AltsContextProto.java b/alts/src/generated/main/java/io/grpc/alts/internal/AltsContextProto.java deleted file mode 100644 index da27b405376..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/AltsContextProto.java +++ /dev/null @@ -1,80 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/altscontext.proto - -package io.grpc.alts.internal; - -public final class AltsContextProto { - private AltsContextProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_AltsContext_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_AltsContext_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_AltsContext_PeerAttributesEntry_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_AltsContext_PeerAttributesEntry_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\032grpc/gcp/altscontext.proto\022\010grpc.gcp\032(" + - "grpc/gcp/transport_security_common.proto" + - "\"\347\002\n\013AltsContext\022\034\n\024application_protocol" + - "\030\001 \001(\t\022\027\n\017record_protocol\030\002 \001(\t\022/\n\016secur" + - "ity_level\030\003 \001(\0162\027.grpc.gcp.SecurityLevel" + - "\022\034\n\024peer_service_account\030\004 \001(\t\022\035\n\025local_" + - "service_account\030\005 \001(\t\0228\n\021peer_rpc_versio" + - "ns\030\006 \001(\0132\035.grpc.gcp.RpcProtocolVersions\022" + - "B\n\017peer_attributes\030\007 \003(\0132).grpc.gcp.Alts" + - "Context.PeerAttributesEntry\0325\n\023PeerAttri" + - "butesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\002" + - "8\001Bl\n\025io.grpc.alts.internalB\020AltsContext" + - "ProtoP\001Z?google.golang.org/grpc/credenti" + - "als/alts/internal/proto/grpc_gcpb\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - io.grpc.alts.internal.TransportSecurityCommonProto.getDescriptor(), - }, assigner); - internal_static_grpc_gcp_AltsContext_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_grpc_gcp_AltsContext_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_AltsContext_descriptor, - new java.lang.String[] { "ApplicationProtocol", "RecordProtocol", "SecurityLevel", "PeerServiceAccount", "LocalServiceAccount", "PeerRpcVersions", "PeerAttributes", }); - internal_static_grpc_gcp_AltsContext_PeerAttributesEntry_descriptor = - internal_static_grpc_gcp_AltsContext_descriptor.getNestedTypes().get(0); - internal_static_grpc_gcp_AltsContext_PeerAttributesEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_AltsContext_PeerAttributesEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - io.grpc.alts.internal.TransportSecurityCommonProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/Endpoint.java b/alts/src/generated/main/java/io/grpc/alts/internal/Endpoint.java deleted file mode 100644 index 4d5f08d4134..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/Endpoint.java +++ /dev/null @@ -1,736 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.Endpoint} - */ -public final class Endpoint extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.Endpoint) - EndpointOrBuilder { -private static final long serialVersionUID = 0L; - // Use Endpoint.newBuilder() to construct. - private Endpoint(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Endpoint() { - ipAddress_ = ""; - port_ = 0; - protocol_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Endpoint( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - ipAddress_ = s; - break; - } - case 16: { - - port_ = input.readInt32(); - break; - } - case 24: { - int rawValue = input.readEnum(); - - protocol_ = rawValue; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Endpoint_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Endpoint_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.Endpoint.class, io.grpc.alts.internal.Endpoint.Builder.class); - } - - public static final int IP_ADDRESS_FIELD_NUMBER = 1; - private volatile java.lang.Object ipAddress_; - /** - *
-   * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-   * "192.168.0.1" or "2001:db8::1".
-   * 
- * - * string ip_address = 1; - */ - public java.lang.String getIpAddress() { - java.lang.Object ref = ipAddress_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - ipAddress_ = s; - return s; - } - } - /** - *
-   * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-   * "192.168.0.1" or "2001:db8::1".
-   * 
- * - * string ip_address = 1; - */ - public com.google.protobuf.ByteString - getIpAddressBytes() { - java.lang.Object ref = ipAddress_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - ipAddress_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PORT_FIELD_NUMBER = 2; - private int port_; - /** - *
-   * Port number.
-   * 
- * - * int32 port = 2; - */ - public int getPort() { - return port_; - } - - public static final int PROTOCOL_FIELD_NUMBER = 3; - private int protocol_; - /** - *
-   * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-   * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public int getProtocolValue() { - return protocol_; - } - /** - *
-   * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-   * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public io.grpc.alts.internal.NetworkProtocol getProtocol() { - io.grpc.alts.internal.NetworkProtocol result = io.grpc.alts.internal.NetworkProtocol.valueOf(protocol_); - return result == null ? io.grpc.alts.internal.NetworkProtocol.UNRECOGNIZED : result; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getIpAddressBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, ipAddress_); - } - if (port_ != 0) { - output.writeInt32(2, port_); - } - if (protocol_ != io.grpc.alts.internal.NetworkProtocol.NETWORK_PROTOCOL_UNSPECIFIED.getNumber()) { - output.writeEnum(3, protocol_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getIpAddressBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, ipAddress_); - } - if (port_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, port_); - } - if (protocol_ != io.grpc.alts.internal.NetworkProtocol.NETWORK_PROTOCOL_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(3, protocol_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.Endpoint)) { - return super.equals(obj); - } - io.grpc.alts.internal.Endpoint other = (io.grpc.alts.internal.Endpoint) obj; - - boolean result = true; - result = result && getIpAddress() - .equals(other.getIpAddress()); - result = result && (getPort() - == other.getPort()); - result = result && protocol_ == other.protocol_; - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + IP_ADDRESS_FIELD_NUMBER; - hash = (53 * hash) + getIpAddress().hashCode(); - hash = (37 * hash) + PORT_FIELD_NUMBER; - hash = (53 * hash) + getPort(); - hash = (37 * hash) + PROTOCOL_FIELD_NUMBER; - hash = (53 * hash) + protocol_; - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.Endpoint parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.Endpoint parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.Endpoint parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.Endpoint parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.Endpoint parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.Endpoint parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.Endpoint prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.Endpoint} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.Endpoint) - io.grpc.alts.internal.EndpointOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Endpoint_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Endpoint_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.Endpoint.class, io.grpc.alts.internal.Endpoint.Builder.class); - } - - // Construct using io.grpc.alts.internal.Endpoint.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - ipAddress_ = ""; - - port_ = 0; - - protocol_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Endpoint_descriptor; - } - - public io.grpc.alts.internal.Endpoint getDefaultInstanceForType() { - return io.grpc.alts.internal.Endpoint.getDefaultInstance(); - } - - public io.grpc.alts.internal.Endpoint build() { - io.grpc.alts.internal.Endpoint result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.Endpoint buildPartial() { - io.grpc.alts.internal.Endpoint result = new io.grpc.alts.internal.Endpoint(this); - result.ipAddress_ = ipAddress_; - result.port_ = port_; - result.protocol_ = protocol_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.Endpoint) { - return mergeFrom((io.grpc.alts.internal.Endpoint)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.Endpoint other) { - if (other == io.grpc.alts.internal.Endpoint.getDefaultInstance()) return this; - if (!other.getIpAddress().isEmpty()) { - ipAddress_ = other.ipAddress_; - onChanged(); - } - if (other.getPort() != 0) { - setPort(other.getPort()); - } - if (other.protocol_ != 0) { - setProtocolValue(other.getProtocolValue()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.Endpoint parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.Endpoint) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object ipAddress_ = ""; - /** - *
-     * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-     * "192.168.0.1" or "2001:db8::1".
-     * 
- * - * string ip_address = 1; - */ - public java.lang.String getIpAddress() { - java.lang.Object ref = ipAddress_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - ipAddress_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-     * "192.168.0.1" or "2001:db8::1".
-     * 
- * - * string ip_address = 1; - */ - public com.google.protobuf.ByteString - getIpAddressBytes() { - java.lang.Object ref = ipAddress_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - ipAddress_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-     * "192.168.0.1" or "2001:db8::1".
-     * 
- * - * string ip_address = 1; - */ - public Builder setIpAddress( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - ipAddress_ = value; - onChanged(); - return this; - } - /** - *
-     * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-     * "192.168.0.1" or "2001:db8::1".
-     * 
- * - * string ip_address = 1; - */ - public Builder clearIpAddress() { - - ipAddress_ = getDefaultInstance().getIpAddress(); - onChanged(); - return this; - } - /** - *
-     * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-     * "192.168.0.1" or "2001:db8::1".
-     * 
- * - * string ip_address = 1; - */ - public Builder setIpAddressBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - ipAddress_ = value; - onChanged(); - return this; - } - - private int port_ ; - /** - *
-     * Port number.
-     * 
- * - * int32 port = 2; - */ - public int getPort() { - return port_; - } - /** - *
-     * Port number.
-     * 
- * - * int32 port = 2; - */ - public Builder setPort(int value) { - - port_ = value; - onChanged(); - return this; - } - /** - *
-     * Port number.
-     * 
- * - * int32 port = 2; - */ - public Builder clearPort() { - - port_ = 0; - onChanged(); - return this; - } - - private int protocol_ = 0; - /** - *
-     * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-     * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public int getProtocolValue() { - return protocol_; - } - /** - *
-     * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-     * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public Builder setProtocolValue(int value) { - protocol_ = value; - onChanged(); - return this; - } - /** - *
-     * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-     * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public io.grpc.alts.internal.NetworkProtocol getProtocol() { - io.grpc.alts.internal.NetworkProtocol result = io.grpc.alts.internal.NetworkProtocol.valueOf(protocol_); - return result == null ? io.grpc.alts.internal.NetworkProtocol.UNRECOGNIZED : result; - } - /** - *
-     * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-     * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public Builder setProtocol(io.grpc.alts.internal.NetworkProtocol value) { - if (value == null) { - throw new NullPointerException(); - } - - protocol_ = value.getNumber(); - onChanged(); - return this; - } - /** - *
-     * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-     * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - public Builder clearProtocol() { - - protocol_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.Endpoint) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.Endpoint) - private static final io.grpc.alts.internal.Endpoint DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.Endpoint(); - } - - public static io.grpc.alts.internal.Endpoint getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Endpoint parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Endpoint(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.Endpoint getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/EndpointOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/EndpointOrBuilder.java deleted file mode 100644 index 25ae0fe8206..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/EndpointOrBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface EndpointOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.Endpoint) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-   * "192.168.0.1" or "2001:db8::1".
-   * 
- * - * string ip_address = 1; - */ - java.lang.String getIpAddress(); - /** - *
-   * IP address. It should contain an IPv4 or IPv6 string literal, e.g.
-   * "192.168.0.1" or "2001:db8::1".
-   * 
- * - * string ip_address = 1; - */ - com.google.protobuf.ByteString - getIpAddressBytes(); - - /** - *
-   * Port number.
-   * 
- * - * int32 port = 2; - */ - int getPort(); - - /** - *
-   * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-   * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - int getProtocolValue(); - /** - *
-   * Network protocol (e.g., TCP, UDP) associated with this endpoint.
-   * 
- * - * .grpc.gcp.NetworkProtocol protocol = 3; - */ - io.grpc.alts.internal.NetworkProtocol getProtocol(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakeProtocol.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakeProtocol.java deleted file mode 100644 index 6be49fe03e6..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakeProtocol.java +++ /dev/null @@ -1,136 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf enum {@code grpc.gcp.HandshakeProtocol} - */ -public enum HandshakeProtocol - implements com.google.protobuf.ProtocolMessageEnum { - /** - *
-   * Default value.
-   * 
- * - * HANDSHAKE_PROTOCOL_UNSPECIFIED = 0; - */ - HANDSHAKE_PROTOCOL_UNSPECIFIED(0), - /** - *
-   * TLS handshake protocol.
-   * 
- * - * TLS = 1; - */ - TLS(1), - /** - *
-   * Application Layer Transport Security handshake protocol.
-   * 
- * - * ALTS = 2; - */ - ALTS(2), - UNRECOGNIZED(-1), - ; - - /** - *
-   * Default value.
-   * 
- * - * HANDSHAKE_PROTOCOL_UNSPECIFIED = 0; - */ - public static final int HANDSHAKE_PROTOCOL_UNSPECIFIED_VALUE = 0; - /** - *
-   * TLS handshake protocol.
-   * 
- * - * TLS = 1; - */ - public static final int TLS_VALUE = 1; - /** - *
-   * Application Layer Transport Security handshake protocol.
-   * 
- * - * ALTS = 2; - */ - public static final int ALTS_VALUE = 2; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static HandshakeProtocol valueOf(int value) { - return forNumber(value); - } - - public static HandshakeProtocol forNumber(int value) { - switch (value) { - case 0: return HANDSHAKE_PROTOCOL_UNSPECIFIED; - case 1: return TLS; - case 2: return ALTS; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - HandshakeProtocol> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public HandshakeProtocol findValueByNumber(int number) { - return HandshakeProtocol.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.getDescriptor().getEnumTypes().get(0); - } - - private static final HandshakeProtocol[] VALUES = values(); - - public static HandshakeProtocol valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private HandshakeProtocol(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:grpc.gcp.HandshakeProtocol) -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerProto.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerProto.java deleted file mode 100644 index 60ffa51a739..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerProto.java +++ /dev/null @@ -1,235 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public final class HandshakerProto { - private HandshakerProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_Endpoint_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_Endpoint_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_Identity_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_Identity_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_Identity_AttributesEntry_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_Identity_AttributesEntry_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_StartClientHandshakeReq_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_StartClientHandshakeReq_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_ServerHandshakeParameters_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_ServerHandshakeParameters_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_StartServerHandshakeReq_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_StartServerHandshakeReq_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_NextHandshakeMessageReq_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_NextHandshakeMessageReq_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_HandshakerReq_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_HandshakerReq_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_HandshakerResult_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_HandshakerResult_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_HandshakerStatus_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_HandshakerStatus_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_HandshakerResp_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_HandshakerResp_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\031grpc/gcp/handshaker.proto\022\010grpc.gcp\032(g" + - "rpc/gcp/transport_security_common.proto\"" + - "Y\n\010Endpoint\022\022\n\nip_address\030\001 \001(\t\022\014\n\004port\030" + - "\002 \001(\005\022+\n\010protocol\030\003 \001(\0162\031.grpc.gcp.Netwo" + - "rkProtocol\"\266\001\n\010Identity\022\031\n\017service_accou" + - "nt\030\001 \001(\tH\000\022\022\n\010hostname\030\002 \001(\tH\000\0226\n\nattrib" + - "utes\030\003 \003(\0132\".grpc.gcp.Identity.Attribute" + - "sEntry\0321\n\017AttributesEntry\022\013\n\003key\030\001 \001(\t\022\r" + - "\n\005value\030\002 \001(\t:\0028\001B\020\n\016identity_oneof\"\222\003\n\027" + - "StartClientHandshakeReq\022@\n\033handshake_sec" + - "urity_protocol\030\001 \001(\0162\033.grpc.gcp.Handshak" + - "eProtocol\022\035\n\025application_protocols\030\002 \003(\t" + - "\022\030\n\020record_protocols\030\003 \003(\t\022-\n\021target_ide" + - "ntities\030\004 \003(\0132\022.grpc.gcp.Identity\022*\n\016loc" + - "al_identity\030\005 \001(\0132\022.grpc.gcp.Identity\022*\n" + - "\016local_endpoint\030\006 \001(\0132\022.grpc.gcp.Endpoin" + - "t\022+\n\017remote_endpoint\030\007 \001(\0132\022.grpc.gcp.En" + - "dpoint\022\023\n\013target_name\030\010 \001(\t\0223\n\014rpc_versi" + - "ons\030\t \001(\0132\035.grpc.gcp.RpcProtocolVersions" + - "\"c\n\031ServerHandshakeParameters\022\030\n\020record_" + - "protocols\030\001 \003(\t\022,\n\020local_identities\030\002 \003(" + - "\0132\022.grpc.gcp.Identity\"\223\003\n\027StartServerHan" + - "dshakeReq\022\035\n\025application_protocols\030\001 \003(\t" + - "\022X\n\024handshake_parameters\030\002 \003(\0132:.grpc.gc" + - "p.StartServerHandshakeReq.HandshakeParam" + - "etersEntry\022\020\n\010in_bytes\030\003 \001(\014\022*\n\016local_en" + - "dpoint\030\004 \001(\0132\022.grpc.gcp.Endpoint\022+\n\017remo" + - "te_endpoint\030\005 \001(\0132\022.grpc.gcp.Endpoint\0223\n" + - "\014rpc_versions\030\006 \001(\0132\035.grpc.gcp.RpcProtoc" + - "olVersions\032_\n\030HandshakeParametersEntry\022\013" + - "\n\003key\030\001 \001(\005\0222\n\005value\030\002 \001(\0132#.grpc.gcp.Se" + - "rverHandshakeParameters:\0028\001\"+\n\027NextHands" + - "hakeMessageReq\022\020\n\010in_bytes\030\001 \001(\014\"\305\001\n\rHan" + - "dshakerReq\0229\n\014client_start\030\001 \001(\0132!.grpc." + - "gcp.StartClientHandshakeReqH\000\0229\n\014server_" + - "start\030\002 \001(\0132!.grpc.gcp.StartServerHandsh" + - "akeReqH\000\0221\n\004next\030\003 \001(\0132!.grpc.gcp.NextHa" + - "ndshakeMessageReqH\000B\013\n\treq_oneof\"\207\002\n\020Han" + - "dshakerResult\022\034\n\024application_protocol\030\001 " + - "\001(\t\022\027\n\017record_protocol\030\002 \001(\t\022\020\n\010key_data" + - "\030\003 \001(\014\022)\n\rpeer_identity\030\004 \001(\0132\022.grpc.gcp" + - ".Identity\022*\n\016local_identity\030\005 \001(\0132\022.grpc" + - ".gcp.Identity\022\031\n\021keep_channel_open\030\006 \001(\010" + - "\0228\n\021peer_rpc_versions\030\007 \001(\0132\035.grpc.gcp.R" + - "pcProtocolVersions\"1\n\020HandshakerStatus\022\014" + - "\n\004code\030\001 \001(\r\022\017\n\007details\030\002 \001(\t\"\224\001\n\016Handsh" + - "akerResp\022\022\n\nout_frames\030\001 \001(\014\022\026\n\016bytes_co" + - "nsumed\030\002 \001(\r\022*\n\006result\030\003 \001(\0132\032.grpc.gcp." + - "HandshakerResult\022*\n\006status\030\004 \001(\0132\032.grpc." + - "gcp.HandshakerStatus*J\n\021HandshakeProtoco" + - "l\022\"\n\036HANDSHAKE_PROTOCOL_UNSPECIFIED\020\000\022\007\n" + - "\003TLS\020\001\022\010\n\004ALTS\020\002*E\n\017NetworkProtocol\022 \n\034N" + - "ETWORK_PROTOCOL_UNSPECIFIED\020\000\022\007\n\003TCP\020\001\022\007" + - "\n\003UDP\020\0022[\n\021HandshakerService\022F\n\013DoHandsh" + - "ake\022\027.grpc.gcp.HandshakerReq\032\030.grpc.gcp." + - "HandshakerResp\"\000(\0010\001Bk\n\025io.grpc.alts.int" + - "ernalB\017HandshakerProtoP\001Z?google.golang." + - "org/grpc/credentials/alts/internal/proto" + - "/grpc_gcpb\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - io.grpc.alts.internal.TransportSecurityCommonProto.getDescriptor(), - }, assigner); - internal_static_grpc_gcp_Endpoint_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_grpc_gcp_Endpoint_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_Endpoint_descriptor, - new java.lang.String[] { "IpAddress", "Port", "Protocol", }); - internal_static_grpc_gcp_Identity_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_grpc_gcp_Identity_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_Identity_descriptor, - new java.lang.String[] { "ServiceAccount", "Hostname", "Attributes", "IdentityOneof", }); - internal_static_grpc_gcp_Identity_AttributesEntry_descriptor = - internal_static_grpc_gcp_Identity_descriptor.getNestedTypes().get(0); - internal_static_grpc_gcp_Identity_AttributesEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_Identity_AttributesEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_grpc_gcp_StartClientHandshakeReq_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_grpc_gcp_StartClientHandshakeReq_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_StartClientHandshakeReq_descriptor, - new java.lang.String[] { "HandshakeSecurityProtocol", "ApplicationProtocols", "RecordProtocols", "TargetIdentities", "LocalIdentity", "LocalEndpoint", "RemoteEndpoint", "TargetName", "RpcVersions", }); - internal_static_grpc_gcp_ServerHandshakeParameters_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_grpc_gcp_ServerHandshakeParameters_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_ServerHandshakeParameters_descriptor, - new java.lang.String[] { "RecordProtocols", "LocalIdentities", }); - internal_static_grpc_gcp_StartServerHandshakeReq_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_grpc_gcp_StartServerHandshakeReq_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_StartServerHandshakeReq_descriptor, - new java.lang.String[] { "ApplicationProtocols", "HandshakeParameters", "InBytes", "LocalEndpoint", "RemoteEndpoint", "RpcVersions", }); - internal_static_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_descriptor = - internal_static_grpc_gcp_StartServerHandshakeReq_descriptor.getNestedTypes().get(0); - internal_static_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_grpc_gcp_NextHandshakeMessageReq_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_grpc_gcp_NextHandshakeMessageReq_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_NextHandshakeMessageReq_descriptor, - new java.lang.String[] { "InBytes", }); - internal_static_grpc_gcp_HandshakerReq_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_grpc_gcp_HandshakerReq_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_HandshakerReq_descriptor, - new java.lang.String[] { "ClientStart", "ServerStart", "Next", "ReqOneof", }); - internal_static_grpc_gcp_HandshakerResult_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_grpc_gcp_HandshakerResult_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_HandshakerResult_descriptor, - new java.lang.String[] { "ApplicationProtocol", "RecordProtocol", "KeyData", "PeerIdentity", "LocalIdentity", "KeepChannelOpen", "PeerRpcVersions", }); - internal_static_grpc_gcp_HandshakerStatus_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_grpc_gcp_HandshakerStatus_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_HandshakerStatus_descriptor, - new java.lang.String[] { "Code", "Details", }); - internal_static_grpc_gcp_HandshakerResp_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_grpc_gcp_HandshakerResp_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_HandshakerResp_descriptor, - new java.lang.String[] { "OutFrames", "BytesConsumed", "Result", "Status", }); - io.grpc.alts.internal.TransportSecurityCommonProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerReq.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerReq.java deleted file mode 100644 index 57ab28351de..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerReq.java +++ /dev/null @@ -1,1213 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.HandshakerReq} - */ -public final class HandshakerReq extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.HandshakerReq) - HandshakerReqOrBuilder { -private static final long serialVersionUID = 0L; - // Use HandshakerReq.newBuilder() to construct. - private HandshakerReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private HandshakerReq() { - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private HandshakerReq( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - io.grpc.alts.internal.StartClientHandshakeReq.Builder subBuilder = null; - if (reqOneofCase_ == 1) { - subBuilder = ((io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_).toBuilder(); - } - reqOneof_ = - input.readMessage(io.grpc.alts.internal.StartClientHandshakeReq.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_); - reqOneof_ = subBuilder.buildPartial(); - } - reqOneofCase_ = 1; - break; - } - case 18: { - io.grpc.alts.internal.StartServerHandshakeReq.Builder subBuilder = null; - if (reqOneofCase_ == 2) { - subBuilder = ((io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_).toBuilder(); - } - reqOneof_ = - input.readMessage(io.grpc.alts.internal.StartServerHandshakeReq.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_); - reqOneof_ = subBuilder.buildPartial(); - } - reqOneofCase_ = 2; - break; - } - case 26: { - io.grpc.alts.internal.NextHandshakeMessageReq.Builder subBuilder = null; - if (reqOneofCase_ == 3) { - subBuilder = ((io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_).toBuilder(); - } - reqOneof_ = - input.readMessage(io.grpc.alts.internal.NextHandshakeMessageReq.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_); - reqOneof_ = subBuilder.buildPartial(); - } - reqOneofCase_ = 3; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerReq_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerReq.class, io.grpc.alts.internal.HandshakerReq.Builder.class); - } - - private int reqOneofCase_ = 0; - private java.lang.Object reqOneof_; - public enum ReqOneofCase - implements com.google.protobuf.Internal.EnumLite { - CLIENT_START(1), - SERVER_START(2), - NEXT(3), - REQONEOF_NOT_SET(0); - private final int value; - private ReqOneofCase(int value) { - this.value = value; - } - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static ReqOneofCase valueOf(int value) { - return forNumber(value); - } - - public static ReqOneofCase forNumber(int value) { - switch (value) { - case 1: return CLIENT_START; - case 2: return SERVER_START; - case 3: return NEXT; - case 0: return REQONEOF_NOT_SET; - default: return null; - } - } - public int getNumber() { - return this.value; - } - }; - - public ReqOneofCase - getReqOneofCase() { - return ReqOneofCase.forNumber( - reqOneofCase_); - } - - public static final int CLIENT_START_FIELD_NUMBER = 1; - /** - *
-   * The start client handshake request message.
-   * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public boolean hasClientStart() { - return reqOneofCase_ == 1; - } - /** - *
-   * The start client handshake request message.
-   * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public io.grpc.alts.internal.StartClientHandshakeReq getClientStart() { - if (reqOneofCase_ == 1) { - return (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } - /** - *
-   * The start client handshake request message.
-   * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public io.grpc.alts.internal.StartClientHandshakeReqOrBuilder getClientStartOrBuilder() { - if (reqOneofCase_ == 1) { - return (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } - - public static final int SERVER_START_FIELD_NUMBER = 2; - /** - *
-   * The start server handshake request message.
-   * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public boolean hasServerStart() { - return reqOneofCase_ == 2; - } - /** - *
-   * The start server handshake request message.
-   * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public io.grpc.alts.internal.StartServerHandshakeReq getServerStart() { - if (reqOneofCase_ == 2) { - return (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } - /** - *
-   * The start server handshake request message.
-   * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public io.grpc.alts.internal.StartServerHandshakeReqOrBuilder getServerStartOrBuilder() { - if (reqOneofCase_ == 2) { - return (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } - - public static final int NEXT_FIELD_NUMBER = 3; - /** - *
-   * The next handshake request message.
-   * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public boolean hasNext() { - return reqOneofCase_ == 3; - } - /** - *
-   * The next handshake request message.
-   * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public io.grpc.alts.internal.NextHandshakeMessageReq getNext() { - if (reqOneofCase_ == 3) { - return (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_; - } - return io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } - /** - *
-   * The next handshake request message.
-   * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder getNextOrBuilder() { - if (reqOneofCase_ == 3) { - return (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_; - } - return io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (reqOneofCase_ == 1) { - output.writeMessage(1, (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_); - } - if (reqOneofCase_ == 2) { - output.writeMessage(2, (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_); - } - if (reqOneofCase_ == 3) { - output.writeMessage(3, (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (reqOneofCase_ == 1) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_); - } - if (reqOneofCase_ == 2) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_); - } - if (reqOneofCase_ == 3) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.HandshakerReq)) { - return super.equals(obj); - } - io.grpc.alts.internal.HandshakerReq other = (io.grpc.alts.internal.HandshakerReq) obj; - - boolean result = true; - result = result && getReqOneofCase().equals( - other.getReqOneofCase()); - if (!result) return false; - switch (reqOneofCase_) { - case 1: - result = result && getClientStart() - .equals(other.getClientStart()); - break; - case 2: - result = result && getServerStart() - .equals(other.getServerStart()); - break; - case 3: - result = result && getNext() - .equals(other.getNext()); - break; - case 0: - default: - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - switch (reqOneofCase_) { - case 1: - hash = (37 * hash) + CLIENT_START_FIELD_NUMBER; - hash = (53 * hash) + getClientStart().hashCode(); - break; - case 2: - hash = (37 * hash) + SERVER_START_FIELD_NUMBER; - hash = (53 * hash) + getServerStart().hashCode(); - break; - case 3: - hash = (37 * hash) + NEXT_FIELD_NUMBER; - hash = (53 * hash) + getNext().hashCode(); - break; - case 0: - default: - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.HandshakerReq parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerReq parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerReq parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerReq parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.HandshakerReq prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.HandshakerReq} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.HandshakerReq) - io.grpc.alts.internal.HandshakerReqOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerReq_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerReq.class, io.grpc.alts.internal.HandshakerReq.Builder.class); - } - - // Construct using io.grpc.alts.internal.HandshakerReq.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - reqOneofCase_ = 0; - reqOneof_ = null; - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerReq_descriptor; - } - - public io.grpc.alts.internal.HandshakerReq getDefaultInstanceForType() { - return io.grpc.alts.internal.HandshakerReq.getDefaultInstance(); - } - - public io.grpc.alts.internal.HandshakerReq build() { - io.grpc.alts.internal.HandshakerReq result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.HandshakerReq buildPartial() { - io.grpc.alts.internal.HandshakerReq result = new io.grpc.alts.internal.HandshakerReq(this); - if (reqOneofCase_ == 1) { - if (clientStartBuilder_ == null) { - result.reqOneof_ = reqOneof_; - } else { - result.reqOneof_ = clientStartBuilder_.build(); - } - } - if (reqOneofCase_ == 2) { - if (serverStartBuilder_ == null) { - result.reqOneof_ = reqOneof_; - } else { - result.reqOneof_ = serverStartBuilder_.build(); - } - } - if (reqOneofCase_ == 3) { - if (nextBuilder_ == null) { - result.reqOneof_ = reqOneof_; - } else { - result.reqOneof_ = nextBuilder_.build(); - } - } - result.reqOneofCase_ = reqOneofCase_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.HandshakerReq) { - return mergeFrom((io.grpc.alts.internal.HandshakerReq)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.HandshakerReq other) { - if (other == io.grpc.alts.internal.HandshakerReq.getDefaultInstance()) return this; - switch (other.getReqOneofCase()) { - case CLIENT_START: { - mergeClientStart(other.getClientStart()); - break; - } - case SERVER_START: { - mergeServerStart(other.getServerStart()); - break; - } - case NEXT: { - mergeNext(other.getNext()); - break; - } - case REQONEOF_NOT_SET: { - break; - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.HandshakerReq parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.HandshakerReq) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int reqOneofCase_ = 0; - private java.lang.Object reqOneof_; - public ReqOneofCase - getReqOneofCase() { - return ReqOneofCase.forNumber( - reqOneofCase_); - } - - public Builder clearReqOneof() { - reqOneofCase_ = 0; - reqOneof_ = null; - onChanged(); - return this; - } - - - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.StartClientHandshakeReq, io.grpc.alts.internal.StartClientHandshakeReq.Builder, io.grpc.alts.internal.StartClientHandshakeReqOrBuilder> clientStartBuilder_; - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public boolean hasClientStart() { - return reqOneofCase_ == 1; - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public io.grpc.alts.internal.StartClientHandshakeReq getClientStart() { - if (clientStartBuilder_ == null) { - if (reqOneofCase_ == 1) { - return (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } else { - if (reqOneofCase_ == 1) { - return clientStartBuilder_.getMessage(); - } - return io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public Builder setClientStart(io.grpc.alts.internal.StartClientHandshakeReq value) { - if (clientStartBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - reqOneof_ = value; - onChanged(); - } else { - clientStartBuilder_.setMessage(value); - } - reqOneofCase_ = 1; - return this; - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public Builder setClientStart( - io.grpc.alts.internal.StartClientHandshakeReq.Builder builderForValue) { - if (clientStartBuilder_ == null) { - reqOneof_ = builderForValue.build(); - onChanged(); - } else { - clientStartBuilder_.setMessage(builderForValue.build()); - } - reqOneofCase_ = 1; - return this; - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public Builder mergeClientStart(io.grpc.alts.internal.StartClientHandshakeReq value) { - if (clientStartBuilder_ == null) { - if (reqOneofCase_ == 1 && - reqOneof_ != io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance()) { - reqOneof_ = io.grpc.alts.internal.StartClientHandshakeReq.newBuilder((io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_) - .mergeFrom(value).buildPartial(); - } else { - reqOneof_ = value; - } - onChanged(); - } else { - if (reqOneofCase_ == 1) { - clientStartBuilder_.mergeFrom(value); - } - clientStartBuilder_.setMessage(value); - } - reqOneofCase_ = 1; - return this; - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public Builder clearClientStart() { - if (clientStartBuilder_ == null) { - if (reqOneofCase_ == 1) { - reqOneofCase_ = 0; - reqOneof_ = null; - onChanged(); - } - } else { - if (reqOneofCase_ == 1) { - reqOneofCase_ = 0; - reqOneof_ = null; - } - clientStartBuilder_.clear(); - } - return this; - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public io.grpc.alts.internal.StartClientHandshakeReq.Builder getClientStartBuilder() { - return getClientStartFieldBuilder().getBuilder(); - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - public io.grpc.alts.internal.StartClientHandshakeReqOrBuilder getClientStartOrBuilder() { - if ((reqOneofCase_ == 1) && (clientStartBuilder_ != null)) { - return clientStartBuilder_.getMessageOrBuilder(); - } else { - if (reqOneofCase_ == 1) { - return (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } - } - /** - *
-     * The start client handshake request message.
-     * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.StartClientHandshakeReq, io.grpc.alts.internal.StartClientHandshakeReq.Builder, io.grpc.alts.internal.StartClientHandshakeReqOrBuilder> - getClientStartFieldBuilder() { - if (clientStartBuilder_ == null) { - if (!(reqOneofCase_ == 1)) { - reqOneof_ = io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } - clientStartBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.StartClientHandshakeReq, io.grpc.alts.internal.StartClientHandshakeReq.Builder, io.grpc.alts.internal.StartClientHandshakeReqOrBuilder>( - (io.grpc.alts.internal.StartClientHandshakeReq) reqOneof_, - getParentForChildren(), - isClean()); - reqOneof_ = null; - } - reqOneofCase_ = 1; - onChanged();; - return clientStartBuilder_; - } - - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.StartServerHandshakeReq, io.grpc.alts.internal.StartServerHandshakeReq.Builder, io.grpc.alts.internal.StartServerHandshakeReqOrBuilder> serverStartBuilder_; - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public boolean hasServerStart() { - return reqOneofCase_ == 2; - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public io.grpc.alts.internal.StartServerHandshakeReq getServerStart() { - if (serverStartBuilder_ == null) { - if (reqOneofCase_ == 2) { - return (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } else { - if (reqOneofCase_ == 2) { - return serverStartBuilder_.getMessage(); - } - return io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public Builder setServerStart(io.grpc.alts.internal.StartServerHandshakeReq value) { - if (serverStartBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - reqOneof_ = value; - onChanged(); - } else { - serverStartBuilder_.setMessage(value); - } - reqOneofCase_ = 2; - return this; - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public Builder setServerStart( - io.grpc.alts.internal.StartServerHandshakeReq.Builder builderForValue) { - if (serverStartBuilder_ == null) { - reqOneof_ = builderForValue.build(); - onChanged(); - } else { - serverStartBuilder_.setMessage(builderForValue.build()); - } - reqOneofCase_ = 2; - return this; - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public Builder mergeServerStart(io.grpc.alts.internal.StartServerHandshakeReq value) { - if (serverStartBuilder_ == null) { - if (reqOneofCase_ == 2 && - reqOneof_ != io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance()) { - reqOneof_ = io.grpc.alts.internal.StartServerHandshakeReq.newBuilder((io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_) - .mergeFrom(value).buildPartial(); - } else { - reqOneof_ = value; - } - onChanged(); - } else { - if (reqOneofCase_ == 2) { - serverStartBuilder_.mergeFrom(value); - } - serverStartBuilder_.setMessage(value); - } - reqOneofCase_ = 2; - return this; - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public Builder clearServerStart() { - if (serverStartBuilder_ == null) { - if (reqOneofCase_ == 2) { - reqOneofCase_ = 0; - reqOneof_ = null; - onChanged(); - } - } else { - if (reqOneofCase_ == 2) { - reqOneofCase_ = 0; - reqOneof_ = null; - } - serverStartBuilder_.clear(); - } - return this; - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public io.grpc.alts.internal.StartServerHandshakeReq.Builder getServerStartBuilder() { - return getServerStartFieldBuilder().getBuilder(); - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - public io.grpc.alts.internal.StartServerHandshakeReqOrBuilder getServerStartOrBuilder() { - if ((reqOneofCase_ == 2) && (serverStartBuilder_ != null)) { - return serverStartBuilder_.getMessageOrBuilder(); - } else { - if (reqOneofCase_ == 2) { - return (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_; - } - return io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } - } - /** - *
-     * The start server handshake request message.
-     * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.StartServerHandshakeReq, io.grpc.alts.internal.StartServerHandshakeReq.Builder, io.grpc.alts.internal.StartServerHandshakeReqOrBuilder> - getServerStartFieldBuilder() { - if (serverStartBuilder_ == null) { - if (!(reqOneofCase_ == 2)) { - reqOneof_ = io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } - serverStartBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.StartServerHandshakeReq, io.grpc.alts.internal.StartServerHandshakeReq.Builder, io.grpc.alts.internal.StartServerHandshakeReqOrBuilder>( - (io.grpc.alts.internal.StartServerHandshakeReq) reqOneof_, - getParentForChildren(), - isClean()); - reqOneof_ = null; - } - reqOneofCase_ = 2; - onChanged();; - return serverStartBuilder_; - } - - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.NextHandshakeMessageReq, io.grpc.alts.internal.NextHandshakeMessageReq.Builder, io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder> nextBuilder_; - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public boolean hasNext() { - return reqOneofCase_ == 3; - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public io.grpc.alts.internal.NextHandshakeMessageReq getNext() { - if (nextBuilder_ == null) { - if (reqOneofCase_ == 3) { - return (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_; - } - return io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } else { - if (reqOneofCase_ == 3) { - return nextBuilder_.getMessage(); - } - return io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public Builder setNext(io.grpc.alts.internal.NextHandshakeMessageReq value) { - if (nextBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - reqOneof_ = value; - onChanged(); - } else { - nextBuilder_.setMessage(value); - } - reqOneofCase_ = 3; - return this; - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public Builder setNext( - io.grpc.alts.internal.NextHandshakeMessageReq.Builder builderForValue) { - if (nextBuilder_ == null) { - reqOneof_ = builderForValue.build(); - onChanged(); - } else { - nextBuilder_.setMessage(builderForValue.build()); - } - reqOneofCase_ = 3; - return this; - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public Builder mergeNext(io.grpc.alts.internal.NextHandshakeMessageReq value) { - if (nextBuilder_ == null) { - if (reqOneofCase_ == 3 && - reqOneof_ != io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance()) { - reqOneof_ = io.grpc.alts.internal.NextHandshakeMessageReq.newBuilder((io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_) - .mergeFrom(value).buildPartial(); - } else { - reqOneof_ = value; - } - onChanged(); - } else { - if (reqOneofCase_ == 3) { - nextBuilder_.mergeFrom(value); - } - nextBuilder_.setMessage(value); - } - reqOneofCase_ = 3; - return this; - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public Builder clearNext() { - if (nextBuilder_ == null) { - if (reqOneofCase_ == 3) { - reqOneofCase_ = 0; - reqOneof_ = null; - onChanged(); - } - } else { - if (reqOneofCase_ == 3) { - reqOneofCase_ = 0; - reqOneof_ = null; - } - nextBuilder_.clear(); - } - return this; - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public io.grpc.alts.internal.NextHandshakeMessageReq.Builder getNextBuilder() { - return getNextFieldBuilder().getBuilder(); - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - public io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder getNextOrBuilder() { - if ((reqOneofCase_ == 3) && (nextBuilder_ != null)) { - return nextBuilder_.getMessageOrBuilder(); - } else { - if (reqOneofCase_ == 3) { - return (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_; - } - return io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } - } - /** - *
-     * The next handshake request message.
-     * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.NextHandshakeMessageReq, io.grpc.alts.internal.NextHandshakeMessageReq.Builder, io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder> - getNextFieldBuilder() { - if (nextBuilder_ == null) { - if (!(reqOneofCase_ == 3)) { - reqOneof_ = io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } - nextBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.NextHandshakeMessageReq, io.grpc.alts.internal.NextHandshakeMessageReq.Builder, io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder>( - (io.grpc.alts.internal.NextHandshakeMessageReq) reqOneof_, - getParentForChildren(), - isClean()); - reqOneof_ = null; - } - reqOneofCase_ = 3; - onChanged();; - return nextBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.HandshakerReq) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.HandshakerReq) - private static final io.grpc.alts.internal.HandshakerReq DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.HandshakerReq(); - } - - public static io.grpc.alts.internal.HandshakerReq getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HandshakerReq parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new HandshakerReq(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.HandshakerReq getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerReqOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerReqOrBuilder.java deleted file mode 100644 index 5dedca8a73a..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerReqOrBuilder.java +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface HandshakerReqOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.HandshakerReq) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The start client handshake request message.
-   * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - boolean hasClientStart(); - /** - *
-   * The start client handshake request message.
-   * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - io.grpc.alts.internal.StartClientHandshakeReq getClientStart(); - /** - *
-   * The start client handshake request message.
-   * 
- * - * .grpc.gcp.StartClientHandshakeReq client_start = 1; - */ - io.grpc.alts.internal.StartClientHandshakeReqOrBuilder getClientStartOrBuilder(); - - /** - *
-   * The start server handshake request message.
-   * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - boolean hasServerStart(); - /** - *
-   * The start server handshake request message.
-   * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - io.grpc.alts.internal.StartServerHandshakeReq getServerStart(); - /** - *
-   * The start server handshake request message.
-   * 
- * - * .grpc.gcp.StartServerHandshakeReq server_start = 2; - */ - io.grpc.alts.internal.StartServerHandshakeReqOrBuilder getServerStartOrBuilder(); - - /** - *
-   * The next handshake request message.
-   * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - boolean hasNext(); - /** - *
-   * The next handshake request message.
-   * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - io.grpc.alts.internal.NextHandshakeMessageReq getNext(); - /** - *
-   * The next handshake request message.
-   * 
- * - * .grpc.gcp.NextHandshakeMessageReq next = 3; - */ - io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder getNextOrBuilder(); - - public io.grpc.alts.internal.HandshakerReq.ReqOneofCase getReqOneofCase(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResp.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResp.java deleted file mode 100644 index 483e5da6883..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResp.java +++ /dev/null @@ -1,1034 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.HandshakerResp} - */ -public final class HandshakerResp extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.HandshakerResp) - HandshakerRespOrBuilder { -private static final long serialVersionUID = 0L; - // Use HandshakerResp.newBuilder() to construct. - private HandshakerResp(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private HandshakerResp() { - outFrames_ = com.google.protobuf.ByteString.EMPTY; - bytesConsumed_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private HandshakerResp( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - - outFrames_ = input.readBytes(); - break; - } - case 16: { - - bytesConsumed_ = input.readUInt32(); - break; - } - case 26: { - io.grpc.alts.internal.HandshakerResult.Builder subBuilder = null; - if (result_ != null) { - subBuilder = result_.toBuilder(); - } - result_ = input.readMessage(io.grpc.alts.internal.HandshakerResult.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(result_); - result_ = subBuilder.buildPartial(); - } - - break; - } - case 34: { - io.grpc.alts.internal.HandshakerStatus.Builder subBuilder = null; - if (status_ != null) { - subBuilder = status_.toBuilder(); - } - status_ = input.readMessage(io.grpc.alts.internal.HandshakerStatus.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(status_); - status_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResp_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResp_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerResp.class, io.grpc.alts.internal.HandshakerResp.Builder.class); - } - - public static final int OUT_FRAMES_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString outFrames_; - /** - *
-   * Frames to be given to the peer for the NextHandshakeMessageReq. May be
-   * empty if no out_frames have to be sent to the peer or if in_bytes in the
-   * HandshakerReq are incomplete. All the non-empty out frames must be sent to
-   * the peer even if the handshaker status is not OK as these frames may
-   * contain the alert frames.
-   * 
- * - * bytes out_frames = 1; - */ - public com.google.protobuf.ByteString getOutFrames() { - return outFrames_; - } - - public static final int BYTES_CONSUMED_FIELD_NUMBER = 2; - private int bytesConsumed_; - /** - *
-   * Number of bytes in the in_bytes consumed by the handshaker. It is possible
-   * that part of in_bytes in HandshakerReq was unrelated to the handshake
-   * process.
-   * 
- * - * uint32 bytes_consumed = 2; - */ - public int getBytesConsumed() { - return bytesConsumed_; - } - - public static final int RESULT_FIELD_NUMBER = 3; - private io.grpc.alts.internal.HandshakerResult result_; - /** - *
-   * This is set iff the handshake was successful. out_frames may still be set
-   * to frames that needs to be forwarded to the peer.
-   * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public boolean hasResult() { - return result_ != null; - } - /** - *
-   * This is set iff the handshake was successful. out_frames may still be set
-   * to frames that needs to be forwarded to the peer.
-   * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public io.grpc.alts.internal.HandshakerResult getResult() { - return result_ == null ? io.grpc.alts.internal.HandshakerResult.getDefaultInstance() : result_; - } - /** - *
-   * This is set iff the handshake was successful. out_frames may still be set
-   * to frames that needs to be forwarded to the peer.
-   * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public io.grpc.alts.internal.HandshakerResultOrBuilder getResultOrBuilder() { - return getResult(); - } - - public static final int STATUS_FIELD_NUMBER = 4; - private io.grpc.alts.internal.HandshakerStatus status_; - /** - *
-   * Status of the handshaker.
-   * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public boolean hasStatus() { - return status_ != null; - } - /** - *
-   * Status of the handshaker.
-   * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public io.grpc.alts.internal.HandshakerStatus getStatus() { - return status_ == null ? io.grpc.alts.internal.HandshakerStatus.getDefaultInstance() : status_; - } - /** - *
-   * Status of the handshaker.
-   * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public io.grpc.alts.internal.HandshakerStatusOrBuilder getStatusOrBuilder() { - return getStatus(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!outFrames_.isEmpty()) { - output.writeBytes(1, outFrames_); - } - if (bytesConsumed_ != 0) { - output.writeUInt32(2, bytesConsumed_); - } - if (result_ != null) { - output.writeMessage(3, getResult()); - } - if (status_ != null) { - output.writeMessage(4, getStatus()); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!outFrames_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, outFrames_); - } - if (bytesConsumed_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(2, bytesConsumed_); - } - if (result_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getResult()); - } - if (status_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getStatus()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.HandshakerResp)) { - return super.equals(obj); - } - io.grpc.alts.internal.HandshakerResp other = (io.grpc.alts.internal.HandshakerResp) obj; - - boolean result = true; - result = result && getOutFrames() - .equals(other.getOutFrames()); - result = result && (getBytesConsumed() - == other.getBytesConsumed()); - result = result && (hasResult() == other.hasResult()); - if (hasResult()) { - result = result && getResult() - .equals(other.getResult()); - } - result = result && (hasStatus() == other.hasStatus()); - if (hasStatus()) { - result = result && getStatus() - .equals(other.getStatus()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + OUT_FRAMES_FIELD_NUMBER; - hash = (53 * hash) + getOutFrames().hashCode(); - hash = (37 * hash) + BYTES_CONSUMED_FIELD_NUMBER; - hash = (53 * hash) + getBytesConsumed(); - if (hasResult()) { - hash = (37 * hash) + RESULT_FIELD_NUMBER; - hash = (53 * hash) + getResult().hashCode(); - } - if (hasStatus()) { - hash = (37 * hash) + STATUS_FIELD_NUMBER; - hash = (53 * hash) + getStatus().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.HandshakerResp parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResp parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerResp parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerResp parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.HandshakerResp prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.HandshakerResp} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.HandshakerResp) - io.grpc.alts.internal.HandshakerRespOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResp_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResp_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerResp.class, io.grpc.alts.internal.HandshakerResp.Builder.class); - } - - // Construct using io.grpc.alts.internal.HandshakerResp.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - outFrames_ = com.google.protobuf.ByteString.EMPTY; - - bytesConsumed_ = 0; - - if (resultBuilder_ == null) { - result_ = null; - } else { - result_ = null; - resultBuilder_ = null; - } - if (statusBuilder_ == null) { - status_ = null; - } else { - status_ = null; - statusBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResp_descriptor; - } - - public io.grpc.alts.internal.HandshakerResp getDefaultInstanceForType() { - return io.grpc.alts.internal.HandshakerResp.getDefaultInstance(); - } - - public io.grpc.alts.internal.HandshakerResp build() { - io.grpc.alts.internal.HandshakerResp result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.HandshakerResp buildPartial() { - io.grpc.alts.internal.HandshakerResp result = new io.grpc.alts.internal.HandshakerResp(this); - result.outFrames_ = outFrames_; - result.bytesConsumed_ = bytesConsumed_; - if (resultBuilder_ == null) { - result.result_ = result_; - } else { - result.result_ = resultBuilder_.build(); - } - if (statusBuilder_ == null) { - result.status_ = status_; - } else { - result.status_ = statusBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.HandshakerResp) { - return mergeFrom((io.grpc.alts.internal.HandshakerResp)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.HandshakerResp other) { - if (other == io.grpc.alts.internal.HandshakerResp.getDefaultInstance()) return this; - if (other.getOutFrames() != com.google.protobuf.ByteString.EMPTY) { - setOutFrames(other.getOutFrames()); - } - if (other.getBytesConsumed() != 0) { - setBytesConsumed(other.getBytesConsumed()); - } - if (other.hasResult()) { - mergeResult(other.getResult()); - } - if (other.hasStatus()) { - mergeStatus(other.getStatus()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.HandshakerResp parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.HandshakerResp) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private com.google.protobuf.ByteString outFrames_ = com.google.protobuf.ByteString.EMPTY; - /** - *
-     * Frames to be given to the peer for the NextHandshakeMessageReq. May be
-     * empty if no out_frames have to be sent to the peer or if in_bytes in the
-     * HandshakerReq are incomplete. All the non-empty out frames must be sent to
-     * the peer even if the handshaker status is not OK as these frames may
-     * contain the alert frames.
-     * 
- * - * bytes out_frames = 1; - */ - public com.google.protobuf.ByteString getOutFrames() { - return outFrames_; - } - /** - *
-     * Frames to be given to the peer for the NextHandshakeMessageReq. May be
-     * empty if no out_frames have to be sent to the peer or if in_bytes in the
-     * HandshakerReq are incomplete. All the non-empty out frames must be sent to
-     * the peer even if the handshaker status is not OK as these frames may
-     * contain the alert frames.
-     * 
- * - * bytes out_frames = 1; - */ - public Builder setOutFrames(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - outFrames_ = value; - onChanged(); - return this; - } - /** - *
-     * Frames to be given to the peer for the NextHandshakeMessageReq. May be
-     * empty if no out_frames have to be sent to the peer or if in_bytes in the
-     * HandshakerReq are incomplete. All the non-empty out frames must be sent to
-     * the peer even if the handshaker status is not OK as these frames may
-     * contain the alert frames.
-     * 
- * - * bytes out_frames = 1; - */ - public Builder clearOutFrames() { - - outFrames_ = getDefaultInstance().getOutFrames(); - onChanged(); - return this; - } - - private int bytesConsumed_ ; - /** - *
-     * Number of bytes in the in_bytes consumed by the handshaker. It is possible
-     * that part of in_bytes in HandshakerReq was unrelated to the handshake
-     * process.
-     * 
- * - * uint32 bytes_consumed = 2; - */ - public int getBytesConsumed() { - return bytesConsumed_; - } - /** - *
-     * Number of bytes in the in_bytes consumed by the handshaker. It is possible
-     * that part of in_bytes in HandshakerReq was unrelated to the handshake
-     * process.
-     * 
- * - * uint32 bytes_consumed = 2; - */ - public Builder setBytesConsumed(int value) { - - bytesConsumed_ = value; - onChanged(); - return this; - } - /** - *
-     * Number of bytes in the in_bytes consumed by the handshaker. It is possible
-     * that part of in_bytes in HandshakerReq was unrelated to the handshake
-     * process.
-     * 
- * - * uint32 bytes_consumed = 2; - */ - public Builder clearBytesConsumed() { - - bytesConsumed_ = 0; - onChanged(); - return this; - } - - private io.grpc.alts.internal.HandshakerResult result_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.HandshakerResult, io.grpc.alts.internal.HandshakerResult.Builder, io.grpc.alts.internal.HandshakerResultOrBuilder> resultBuilder_; - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public boolean hasResult() { - return resultBuilder_ != null || result_ != null; - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public io.grpc.alts.internal.HandshakerResult getResult() { - if (resultBuilder_ == null) { - return result_ == null ? io.grpc.alts.internal.HandshakerResult.getDefaultInstance() : result_; - } else { - return resultBuilder_.getMessage(); - } - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public Builder setResult(io.grpc.alts.internal.HandshakerResult value) { - if (resultBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - result_ = value; - onChanged(); - } else { - resultBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public Builder setResult( - io.grpc.alts.internal.HandshakerResult.Builder builderForValue) { - if (resultBuilder_ == null) { - result_ = builderForValue.build(); - onChanged(); - } else { - resultBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public Builder mergeResult(io.grpc.alts.internal.HandshakerResult value) { - if (resultBuilder_ == null) { - if (result_ != null) { - result_ = - io.grpc.alts.internal.HandshakerResult.newBuilder(result_).mergeFrom(value).buildPartial(); - } else { - result_ = value; - } - onChanged(); - } else { - resultBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public Builder clearResult() { - if (resultBuilder_ == null) { - result_ = null; - onChanged(); - } else { - result_ = null; - resultBuilder_ = null; - } - - return this; - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public io.grpc.alts.internal.HandshakerResult.Builder getResultBuilder() { - - onChanged(); - return getResultFieldBuilder().getBuilder(); - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - public io.grpc.alts.internal.HandshakerResultOrBuilder getResultOrBuilder() { - if (resultBuilder_ != null) { - return resultBuilder_.getMessageOrBuilder(); - } else { - return result_ == null ? - io.grpc.alts.internal.HandshakerResult.getDefaultInstance() : result_; - } - } - /** - *
-     * This is set iff the handshake was successful. out_frames may still be set
-     * to frames that needs to be forwarded to the peer.
-     * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.HandshakerResult, io.grpc.alts.internal.HandshakerResult.Builder, io.grpc.alts.internal.HandshakerResultOrBuilder> - getResultFieldBuilder() { - if (resultBuilder_ == null) { - resultBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.HandshakerResult, io.grpc.alts.internal.HandshakerResult.Builder, io.grpc.alts.internal.HandshakerResultOrBuilder>( - getResult(), - getParentForChildren(), - isClean()); - result_ = null; - } - return resultBuilder_; - } - - private io.grpc.alts.internal.HandshakerStatus status_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.HandshakerStatus, io.grpc.alts.internal.HandshakerStatus.Builder, io.grpc.alts.internal.HandshakerStatusOrBuilder> statusBuilder_; - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public boolean hasStatus() { - return statusBuilder_ != null || status_ != null; - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public io.grpc.alts.internal.HandshakerStatus getStatus() { - if (statusBuilder_ == null) { - return status_ == null ? io.grpc.alts.internal.HandshakerStatus.getDefaultInstance() : status_; - } else { - return statusBuilder_.getMessage(); - } - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public Builder setStatus(io.grpc.alts.internal.HandshakerStatus value) { - if (statusBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - status_ = value; - onChanged(); - } else { - statusBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public Builder setStatus( - io.grpc.alts.internal.HandshakerStatus.Builder builderForValue) { - if (statusBuilder_ == null) { - status_ = builderForValue.build(); - onChanged(); - } else { - statusBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public Builder mergeStatus(io.grpc.alts.internal.HandshakerStatus value) { - if (statusBuilder_ == null) { - if (status_ != null) { - status_ = - io.grpc.alts.internal.HandshakerStatus.newBuilder(status_).mergeFrom(value).buildPartial(); - } else { - status_ = value; - } - onChanged(); - } else { - statusBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public Builder clearStatus() { - if (statusBuilder_ == null) { - status_ = null; - onChanged(); - } else { - status_ = null; - statusBuilder_ = null; - } - - return this; - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public io.grpc.alts.internal.HandshakerStatus.Builder getStatusBuilder() { - - onChanged(); - return getStatusFieldBuilder().getBuilder(); - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - public io.grpc.alts.internal.HandshakerStatusOrBuilder getStatusOrBuilder() { - if (statusBuilder_ != null) { - return statusBuilder_.getMessageOrBuilder(); - } else { - return status_ == null ? - io.grpc.alts.internal.HandshakerStatus.getDefaultInstance() : status_; - } - } - /** - *
-     * Status of the handshaker.
-     * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.HandshakerStatus, io.grpc.alts.internal.HandshakerStatus.Builder, io.grpc.alts.internal.HandshakerStatusOrBuilder> - getStatusFieldBuilder() { - if (statusBuilder_ == null) { - statusBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.HandshakerStatus, io.grpc.alts.internal.HandshakerStatus.Builder, io.grpc.alts.internal.HandshakerStatusOrBuilder>( - getStatus(), - getParentForChildren(), - isClean()); - status_ = null; - } - return statusBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.HandshakerResp) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.HandshakerResp) - private static final io.grpc.alts.internal.HandshakerResp DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.HandshakerResp(); - } - - public static io.grpc.alts.internal.HandshakerResp getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HandshakerResp parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new HandshakerResp(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.HandshakerResp getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerRespOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerRespOrBuilder.java deleted file mode 100644 index e75909bf172..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerRespOrBuilder.java +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface HandshakerRespOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.HandshakerResp) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * Frames to be given to the peer for the NextHandshakeMessageReq. May be
-   * empty if no out_frames have to be sent to the peer or if in_bytes in the
-   * HandshakerReq are incomplete. All the non-empty out frames must be sent to
-   * the peer even if the handshaker status is not OK as these frames may
-   * contain the alert frames.
-   * 
- * - * bytes out_frames = 1; - */ - com.google.protobuf.ByteString getOutFrames(); - - /** - *
-   * Number of bytes in the in_bytes consumed by the handshaker. It is possible
-   * that part of in_bytes in HandshakerReq was unrelated to the handshake
-   * process.
-   * 
- * - * uint32 bytes_consumed = 2; - */ - int getBytesConsumed(); - - /** - *
-   * This is set iff the handshake was successful. out_frames may still be set
-   * to frames that needs to be forwarded to the peer.
-   * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - boolean hasResult(); - /** - *
-   * This is set iff the handshake was successful. out_frames may still be set
-   * to frames that needs to be forwarded to the peer.
-   * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - io.grpc.alts.internal.HandshakerResult getResult(); - /** - *
-   * This is set iff the handshake was successful. out_frames may still be set
-   * to frames that needs to be forwarded to the peer.
-   * 
- * - * .grpc.gcp.HandshakerResult result = 3; - */ - io.grpc.alts.internal.HandshakerResultOrBuilder getResultOrBuilder(); - - /** - *
-   * Status of the handshaker.
-   * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - boolean hasStatus(); - /** - *
-   * Status of the handshaker.
-   * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - io.grpc.alts.internal.HandshakerStatus getStatus(); - /** - *
-   * Status of the handshaker.
-   * 
- * - * .grpc.gcp.HandshakerStatus status = 4; - */ - io.grpc.alts.internal.HandshakerStatusOrBuilder getStatusOrBuilder(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResult.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResult.java deleted file mode 100644 index 16680c73a34..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResult.java +++ /dev/null @@ -1,1554 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.HandshakerResult} - */ -public final class HandshakerResult extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.HandshakerResult) - HandshakerResultOrBuilder { -private static final long serialVersionUID = 0L; - // Use HandshakerResult.newBuilder() to construct. - private HandshakerResult(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private HandshakerResult() { - applicationProtocol_ = ""; - recordProtocol_ = ""; - keyData_ = com.google.protobuf.ByteString.EMPTY; - keepChannelOpen_ = false; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private HandshakerResult( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - applicationProtocol_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - recordProtocol_ = s; - break; - } - case 26: { - - keyData_ = input.readBytes(); - break; - } - case 34: { - io.grpc.alts.internal.Identity.Builder subBuilder = null; - if (peerIdentity_ != null) { - subBuilder = peerIdentity_.toBuilder(); - } - peerIdentity_ = input.readMessage(io.grpc.alts.internal.Identity.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(peerIdentity_); - peerIdentity_ = subBuilder.buildPartial(); - } - - break; - } - case 42: { - io.grpc.alts.internal.Identity.Builder subBuilder = null; - if (localIdentity_ != null) { - subBuilder = localIdentity_.toBuilder(); - } - localIdentity_ = input.readMessage(io.grpc.alts.internal.Identity.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(localIdentity_); - localIdentity_ = subBuilder.buildPartial(); - } - - break; - } - case 48: { - - keepChannelOpen_ = input.readBool(); - break; - } - case 58: { - io.grpc.alts.internal.RpcProtocolVersions.Builder subBuilder = null; - if (peerRpcVersions_ != null) { - subBuilder = peerRpcVersions_.toBuilder(); - } - peerRpcVersions_ = input.readMessage(io.grpc.alts.internal.RpcProtocolVersions.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(peerRpcVersions_); - peerRpcVersions_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerResult.class, io.grpc.alts.internal.HandshakerResult.Builder.class); - } - - public static final int APPLICATION_PROTOCOL_FIELD_NUMBER = 1; - private volatile java.lang.Object applicationProtocol_; - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - public java.lang.String getApplicationProtocol() { - java.lang.Object ref = applicationProtocol_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - applicationProtocol_ = s; - return s; - } - } - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - public com.google.protobuf.ByteString - getApplicationProtocolBytes() { - java.lang.Object ref = applicationProtocol_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - applicationProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RECORD_PROTOCOL_FIELD_NUMBER = 2; - private volatile java.lang.Object recordProtocol_; - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - public java.lang.String getRecordProtocol() { - java.lang.Object ref = recordProtocol_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - recordProtocol_ = s; - return s; - } - } - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - public com.google.protobuf.ByteString - getRecordProtocolBytes() { - java.lang.Object ref = recordProtocol_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - recordProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int KEY_DATA_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString keyData_; - /** - *
-   * Cryptographic key data. The key data may be more than the key length
-   * required for the record protocol, thus the client of the handshaker
-   * service needs to truncate the key data into the right key length.
-   * 
- * - * bytes key_data = 3; - */ - public com.google.protobuf.ByteString getKeyData() { - return keyData_; - } - - public static final int PEER_IDENTITY_FIELD_NUMBER = 4; - private io.grpc.alts.internal.Identity peerIdentity_; - /** - *
-   * The authenticated identity of the peer.
-   * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public boolean hasPeerIdentity() { - return peerIdentity_ != null; - } - /** - *
-   * The authenticated identity of the peer.
-   * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public io.grpc.alts.internal.Identity getPeerIdentity() { - return peerIdentity_ == null ? io.grpc.alts.internal.Identity.getDefaultInstance() : peerIdentity_; - } - /** - *
-   * The authenticated identity of the peer.
-   * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public io.grpc.alts.internal.IdentityOrBuilder getPeerIdentityOrBuilder() { - return getPeerIdentity(); - } - - public static final int LOCAL_IDENTITY_FIELD_NUMBER = 5; - private io.grpc.alts.internal.Identity localIdentity_; - /** - *
-   * The local identity used in the handshake.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public boolean hasLocalIdentity() { - return localIdentity_ != null; - } - /** - *
-   * The local identity used in the handshake.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.Identity getLocalIdentity() { - return localIdentity_ == null ? io.grpc.alts.internal.Identity.getDefaultInstance() : localIdentity_; - } - /** - *
-   * The local identity used in the handshake.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.IdentityOrBuilder getLocalIdentityOrBuilder() { - return getLocalIdentity(); - } - - public static final int KEEP_CHANNEL_OPEN_FIELD_NUMBER = 6; - private boolean keepChannelOpen_; - /** - *
-   * Indicate whether the handshaker service client should keep the channel
-   * between the handshaker service open, e.g., in order to handle
-   * post-handshake messages in the future.
-   * 
- * - * bool keep_channel_open = 6; - */ - public boolean getKeepChannelOpen() { - return keepChannelOpen_; - } - - public static final int PEER_RPC_VERSIONS_FIELD_NUMBER = 7; - private io.grpc.alts.internal.RpcProtocolVersions peerRpcVersions_; - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public boolean hasPeerRpcVersions() { - return peerRpcVersions_ != null; - } - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public io.grpc.alts.internal.RpcProtocolVersions getPeerRpcVersions() { - return peerRpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : peerRpcVersions_; - } - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getPeerRpcVersionsOrBuilder() { - return getPeerRpcVersions(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getApplicationProtocolBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, applicationProtocol_); - } - if (!getRecordProtocolBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, recordProtocol_); - } - if (!keyData_.isEmpty()) { - output.writeBytes(3, keyData_); - } - if (peerIdentity_ != null) { - output.writeMessage(4, getPeerIdentity()); - } - if (localIdentity_ != null) { - output.writeMessage(5, getLocalIdentity()); - } - if (keepChannelOpen_ != false) { - output.writeBool(6, keepChannelOpen_); - } - if (peerRpcVersions_ != null) { - output.writeMessage(7, getPeerRpcVersions()); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getApplicationProtocolBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, applicationProtocol_); - } - if (!getRecordProtocolBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, recordProtocol_); - } - if (!keyData_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, keyData_); - } - if (peerIdentity_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getPeerIdentity()); - } - if (localIdentity_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, getLocalIdentity()); - } - if (keepChannelOpen_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(6, keepChannelOpen_); - } - if (peerRpcVersions_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, getPeerRpcVersions()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.HandshakerResult)) { - return super.equals(obj); - } - io.grpc.alts.internal.HandshakerResult other = (io.grpc.alts.internal.HandshakerResult) obj; - - boolean result = true; - result = result && getApplicationProtocol() - .equals(other.getApplicationProtocol()); - result = result && getRecordProtocol() - .equals(other.getRecordProtocol()); - result = result && getKeyData() - .equals(other.getKeyData()); - result = result && (hasPeerIdentity() == other.hasPeerIdentity()); - if (hasPeerIdentity()) { - result = result && getPeerIdentity() - .equals(other.getPeerIdentity()); - } - result = result && (hasLocalIdentity() == other.hasLocalIdentity()); - if (hasLocalIdentity()) { - result = result && getLocalIdentity() - .equals(other.getLocalIdentity()); - } - result = result && (getKeepChannelOpen() - == other.getKeepChannelOpen()); - result = result && (hasPeerRpcVersions() == other.hasPeerRpcVersions()); - if (hasPeerRpcVersions()) { - result = result && getPeerRpcVersions() - .equals(other.getPeerRpcVersions()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + APPLICATION_PROTOCOL_FIELD_NUMBER; - hash = (53 * hash) + getApplicationProtocol().hashCode(); - hash = (37 * hash) + RECORD_PROTOCOL_FIELD_NUMBER; - hash = (53 * hash) + getRecordProtocol().hashCode(); - hash = (37 * hash) + KEY_DATA_FIELD_NUMBER; - hash = (53 * hash) + getKeyData().hashCode(); - if (hasPeerIdentity()) { - hash = (37 * hash) + PEER_IDENTITY_FIELD_NUMBER; - hash = (53 * hash) + getPeerIdentity().hashCode(); - } - if (hasLocalIdentity()) { - hash = (37 * hash) + LOCAL_IDENTITY_FIELD_NUMBER; - hash = (53 * hash) + getLocalIdentity().hashCode(); - } - hash = (37 * hash) + KEEP_CHANNEL_OPEN_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getKeepChannelOpen()); - if (hasPeerRpcVersions()) { - hash = (37 * hash) + PEER_RPC_VERSIONS_FIELD_NUMBER; - hash = (53 * hash) + getPeerRpcVersions().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.HandshakerResult parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResult parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerResult parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerResult parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.HandshakerResult prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.HandshakerResult} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.HandshakerResult) - io.grpc.alts.internal.HandshakerResultOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerResult.class, io.grpc.alts.internal.HandshakerResult.Builder.class); - } - - // Construct using io.grpc.alts.internal.HandshakerResult.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - applicationProtocol_ = ""; - - recordProtocol_ = ""; - - keyData_ = com.google.protobuf.ByteString.EMPTY; - - if (peerIdentityBuilder_ == null) { - peerIdentity_ = null; - } else { - peerIdentity_ = null; - peerIdentityBuilder_ = null; - } - if (localIdentityBuilder_ == null) { - localIdentity_ = null; - } else { - localIdentity_ = null; - localIdentityBuilder_ = null; - } - keepChannelOpen_ = false; - - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersions_ = null; - } else { - peerRpcVersions_ = null; - peerRpcVersionsBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerResult_descriptor; - } - - public io.grpc.alts.internal.HandshakerResult getDefaultInstanceForType() { - return io.grpc.alts.internal.HandshakerResult.getDefaultInstance(); - } - - public io.grpc.alts.internal.HandshakerResult build() { - io.grpc.alts.internal.HandshakerResult result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.HandshakerResult buildPartial() { - io.grpc.alts.internal.HandshakerResult result = new io.grpc.alts.internal.HandshakerResult(this); - result.applicationProtocol_ = applicationProtocol_; - result.recordProtocol_ = recordProtocol_; - result.keyData_ = keyData_; - if (peerIdentityBuilder_ == null) { - result.peerIdentity_ = peerIdentity_; - } else { - result.peerIdentity_ = peerIdentityBuilder_.build(); - } - if (localIdentityBuilder_ == null) { - result.localIdentity_ = localIdentity_; - } else { - result.localIdentity_ = localIdentityBuilder_.build(); - } - result.keepChannelOpen_ = keepChannelOpen_; - if (peerRpcVersionsBuilder_ == null) { - result.peerRpcVersions_ = peerRpcVersions_; - } else { - result.peerRpcVersions_ = peerRpcVersionsBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.HandshakerResult) { - return mergeFrom((io.grpc.alts.internal.HandshakerResult)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.HandshakerResult other) { - if (other == io.grpc.alts.internal.HandshakerResult.getDefaultInstance()) return this; - if (!other.getApplicationProtocol().isEmpty()) { - applicationProtocol_ = other.applicationProtocol_; - onChanged(); - } - if (!other.getRecordProtocol().isEmpty()) { - recordProtocol_ = other.recordProtocol_; - onChanged(); - } - if (other.getKeyData() != com.google.protobuf.ByteString.EMPTY) { - setKeyData(other.getKeyData()); - } - if (other.hasPeerIdentity()) { - mergePeerIdentity(other.getPeerIdentity()); - } - if (other.hasLocalIdentity()) { - mergeLocalIdentity(other.getLocalIdentity()); - } - if (other.getKeepChannelOpen() != false) { - setKeepChannelOpen(other.getKeepChannelOpen()); - } - if (other.hasPeerRpcVersions()) { - mergePeerRpcVersions(other.getPeerRpcVersions()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.HandshakerResult parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.HandshakerResult) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object applicationProtocol_ = ""; - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public java.lang.String getApplicationProtocol() { - java.lang.Object ref = applicationProtocol_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - applicationProtocol_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public com.google.protobuf.ByteString - getApplicationProtocolBytes() { - java.lang.Object ref = applicationProtocol_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - applicationProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public Builder setApplicationProtocol( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - applicationProtocol_ = value; - onChanged(); - return this; - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public Builder clearApplicationProtocol() { - - applicationProtocol_ = getDefaultInstance().getApplicationProtocol(); - onChanged(); - return this; - } - /** - *
-     * The application protocol negotiated for this connection.
-     * 
- * - * string application_protocol = 1; - */ - public Builder setApplicationProtocolBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - applicationProtocol_ = value; - onChanged(); - return this; - } - - private java.lang.Object recordProtocol_ = ""; - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public java.lang.String getRecordProtocol() { - java.lang.Object ref = recordProtocol_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - recordProtocol_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public com.google.protobuf.ByteString - getRecordProtocolBytes() { - java.lang.Object ref = recordProtocol_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - recordProtocol_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public Builder setRecordProtocol( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - recordProtocol_ = value; - onChanged(); - return this; - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public Builder clearRecordProtocol() { - - recordProtocol_ = getDefaultInstance().getRecordProtocol(); - onChanged(); - return this; - } - /** - *
-     * The record protocol negotiated for this connection.
-     * 
- * - * string record_protocol = 2; - */ - public Builder setRecordProtocolBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - recordProtocol_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString keyData_ = com.google.protobuf.ByteString.EMPTY; - /** - *
-     * Cryptographic key data. The key data may be more than the key length
-     * required for the record protocol, thus the client of the handshaker
-     * service needs to truncate the key data into the right key length.
-     * 
- * - * bytes key_data = 3; - */ - public com.google.protobuf.ByteString getKeyData() { - return keyData_; - } - /** - *
-     * Cryptographic key data. The key data may be more than the key length
-     * required for the record protocol, thus the client of the handshaker
-     * service needs to truncate the key data into the right key length.
-     * 
- * - * bytes key_data = 3; - */ - public Builder setKeyData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - keyData_ = value; - onChanged(); - return this; - } - /** - *
-     * Cryptographic key data. The key data may be more than the key length
-     * required for the record protocol, thus the client of the handshaker
-     * service needs to truncate the key data into the right key length.
-     * 
- * - * bytes key_data = 3; - */ - public Builder clearKeyData() { - - keyData_ = getDefaultInstance().getKeyData(); - onChanged(); - return this; - } - - private io.grpc.alts.internal.Identity peerIdentity_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> peerIdentityBuilder_; - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public boolean hasPeerIdentity() { - return peerIdentityBuilder_ != null || peerIdentity_ != null; - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public io.grpc.alts.internal.Identity getPeerIdentity() { - if (peerIdentityBuilder_ == null) { - return peerIdentity_ == null ? io.grpc.alts.internal.Identity.getDefaultInstance() : peerIdentity_; - } else { - return peerIdentityBuilder_.getMessage(); - } - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public Builder setPeerIdentity(io.grpc.alts.internal.Identity value) { - if (peerIdentityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - peerIdentity_ = value; - onChanged(); - } else { - peerIdentityBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public Builder setPeerIdentity( - io.grpc.alts.internal.Identity.Builder builderForValue) { - if (peerIdentityBuilder_ == null) { - peerIdentity_ = builderForValue.build(); - onChanged(); - } else { - peerIdentityBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public Builder mergePeerIdentity(io.grpc.alts.internal.Identity value) { - if (peerIdentityBuilder_ == null) { - if (peerIdentity_ != null) { - peerIdentity_ = - io.grpc.alts.internal.Identity.newBuilder(peerIdentity_).mergeFrom(value).buildPartial(); - } else { - peerIdentity_ = value; - } - onChanged(); - } else { - peerIdentityBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public Builder clearPeerIdentity() { - if (peerIdentityBuilder_ == null) { - peerIdentity_ = null; - onChanged(); - } else { - peerIdentity_ = null; - peerIdentityBuilder_ = null; - } - - return this; - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public io.grpc.alts.internal.Identity.Builder getPeerIdentityBuilder() { - - onChanged(); - return getPeerIdentityFieldBuilder().getBuilder(); - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - public io.grpc.alts.internal.IdentityOrBuilder getPeerIdentityOrBuilder() { - if (peerIdentityBuilder_ != null) { - return peerIdentityBuilder_.getMessageOrBuilder(); - } else { - return peerIdentity_ == null ? - io.grpc.alts.internal.Identity.getDefaultInstance() : peerIdentity_; - } - } - /** - *
-     * The authenticated identity of the peer.
-     * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> - getPeerIdentityFieldBuilder() { - if (peerIdentityBuilder_ == null) { - peerIdentityBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder>( - getPeerIdentity(), - getParentForChildren(), - isClean()); - peerIdentity_ = null; - } - return peerIdentityBuilder_; - } - - private io.grpc.alts.internal.Identity localIdentity_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> localIdentityBuilder_; - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public boolean hasLocalIdentity() { - return localIdentityBuilder_ != null || localIdentity_ != null; - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.Identity getLocalIdentity() { - if (localIdentityBuilder_ == null) { - return localIdentity_ == null ? io.grpc.alts.internal.Identity.getDefaultInstance() : localIdentity_; - } else { - return localIdentityBuilder_.getMessage(); - } - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder setLocalIdentity(io.grpc.alts.internal.Identity value) { - if (localIdentityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - localIdentity_ = value; - onChanged(); - } else { - localIdentityBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder setLocalIdentity( - io.grpc.alts.internal.Identity.Builder builderForValue) { - if (localIdentityBuilder_ == null) { - localIdentity_ = builderForValue.build(); - onChanged(); - } else { - localIdentityBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder mergeLocalIdentity(io.grpc.alts.internal.Identity value) { - if (localIdentityBuilder_ == null) { - if (localIdentity_ != null) { - localIdentity_ = - io.grpc.alts.internal.Identity.newBuilder(localIdentity_).mergeFrom(value).buildPartial(); - } else { - localIdentity_ = value; - } - onChanged(); - } else { - localIdentityBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder clearLocalIdentity() { - if (localIdentityBuilder_ == null) { - localIdentity_ = null; - onChanged(); - } else { - localIdentity_ = null; - localIdentityBuilder_ = null; - } - - return this; - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.Identity.Builder getLocalIdentityBuilder() { - - onChanged(); - return getLocalIdentityFieldBuilder().getBuilder(); - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.IdentityOrBuilder getLocalIdentityOrBuilder() { - if (localIdentityBuilder_ != null) { - return localIdentityBuilder_.getMessageOrBuilder(); - } else { - return localIdentity_ == null ? - io.grpc.alts.internal.Identity.getDefaultInstance() : localIdentity_; - } - } - /** - *
-     * The local identity used in the handshake.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> - getLocalIdentityFieldBuilder() { - if (localIdentityBuilder_ == null) { - localIdentityBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder>( - getLocalIdentity(), - getParentForChildren(), - isClean()); - localIdentity_ = null; - } - return localIdentityBuilder_; - } - - private boolean keepChannelOpen_ ; - /** - *
-     * Indicate whether the handshaker service client should keep the channel
-     * between the handshaker service open, e.g., in order to handle
-     * post-handshake messages in the future.
-     * 
- * - * bool keep_channel_open = 6; - */ - public boolean getKeepChannelOpen() { - return keepChannelOpen_; - } - /** - *
-     * Indicate whether the handshaker service client should keep the channel
-     * between the handshaker service open, e.g., in order to handle
-     * post-handshake messages in the future.
-     * 
- * - * bool keep_channel_open = 6; - */ - public Builder setKeepChannelOpen(boolean value) { - - keepChannelOpen_ = value; - onChanged(); - return this; - } - /** - *
-     * Indicate whether the handshaker service client should keep the channel
-     * between the handshaker service open, e.g., in order to handle
-     * post-handshake messages in the future.
-     * 
- * - * bool keep_channel_open = 6; - */ - public Builder clearKeepChannelOpen() { - - keepChannelOpen_ = false; - onChanged(); - return this; - } - - private io.grpc.alts.internal.RpcProtocolVersions peerRpcVersions_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> peerRpcVersionsBuilder_; - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public boolean hasPeerRpcVersions() { - return peerRpcVersionsBuilder_ != null || peerRpcVersions_ != null; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public io.grpc.alts.internal.RpcProtocolVersions getPeerRpcVersions() { - if (peerRpcVersionsBuilder_ == null) { - return peerRpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : peerRpcVersions_; - } else { - return peerRpcVersionsBuilder_.getMessage(); - } - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public Builder setPeerRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (peerRpcVersionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - peerRpcVersions_ = value; - onChanged(); - } else { - peerRpcVersionsBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public Builder setPeerRpcVersions( - io.grpc.alts.internal.RpcProtocolVersions.Builder builderForValue) { - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersions_ = builderForValue.build(); - onChanged(); - } else { - peerRpcVersionsBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public Builder mergePeerRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (peerRpcVersionsBuilder_ == null) { - if (peerRpcVersions_ != null) { - peerRpcVersions_ = - io.grpc.alts.internal.RpcProtocolVersions.newBuilder(peerRpcVersions_).mergeFrom(value).buildPartial(); - } else { - peerRpcVersions_ = value; - } - onChanged(); - } else { - peerRpcVersionsBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public Builder clearPeerRpcVersions() { - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersions_ = null; - onChanged(); - } else { - peerRpcVersions_ = null; - peerRpcVersionsBuilder_ = null; - } - - return this; - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Builder getPeerRpcVersionsBuilder() { - - onChanged(); - return getPeerRpcVersionsFieldBuilder().getBuilder(); - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getPeerRpcVersionsOrBuilder() { - if (peerRpcVersionsBuilder_ != null) { - return peerRpcVersionsBuilder_.getMessageOrBuilder(); - } else { - return peerRpcVersions_ == null ? - io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : peerRpcVersions_; - } - } - /** - *
-     * The RPC protocol versions supported by the peer.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> - getPeerRpcVersionsFieldBuilder() { - if (peerRpcVersionsBuilder_ == null) { - peerRpcVersionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder>( - getPeerRpcVersions(), - getParentForChildren(), - isClean()); - peerRpcVersions_ = null; - } - return peerRpcVersionsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.HandshakerResult) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.HandshakerResult) - private static final io.grpc.alts.internal.HandshakerResult DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.HandshakerResult(); - } - - public static io.grpc.alts.internal.HandshakerResult getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HandshakerResult parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new HandshakerResult(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.HandshakerResult getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResultOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResultOrBuilder.java deleted file mode 100644 index fbf0f5d0616..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerResultOrBuilder.java +++ /dev/null @@ -1,142 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface HandshakerResultOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.HandshakerResult) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - java.lang.String getApplicationProtocol(); - /** - *
-   * The application protocol negotiated for this connection.
-   * 
- * - * string application_protocol = 1; - */ - com.google.protobuf.ByteString - getApplicationProtocolBytes(); - - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - java.lang.String getRecordProtocol(); - /** - *
-   * The record protocol negotiated for this connection.
-   * 
- * - * string record_protocol = 2; - */ - com.google.protobuf.ByteString - getRecordProtocolBytes(); - - /** - *
-   * Cryptographic key data. The key data may be more than the key length
-   * required for the record protocol, thus the client of the handshaker
-   * service needs to truncate the key data into the right key length.
-   * 
- * - * bytes key_data = 3; - */ - com.google.protobuf.ByteString getKeyData(); - - /** - *
-   * The authenticated identity of the peer.
-   * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - boolean hasPeerIdentity(); - /** - *
-   * The authenticated identity of the peer.
-   * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - io.grpc.alts.internal.Identity getPeerIdentity(); - /** - *
-   * The authenticated identity of the peer.
-   * 
- * - * .grpc.gcp.Identity peer_identity = 4; - */ - io.grpc.alts.internal.IdentityOrBuilder getPeerIdentityOrBuilder(); - - /** - *
-   * The local identity used in the handshake.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - boolean hasLocalIdentity(); - /** - *
-   * The local identity used in the handshake.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - io.grpc.alts.internal.Identity getLocalIdentity(); - /** - *
-   * The local identity used in the handshake.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - io.grpc.alts.internal.IdentityOrBuilder getLocalIdentityOrBuilder(); - - /** - *
-   * Indicate whether the handshaker service client should keep the channel
-   * between the handshaker service open, e.g., in order to handle
-   * post-handshake messages in the future.
-   * 
- * - * bool keep_channel_open = 6; - */ - boolean getKeepChannelOpen(); - - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - boolean hasPeerRpcVersions(); - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - io.grpc.alts.internal.RpcProtocolVersions getPeerRpcVersions(); - /** - *
-   * The RPC protocol versions supported by the peer.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions peer_rpc_versions = 7; - */ - io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getPeerRpcVersionsOrBuilder(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerStatus.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerStatus.java deleted file mode 100644 index 3fd497daf21..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerStatus.java +++ /dev/null @@ -1,618 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.HandshakerStatus} - */ -public final class HandshakerStatus extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.HandshakerStatus) - HandshakerStatusOrBuilder { -private static final long serialVersionUID = 0L; - // Use HandshakerStatus.newBuilder() to construct. - private HandshakerStatus(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private HandshakerStatus() { - code_ = 0; - details_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private HandshakerStatus( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - - code_ = input.readUInt32(); - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - details_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerStatus_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerStatus_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerStatus.class, io.grpc.alts.internal.HandshakerStatus.Builder.class); - } - - public static final int CODE_FIELD_NUMBER = 1; - private int code_; - /** - *
-   * The status code. This could be the gRPC status code.
-   * 
- * - * uint32 code = 1; - */ - public int getCode() { - return code_; - } - - public static final int DETAILS_FIELD_NUMBER = 2; - private volatile java.lang.Object details_; - /** - *
-   * The status details.
-   * 
- * - * string details = 2; - */ - public java.lang.String getDetails() { - java.lang.Object ref = details_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - details_ = s; - return s; - } - } - /** - *
-   * The status details.
-   * 
- * - * string details = 2; - */ - public com.google.protobuf.ByteString - getDetailsBytes() { - java.lang.Object ref = details_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - details_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (code_ != 0) { - output.writeUInt32(1, code_); - } - if (!getDetailsBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, details_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (code_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, code_); - } - if (!getDetailsBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, details_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.HandshakerStatus)) { - return super.equals(obj); - } - io.grpc.alts.internal.HandshakerStatus other = (io.grpc.alts.internal.HandshakerStatus) obj; - - boolean result = true; - result = result && (getCode() - == other.getCode()); - result = result && getDetails() - .equals(other.getDetails()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + CODE_FIELD_NUMBER; - hash = (53 * hash) + getCode(); - hash = (37 * hash) + DETAILS_FIELD_NUMBER; - hash = (53 * hash) + getDetails().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerStatus parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerStatus parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.HandshakerStatus parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.HandshakerStatus prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.HandshakerStatus} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.HandshakerStatus) - io.grpc.alts.internal.HandshakerStatusOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerStatus_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerStatus_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.HandshakerStatus.class, io.grpc.alts.internal.HandshakerStatus.Builder.class); - } - - // Construct using io.grpc.alts.internal.HandshakerStatus.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - code_ = 0; - - details_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_HandshakerStatus_descriptor; - } - - public io.grpc.alts.internal.HandshakerStatus getDefaultInstanceForType() { - return io.grpc.alts.internal.HandshakerStatus.getDefaultInstance(); - } - - public io.grpc.alts.internal.HandshakerStatus build() { - io.grpc.alts.internal.HandshakerStatus result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.HandshakerStatus buildPartial() { - io.grpc.alts.internal.HandshakerStatus result = new io.grpc.alts.internal.HandshakerStatus(this); - result.code_ = code_; - result.details_ = details_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.HandshakerStatus) { - return mergeFrom((io.grpc.alts.internal.HandshakerStatus)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.HandshakerStatus other) { - if (other == io.grpc.alts.internal.HandshakerStatus.getDefaultInstance()) return this; - if (other.getCode() != 0) { - setCode(other.getCode()); - } - if (!other.getDetails().isEmpty()) { - details_ = other.details_; - onChanged(); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.HandshakerStatus parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.HandshakerStatus) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int code_ ; - /** - *
-     * The status code. This could be the gRPC status code.
-     * 
- * - * uint32 code = 1; - */ - public int getCode() { - return code_; - } - /** - *
-     * The status code. This could be the gRPC status code.
-     * 
- * - * uint32 code = 1; - */ - public Builder setCode(int value) { - - code_ = value; - onChanged(); - return this; - } - /** - *
-     * The status code. This could be the gRPC status code.
-     * 
- * - * uint32 code = 1; - */ - public Builder clearCode() { - - code_ = 0; - onChanged(); - return this; - } - - private java.lang.Object details_ = ""; - /** - *
-     * The status details.
-     * 
- * - * string details = 2; - */ - public java.lang.String getDetails() { - java.lang.Object ref = details_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - details_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * The status details.
-     * 
- * - * string details = 2; - */ - public com.google.protobuf.ByteString - getDetailsBytes() { - java.lang.Object ref = details_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - details_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * The status details.
-     * 
- * - * string details = 2; - */ - public Builder setDetails( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - details_ = value; - onChanged(); - return this; - } - /** - *
-     * The status details.
-     * 
- * - * string details = 2; - */ - public Builder clearDetails() { - - details_ = getDefaultInstance().getDetails(); - onChanged(); - return this; - } - /** - *
-     * The status details.
-     * 
- * - * string details = 2; - */ - public Builder setDetailsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - details_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.HandshakerStatus) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.HandshakerStatus) - private static final io.grpc.alts.internal.HandshakerStatus DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.HandshakerStatus(); - } - - public static io.grpc.alts.internal.HandshakerStatus getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HandshakerStatus parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new HandshakerStatus(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.HandshakerStatus getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerStatusOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerStatusOrBuilder.java deleted file mode 100644 index 0ac69753feb..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/HandshakerStatusOrBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface HandshakerStatusOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.HandshakerStatus) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The status code. This could be the gRPC status code.
-   * 
- * - * uint32 code = 1; - */ - int getCode(); - - /** - *
-   * The status details.
-   * 
- * - * string details = 2; - */ - java.lang.String getDetails(); - /** - *
-   * The status details.
-   * 
- * - * string details = 2; - */ - com.google.protobuf.ByteString - getDetailsBytes(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/Identity.java b/alts/src/generated/main/java/io/grpc/alts/internal/Identity.java deleted file mode 100644 index 235bb3366a8..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/Identity.java +++ /dev/null @@ -1,1142 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.Identity} - */ -public final class Identity extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.Identity) - IdentityOrBuilder { -private static final long serialVersionUID = 0L; - // Use Identity.newBuilder() to construct. - private Identity(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Identity() { - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Identity( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - identityOneofCase_ = 1; - identityOneof_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - identityOneofCase_ = 2; - identityOneof_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - attributes_ = com.google.protobuf.MapField.newMapField( - AttributesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000004; - } - com.google.protobuf.MapEntry - attributes__ = input.readMessage( - AttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - attributes_.getMutableMap().put( - attributes__.getKey(), attributes__.getValue()); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Identity_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 3: - return internalGetAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Identity_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.Identity.class, io.grpc.alts.internal.Identity.Builder.class); - } - - private int bitField0_; - private int identityOneofCase_ = 0; - private java.lang.Object identityOneof_; - public enum IdentityOneofCase - implements com.google.protobuf.Internal.EnumLite { - SERVICE_ACCOUNT(1), - HOSTNAME(2), - IDENTITYONEOF_NOT_SET(0); - private final int value; - private IdentityOneofCase(int value) { - this.value = value; - } - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static IdentityOneofCase valueOf(int value) { - return forNumber(value); - } - - public static IdentityOneofCase forNumber(int value) { - switch (value) { - case 1: return SERVICE_ACCOUNT; - case 2: return HOSTNAME; - case 0: return IDENTITYONEOF_NOT_SET; - default: return null; - } - } - public int getNumber() { - return this.value; - } - }; - - public IdentityOneofCase - getIdentityOneofCase() { - return IdentityOneofCase.forNumber( - identityOneofCase_); - } - - public static final int SERVICE_ACCOUNT_FIELD_NUMBER = 1; - /** - *
-   * Service account of a connection endpoint.
-   * 
- * - * string service_account = 1; - */ - public java.lang.String getServiceAccount() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 1) { - ref = identityOneof_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (identityOneofCase_ == 1) { - identityOneof_ = s; - } - return s; - } - } - /** - *
-   * Service account of a connection endpoint.
-   * 
- * - * string service_account = 1; - */ - public com.google.protobuf.ByteString - getServiceAccountBytes() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 1) { - ref = identityOneof_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (identityOneofCase_ == 1) { - identityOneof_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int HOSTNAME_FIELD_NUMBER = 2; - /** - *
-   * Hostname of a connection endpoint.
-   * 
- * - * string hostname = 2; - */ - public java.lang.String getHostname() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 2) { - ref = identityOneof_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (identityOneofCase_ == 2) { - identityOneof_ = s; - } - return s; - } - } - /** - *
-   * Hostname of a connection endpoint.
-   * 
- * - * string hostname = 2; - */ - public com.google.protobuf.ByteString - getHostnameBytes() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 2) { - ref = identityOneof_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (identityOneofCase_ == 2) { - identityOneof_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ATTRIBUTES_FIELD_NUMBER = 3; - private static final class AttributesDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.String> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Identity_AttributesEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> attributes_; - private com.google.protobuf.MapField - internalGetAttributes() { - if (attributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - return attributes_; - } - - public int getAttributesCount() { - return internalGetAttributes().getMap().size(); - } - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - - public boolean containsAttributes( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetAttributes().getMap().containsKey(key); - } - /** - * Use {@link #getAttributesMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getAttributes() { - return getAttributesMap(); - } - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - - public java.util.Map getAttributesMap() { - return internalGetAttributes().getMap(); - } - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - - public java.lang.String getAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetAttributes().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - - public java.lang.String getAttributesOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetAttributes().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (identityOneofCase_ == 1) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, identityOneof_); - } - if (identityOneofCase_ == 2) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, identityOneof_); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetAttributes(), - AttributesDefaultEntryHolder.defaultEntry, - 3); - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (identityOneofCase_ == 1) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, identityOneof_); - } - if (identityOneofCase_ == 2) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, identityOneof_); - } - for (java.util.Map.Entry entry - : internalGetAttributes().getMap().entrySet()) { - com.google.protobuf.MapEntry - attributes__ = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, attributes__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.Identity)) { - return super.equals(obj); - } - io.grpc.alts.internal.Identity other = (io.grpc.alts.internal.Identity) obj; - - boolean result = true; - result = result && internalGetAttributes().equals( - other.internalGetAttributes()); - result = result && getIdentityOneofCase().equals( - other.getIdentityOneofCase()); - if (!result) return false; - switch (identityOneofCase_) { - case 1: - result = result && getServiceAccount() - .equals(other.getServiceAccount()); - break; - case 2: - result = result && getHostname() - .equals(other.getHostname()); - break; - case 0: - default: - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (!internalGetAttributes().getMap().isEmpty()) { - hash = (37 * hash) + ATTRIBUTES_FIELD_NUMBER; - hash = (53 * hash) + internalGetAttributes().hashCode(); - } - switch (identityOneofCase_) { - case 1: - hash = (37 * hash) + SERVICE_ACCOUNT_FIELD_NUMBER; - hash = (53 * hash) + getServiceAccount().hashCode(); - break; - case 2: - hash = (37 * hash) + HOSTNAME_FIELD_NUMBER; - hash = (53 * hash) + getHostname().hashCode(); - break; - case 0: - default: - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.Identity parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.Identity parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.Identity parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.Identity parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.Identity parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.Identity parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.Identity parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.Identity parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.Identity parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.Identity parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.Identity parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.Identity parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.Identity prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.Identity} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.Identity) - io.grpc.alts.internal.IdentityOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Identity_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 3: - return internalGetAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 3: - return internalGetMutableAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Identity_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.Identity.class, io.grpc.alts.internal.Identity.Builder.class); - } - - // Construct using io.grpc.alts.internal.Identity.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - internalGetMutableAttributes().clear(); - identityOneofCase_ = 0; - identityOneof_ = null; - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_Identity_descriptor; - } - - public io.grpc.alts.internal.Identity getDefaultInstanceForType() { - return io.grpc.alts.internal.Identity.getDefaultInstance(); - } - - public io.grpc.alts.internal.Identity build() { - io.grpc.alts.internal.Identity result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.Identity buildPartial() { - io.grpc.alts.internal.Identity result = new io.grpc.alts.internal.Identity(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (identityOneofCase_ == 1) { - result.identityOneof_ = identityOneof_; - } - if (identityOneofCase_ == 2) { - result.identityOneof_ = identityOneof_; - } - result.attributes_ = internalGetAttributes(); - result.attributes_.makeImmutable(); - result.bitField0_ = to_bitField0_; - result.identityOneofCase_ = identityOneofCase_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.Identity) { - return mergeFrom((io.grpc.alts.internal.Identity)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.Identity other) { - if (other == io.grpc.alts.internal.Identity.getDefaultInstance()) return this; - internalGetMutableAttributes().mergeFrom( - other.internalGetAttributes()); - switch (other.getIdentityOneofCase()) { - case SERVICE_ACCOUNT: { - identityOneofCase_ = 1; - identityOneof_ = other.identityOneof_; - onChanged(); - break; - } - case HOSTNAME: { - identityOneofCase_ = 2; - identityOneof_ = other.identityOneof_; - onChanged(); - break; - } - case IDENTITYONEOF_NOT_SET: { - break; - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.Identity parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.Identity) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int identityOneofCase_ = 0; - private java.lang.Object identityOneof_; - public IdentityOneofCase - getIdentityOneofCase() { - return IdentityOneofCase.forNumber( - identityOneofCase_); - } - - public Builder clearIdentityOneof() { - identityOneofCase_ = 0; - identityOneof_ = null; - onChanged(); - return this; - } - - private int bitField0_; - - /** - *
-     * Service account of a connection endpoint.
-     * 
- * - * string service_account = 1; - */ - public java.lang.String getServiceAccount() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 1) { - ref = identityOneof_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (identityOneofCase_ == 1) { - identityOneof_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * Service account of a connection endpoint.
-     * 
- * - * string service_account = 1; - */ - public com.google.protobuf.ByteString - getServiceAccountBytes() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 1) { - ref = identityOneof_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (identityOneofCase_ == 1) { - identityOneof_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * Service account of a connection endpoint.
-     * 
- * - * string service_account = 1; - */ - public Builder setServiceAccount( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - identityOneofCase_ = 1; - identityOneof_ = value; - onChanged(); - return this; - } - /** - *
-     * Service account of a connection endpoint.
-     * 
- * - * string service_account = 1; - */ - public Builder clearServiceAccount() { - if (identityOneofCase_ == 1) { - identityOneofCase_ = 0; - identityOneof_ = null; - onChanged(); - } - return this; - } - /** - *
-     * Service account of a connection endpoint.
-     * 
- * - * string service_account = 1; - */ - public Builder setServiceAccountBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - identityOneofCase_ = 1; - identityOneof_ = value; - onChanged(); - return this; - } - - /** - *
-     * Hostname of a connection endpoint.
-     * 
- * - * string hostname = 2; - */ - public java.lang.String getHostname() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 2) { - ref = identityOneof_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (identityOneofCase_ == 2) { - identityOneof_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * Hostname of a connection endpoint.
-     * 
- * - * string hostname = 2; - */ - public com.google.protobuf.ByteString - getHostnameBytes() { - java.lang.Object ref = ""; - if (identityOneofCase_ == 2) { - ref = identityOneof_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (identityOneofCase_ == 2) { - identityOneof_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * Hostname of a connection endpoint.
-     * 
- * - * string hostname = 2; - */ - public Builder setHostname( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - identityOneofCase_ = 2; - identityOneof_ = value; - onChanged(); - return this; - } - /** - *
-     * Hostname of a connection endpoint.
-     * 
- * - * string hostname = 2; - */ - public Builder clearHostname() { - if (identityOneofCase_ == 2) { - identityOneofCase_ = 0; - identityOneof_ = null; - onChanged(); - } - return this; - } - /** - *
-     * Hostname of a connection endpoint.
-     * 
- * - * string hostname = 2; - */ - public Builder setHostnameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - identityOneofCase_ = 2; - identityOneof_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> attributes_; - private com.google.protobuf.MapField - internalGetAttributes() { - if (attributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - return attributes_; - } - private com.google.protobuf.MapField - internalGetMutableAttributes() { - onChanged();; - if (attributes_ == null) { - attributes_ = com.google.protobuf.MapField.newMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - if (!attributes_.isMutable()) { - attributes_ = attributes_.copy(); - } - return attributes_; - } - - public int getAttributesCount() { - return internalGetAttributes().getMap().size(); - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - - public boolean containsAttributes( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetAttributes().getMap().containsKey(key); - } - /** - * Use {@link #getAttributesMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getAttributes() { - return getAttributesMap(); - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - - public java.util.Map getAttributesMap() { - return internalGetAttributes().getMap(); - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - - public java.lang.String getAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetAttributes().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - - public java.lang.String getAttributesOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetAttributes().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearAttributes() { - internalGetMutableAttributes().getMutableMap() - .clear(); - return this; - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - - public Builder removeAttributes( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - internalGetMutableAttributes().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableAttributes() { - return internalGetMutableAttributes().getMutableMap(); - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - public Builder putAttributes( - java.lang.String key, - java.lang.String value) { - if (key == null) { throw new java.lang.NullPointerException(); } - if (value == null) { throw new java.lang.NullPointerException(); } - internalGetMutableAttributes().getMutableMap() - .put(key, value); - return this; - } - /** - *
-     * Additional attributes of the identity.
-     * 
- * - * map<string, string> attributes = 3; - */ - - public Builder putAllAttributes( - java.util.Map values) { - internalGetMutableAttributes().getMutableMap() - .putAll(values); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.Identity) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.Identity) - private static final io.grpc.alts.internal.Identity DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.Identity(); - } - - public static io.grpc.alts.internal.Identity getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Identity parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Identity(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.Identity getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/IdentityOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/IdentityOrBuilder.java deleted file mode 100644 index 0cf096c4aa9..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/IdentityOrBuilder.java +++ /dev/null @@ -1,101 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface IdentityOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.Identity) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * Service account of a connection endpoint.
-   * 
- * - * string service_account = 1; - */ - java.lang.String getServiceAccount(); - /** - *
-   * Service account of a connection endpoint.
-   * 
- * - * string service_account = 1; - */ - com.google.protobuf.ByteString - getServiceAccountBytes(); - - /** - *
-   * Hostname of a connection endpoint.
-   * 
- * - * string hostname = 2; - */ - java.lang.String getHostname(); - /** - *
-   * Hostname of a connection endpoint.
-   * 
- * - * string hostname = 2; - */ - com.google.protobuf.ByteString - getHostnameBytes(); - - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - int getAttributesCount(); - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - boolean containsAttributes( - java.lang.String key); - /** - * Use {@link #getAttributesMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getAttributes(); - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - java.util.Map - getAttributesMap(); - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - - java.lang.String getAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue); - /** - *
-   * Additional attributes of the identity.
-   * 
- * - * map<string, string> attributes = 3; - */ - - java.lang.String getAttributesOrThrow( - java.lang.String key); - - public io.grpc.alts.internal.Identity.IdentityOneofCase getIdentityOneofCase(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/NetworkProtocol.java b/alts/src/generated/main/java/io/grpc/alts/internal/NetworkProtocol.java deleted file mode 100644 index 78b78a79dc1..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/NetworkProtocol.java +++ /dev/null @@ -1,112 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf enum {@code grpc.gcp.NetworkProtocol} - */ -public enum NetworkProtocol - implements com.google.protobuf.ProtocolMessageEnum { - /** - * NETWORK_PROTOCOL_UNSPECIFIED = 0; - */ - NETWORK_PROTOCOL_UNSPECIFIED(0), - /** - * TCP = 1; - */ - TCP(1), - /** - * UDP = 2; - */ - UDP(2), - UNRECOGNIZED(-1), - ; - - /** - * NETWORK_PROTOCOL_UNSPECIFIED = 0; - */ - public static final int NETWORK_PROTOCOL_UNSPECIFIED_VALUE = 0; - /** - * TCP = 1; - */ - public static final int TCP_VALUE = 1; - /** - * UDP = 2; - */ - public static final int UDP_VALUE = 2; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static NetworkProtocol valueOf(int value) { - return forNumber(value); - } - - public static NetworkProtocol forNumber(int value) { - switch (value) { - case 0: return NETWORK_PROTOCOL_UNSPECIFIED; - case 1: return TCP; - case 2: return UDP; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - NetworkProtocol> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public NetworkProtocol findValueByNumber(int number) { - return NetworkProtocol.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.getDescriptor().getEnumTypes().get(1); - } - - private static final NetworkProtocol[] VALUES = values(); - - public static NetworkProtocol valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private NetworkProtocol(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:grpc.gcp.NetworkProtocol) -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/NextHandshakeMessageReq.java b/alts/src/generated/main/java/io/grpc/alts/internal/NextHandshakeMessageReq.java deleted file mode 100644 index 7028aa9cca3..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/NextHandshakeMessageReq.java +++ /dev/null @@ -1,474 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.NextHandshakeMessageReq} - */ -public final class NextHandshakeMessageReq extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.NextHandshakeMessageReq) - NextHandshakeMessageReqOrBuilder { -private static final long serialVersionUID = 0L; - // Use NextHandshakeMessageReq.newBuilder() to construct. - private NextHandshakeMessageReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private NextHandshakeMessageReq() { - inBytes_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private NextHandshakeMessageReq( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - - inBytes_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_NextHandshakeMessageReq_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_NextHandshakeMessageReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.NextHandshakeMessageReq.class, io.grpc.alts.internal.NextHandshakeMessageReq.Builder.class); - } - - public static final int IN_BYTES_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString inBytes_; - /** - *
-   * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-   * that the peer's out_frames are split into multiple NextHandshakerMessageReq
-   * messages.
-   * 
- * - * bytes in_bytes = 1; - */ - public com.google.protobuf.ByteString getInBytes() { - return inBytes_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!inBytes_.isEmpty()) { - output.writeBytes(1, inBytes_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!inBytes_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, inBytes_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.NextHandshakeMessageReq)) { - return super.equals(obj); - } - io.grpc.alts.internal.NextHandshakeMessageReq other = (io.grpc.alts.internal.NextHandshakeMessageReq) obj; - - boolean result = true; - result = result && getInBytes() - .equals(other.getInBytes()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + IN_BYTES_FIELD_NUMBER; - hash = (53 * hash) + getInBytes().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.NextHandshakeMessageReq parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.NextHandshakeMessageReq prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.NextHandshakeMessageReq} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.NextHandshakeMessageReq) - io.grpc.alts.internal.NextHandshakeMessageReqOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_NextHandshakeMessageReq_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_NextHandshakeMessageReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.NextHandshakeMessageReq.class, io.grpc.alts.internal.NextHandshakeMessageReq.Builder.class); - } - - // Construct using io.grpc.alts.internal.NextHandshakeMessageReq.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - inBytes_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_NextHandshakeMessageReq_descriptor; - } - - public io.grpc.alts.internal.NextHandshakeMessageReq getDefaultInstanceForType() { - return io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance(); - } - - public io.grpc.alts.internal.NextHandshakeMessageReq build() { - io.grpc.alts.internal.NextHandshakeMessageReq result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.NextHandshakeMessageReq buildPartial() { - io.grpc.alts.internal.NextHandshakeMessageReq result = new io.grpc.alts.internal.NextHandshakeMessageReq(this); - result.inBytes_ = inBytes_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.NextHandshakeMessageReq) { - return mergeFrom((io.grpc.alts.internal.NextHandshakeMessageReq)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.NextHandshakeMessageReq other) { - if (other == io.grpc.alts.internal.NextHandshakeMessageReq.getDefaultInstance()) return this; - if (other.getInBytes() != com.google.protobuf.ByteString.EMPTY) { - setInBytes(other.getInBytes()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.NextHandshakeMessageReq parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.NextHandshakeMessageReq) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private com.google.protobuf.ByteString inBytes_ = com.google.protobuf.ByteString.EMPTY; - /** - *
-     * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-     * that the peer's out_frames are split into multiple NextHandshakerMessageReq
-     * messages.
-     * 
- * - * bytes in_bytes = 1; - */ - public com.google.protobuf.ByteString getInBytes() { - return inBytes_; - } - /** - *
-     * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-     * that the peer's out_frames are split into multiple NextHandshakerMessageReq
-     * messages.
-     * 
- * - * bytes in_bytes = 1; - */ - public Builder setInBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - inBytes_ = value; - onChanged(); - return this; - } - /** - *
-     * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-     * that the peer's out_frames are split into multiple NextHandshakerMessageReq
-     * messages.
-     * 
- * - * bytes in_bytes = 1; - */ - public Builder clearInBytes() { - - inBytes_ = getDefaultInstance().getInBytes(); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.NextHandshakeMessageReq) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.NextHandshakeMessageReq) - private static final io.grpc.alts.internal.NextHandshakeMessageReq DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.NextHandshakeMessageReq(); - } - - public static io.grpc.alts.internal.NextHandshakeMessageReq getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public NextHandshakeMessageReq parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new NextHandshakeMessageReq(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.NextHandshakeMessageReq getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/NextHandshakeMessageReqOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/NextHandshakeMessageReqOrBuilder.java deleted file mode 100644 index 3c3f0a57fc8..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/NextHandshakeMessageReqOrBuilder.java +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface NextHandshakeMessageReqOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.NextHandshakeMessageReq) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-   * that the peer's out_frames are split into multiple NextHandshakerMessageReq
-   * messages.
-   * 
- * - * bytes in_bytes = 1; - */ - com.google.protobuf.ByteString getInBytes(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/RpcProtocolVersions.java b/alts/src/generated/main/java/io/grpc/alts/internal/RpcProtocolVersions.java deleted file mode 100644 index e415be26168..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/RpcProtocolVersions.java +++ /dev/null @@ -1,1377 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/transport_security_common.proto - -package io.grpc.alts.internal; - -/** - *
- * Max and min supported RPC protocol versions.
- * 
- * - * Protobuf type {@code grpc.gcp.RpcProtocolVersions} - */ -public final class RpcProtocolVersions extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.RpcProtocolVersions) - RpcProtocolVersionsOrBuilder { -private static final long serialVersionUID = 0L; - // Use RpcProtocolVersions.newBuilder() to construct. - private RpcProtocolVersions(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private RpcProtocolVersions() { - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private RpcProtocolVersions( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - io.grpc.alts.internal.RpcProtocolVersions.Version.Builder subBuilder = null; - if (maxRpcVersion_ != null) { - subBuilder = maxRpcVersion_.toBuilder(); - } - maxRpcVersion_ = input.readMessage(io.grpc.alts.internal.RpcProtocolVersions.Version.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(maxRpcVersion_); - maxRpcVersion_ = subBuilder.buildPartial(); - } - - break; - } - case 18: { - io.grpc.alts.internal.RpcProtocolVersions.Version.Builder subBuilder = null; - if (minRpcVersion_ != null) { - subBuilder = minRpcVersion_.toBuilder(); - } - minRpcVersion_ = input.readMessage(io.grpc.alts.internal.RpcProtocolVersions.Version.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(minRpcVersion_); - minRpcVersion_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.RpcProtocolVersions.class, io.grpc.alts.internal.RpcProtocolVersions.Builder.class); - } - - public interface VersionOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.RpcProtocolVersions.Version) - com.google.protobuf.MessageOrBuilder { - - /** - * uint32 major = 1; - */ - int getMajor(); - - /** - * uint32 minor = 2; - */ - int getMinor(); - } - /** - *
-   * RPC version contains a major version and a minor version.
-   * 
- * - * Protobuf type {@code grpc.gcp.RpcProtocolVersions.Version} - */ - public static final class Version extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.RpcProtocolVersions.Version) - VersionOrBuilder { - private static final long serialVersionUID = 0L; - // Use Version.newBuilder() to construct. - private Version(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Version() { - major_ = 0; - minor_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Version( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - - major_ = input.readUInt32(); - break; - } - case 16: { - - minor_ = input.readUInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_Version_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_Version_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.RpcProtocolVersions.Version.class, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder.class); - } - - public static final int MAJOR_FIELD_NUMBER = 1; - private int major_; - /** - * uint32 major = 1; - */ - public int getMajor() { - return major_; - } - - public static final int MINOR_FIELD_NUMBER = 2; - private int minor_; - /** - * uint32 minor = 2; - */ - public int getMinor() { - return minor_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (major_ != 0) { - output.writeUInt32(1, major_); - } - if (minor_ != 0) { - output.writeUInt32(2, minor_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (major_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(1, major_); - } - if (minor_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(2, minor_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.RpcProtocolVersions.Version)) { - return super.equals(obj); - } - io.grpc.alts.internal.RpcProtocolVersions.Version other = (io.grpc.alts.internal.RpcProtocolVersions.Version) obj; - - boolean result = true; - result = result && (getMajor() - == other.getMajor()); - result = result && (getMinor() - == other.getMinor()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + MAJOR_FIELD_NUMBER; - hash = (53 * hash) + getMajor(); - hash = (37 * hash) + MINOR_FIELD_NUMBER; - hash = (53 * hash) + getMinor(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.RpcProtocolVersions.Version parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.RpcProtocolVersions.Version prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-     * RPC version contains a major version and a minor version.
-     * 
- * - * Protobuf type {@code grpc.gcp.RpcProtocolVersions.Version} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.RpcProtocolVersions.Version) - io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_Version_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_Version_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.RpcProtocolVersions.Version.class, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder.class); - } - - // Construct using io.grpc.alts.internal.RpcProtocolVersions.Version.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - major_ = 0; - - minor_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_Version_descriptor; - } - - public io.grpc.alts.internal.RpcProtocolVersions.Version getDefaultInstanceForType() { - return io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance(); - } - - public io.grpc.alts.internal.RpcProtocolVersions.Version build() { - io.grpc.alts.internal.RpcProtocolVersions.Version result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.RpcProtocolVersions.Version buildPartial() { - io.grpc.alts.internal.RpcProtocolVersions.Version result = new io.grpc.alts.internal.RpcProtocolVersions.Version(this); - result.major_ = major_; - result.minor_ = minor_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.RpcProtocolVersions.Version) { - return mergeFrom((io.grpc.alts.internal.RpcProtocolVersions.Version)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.RpcProtocolVersions.Version other) { - if (other == io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance()) return this; - if (other.getMajor() != 0) { - setMajor(other.getMajor()); - } - if (other.getMinor() != 0) { - setMinor(other.getMinor()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.RpcProtocolVersions.Version parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.RpcProtocolVersions.Version) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int major_ ; - /** - * uint32 major = 1; - */ - public int getMajor() { - return major_; - } - /** - * uint32 major = 1; - */ - public Builder setMajor(int value) { - - major_ = value; - onChanged(); - return this; - } - /** - * uint32 major = 1; - */ - public Builder clearMajor() { - - major_ = 0; - onChanged(); - return this; - } - - private int minor_ ; - /** - * uint32 minor = 2; - */ - public int getMinor() { - return minor_; - } - /** - * uint32 minor = 2; - */ - public Builder setMinor(int value) { - - minor_ = value; - onChanged(); - return this; - } - /** - * uint32 minor = 2; - */ - public Builder clearMinor() { - - minor_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.RpcProtocolVersions.Version) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.RpcProtocolVersions.Version) - private static final io.grpc.alts.internal.RpcProtocolVersions.Version DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.RpcProtocolVersions.Version(); - } - - public static io.grpc.alts.internal.RpcProtocolVersions.Version getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Version parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Version(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.RpcProtocolVersions.Version getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public static final int MAX_RPC_VERSION_FIELD_NUMBER = 1; - private io.grpc.alts.internal.RpcProtocolVersions.Version maxRpcVersion_; - /** - *
-   * Maximum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public boolean hasMaxRpcVersion() { - return maxRpcVersion_ != null; - } - /** - *
-   * Maximum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Version getMaxRpcVersion() { - return maxRpcVersion_ == null ? io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance() : maxRpcVersion_; - } - /** - *
-   * Maximum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder getMaxRpcVersionOrBuilder() { - return getMaxRpcVersion(); - } - - public static final int MIN_RPC_VERSION_FIELD_NUMBER = 2; - private io.grpc.alts.internal.RpcProtocolVersions.Version minRpcVersion_; - /** - *
-   * Minimum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public boolean hasMinRpcVersion() { - return minRpcVersion_ != null; - } - /** - *
-   * Minimum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Version getMinRpcVersion() { - return minRpcVersion_ == null ? io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance() : minRpcVersion_; - } - /** - *
-   * Minimum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder getMinRpcVersionOrBuilder() { - return getMinRpcVersion(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (maxRpcVersion_ != null) { - output.writeMessage(1, getMaxRpcVersion()); - } - if (minRpcVersion_ != null) { - output.writeMessage(2, getMinRpcVersion()); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (maxRpcVersion_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getMaxRpcVersion()); - } - if (minRpcVersion_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, getMinRpcVersion()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.RpcProtocolVersions)) { - return super.equals(obj); - } - io.grpc.alts.internal.RpcProtocolVersions other = (io.grpc.alts.internal.RpcProtocolVersions) obj; - - boolean result = true; - result = result && (hasMaxRpcVersion() == other.hasMaxRpcVersion()); - if (hasMaxRpcVersion()) { - result = result && getMaxRpcVersion() - .equals(other.getMaxRpcVersion()); - } - result = result && (hasMinRpcVersion() == other.hasMinRpcVersion()); - if (hasMinRpcVersion()) { - result = result && getMinRpcVersion() - .equals(other.getMinRpcVersion()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasMaxRpcVersion()) { - hash = (37 * hash) + MAX_RPC_VERSION_FIELD_NUMBER; - hash = (53 * hash) + getMaxRpcVersion().hashCode(); - } - if (hasMinRpcVersion()) { - hash = (37 * hash) + MIN_RPC_VERSION_FIELD_NUMBER; - hash = (53 * hash) + getMinRpcVersion().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.RpcProtocolVersions parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.RpcProtocolVersions prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - *
-   * Max and min supported RPC protocol versions.
-   * 
- * - * Protobuf type {@code grpc.gcp.RpcProtocolVersions} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.RpcProtocolVersions) - io.grpc.alts.internal.RpcProtocolVersionsOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.RpcProtocolVersions.class, io.grpc.alts.internal.RpcProtocolVersions.Builder.class); - } - - // Construct using io.grpc.alts.internal.RpcProtocolVersions.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - if (maxRpcVersionBuilder_ == null) { - maxRpcVersion_ = null; - } else { - maxRpcVersion_ = null; - maxRpcVersionBuilder_ = null; - } - if (minRpcVersionBuilder_ == null) { - minRpcVersion_ = null; - } else { - minRpcVersion_ = null; - minRpcVersionBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.TransportSecurityCommonProto.internal_static_grpc_gcp_RpcProtocolVersions_descriptor; - } - - public io.grpc.alts.internal.RpcProtocolVersions getDefaultInstanceForType() { - return io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance(); - } - - public io.grpc.alts.internal.RpcProtocolVersions build() { - io.grpc.alts.internal.RpcProtocolVersions result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.RpcProtocolVersions buildPartial() { - io.grpc.alts.internal.RpcProtocolVersions result = new io.grpc.alts.internal.RpcProtocolVersions(this); - if (maxRpcVersionBuilder_ == null) { - result.maxRpcVersion_ = maxRpcVersion_; - } else { - result.maxRpcVersion_ = maxRpcVersionBuilder_.build(); - } - if (minRpcVersionBuilder_ == null) { - result.minRpcVersion_ = minRpcVersion_; - } else { - result.minRpcVersion_ = minRpcVersionBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.RpcProtocolVersions) { - return mergeFrom((io.grpc.alts.internal.RpcProtocolVersions)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.RpcProtocolVersions other) { - if (other == io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance()) return this; - if (other.hasMaxRpcVersion()) { - mergeMaxRpcVersion(other.getMaxRpcVersion()); - } - if (other.hasMinRpcVersion()) { - mergeMinRpcVersion(other.getMinRpcVersion()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.RpcProtocolVersions parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.RpcProtocolVersions) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private io.grpc.alts.internal.RpcProtocolVersions.Version maxRpcVersion_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions.Version, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder, io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder> maxRpcVersionBuilder_; - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public boolean hasMaxRpcVersion() { - return maxRpcVersionBuilder_ != null || maxRpcVersion_ != null; - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Version getMaxRpcVersion() { - if (maxRpcVersionBuilder_ == null) { - return maxRpcVersion_ == null ? io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance() : maxRpcVersion_; - } else { - return maxRpcVersionBuilder_.getMessage(); - } - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public Builder setMaxRpcVersion(io.grpc.alts.internal.RpcProtocolVersions.Version value) { - if (maxRpcVersionBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - maxRpcVersion_ = value; - onChanged(); - } else { - maxRpcVersionBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public Builder setMaxRpcVersion( - io.grpc.alts.internal.RpcProtocolVersions.Version.Builder builderForValue) { - if (maxRpcVersionBuilder_ == null) { - maxRpcVersion_ = builderForValue.build(); - onChanged(); - } else { - maxRpcVersionBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public Builder mergeMaxRpcVersion(io.grpc.alts.internal.RpcProtocolVersions.Version value) { - if (maxRpcVersionBuilder_ == null) { - if (maxRpcVersion_ != null) { - maxRpcVersion_ = - io.grpc.alts.internal.RpcProtocolVersions.Version.newBuilder(maxRpcVersion_).mergeFrom(value).buildPartial(); - } else { - maxRpcVersion_ = value; - } - onChanged(); - } else { - maxRpcVersionBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public Builder clearMaxRpcVersion() { - if (maxRpcVersionBuilder_ == null) { - maxRpcVersion_ = null; - onChanged(); - } else { - maxRpcVersion_ = null; - maxRpcVersionBuilder_ = null; - } - - return this; - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Version.Builder getMaxRpcVersionBuilder() { - - onChanged(); - return getMaxRpcVersionFieldBuilder().getBuilder(); - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - public io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder getMaxRpcVersionOrBuilder() { - if (maxRpcVersionBuilder_ != null) { - return maxRpcVersionBuilder_.getMessageOrBuilder(); - } else { - return maxRpcVersion_ == null ? - io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance() : maxRpcVersion_; - } - } - /** - *
-     * Maximum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions.Version, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder, io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder> - getMaxRpcVersionFieldBuilder() { - if (maxRpcVersionBuilder_ == null) { - maxRpcVersionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions.Version, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder, io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder>( - getMaxRpcVersion(), - getParentForChildren(), - isClean()); - maxRpcVersion_ = null; - } - return maxRpcVersionBuilder_; - } - - private io.grpc.alts.internal.RpcProtocolVersions.Version minRpcVersion_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions.Version, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder, io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder> minRpcVersionBuilder_; - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public boolean hasMinRpcVersion() { - return minRpcVersionBuilder_ != null || minRpcVersion_ != null; - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Version getMinRpcVersion() { - if (minRpcVersionBuilder_ == null) { - return minRpcVersion_ == null ? io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance() : minRpcVersion_; - } else { - return minRpcVersionBuilder_.getMessage(); - } - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public Builder setMinRpcVersion(io.grpc.alts.internal.RpcProtocolVersions.Version value) { - if (minRpcVersionBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - minRpcVersion_ = value; - onChanged(); - } else { - minRpcVersionBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public Builder setMinRpcVersion( - io.grpc.alts.internal.RpcProtocolVersions.Version.Builder builderForValue) { - if (minRpcVersionBuilder_ == null) { - minRpcVersion_ = builderForValue.build(); - onChanged(); - } else { - minRpcVersionBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public Builder mergeMinRpcVersion(io.grpc.alts.internal.RpcProtocolVersions.Version value) { - if (minRpcVersionBuilder_ == null) { - if (minRpcVersion_ != null) { - minRpcVersion_ = - io.grpc.alts.internal.RpcProtocolVersions.Version.newBuilder(minRpcVersion_).mergeFrom(value).buildPartial(); - } else { - minRpcVersion_ = value; - } - onChanged(); - } else { - minRpcVersionBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public Builder clearMinRpcVersion() { - if (minRpcVersionBuilder_ == null) { - minRpcVersion_ = null; - onChanged(); - } else { - minRpcVersion_ = null; - minRpcVersionBuilder_ = null; - } - - return this; - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Version.Builder getMinRpcVersionBuilder() { - - onChanged(); - return getMinRpcVersionFieldBuilder().getBuilder(); - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - public io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder getMinRpcVersionOrBuilder() { - if (minRpcVersionBuilder_ != null) { - return minRpcVersionBuilder_.getMessageOrBuilder(); - } else { - return minRpcVersion_ == null ? - io.grpc.alts.internal.RpcProtocolVersions.Version.getDefaultInstance() : minRpcVersion_; - } - } - /** - *
-     * Minimum supported RPC version.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions.Version, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder, io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder> - getMinRpcVersionFieldBuilder() { - if (minRpcVersionBuilder_ == null) { - minRpcVersionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions.Version, io.grpc.alts.internal.RpcProtocolVersions.Version.Builder, io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder>( - getMinRpcVersion(), - getParentForChildren(), - isClean()); - minRpcVersion_ = null; - } - return minRpcVersionBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.RpcProtocolVersions) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.RpcProtocolVersions) - private static final io.grpc.alts.internal.RpcProtocolVersions DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.RpcProtocolVersions(); - } - - public static io.grpc.alts.internal.RpcProtocolVersions getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public RpcProtocolVersions parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new RpcProtocolVersions(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.RpcProtocolVersions getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/RpcProtocolVersionsOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/RpcProtocolVersionsOrBuilder.java deleted file mode 100644 index 774a6cc571d..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/RpcProtocolVersionsOrBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/transport_security_common.proto - -package io.grpc.alts.internal; - -public interface RpcProtocolVersionsOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.RpcProtocolVersions) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * Maximum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - boolean hasMaxRpcVersion(); - /** - *
-   * Maximum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - io.grpc.alts.internal.RpcProtocolVersions.Version getMaxRpcVersion(); - /** - *
-   * Maximum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version max_rpc_version = 1; - */ - io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder getMaxRpcVersionOrBuilder(); - - /** - *
-   * Minimum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - boolean hasMinRpcVersion(); - /** - *
-   * Minimum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - io.grpc.alts.internal.RpcProtocolVersions.Version getMinRpcVersion(); - /** - *
-   * Minimum supported RPC version.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions.Version min_rpc_version = 2; - */ - io.grpc.alts.internal.RpcProtocolVersions.VersionOrBuilder getMinRpcVersionOrBuilder(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/SecurityLevel.java b/alts/src/generated/main/java/io/grpc/alts/internal/SecurityLevel.java deleted file mode 100644 index aee2108f8af..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/SecurityLevel.java +++ /dev/null @@ -1,117 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/transport_security_common.proto - -package io.grpc.alts.internal; - -/** - *
- * The security level of the created channel. The list is sorted in increasing
- * level of security. This order must always be maintained.
- * 
- * - * Protobuf enum {@code grpc.gcp.SecurityLevel} - */ -public enum SecurityLevel - implements com.google.protobuf.ProtocolMessageEnum { - /** - * SECURITY_NONE = 0; - */ - SECURITY_NONE(0), - /** - * INTEGRITY_ONLY = 1; - */ - INTEGRITY_ONLY(1), - /** - * INTEGRITY_AND_PRIVACY = 2; - */ - INTEGRITY_AND_PRIVACY(2), - UNRECOGNIZED(-1), - ; - - /** - * SECURITY_NONE = 0; - */ - public static final int SECURITY_NONE_VALUE = 0; - /** - * INTEGRITY_ONLY = 1; - */ - public static final int INTEGRITY_ONLY_VALUE = 1; - /** - * INTEGRITY_AND_PRIVACY = 2; - */ - public static final int INTEGRITY_AND_PRIVACY_VALUE = 2; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static SecurityLevel valueOf(int value) { - return forNumber(value); - } - - public static SecurityLevel forNumber(int value) { - switch (value) { - case 0: return SECURITY_NONE; - case 1: return INTEGRITY_ONLY; - case 2: return INTEGRITY_AND_PRIVACY; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - SecurityLevel> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public SecurityLevel findValueByNumber(int number) { - return SecurityLevel.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return io.grpc.alts.internal.TransportSecurityCommonProto.getDescriptor().getEnumTypes().get(0); - } - - private static final SecurityLevel[] VALUES = values(); - - public static SecurityLevel valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private SecurityLevel(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:grpc.gcp.SecurityLevel) -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/ServerHandshakeParameters.java b/alts/src/generated/main/java/io/grpc/alts/internal/ServerHandshakeParameters.java deleted file mode 100644 index 3c733c6dd51..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/ServerHandshakeParameters.java +++ /dev/null @@ -1,1084 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.ServerHandshakeParameters} - */ -public final class ServerHandshakeParameters extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.ServerHandshakeParameters) - ServerHandshakeParametersOrBuilder { -private static final long serialVersionUID = 0L; - // Use ServerHandshakeParameters.newBuilder() to construct. - private ServerHandshakeParameters(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private ServerHandshakeParameters() { - recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - localIdentities_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private ServerHandshakeParameters( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - recordProtocols_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - recordProtocols_.add(s); - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - localIdentities_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - localIdentities_.add( - input.readMessage(io.grpc.alts.internal.Identity.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - recordProtocols_ = recordProtocols_.getUnmodifiableView(); - } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - localIdentities_ = java.util.Collections.unmodifiableList(localIdentities_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_ServerHandshakeParameters_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_ServerHandshakeParameters_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.ServerHandshakeParameters.class, io.grpc.alts.internal.ServerHandshakeParameters.Builder.class); - } - - public static final int RECORD_PROTOCOLS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList recordProtocols_; - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - public com.google.protobuf.ProtocolStringList - getRecordProtocolsList() { - return recordProtocols_; - } - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - public int getRecordProtocolsCount() { - return recordProtocols_.size(); - } - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - public java.lang.String getRecordProtocols(int index) { - return recordProtocols_.get(index); - } - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - public com.google.protobuf.ByteString - getRecordProtocolsBytes(int index) { - return recordProtocols_.getByteString(index); - } - - public static final int LOCAL_IDENTITIES_FIELD_NUMBER = 2; - private java.util.List localIdentities_; - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public java.util.List getLocalIdentitiesList() { - return localIdentities_; - } - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public java.util.List - getLocalIdentitiesOrBuilderList() { - return localIdentities_; - } - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public int getLocalIdentitiesCount() { - return localIdentities_.size(); - } - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.Identity getLocalIdentities(int index) { - return localIdentities_.get(index); - } - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.IdentityOrBuilder getLocalIdentitiesOrBuilder( - int index) { - return localIdentities_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < recordProtocols_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, recordProtocols_.getRaw(i)); - } - for (int i = 0; i < localIdentities_.size(); i++) { - output.writeMessage(2, localIdentities_.get(i)); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < recordProtocols_.size(); i++) { - dataSize += computeStringSizeNoTag(recordProtocols_.getRaw(i)); - } - size += dataSize; - size += 1 * getRecordProtocolsList().size(); - } - for (int i = 0; i < localIdentities_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, localIdentities_.get(i)); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.ServerHandshakeParameters)) { - return super.equals(obj); - } - io.grpc.alts.internal.ServerHandshakeParameters other = (io.grpc.alts.internal.ServerHandshakeParameters) obj; - - boolean result = true; - result = result && getRecordProtocolsList() - .equals(other.getRecordProtocolsList()); - result = result && getLocalIdentitiesList() - .equals(other.getLocalIdentitiesList()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getRecordProtocolsCount() > 0) { - hash = (37 * hash) + RECORD_PROTOCOLS_FIELD_NUMBER; - hash = (53 * hash) + getRecordProtocolsList().hashCode(); - } - if (getLocalIdentitiesCount() > 0) { - hash = (37 * hash) + LOCAL_IDENTITIES_FIELD_NUMBER; - hash = (53 * hash) + getLocalIdentitiesList().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.ServerHandshakeParameters parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.ServerHandshakeParameters prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.ServerHandshakeParameters} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.ServerHandshakeParameters) - io.grpc.alts.internal.ServerHandshakeParametersOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_ServerHandshakeParameters_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_ServerHandshakeParameters_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.ServerHandshakeParameters.class, io.grpc.alts.internal.ServerHandshakeParameters.Builder.class); - } - - // Construct using io.grpc.alts.internal.ServerHandshakeParameters.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getLocalIdentitiesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - if (localIdentitiesBuilder_ == null) { - localIdentities_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - } else { - localIdentitiesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_ServerHandshakeParameters_descriptor; - } - - public io.grpc.alts.internal.ServerHandshakeParameters getDefaultInstanceForType() { - return io.grpc.alts.internal.ServerHandshakeParameters.getDefaultInstance(); - } - - public io.grpc.alts.internal.ServerHandshakeParameters build() { - io.grpc.alts.internal.ServerHandshakeParameters result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.ServerHandshakeParameters buildPartial() { - io.grpc.alts.internal.ServerHandshakeParameters result = new io.grpc.alts.internal.ServerHandshakeParameters(this); - int from_bitField0_ = bitField0_; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - recordProtocols_ = recordProtocols_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.recordProtocols_ = recordProtocols_; - if (localIdentitiesBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - localIdentities_ = java.util.Collections.unmodifiableList(localIdentities_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.localIdentities_ = localIdentities_; - } else { - result.localIdentities_ = localIdentitiesBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.ServerHandshakeParameters) { - return mergeFrom((io.grpc.alts.internal.ServerHandshakeParameters)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.ServerHandshakeParameters other) { - if (other == io.grpc.alts.internal.ServerHandshakeParameters.getDefaultInstance()) return this; - if (!other.recordProtocols_.isEmpty()) { - if (recordProtocols_.isEmpty()) { - recordProtocols_ = other.recordProtocols_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureRecordProtocolsIsMutable(); - recordProtocols_.addAll(other.recordProtocols_); - } - onChanged(); - } - if (localIdentitiesBuilder_ == null) { - if (!other.localIdentities_.isEmpty()) { - if (localIdentities_.isEmpty()) { - localIdentities_ = other.localIdentities_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureLocalIdentitiesIsMutable(); - localIdentities_.addAll(other.localIdentities_); - } - onChanged(); - } - } else { - if (!other.localIdentities_.isEmpty()) { - if (localIdentitiesBuilder_.isEmpty()) { - localIdentitiesBuilder_.dispose(); - localIdentitiesBuilder_ = null; - localIdentities_ = other.localIdentities_; - bitField0_ = (bitField0_ & ~0x00000002); - localIdentitiesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getLocalIdentitiesFieldBuilder() : null; - } else { - localIdentitiesBuilder_.addAllMessages(other.localIdentities_); - } - } - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.ServerHandshakeParameters parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.ServerHandshakeParameters) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.LazyStringList recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureRecordProtocolsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - recordProtocols_ = new com.google.protobuf.LazyStringArrayList(recordProtocols_); - bitField0_ |= 0x00000001; - } - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public com.google.protobuf.ProtocolStringList - getRecordProtocolsList() { - return recordProtocols_.getUnmodifiableView(); - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public int getRecordProtocolsCount() { - return recordProtocols_.size(); - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public java.lang.String getRecordProtocols(int index) { - return recordProtocols_.get(index); - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public com.google.protobuf.ByteString - getRecordProtocolsBytes(int index) { - return recordProtocols_.getByteString(index); - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public Builder setRecordProtocols( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureRecordProtocolsIsMutable(); - recordProtocols_.set(index, value); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public Builder addRecordProtocols( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureRecordProtocolsIsMutable(); - recordProtocols_.add(value); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public Builder addAllRecordProtocols( - java.lang.Iterable values) { - ensureRecordProtocolsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, recordProtocols_); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public Builder clearRecordProtocols() { - recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the server, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 1; - */ - public Builder addRecordProtocolsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureRecordProtocolsIsMutable(); - recordProtocols_.add(value); - onChanged(); - return this; - } - - private java.util.List localIdentities_ = - java.util.Collections.emptyList(); - private void ensureLocalIdentitiesIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - localIdentities_ = new java.util.ArrayList(localIdentities_); - bitField0_ |= 0x00000002; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> localIdentitiesBuilder_; - - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public java.util.List getLocalIdentitiesList() { - if (localIdentitiesBuilder_ == null) { - return java.util.Collections.unmodifiableList(localIdentities_); - } else { - return localIdentitiesBuilder_.getMessageList(); - } - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public int getLocalIdentitiesCount() { - if (localIdentitiesBuilder_ == null) { - return localIdentities_.size(); - } else { - return localIdentitiesBuilder_.getCount(); - } - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.Identity getLocalIdentities(int index) { - if (localIdentitiesBuilder_ == null) { - return localIdentities_.get(index); - } else { - return localIdentitiesBuilder_.getMessage(index); - } - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder setLocalIdentities( - int index, io.grpc.alts.internal.Identity value) { - if (localIdentitiesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureLocalIdentitiesIsMutable(); - localIdentities_.set(index, value); - onChanged(); - } else { - localIdentitiesBuilder_.setMessage(index, value); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder setLocalIdentities( - int index, io.grpc.alts.internal.Identity.Builder builderForValue) { - if (localIdentitiesBuilder_ == null) { - ensureLocalIdentitiesIsMutable(); - localIdentities_.set(index, builderForValue.build()); - onChanged(); - } else { - localIdentitiesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder addLocalIdentities(io.grpc.alts.internal.Identity value) { - if (localIdentitiesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureLocalIdentitiesIsMutable(); - localIdentities_.add(value); - onChanged(); - } else { - localIdentitiesBuilder_.addMessage(value); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder addLocalIdentities( - int index, io.grpc.alts.internal.Identity value) { - if (localIdentitiesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureLocalIdentitiesIsMutable(); - localIdentities_.add(index, value); - onChanged(); - } else { - localIdentitiesBuilder_.addMessage(index, value); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder addLocalIdentities( - io.grpc.alts.internal.Identity.Builder builderForValue) { - if (localIdentitiesBuilder_ == null) { - ensureLocalIdentitiesIsMutable(); - localIdentities_.add(builderForValue.build()); - onChanged(); - } else { - localIdentitiesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder addLocalIdentities( - int index, io.grpc.alts.internal.Identity.Builder builderForValue) { - if (localIdentitiesBuilder_ == null) { - ensureLocalIdentitiesIsMutable(); - localIdentities_.add(index, builderForValue.build()); - onChanged(); - } else { - localIdentitiesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder addAllLocalIdentities( - java.lang.Iterable values) { - if (localIdentitiesBuilder_ == null) { - ensureLocalIdentitiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, localIdentities_); - onChanged(); - } else { - localIdentitiesBuilder_.addAllMessages(values); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder clearLocalIdentities() { - if (localIdentitiesBuilder_ == null) { - localIdentities_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - localIdentitiesBuilder_.clear(); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public Builder removeLocalIdentities(int index) { - if (localIdentitiesBuilder_ == null) { - ensureLocalIdentitiesIsMutable(); - localIdentities_.remove(index); - onChanged(); - } else { - localIdentitiesBuilder_.remove(index); - } - return this; - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.Identity.Builder getLocalIdentitiesBuilder( - int index) { - return getLocalIdentitiesFieldBuilder().getBuilder(index); - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.IdentityOrBuilder getLocalIdentitiesOrBuilder( - int index) { - if (localIdentitiesBuilder_ == null) { - return localIdentities_.get(index); } else { - return localIdentitiesBuilder_.getMessageOrBuilder(index); - } - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public java.util.List - getLocalIdentitiesOrBuilderList() { - if (localIdentitiesBuilder_ != null) { - return localIdentitiesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(localIdentities_); - } - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.Identity.Builder addLocalIdentitiesBuilder() { - return getLocalIdentitiesFieldBuilder().addBuilder( - io.grpc.alts.internal.Identity.getDefaultInstance()); - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public io.grpc.alts.internal.Identity.Builder addLocalIdentitiesBuilder( - int index) { - return getLocalIdentitiesFieldBuilder().addBuilder( - index, io.grpc.alts.internal.Identity.getDefaultInstance()); - } - /** - *
-     * (Optional) A list of local identities supported by the server, if
-     * specified. Otherwise, the handshaker chooses a default local identity.
-     * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - public java.util.List - getLocalIdentitiesBuilderList() { - return getLocalIdentitiesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> - getLocalIdentitiesFieldBuilder() { - if (localIdentitiesBuilder_ == null) { - localIdentitiesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder>( - localIdentities_, - ((bitField0_ & 0x00000002) == 0x00000002), - getParentForChildren(), - isClean()); - localIdentities_ = null; - } - return localIdentitiesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.ServerHandshakeParameters) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.ServerHandshakeParameters) - private static final io.grpc.alts.internal.ServerHandshakeParameters DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.ServerHandshakeParameters(); - } - - public static io.grpc.alts.internal.ServerHandshakeParameters getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ServerHandshakeParameters parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new ServerHandshakeParameters(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.ServerHandshakeParameters getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/ServerHandshakeParametersOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/ServerHandshakeParametersOrBuilder.java deleted file mode 100644 index 2b16fe509cd..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/ServerHandshakeParametersOrBuilder.java +++ /dev/null @@ -1,97 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface ServerHandshakeParametersOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.ServerHandshakeParameters) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - java.util.List - getRecordProtocolsList(); - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - int getRecordProtocolsCount(); - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - java.lang.String getRecordProtocols(int index); - /** - *
-   * The record protocols supported by the server, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 1; - */ - com.google.protobuf.ByteString - getRecordProtocolsBytes(int index); - - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - java.util.List - getLocalIdentitiesList(); - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - io.grpc.alts.internal.Identity getLocalIdentities(int index); - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - int getLocalIdentitiesCount(); - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - java.util.List - getLocalIdentitiesOrBuilderList(); - /** - *
-   * (Optional) A list of local identities supported by the server, if
-   * specified. Otherwise, the handshaker chooses a default local identity.
-   * 
- * - * repeated .grpc.gcp.Identity local_identities = 2; - */ - io.grpc.alts.internal.IdentityOrBuilder getLocalIdentitiesOrBuilder( - int index); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/StartClientHandshakeReq.java b/alts/src/generated/main/java/io/grpc/alts/internal/StartClientHandshakeReq.java deleted file mode 100644 index 41aeb12f8f6..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/StartClientHandshakeReq.java +++ /dev/null @@ -1,2577 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.StartClientHandshakeReq} - */ -public final class StartClientHandshakeReq extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.StartClientHandshakeReq) - StartClientHandshakeReqOrBuilder { -private static final long serialVersionUID = 0L; - // Use StartClientHandshakeReq.newBuilder() to construct. - private StartClientHandshakeReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private StartClientHandshakeReq() { - handshakeSecurityProtocol_ = 0; - applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - targetIdentities_ = java.util.Collections.emptyList(); - targetName_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private StartClientHandshakeReq( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - int rawValue = input.readEnum(); - - handshakeSecurityProtocol_ = rawValue; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - applicationProtocols_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - applicationProtocols_.add(s); - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - recordProtocols_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000004; - } - recordProtocols_.add(s); - break; - } - case 34: { - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - targetIdentities_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; - } - targetIdentities_.add( - input.readMessage(io.grpc.alts.internal.Identity.parser(), extensionRegistry)); - break; - } - case 42: { - io.grpc.alts.internal.Identity.Builder subBuilder = null; - if (localIdentity_ != null) { - subBuilder = localIdentity_.toBuilder(); - } - localIdentity_ = input.readMessage(io.grpc.alts.internal.Identity.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(localIdentity_); - localIdentity_ = subBuilder.buildPartial(); - } - - break; - } - case 50: { - io.grpc.alts.internal.Endpoint.Builder subBuilder = null; - if (localEndpoint_ != null) { - subBuilder = localEndpoint_.toBuilder(); - } - localEndpoint_ = input.readMessage(io.grpc.alts.internal.Endpoint.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(localEndpoint_); - localEndpoint_ = subBuilder.buildPartial(); - } - - break; - } - case 58: { - io.grpc.alts.internal.Endpoint.Builder subBuilder = null; - if (remoteEndpoint_ != null) { - subBuilder = remoteEndpoint_.toBuilder(); - } - remoteEndpoint_ = input.readMessage(io.grpc.alts.internal.Endpoint.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(remoteEndpoint_); - remoteEndpoint_ = subBuilder.buildPartial(); - } - - break; - } - case 66: { - java.lang.String s = input.readStringRequireUtf8(); - - targetName_ = s; - break; - } - case 74: { - io.grpc.alts.internal.RpcProtocolVersions.Builder subBuilder = null; - if (rpcVersions_ != null) { - subBuilder = rpcVersions_.toBuilder(); - } - rpcVersions_ = input.readMessage(io.grpc.alts.internal.RpcProtocolVersions.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(rpcVersions_); - rpcVersions_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - applicationProtocols_ = applicationProtocols_.getUnmodifiableView(); - } - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - recordProtocols_ = recordProtocols_.getUnmodifiableView(); - } - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - targetIdentities_ = java.util.Collections.unmodifiableList(targetIdentities_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartClientHandshakeReq_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartClientHandshakeReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.StartClientHandshakeReq.class, io.grpc.alts.internal.StartClientHandshakeReq.Builder.class); - } - - private int bitField0_; - public static final int HANDSHAKE_SECURITY_PROTOCOL_FIELD_NUMBER = 1; - private int handshakeSecurityProtocol_; - /** - *
-   * Handshake security protocol requested by the client.
-   * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public int getHandshakeSecurityProtocolValue() { - return handshakeSecurityProtocol_; - } - /** - *
-   * Handshake security protocol requested by the client.
-   * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public io.grpc.alts.internal.HandshakeProtocol getHandshakeSecurityProtocol() { - io.grpc.alts.internal.HandshakeProtocol result = io.grpc.alts.internal.HandshakeProtocol.valueOf(handshakeSecurityProtocol_); - return result == null ? io.grpc.alts.internal.HandshakeProtocol.UNRECOGNIZED : result; - } - - public static final int APPLICATION_PROTOCOLS_FIELD_NUMBER = 2; - private com.google.protobuf.LazyStringList applicationProtocols_; - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - public com.google.protobuf.ProtocolStringList - getApplicationProtocolsList() { - return applicationProtocols_; - } - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - public int getApplicationProtocolsCount() { - return applicationProtocols_.size(); - } - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - public java.lang.String getApplicationProtocols(int index) { - return applicationProtocols_.get(index); - } - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - public com.google.protobuf.ByteString - getApplicationProtocolsBytes(int index) { - return applicationProtocols_.getByteString(index); - } - - public static final int RECORD_PROTOCOLS_FIELD_NUMBER = 3; - private com.google.protobuf.LazyStringList recordProtocols_; - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - public com.google.protobuf.ProtocolStringList - getRecordProtocolsList() { - return recordProtocols_; - } - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - public int getRecordProtocolsCount() { - return recordProtocols_.size(); - } - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - public java.lang.String getRecordProtocols(int index) { - return recordProtocols_.get(index); - } - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - public com.google.protobuf.ByteString - getRecordProtocolsBytes(int index) { - return recordProtocols_.getByteString(index); - } - - public static final int TARGET_IDENTITIES_FIELD_NUMBER = 4; - private java.util.List targetIdentities_; - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public java.util.List getTargetIdentitiesList() { - return targetIdentities_; - } - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public java.util.List - getTargetIdentitiesOrBuilderList() { - return targetIdentities_; - } - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public int getTargetIdentitiesCount() { - return targetIdentities_.size(); - } - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.Identity getTargetIdentities(int index) { - return targetIdentities_.get(index); - } - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.IdentityOrBuilder getTargetIdentitiesOrBuilder( - int index) { - return targetIdentities_.get(index); - } - - public static final int LOCAL_IDENTITY_FIELD_NUMBER = 5; - private io.grpc.alts.internal.Identity localIdentity_; - /** - *
-   * (Optional) Application may specify a local identity. Otherwise, the
-   * handshaker chooses a default local identity.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public boolean hasLocalIdentity() { - return localIdentity_ != null; - } - /** - *
-   * (Optional) Application may specify a local identity. Otherwise, the
-   * handshaker chooses a default local identity.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.Identity getLocalIdentity() { - return localIdentity_ == null ? io.grpc.alts.internal.Identity.getDefaultInstance() : localIdentity_; - } - /** - *
-   * (Optional) Application may specify a local identity. Otherwise, the
-   * handshaker chooses a default local identity.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.IdentityOrBuilder getLocalIdentityOrBuilder() { - return getLocalIdentity(); - } - - public static final int LOCAL_ENDPOINT_FIELD_NUMBER = 6; - private io.grpc.alts.internal.Endpoint localEndpoint_; - /** - *
-   * (Optional) Local endpoint information of the connection to the server,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public boolean hasLocalEndpoint() { - return localEndpoint_ != null; - } - /** - *
-   * (Optional) Local endpoint information of the connection to the server,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public io.grpc.alts.internal.Endpoint getLocalEndpoint() { - return localEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : localEndpoint_; - } - /** - *
-   * (Optional) Local endpoint information of the connection to the server,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public io.grpc.alts.internal.EndpointOrBuilder getLocalEndpointOrBuilder() { - return getLocalEndpoint(); - } - - public static final int REMOTE_ENDPOINT_FIELD_NUMBER = 7; - private io.grpc.alts.internal.Endpoint remoteEndpoint_; - /** - *
-   * (Optional) Endpoint information of the remote server, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public boolean hasRemoteEndpoint() { - return remoteEndpoint_ != null; - } - /** - *
-   * (Optional) Endpoint information of the remote server, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public io.grpc.alts.internal.Endpoint getRemoteEndpoint() { - return remoteEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : remoteEndpoint_; - } - /** - *
-   * (Optional) Endpoint information of the remote server, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public io.grpc.alts.internal.EndpointOrBuilder getRemoteEndpointOrBuilder() { - return getRemoteEndpoint(); - } - - public static final int TARGET_NAME_FIELD_NUMBER = 8; - private volatile java.lang.Object targetName_; - /** - *
-   * (Optional) If target name is provided, a secure naming check is performed
-   * to verify that the peer authenticated identity is indeed authorized to run
-   * the target name.
-   * 
- * - * string target_name = 8; - */ - public java.lang.String getTargetName() { - java.lang.Object ref = targetName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - targetName_ = s; - return s; - } - } - /** - *
-   * (Optional) If target name is provided, a secure naming check is performed
-   * to verify that the peer authenticated identity is indeed authorized to run
-   * the target name.
-   * 
- * - * string target_name = 8; - */ - public com.google.protobuf.ByteString - getTargetNameBytes() { - java.lang.Object ref = targetName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - targetName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RPC_VERSIONS_FIELD_NUMBER = 9; - private io.grpc.alts.internal.RpcProtocolVersions rpcVersions_; - /** - *
-   * (Optional) RPC protocol versions supported by the client.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public boolean hasRpcVersions() { - return rpcVersions_ != null; - } - /** - *
-   * (Optional) RPC protocol versions supported by the client.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public io.grpc.alts.internal.RpcProtocolVersions getRpcVersions() { - return rpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : rpcVersions_; - } - /** - *
-   * (Optional) RPC protocol versions supported by the client.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getRpcVersionsOrBuilder() { - return getRpcVersions(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (handshakeSecurityProtocol_ != io.grpc.alts.internal.HandshakeProtocol.HANDSHAKE_PROTOCOL_UNSPECIFIED.getNumber()) { - output.writeEnum(1, handshakeSecurityProtocol_); - } - for (int i = 0; i < applicationProtocols_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, applicationProtocols_.getRaw(i)); - } - for (int i = 0; i < recordProtocols_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, recordProtocols_.getRaw(i)); - } - for (int i = 0; i < targetIdentities_.size(); i++) { - output.writeMessage(4, targetIdentities_.get(i)); - } - if (localIdentity_ != null) { - output.writeMessage(5, getLocalIdentity()); - } - if (localEndpoint_ != null) { - output.writeMessage(6, getLocalEndpoint()); - } - if (remoteEndpoint_ != null) { - output.writeMessage(7, getRemoteEndpoint()); - } - if (!getTargetNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, targetName_); - } - if (rpcVersions_ != null) { - output.writeMessage(9, getRpcVersions()); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (handshakeSecurityProtocol_ != io.grpc.alts.internal.HandshakeProtocol.HANDSHAKE_PROTOCOL_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(1, handshakeSecurityProtocol_); - } - { - int dataSize = 0; - for (int i = 0; i < applicationProtocols_.size(); i++) { - dataSize += computeStringSizeNoTag(applicationProtocols_.getRaw(i)); - } - size += dataSize; - size += 1 * getApplicationProtocolsList().size(); - } - { - int dataSize = 0; - for (int i = 0; i < recordProtocols_.size(); i++) { - dataSize += computeStringSizeNoTag(recordProtocols_.getRaw(i)); - } - size += dataSize; - size += 1 * getRecordProtocolsList().size(); - } - for (int i = 0; i < targetIdentities_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, targetIdentities_.get(i)); - } - if (localIdentity_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, getLocalIdentity()); - } - if (localEndpoint_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, getLocalEndpoint()); - } - if (remoteEndpoint_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, getRemoteEndpoint()); - } - if (!getTargetNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, targetName_); - } - if (rpcVersions_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, getRpcVersions()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.StartClientHandshakeReq)) { - return super.equals(obj); - } - io.grpc.alts.internal.StartClientHandshakeReq other = (io.grpc.alts.internal.StartClientHandshakeReq) obj; - - boolean result = true; - result = result && handshakeSecurityProtocol_ == other.handshakeSecurityProtocol_; - result = result && getApplicationProtocolsList() - .equals(other.getApplicationProtocolsList()); - result = result && getRecordProtocolsList() - .equals(other.getRecordProtocolsList()); - result = result && getTargetIdentitiesList() - .equals(other.getTargetIdentitiesList()); - result = result && (hasLocalIdentity() == other.hasLocalIdentity()); - if (hasLocalIdentity()) { - result = result && getLocalIdentity() - .equals(other.getLocalIdentity()); - } - result = result && (hasLocalEndpoint() == other.hasLocalEndpoint()); - if (hasLocalEndpoint()) { - result = result && getLocalEndpoint() - .equals(other.getLocalEndpoint()); - } - result = result && (hasRemoteEndpoint() == other.hasRemoteEndpoint()); - if (hasRemoteEndpoint()) { - result = result && getRemoteEndpoint() - .equals(other.getRemoteEndpoint()); - } - result = result && getTargetName() - .equals(other.getTargetName()); - result = result && (hasRpcVersions() == other.hasRpcVersions()); - if (hasRpcVersions()) { - result = result && getRpcVersions() - .equals(other.getRpcVersions()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + HANDSHAKE_SECURITY_PROTOCOL_FIELD_NUMBER; - hash = (53 * hash) + handshakeSecurityProtocol_; - if (getApplicationProtocolsCount() > 0) { - hash = (37 * hash) + APPLICATION_PROTOCOLS_FIELD_NUMBER; - hash = (53 * hash) + getApplicationProtocolsList().hashCode(); - } - if (getRecordProtocolsCount() > 0) { - hash = (37 * hash) + RECORD_PROTOCOLS_FIELD_NUMBER; - hash = (53 * hash) + getRecordProtocolsList().hashCode(); - } - if (getTargetIdentitiesCount() > 0) { - hash = (37 * hash) + TARGET_IDENTITIES_FIELD_NUMBER; - hash = (53 * hash) + getTargetIdentitiesList().hashCode(); - } - if (hasLocalIdentity()) { - hash = (37 * hash) + LOCAL_IDENTITY_FIELD_NUMBER; - hash = (53 * hash) + getLocalIdentity().hashCode(); - } - if (hasLocalEndpoint()) { - hash = (37 * hash) + LOCAL_ENDPOINT_FIELD_NUMBER; - hash = (53 * hash) + getLocalEndpoint().hashCode(); - } - if (hasRemoteEndpoint()) { - hash = (37 * hash) + REMOTE_ENDPOINT_FIELD_NUMBER; - hash = (53 * hash) + getRemoteEndpoint().hashCode(); - } - hash = (37 * hash) + TARGET_NAME_FIELD_NUMBER; - hash = (53 * hash) + getTargetName().hashCode(); - if (hasRpcVersions()) { - hash = (37 * hash) + RPC_VERSIONS_FIELD_NUMBER; - hash = (53 * hash) + getRpcVersions().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.StartClientHandshakeReq parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.StartClientHandshakeReq prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.StartClientHandshakeReq} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.StartClientHandshakeReq) - io.grpc.alts.internal.StartClientHandshakeReqOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartClientHandshakeReq_descriptor; - } - - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartClientHandshakeReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.StartClientHandshakeReq.class, io.grpc.alts.internal.StartClientHandshakeReq.Builder.class); - } - - // Construct using io.grpc.alts.internal.StartClientHandshakeReq.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getTargetIdentitiesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - handshakeSecurityProtocol_ = 0; - - applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - if (targetIdentitiesBuilder_ == null) { - targetIdentities_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - } else { - targetIdentitiesBuilder_.clear(); - } - if (localIdentityBuilder_ == null) { - localIdentity_ = null; - } else { - localIdentity_ = null; - localIdentityBuilder_ = null; - } - if (localEndpointBuilder_ == null) { - localEndpoint_ = null; - } else { - localEndpoint_ = null; - localEndpointBuilder_ = null; - } - if (remoteEndpointBuilder_ == null) { - remoteEndpoint_ = null; - } else { - remoteEndpoint_ = null; - remoteEndpointBuilder_ = null; - } - targetName_ = ""; - - if (rpcVersionsBuilder_ == null) { - rpcVersions_ = null; - } else { - rpcVersions_ = null; - rpcVersionsBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartClientHandshakeReq_descriptor; - } - - public io.grpc.alts.internal.StartClientHandshakeReq getDefaultInstanceForType() { - return io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance(); - } - - public io.grpc.alts.internal.StartClientHandshakeReq build() { - io.grpc.alts.internal.StartClientHandshakeReq result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.StartClientHandshakeReq buildPartial() { - io.grpc.alts.internal.StartClientHandshakeReq result = new io.grpc.alts.internal.StartClientHandshakeReq(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.handshakeSecurityProtocol_ = handshakeSecurityProtocol_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - applicationProtocols_ = applicationProtocols_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.applicationProtocols_ = applicationProtocols_; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - recordProtocols_ = recordProtocols_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.recordProtocols_ = recordProtocols_; - if (targetIdentitiesBuilder_ == null) { - if (((bitField0_ & 0x00000008) == 0x00000008)) { - targetIdentities_ = java.util.Collections.unmodifiableList(targetIdentities_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.targetIdentities_ = targetIdentities_; - } else { - result.targetIdentities_ = targetIdentitiesBuilder_.build(); - } - if (localIdentityBuilder_ == null) { - result.localIdentity_ = localIdentity_; - } else { - result.localIdentity_ = localIdentityBuilder_.build(); - } - if (localEndpointBuilder_ == null) { - result.localEndpoint_ = localEndpoint_; - } else { - result.localEndpoint_ = localEndpointBuilder_.build(); - } - if (remoteEndpointBuilder_ == null) { - result.remoteEndpoint_ = remoteEndpoint_; - } else { - result.remoteEndpoint_ = remoteEndpointBuilder_.build(); - } - result.targetName_ = targetName_; - if (rpcVersionsBuilder_ == null) { - result.rpcVersions_ = rpcVersions_; - } else { - result.rpcVersions_ = rpcVersionsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.StartClientHandshakeReq) { - return mergeFrom((io.grpc.alts.internal.StartClientHandshakeReq)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.StartClientHandshakeReq other) { - if (other == io.grpc.alts.internal.StartClientHandshakeReq.getDefaultInstance()) return this; - if (other.handshakeSecurityProtocol_ != 0) { - setHandshakeSecurityProtocolValue(other.getHandshakeSecurityProtocolValue()); - } - if (!other.applicationProtocols_.isEmpty()) { - if (applicationProtocols_.isEmpty()) { - applicationProtocols_ = other.applicationProtocols_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.addAll(other.applicationProtocols_); - } - onChanged(); - } - if (!other.recordProtocols_.isEmpty()) { - if (recordProtocols_.isEmpty()) { - recordProtocols_ = other.recordProtocols_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureRecordProtocolsIsMutable(); - recordProtocols_.addAll(other.recordProtocols_); - } - onChanged(); - } - if (targetIdentitiesBuilder_ == null) { - if (!other.targetIdentities_.isEmpty()) { - if (targetIdentities_.isEmpty()) { - targetIdentities_ = other.targetIdentities_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureTargetIdentitiesIsMutable(); - targetIdentities_.addAll(other.targetIdentities_); - } - onChanged(); - } - } else { - if (!other.targetIdentities_.isEmpty()) { - if (targetIdentitiesBuilder_.isEmpty()) { - targetIdentitiesBuilder_.dispose(); - targetIdentitiesBuilder_ = null; - targetIdentities_ = other.targetIdentities_; - bitField0_ = (bitField0_ & ~0x00000008); - targetIdentitiesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getTargetIdentitiesFieldBuilder() : null; - } else { - targetIdentitiesBuilder_.addAllMessages(other.targetIdentities_); - } - } - } - if (other.hasLocalIdentity()) { - mergeLocalIdentity(other.getLocalIdentity()); - } - if (other.hasLocalEndpoint()) { - mergeLocalEndpoint(other.getLocalEndpoint()); - } - if (other.hasRemoteEndpoint()) { - mergeRemoteEndpoint(other.getRemoteEndpoint()); - } - if (!other.getTargetName().isEmpty()) { - targetName_ = other.targetName_; - onChanged(); - } - if (other.hasRpcVersions()) { - mergeRpcVersions(other.getRpcVersions()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.StartClientHandshakeReq parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.StartClientHandshakeReq) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private int handshakeSecurityProtocol_ = 0; - /** - *
-     * Handshake security protocol requested by the client.
-     * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public int getHandshakeSecurityProtocolValue() { - return handshakeSecurityProtocol_; - } - /** - *
-     * Handshake security protocol requested by the client.
-     * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public Builder setHandshakeSecurityProtocolValue(int value) { - handshakeSecurityProtocol_ = value; - onChanged(); - return this; - } - /** - *
-     * Handshake security protocol requested by the client.
-     * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public io.grpc.alts.internal.HandshakeProtocol getHandshakeSecurityProtocol() { - io.grpc.alts.internal.HandshakeProtocol result = io.grpc.alts.internal.HandshakeProtocol.valueOf(handshakeSecurityProtocol_); - return result == null ? io.grpc.alts.internal.HandshakeProtocol.UNRECOGNIZED : result; - } - /** - *
-     * Handshake security protocol requested by the client.
-     * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public Builder setHandshakeSecurityProtocol(io.grpc.alts.internal.HandshakeProtocol value) { - if (value == null) { - throw new NullPointerException(); - } - - handshakeSecurityProtocol_ = value.getNumber(); - onChanged(); - return this; - } - /** - *
-     * Handshake security protocol requested by the client.
-     * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - public Builder clearHandshakeSecurityProtocol() { - - handshakeSecurityProtocol_ = 0; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureApplicationProtocolsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - applicationProtocols_ = new com.google.protobuf.LazyStringArrayList(applicationProtocols_); - bitField0_ |= 0x00000002; - } - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public com.google.protobuf.ProtocolStringList - getApplicationProtocolsList() { - return applicationProtocols_.getUnmodifiableView(); - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public int getApplicationProtocolsCount() { - return applicationProtocols_.size(); - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public java.lang.String getApplicationProtocols(int index) { - return applicationProtocols_.get(index); - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public com.google.protobuf.ByteString - getApplicationProtocolsBytes(int index) { - return applicationProtocols_.getByteString(index); - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public Builder setApplicationProtocols( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.set(index, value); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public Builder addApplicationProtocols( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.add(value); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public Builder addAllApplicationProtocols( - java.lang.Iterable values) { - ensureApplicationProtocolsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, applicationProtocols_); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public Builder clearApplicationProtocols() { - applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the client, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 2; - */ - public Builder addApplicationProtocolsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.add(value); - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureRecordProtocolsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - recordProtocols_ = new com.google.protobuf.LazyStringArrayList(recordProtocols_); - bitField0_ |= 0x00000004; - } - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public com.google.protobuf.ProtocolStringList - getRecordProtocolsList() { - return recordProtocols_.getUnmodifiableView(); - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public int getRecordProtocolsCount() { - return recordProtocols_.size(); - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public java.lang.String getRecordProtocols(int index) { - return recordProtocols_.get(index); - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public com.google.protobuf.ByteString - getRecordProtocolsBytes(int index) { - return recordProtocols_.getByteString(index); - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public Builder setRecordProtocols( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureRecordProtocolsIsMutable(); - recordProtocols_.set(index, value); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public Builder addRecordProtocols( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureRecordProtocolsIsMutable(); - recordProtocols_.add(value); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public Builder addAllRecordProtocols( - java.lang.Iterable values) { - ensureRecordProtocolsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, recordProtocols_); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public Builder clearRecordProtocols() { - recordProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - return this; - } - /** - *
-     * The record protocols supported by the client, e.g.,
-     * "ALTSRP_GCM_AES128".
-     * 
- * - * repeated string record_protocols = 3; - */ - public Builder addRecordProtocolsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureRecordProtocolsIsMutable(); - recordProtocols_.add(value); - onChanged(); - return this; - } - - private java.util.List targetIdentities_ = - java.util.Collections.emptyList(); - private void ensureTargetIdentitiesIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - targetIdentities_ = new java.util.ArrayList(targetIdentities_); - bitField0_ |= 0x00000008; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> targetIdentitiesBuilder_; - - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public java.util.List getTargetIdentitiesList() { - if (targetIdentitiesBuilder_ == null) { - return java.util.Collections.unmodifiableList(targetIdentities_); - } else { - return targetIdentitiesBuilder_.getMessageList(); - } - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public int getTargetIdentitiesCount() { - if (targetIdentitiesBuilder_ == null) { - return targetIdentities_.size(); - } else { - return targetIdentitiesBuilder_.getCount(); - } - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.Identity getTargetIdentities(int index) { - if (targetIdentitiesBuilder_ == null) { - return targetIdentities_.get(index); - } else { - return targetIdentitiesBuilder_.getMessage(index); - } - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder setTargetIdentities( - int index, io.grpc.alts.internal.Identity value) { - if (targetIdentitiesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTargetIdentitiesIsMutable(); - targetIdentities_.set(index, value); - onChanged(); - } else { - targetIdentitiesBuilder_.setMessage(index, value); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder setTargetIdentities( - int index, io.grpc.alts.internal.Identity.Builder builderForValue) { - if (targetIdentitiesBuilder_ == null) { - ensureTargetIdentitiesIsMutable(); - targetIdentities_.set(index, builderForValue.build()); - onChanged(); - } else { - targetIdentitiesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder addTargetIdentities(io.grpc.alts.internal.Identity value) { - if (targetIdentitiesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTargetIdentitiesIsMutable(); - targetIdentities_.add(value); - onChanged(); - } else { - targetIdentitiesBuilder_.addMessage(value); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder addTargetIdentities( - int index, io.grpc.alts.internal.Identity value) { - if (targetIdentitiesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTargetIdentitiesIsMutable(); - targetIdentities_.add(index, value); - onChanged(); - } else { - targetIdentitiesBuilder_.addMessage(index, value); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder addTargetIdentities( - io.grpc.alts.internal.Identity.Builder builderForValue) { - if (targetIdentitiesBuilder_ == null) { - ensureTargetIdentitiesIsMutable(); - targetIdentities_.add(builderForValue.build()); - onChanged(); - } else { - targetIdentitiesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder addTargetIdentities( - int index, io.grpc.alts.internal.Identity.Builder builderForValue) { - if (targetIdentitiesBuilder_ == null) { - ensureTargetIdentitiesIsMutable(); - targetIdentities_.add(index, builderForValue.build()); - onChanged(); - } else { - targetIdentitiesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder addAllTargetIdentities( - java.lang.Iterable values) { - if (targetIdentitiesBuilder_ == null) { - ensureTargetIdentitiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, targetIdentities_); - onChanged(); - } else { - targetIdentitiesBuilder_.addAllMessages(values); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder clearTargetIdentities() { - if (targetIdentitiesBuilder_ == null) { - targetIdentities_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - onChanged(); - } else { - targetIdentitiesBuilder_.clear(); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public Builder removeTargetIdentities(int index) { - if (targetIdentitiesBuilder_ == null) { - ensureTargetIdentitiesIsMutable(); - targetIdentities_.remove(index); - onChanged(); - } else { - targetIdentitiesBuilder_.remove(index); - } - return this; - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.Identity.Builder getTargetIdentitiesBuilder( - int index) { - return getTargetIdentitiesFieldBuilder().getBuilder(index); - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.IdentityOrBuilder getTargetIdentitiesOrBuilder( - int index) { - if (targetIdentitiesBuilder_ == null) { - return targetIdentities_.get(index); } else { - return targetIdentitiesBuilder_.getMessageOrBuilder(index); - } - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public java.util.List - getTargetIdentitiesOrBuilderList() { - if (targetIdentitiesBuilder_ != null) { - return targetIdentitiesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(targetIdentities_); - } - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.Identity.Builder addTargetIdentitiesBuilder() { - return getTargetIdentitiesFieldBuilder().addBuilder( - io.grpc.alts.internal.Identity.getDefaultInstance()); - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public io.grpc.alts.internal.Identity.Builder addTargetIdentitiesBuilder( - int index) { - return getTargetIdentitiesFieldBuilder().addBuilder( - index, io.grpc.alts.internal.Identity.getDefaultInstance()); - } - /** - *
-     * (Optional) Describes which server identities are acceptable by the client.
-     * If target identities are provided and none of them matches the peer
-     * identity of the server, handshake will fail.
-     * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - public java.util.List - getTargetIdentitiesBuilderList() { - return getTargetIdentitiesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> - getTargetIdentitiesFieldBuilder() { - if (targetIdentitiesBuilder_ == null) { - targetIdentitiesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder>( - targetIdentities_, - ((bitField0_ & 0x00000008) == 0x00000008), - getParentForChildren(), - isClean()); - targetIdentities_ = null; - } - return targetIdentitiesBuilder_; - } - - private io.grpc.alts.internal.Identity localIdentity_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> localIdentityBuilder_; - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public boolean hasLocalIdentity() { - return localIdentityBuilder_ != null || localIdentity_ != null; - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.Identity getLocalIdentity() { - if (localIdentityBuilder_ == null) { - return localIdentity_ == null ? io.grpc.alts.internal.Identity.getDefaultInstance() : localIdentity_; - } else { - return localIdentityBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder setLocalIdentity(io.grpc.alts.internal.Identity value) { - if (localIdentityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - localIdentity_ = value; - onChanged(); - } else { - localIdentityBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder setLocalIdentity( - io.grpc.alts.internal.Identity.Builder builderForValue) { - if (localIdentityBuilder_ == null) { - localIdentity_ = builderForValue.build(); - onChanged(); - } else { - localIdentityBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder mergeLocalIdentity(io.grpc.alts.internal.Identity value) { - if (localIdentityBuilder_ == null) { - if (localIdentity_ != null) { - localIdentity_ = - io.grpc.alts.internal.Identity.newBuilder(localIdentity_).mergeFrom(value).buildPartial(); - } else { - localIdentity_ = value; - } - onChanged(); - } else { - localIdentityBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public Builder clearLocalIdentity() { - if (localIdentityBuilder_ == null) { - localIdentity_ = null; - onChanged(); - } else { - localIdentity_ = null; - localIdentityBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.Identity.Builder getLocalIdentityBuilder() { - - onChanged(); - return getLocalIdentityFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - public io.grpc.alts.internal.IdentityOrBuilder getLocalIdentityOrBuilder() { - if (localIdentityBuilder_ != null) { - return localIdentityBuilder_.getMessageOrBuilder(); - } else { - return localIdentity_ == null ? - io.grpc.alts.internal.Identity.getDefaultInstance() : localIdentity_; - } - } - /** - *
-     * (Optional) Application may specify a local identity. Otherwise, the
-     * handshaker chooses a default local identity.
-     * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder> - getLocalIdentityFieldBuilder() { - if (localIdentityBuilder_ == null) { - localIdentityBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Identity, io.grpc.alts.internal.Identity.Builder, io.grpc.alts.internal.IdentityOrBuilder>( - getLocalIdentity(), - getParentForChildren(), - isClean()); - localIdentity_ = null; - } - return localIdentityBuilder_; - } - - private io.grpc.alts.internal.Endpoint localEndpoint_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> localEndpointBuilder_; - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public boolean hasLocalEndpoint() { - return localEndpointBuilder_ != null || localEndpoint_ != null; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public io.grpc.alts.internal.Endpoint getLocalEndpoint() { - if (localEndpointBuilder_ == null) { - return localEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : localEndpoint_; - } else { - return localEndpointBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public Builder setLocalEndpoint(io.grpc.alts.internal.Endpoint value) { - if (localEndpointBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - localEndpoint_ = value; - onChanged(); - } else { - localEndpointBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public Builder setLocalEndpoint( - io.grpc.alts.internal.Endpoint.Builder builderForValue) { - if (localEndpointBuilder_ == null) { - localEndpoint_ = builderForValue.build(); - onChanged(); - } else { - localEndpointBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public Builder mergeLocalEndpoint(io.grpc.alts.internal.Endpoint value) { - if (localEndpointBuilder_ == null) { - if (localEndpoint_ != null) { - localEndpoint_ = - io.grpc.alts.internal.Endpoint.newBuilder(localEndpoint_).mergeFrom(value).buildPartial(); - } else { - localEndpoint_ = value; - } - onChanged(); - } else { - localEndpointBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public Builder clearLocalEndpoint() { - if (localEndpointBuilder_ == null) { - localEndpoint_ = null; - onChanged(); - } else { - localEndpoint_ = null; - localEndpointBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public io.grpc.alts.internal.Endpoint.Builder getLocalEndpointBuilder() { - - onChanged(); - return getLocalEndpointFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - public io.grpc.alts.internal.EndpointOrBuilder getLocalEndpointOrBuilder() { - if (localEndpointBuilder_ != null) { - return localEndpointBuilder_.getMessageOrBuilder(); - } else { - return localEndpoint_ == null ? - io.grpc.alts.internal.Endpoint.getDefaultInstance() : localEndpoint_; - } - } - /** - *
-     * (Optional) Local endpoint information of the connection to the server,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> - getLocalEndpointFieldBuilder() { - if (localEndpointBuilder_ == null) { - localEndpointBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder>( - getLocalEndpoint(), - getParentForChildren(), - isClean()); - localEndpoint_ = null; - } - return localEndpointBuilder_; - } - - private io.grpc.alts.internal.Endpoint remoteEndpoint_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> remoteEndpointBuilder_; - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public boolean hasRemoteEndpoint() { - return remoteEndpointBuilder_ != null || remoteEndpoint_ != null; - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public io.grpc.alts.internal.Endpoint getRemoteEndpoint() { - if (remoteEndpointBuilder_ == null) { - return remoteEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : remoteEndpoint_; - } else { - return remoteEndpointBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public Builder setRemoteEndpoint(io.grpc.alts.internal.Endpoint value) { - if (remoteEndpointBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - remoteEndpoint_ = value; - onChanged(); - } else { - remoteEndpointBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public Builder setRemoteEndpoint( - io.grpc.alts.internal.Endpoint.Builder builderForValue) { - if (remoteEndpointBuilder_ == null) { - remoteEndpoint_ = builderForValue.build(); - onChanged(); - } else { - remoteEndpointBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public Builder mergeRemoteEndpoint(io.grpc.alts.internal.Endpoint value) { - if (remoteEndpointBuilder_ == null) { - if (remoteEndpoint_ != null) { - remoteEndpoint_ = - io.grpc.alts.internal.Endpoint.newBuilder(remoteEndpoint_).mergeFrom(value).buildPartial(); - } else { - remoteEndpoint_ = value; - } - onChanged(); - } else { - remoteEndpointBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public Builder clearRemoteEndpoint() { - if (remoteEndpointBuilder_ == null) { - remoteEndpoint_ = null; - onChanged(); - } else { - remoteEndpoint_ = null; - remoteEndpointBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public io.grpc.alts.internal.Endpoint.Builder getRemoteEndpointBuilder() { - - onChanged(); - return getRemoteEndpointFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - public io.grpc.alts.internal.EndpointOrBuilder getRemoteEndpointOrBuilder() { - if (remoteEndpointBuilder_ != null) { - return remoteEndpointBuilder_.getMessageOrBuilder(); - } else { - return remoteEndpoint_ == null ? - io.grpc.alts.internal.Endpoint.getDefaultInstance() : remoteEndpoint_; - } - } - /** - *
-     * (Optional) Endpoint information of the remote server, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> - getRemoteEndpointFieldBuilder() { - if (remoteEndpointBuilder_ == null) { - remoteEndpointBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder>( - getRemoteEndpoint(), - getParentForChildren(), - isClean()); - remoteEndpoint_ = null; - } - return remoteEndpointBuilder_; - } - - private java.lang.Object targetName_ = ""; - /** - *
-     * (Optional) If target name is provided, a secure naming check is performed
-     * to verify that the peer authenticated identity is indeed authorized to run
-     * the target name.
-     * 
- * - * string target_name = 8; - */ - public java.lang.String getTargetName() { - java.lang.Object ref = targetName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - targetName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-     * (Optional) If target name is provided, a secure naming check is performed
-     * to verify that the peer authenticated identity is indeed authorized to run
-     * the target name.
-     * 
- * - * string target_name = 8; - */ - public com.google.protobuf.ByteString - getTargetNameBytes() { - java.lang.Object ref = targetName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - targetName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-     * (Optional) If target name is provided, a secure naming check is performed
-     * to verify that the peer authenticated identity is indeed authorized to run
-     * the target name.
-     * 
- * - * string target_name = 8; - */ - public Builder setTargetName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - targetName_ = value; - onChanged(); - return this; - } - /** - *
-     * (Optional) If target name is provided, a secure naming check is performed
-     * to verify that the peer authenticated identity is indeed authorized to run
-     * the target name.
-     * 
- * - * string target_name = 8; - */ - public Builder clearTargetName() { - - targetName_ = getDefaultInstance().getTargetName(); - onChanged(); - return this; - } - /** - *
-     * (Optional) If target name is provided, a secure naming check is performed
-     * to verify that the peer authenticated identity is indeed authorized to run
-     * the target name.
-     * 
- * - * string target_name = 8; - */ - public Builder setTargetNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - targetName_ = value; - onChanged(); - return this; - } - - private io.grpc.alts.internal.RpcProtocolVersions rpcVersions_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> rpcVersionsBuilder_; - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public boolean hasRpcVersions() { - return rpcVersionsBuilder_ != null || rpcVersions_ != null; - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public io.grpc.alts.internal.RpcProtocolVersions getRpcVersions() { - if (rpcVersionsBuilder_ == null) { - return rpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : rpcVersions_; - } else { - return rpcVersionsBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public Builder setRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (rpcVersionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - rpcVersions_ = value; - onChanged(); - } else { - rpcVersionsBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public Builder setRpcVersions( - io.grpc.alts.internal.RpcProtocolVersions.Builder builderForValue) { - if (rpcVersionsBuilder_ == null) { - rpcVersions_ = builderForValue.build(); - onChanged(); - } else { - rpcVersionsBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public Builder mergeRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (rpcVersionsBuilder_ == null) { - if (rpcVersions_ != null) { - rpcVersions_ = - io.grpc.alts.internal.RpcProtocolVersions.newBuilder(rpcVersions_).mergeFrom(value).buildPartial(); - } else { - rpcVersions_ = value; - } - onChanged(); - } else { - rpcVersionsBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public Builder clearRpcVersions() { - if (rpcVersionsBuilder_ == null) { - rpcVersions_ = null; - onChanged(); - } else { - rpcVersions_ = null; - rpcVersionsBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Builder getRpcVersionsBuilder() { - - onChanged(); - return getRpcVersionsFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getRpcVersionsOrBuilder() { - if (rpcVersionsBuilder_ != null) { - return rpcVersionsBuilder_.getMessageOrBuilder(); - } else { - return rpcVersions_ == null ? - io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : rpcVersions_; - } - } - /** - *
-     * (Optional) RPC protocol versions supported by the client.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> - getRpcVersionsFieldBuilder() { - if (rpcVersionsBuilder_ == null) { - rpcVersionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder>( - getRpcVersions(), - getParentForChildren(), - isClean()); - rpcVersions_ = null; - } - return rpcVersionsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.StartClientHandshakeReq) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.StartClientHandshakeReq) - private static final io.grpc.alts.internal.StartClientHandshakeReq DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.StartClientHandshakeReq(); - } - - public static io.grpc.alts.internal.StartClientHandshakeReq getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public StartClientHandshakeReq parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new StartClientHandshakeReq(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.StartClientHandshakeReq getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/StartClientHandshakeReqOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/StartClientHandshakeReqOrBuilder.java deleted file mode 100644 index 7c483c4d94c..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/StartClientHandshakeReqOrBuilder.java +++ /dev/null @@ -1,289 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface StartClientHandshakeReqOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.StartClientHandshakeReq) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * Handshake security protocol requested by the client.
-   * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - int getHandshakeSecurityProtocolValue(); - /** - *
-   * Handshake security protocol requested by the client.
-   * 
- * - * .grpc.gcp.HandshakeProtocol handshake_security_protocol = 1; - */ - io.grpc.alts.internal.HandshakeProtocol getHandshakeSecurityProtocol(); - - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - java.util.List - getApplicationProtocolsList(); - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - int getApplicationProtocolsCount(); - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - java.lang.String getApplicationProtocols(int index); - /** - *
-   * The application protocols supported by the client, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 2; - */ - com.google.protobuf.ByteString - getApplicationProtocolsBytes(int index); - - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - java.util.List - getRecordProtocolsList(); - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - int getRecordProtocolsCount(); - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - java.lang.String getRecordProtocols(int index); - /** - *
-   * The record protocols supported by the client, e.g.,
-   * "ALTSRP_GCM_AES128".
-   * 
- * - * repeated string record_protocols = 3; - */ - com.google.protobuf.ByteString - getRecordProtocolsBytes(int index); - - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - java.util.List - getTargetIdentitiesList(); - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - io.grpc.alts.internal.Identity getTargetIdentities(int index); - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - int getTargetIdentitiesCount(); - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - java.util.List - getTargetIdentitiesOrBuilderList(); - /** - *
-   * (Optional) Describes which server identities are acceptable by the client.
-   * If target identities are provided and none of them matches the peer
-   * identity of the server, handshake will fail.
-   * 
- * - * repeated .grpc.gcp.Identity target_identities = 4; - */ - io.grpc.alts.internal.IdentityOrBuilder getTargetIdentitiesOrBuilder( - int index); - - /** - *
-   * (Optional) Application may specify a local identity. Otherwise, the
-   * handshaker chooses a default local identity.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - boolean hasLocalIdentity(); - /** - *
-   * (Optional) Application may specify a local identity. Otherwise, the
-   * handshaker chooses a default local identity.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - io.grpc.alts.internal.Identity getLocalIdentity(); - /** - *
-   * (Optional) Application may specify a local identity. Otherwise, the
-   * handshaker chooses a default local identity.
-   * 
- * - * .grpc.gcp.Identity local_identity = 5; - */ - io.grpc.alts.internal.IdentityOrBuilder getLocalIdentityOrBuilder(); - - /** - *
-   * (Optional) Local endpoint information of the connection to the server,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - boolean hasLocalEndpoint(); - /** - *
-   * (Optional) Local endpoint information of the connection to the server,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - io.grpc.alts.internal.Endpoint getLocalEndpoint(); - /** - *
-   * (Optional) Local endpoint information of the connection to the server,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 6; - */ - io.grpc.alts.internal.EndpointOrBuilder getLocalEndpointOrBuilder(); - - /** - *
-   * (Optional) Endpoint information of the remote server, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - boolean hasRemoteEndpoint(); - /** - *
-   * (Optional) Endpoint information of the remote server, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - io.grpc.alts.internal.Endpoint getRemoteEndpoint(); - /** - *
-   * (Optional) Endpoint information of the remote server, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 7; - */ - io.grpc.alts.internal.EndpointOrBuilder getRemoteEndpointOrBuilder(); - - /** - *
-   * (Optional) If target name is provided, a secure naming check is performed
-   * to verify that the peer authenticated identity is indeed authorized to run
-   * the target name.
-   * 
- * - * string target_name = 8; - */ - java.lang.String getTargetName(); - /** - *
-   * (Optional) If target name is provided, a secure naming check is performed
-   * to verify that the peer authenticated identity is indeed authorized to run
-   * the target name.
-   * 
- * - * string target_name = 8; - */ - com.google.protobuf.ByteString - getTargetNameBytes(); - - /** - *
-   * (Optional) RPC protocol versions supported by the client.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - boolean hasRpcVersions(); - /** - *
-   * (Optional) RPC protocol versions supported by the client.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - io.grpc.alts.internal.RpcProtocolVersions getRpcVersions(); - /** - *
-   * (Optional) RPC protocol versions supported by the client.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 9; - */ - io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getRpcVersionsOrBuilder(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/StartServerHandshakeReq.java b/alts/src/generated/main/java/io/grpc/alts/internal/StartServerHandshakeReq.java deleted file mode 100644 index 7a4bc171c9b..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/StartServerHandshakeReq.java +++ /dev/null @@ -1,1781 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -/** - * Protobuf type {@code grpc.gcp.StartServerHandshakeReq} - */ -public final class StartServerHandshakeReq extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:grpc.gcp.StartServerHandshakeReq) - StartServerHandshakeReqOrBuilder { -private static final long serialVersionUID = 0L; - // Use StartServerHandshakeReq.newBuilder() to construct. - private StartServerHandshakeReq(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private StartServerHandshakeReq() { - applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - inBytes_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private StartServerHandshakeReq( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - applicationProtocols_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - applicationProtocols_.add(s); - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - handshakeParameters_ = com.google.protobuf.MapField.newMapField( - HandshakeParametersDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000002; - } - com.google.protobuf.MapEntry - handshakeParameters__ = input.readMessage( - HandshakeParametersDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - handshakeParameters_.getMutableMap().put( - handshakeParameters__.getKey(), handshakeParameters__.getValue()); - break; - } - case 26: { - - inBytes_ = input.readBytes(); - break; - } - case 34: { - io.grpc.alts.internal.Endpoint.Builder subBuilder = null; - if (localEndpoint_ != null) { - subBuilder = localEndpoint_.toBuilder(); - } - localEndpoint_ = input.readMessage(io.grpc.alts.internal.Endpoint.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(localEndpoint_); - localEndpoint_ = subBuilder.buildPartial(); - } - - break; - } - case 42: { - io.grpc.alts.internal.Endpoint.Builder subBuilder = null; - if (remoteEndpoint_ != null) { - subBuilder = remoteEndpoint_.toBuilder(); - } - remoteEndpoint_ = input.readMessage(io.grpc.alts.internal.Endpoint.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(remoteEndpoint_); - remoteEndpoint_ = subBuilder.buildPartial(); - } - - break; - } - case 50: { - io.grpc.alts.internal.RpcProtocolVersions.Builder subBuilder = null; - if (rpcVersions_ != null) { - subBuilder = rpcVersions_.toBuilder(); - } - rpcVersions_ = input.readMessage(io.grpc.alts.internal.RpcProtocolVersions.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(rpcVersions_); - rpcVersions_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - applicationProtocols_ = applicationProtocols_.getUnmodifiableView(); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartServerHandshakeReq_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 2: - return internalGetHandshakeParameters(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartServerHandshakeReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.StartServerHandshakeReq.class, io.grpc.alts.internal.StartServerHandshakeReq.Builder.class); - } - - private int bitField0_; - public static final int APPLICATION_PROTOCOLS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList applicationProtocols_; - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - public com.google.protobuf.ProtocolStringList - getApplicationProtocolsList() { - return applicationProtocols_; - } - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - public int getApplicationProtocolsCount() { - return applicationProtocols_.size(); - } - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - public java.lang.String getApplicationProtocols(int index) { - return applicationProtocols_.get(index); - } - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - public com.google.protobuf.ByteString - getApplicationProtocolsBytes(int index) { - return applicationProtocols_.getByteString(index); - } - - public static final int HANDSHAKE_PARAMETERS_FIELD_NUMBER = 2; - private static final class HandshakeParametersDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.Integer, io.grpc.alts.internal.ServerHandshakeParameters> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartServerHandshakeReq_HandshakeParametersEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.INT32, - 0, - com.google.protobuf.WireFormat.FieldType.MESSAGE, - io.grpc.alts.internal.ServerHandshakeParameters.getDefaultInstance()); - } - private com.google.protobuf.MapField< - java.lang.Integer, io.grpc.alts.internal.ServerHandshakeParameters> handshakeParameters_; - private com.google.protobuf.MapField - internalGetHandshakeParameters() { - if (handshakeParameters_ == null) { - return com.google.protobuf.MapField.emptyMapField( - HandshakeParametersDefaultEntryHolder.defaultEntry); - } - return handshakeParameters_; - } - - public int getHandshakeParametersCount() { - return internalGetHandshakeParameters().getMap().size(); - } - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public boolean containsHandshakeParameters( - int key) { - - return internalGetHandshakeParameters().getMap().containsKey(key); - } - /** - * Use {@link #getHandshakeParametersMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getHandshakeParameters() { - return getHandshakeParametersMap(); - } - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public java.util.Map getHandshakeParametersMap() { - return internalGetHandshakeParameters().getMap(); - } - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public io.grpc.alts.internal.ServerHandshakeParameters getHandshakeParametersOrDefault( - int key, - io.grpc.alts.internal.ServerHandshakeParameters defaultValue) { - - java.util.Map map = - internalGetHandshakeParameters().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public io.grpc.alts.internal.ServerHandshakeParameters getHandshakeParametersOrThrow( - int key) { - - java.util.Map map = - internalGetHandshakeParameters().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int IN_BYTES_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString inBytes_; - /** - *
-   * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-   * that the peer's out_frames are split into multiple HandshakReq messages.
-   * 
- * - * bytes in_bytes = 3; - */ - public com.google.protobuf.ByteString getInBytes() { - return inBytes_; - } - - public static final int LOCAL_ENDPOINT_FIELD_NUMBER = 4; - private io.grpc.alts.internal.Endpoint localEndpoint_; - /** - *
-   * (Optional) Local endpoint information of the connection to the client,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public boolean hasLocalEndpoint() { - return localEndpoint_ != null; - } - /** - *
-   * (Optional) Local endpoint information of the connection to the client,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public io.grpc.alts.internal.Endpoint getLocalEndpoint() { - return localEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : localEndpoint_; - } - /** - *
-   * (Optional) Local endpoint information of the connection to the client,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public io.grpc.alts.internal.EndpointOrBuilder getLocalEndpointOrBuilder() { - return getLocalEndpoint(); - } - - public static final int REMOTE_ENDPOINT_FIELD_NUMBER = 5; - private io.grpc.alts.internal.Endpoint remoteEndpoint_; - /** - *
-   * (Optional) Endpoint information of the remote client, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public boolean hasRemoteEndpoint() { - return remoteEndpoint_ != null; - } - /** - *
-   * (Optional) Endpoint information of the remote client, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public io.grpc.alts.internal.Endpoint getRemoteEndpoint() { - return remoteEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : remoteEndpoint_; - } - /** - *
-   * (Optional) Endpoint information of the remote client, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public io.grpc.alts.internal.EndpointOrBuilder getRemoteEndpointOrBuilder() { - return getRemoteEndpoint(); - } - - public static final int RPC_VERSIONS_FIELD_NUMBER = 6; - private io.grpc.alts.internal.RpcProtocolVersions rpcVersions_; - /** - *
-   * (Optional) RPC protocol versions supported by the server.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public boolean hasRpcVersions() { - return rpcVersions_ != null; - } - /** - *
-   * (Optional) RPC protocol versions supported by the server.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersions getRpcVersions() { - return rpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : rpcVersions_; - } - /** - *
-   * (Optional) RPC protocol versions supported by the server.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getRpcVersionsOrBuilder() { - return getRpcVersions(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < applicationProtocols_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, applicationProtocols_.getRaw(i)); - } - com.google.protobuf.GeneratedMessageV3 - .serializeIntegerMapTo( - output, - internalGetHandshakeParameters(), - HandshakeParametersDefaultEntryHolder.defaultEntry, - 2); - if (!inBytes_.isEmpty()) { - output.writeBytes(3, inBytes_); - } - if (localEndpoint_ != null) { - output.writeMessage(4, getLocalEndpoint()); - } - if (remoteEndpoint_ != null) { - output.writeMessage(5, getRemoteEndpoint()); - } - if (rpcVersions_ != null) { - output.writeMessage(6, getRpcVersions()); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < applicationProtocols_.size(); i++) { - dataSize += computeStringSizeNoTag(applicationProtocols_.getRaw(i)); - } - size += dataSize; - size += 1 * getApplicationProtocolsList().size(); - } - for (java.util.Map.Entry entry - : internalGetHandshakeParameters().getMap().entrySet()) { - com.google.protobuf.MapEntry - handshakeParameters__ = HandshakeParametersDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, handshakeParameters__); - } - if (!inBytes_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, inBytes_); - } - if (localEndpoint_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getLocalEndpoint()); - } - if (remoteEndpoint_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, getRemoteEndpoint()); - } - if (rpcVersions_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, getRpcVersions()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof io.grpc.alts.internal.StartServerHandshakeReq)) { - return super.equals(obj); - } - io.grpc.alts.internal.StartServerHandshakeReq other = (io.grpc.alts.internal.StartServerHandshakeReq) obj; - - boolean result = true; - result = result && getApplicationProtocolsList() - .equals(other.getApplicationProtocolsList()); - result = result && internalGetHandshakeParameters().equals( - other.internalGetHandshakeParameters()); - result = result && getInBytes() - .equals(other.getInBytes()); - result = result && (hasLocalEndpoint() == other.hasLocalEndpoint()); - if (hasLocalEndpoint()) { - result = result && getLocalEndpoint() - .equals(other.getLocalEndpoint()); - } - result = result && (hasRemoteEndpoint() == other.hasRemoteEndpoint()); - if (hasRemoteEndpoint()) { - result = result && getRemoteEndpoint() - .equals(other.getRemoteEndpoint()); - } - result = result && (hasRpcVersions() == other.hasRpcVersions()); - if (hasRpcVersions()) { - result = result && getRpcVersions() - .equals(other.getRpcVersions()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getApplicationProtocolsCount() > 0) { - hash = (37 * hash) + APPLICATION_PROTOCOLS_FIELD_NUMBER; - hash = (53 * hash) + getApplicationProtocolsList().hashCode(); - } - if (!internalGetHandshakeParameters().getMap().isEmpty()) { - hash = (37 * hash) + HANDSHAKE_PARAMETERS_FIELD_NUMBER; - hash = (53 * hash) + internalGetHandshakeParameters().hashCode(); - } - hash = (37 * hash) + IN_BYTES_FIELD_NUMBER; - hash = (53 * hash) + getInBytes().hashCode(); - if (hasLocalEndpoint()) { - hash = (37 * hash) + LOCAL_ENDPOINT_FIELD_NUMBER; - hash = (53 * hash) + getLocalEndpoint().hashCode(); - } - if (hasRemoteEndpoint()) { - hash = (37 * hash) + REMOTE_ENDPOINT_FIELD_NUMBER; - hash = (53 * hash) + getRemoteEndpoint().hashCode(); - } - if (hasRpcVersions()) { - hash = (37 * hash) + RPC_VERSIONS_FIELD_NUMBER; - hash = (53 * hash) + getRpcVersions().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static io.grpc.alts.internal.StartServerHandshakeReq parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(io.grpc.alts.internal.StartServerHandshakeReq prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code grpc.gcp.StartServerHandshakeReq} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:grpc.gcp.StartServerHandshakeReq) - io.grpc.alts.internal.StartServerHandshakeReqOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartServerHandshakeReq_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 2: - return internalGetHandshakeParameters(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 2: - return internalGetMutableHandshakeParameters(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartServerHandshakeReq_fieldAccessorTable - .ensureFieldAccessorsInitialized( - io.grpc.alts.internal.StartServerHandshakeReq.class, io.grpc.alts.internal.StartServerHandshakeReq.Builder.class); - } - - // Construct using io.grpc.alts.internal.StartServerHandshakeReq.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - internalGetMutableHandshakeParameters().clear(); - inBytes_ = com.google.protobuf.ByteString.EMPTY; - - if (localEndpointBuilder_ == null) { - localEndpoint_ = null; - } else { - localEndpoint_ = null; - localEndpointBuilder_ = null; - } - if (remoteEndpointBuilder_ == null) { - remoteEndpoint_ = null; - } else { - remoteEndpoint_ = null; - remoteEndpointBuilder_ = null; - } - if (rpcVersionsBuilder_ == null) { - rpcVersions_ = null; - } else { - rpcVersions_ = null; - rpcVersionsBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return io.grpc.alts.internal.HandshakerProto.internal_static_grpc_gcp_StartServerHandshakeReq_descriptor; - } - - public io.grpc.alts.internal.StartServerHandshakeReq getDefaultInstanceForType() { - return io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance(); - } - - public io.grpc.alts.internal.StartServerHandshakeReq build() { - io.grpc.alts.internal.StartServerHandshakeReq result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public io.grpc.alts.internal.StartServerHandshakeReq buildPartial() { - io.grpc.alts.internal.StartServerHandshakeReq result = new io.grpc.alts.internal.StartServerHandshakeReq(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - applicationProtocols_ = applicationProtocols_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.applicationProtocols_ = applicationProtocols_; - result.handshakeParameters_ = internalGetHandshakeParameters(); - result.handshakeParameters_.makeImmutable(); - result.inBytes_ = inBytes_; - if (localEndpointBuilder_ == null) { - result.localEndpoint_ = localEndpoint_; - } else { - result.localEndpoint_ = localEndpointBuilder_.build(); - } - if (remoteEndpointBuilder_ == null) { - result.remoteEndpoint_ = remoteEndpoint_; - } else { - result.remoteEndpoint_ = remoteEndpointBuilder_.build(); - } - if (rpcVersionsBuilder_ == null) { - result.rpcVersions_ = rpcVersions_; - } else { - result.rpcVersions_ = rpcVersionsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder clone() { - return (Builder) super.clone(); - } - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.setField(field, value); - } - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); - } - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); - } - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); - } - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); - } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.grpc.alts.internal.StartServerHandshakeReq) { - return mergeFrom((io.grpc.alts.internal.StartServerHandshakeReq)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(io.grpc.alts.internal.StartServerHandshakeReq other) { - if (other == io.grpc.alts.internal.StartServerHandshakeReq.getDefaultInstance()) return this; - if (!other.applicationProtocols_.isEmpty()) { - if (applicationProtocols_.isEmpty()) { - applicationProtocols_ = other.applicationProtocols_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.addAll(other.applicationProtocols_); - } - onChanged(); - } - internalGetMutableHandshakeParameters().mergeFrom( - other.internalGetHandshakeParameters()); - if (other.getInBytes() != com.google.protobuf.ByteString.EMPTY) { - setInBytes(other.getInBytes()); - } - if (other.hasLocalEndpoint()) { - mergeLocalEndpoint(other.getLocalEndpoint()); - } - if (other.hasRemoteEndpoint()) { - mergeRemoteEndpoint(other.getRemoteEndpoint()); - } - if (other.hasRpcVersions()) { - mergeRpcVersions(other.getRpcVersions()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - io.grpc.alts.internal.StartServerHandshakeReq parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.grpc.alts.internal.StartServerHandshakeReq) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.LazyStringList applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureApplicationProtocolsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - applicationProtocols_ = new com.google.protobuf.LazyStringArrayList(applicationProtocols_); - bitField0_ |= 0x00000001; - } - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public com.google.protobuf.ProtocolStringList - getApplicationProtocolsList() { - return applicationProtocols_.getUnmodifiableView(); - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public int getApplicationProtocolsCount() { - return applicationProtocols_.size(); - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public java.lang.String getApplicationProtocols(int index) { - return applicationProtocols_.get(index); - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public com.google.protobuf.ByteString - getApplicationProtocolsBytes(int index) { - return applicationProtocols_.getByteString(index); - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public Builder setApplicationProtocols( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.set(index, value); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public Builder addApplicationProtocols( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.add(value); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public Builder addAllApplicationProtocols( - java.lang.Iterable values) { - ensureApplicationProtocolsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, applicationProtocols_); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public Builder clearApplicationProtocols() { - applicationProtocols_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - *
-     * The application protocols supported by the server, e.g., "h2" (for http2),
-     * "grpc".
-     * 
- * - * repeated string application_protocols = 1; - */ - public Builder addApplicationProtocolsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureApplicationProtocolsIsMutable(); - applicationProtocols_.add(value); - onChanged(); - return this; - } - - private com.google.protobuf.MapField< - java.lang.Integer, io.grpc.alts.internal.ServerHandshakeParameters> handshakeParameters_; - private com.google.protobuf.MapField - internalGetHandshakeParameters() { - if (handshakeParameters_ == null) { - return com.google.protobuf.MapField.emptyMapField( - HandshakeParametersDefaultEntryHolder.defaultEntry); - } - return handshakeParameters_; - } - private com.google.protobuf.MapField - internalGetMutableHandshakeParameters() { - onChanged();; - if (handshakeParameters_ == null) { - handshakeParameters_ = com.google.protobuf.MapField.newMapField( - HandshakeParametersDefaultEntryHolder.defaultEntry); - } - if (!handshakeParameters_.isMutable()) { - handshakeParameters_ = handshakeParameters_.copy(); - } - return handshakeParameters_; - } - - public int getHandshakeParametersCount() { - return internalGetHandshakeParameters().getMap().size(); - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public boolean containsHandshakeParameters( - int key) { - - return internalGetHandshakeParameters().getMap().containsKey(key); - } - /** - * Use {@link #getHandshakeParametersMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getHandshakeParameters() { - return getHandshakeParametersMap(); - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public java.util.Map getHandshakeParametersMap() { - return internalGetHandshakeParameters().getMap(); - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public io.grpc.alts.internal.ServerHandshakeParameters getHandshakeParametersOrDefault( - int key, - io.grpc.alts.internal.ServerHandshakeParameters defaultValue) { - - java.util.Map map = - internalGetHandshakeParameters().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public io.grpc.alts.internal.ServerHandshakeParameters getHandshakeParametersOrThrow( - int key) { - - java.util.Map map = - internalGetHandshakeParameters().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearHandshakeParameters() { - internalGetMutableHandshakeParameters().getMutableMap() - .clear(); - return this; - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public Builder removeHandshakeParameters( - int key) { - - internalGetMutableHandshakeParameters().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableHandshakeParameters() { - return internalGetMutableHandshakeParameters().getMutableMap(); - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - public Builder putHandshakeParameters( - int key, - io.grpc.alts.internal.ServerHandshakeParameters value) { - - if (value == null) { throw new java.lang.NullPointerException(); } - internalGetMutableHandshakeParameters().getMutableMap() - .put(key, value); - return this; - } - /** - *
-     * Handshake parameters (record protocols and local identities supported by
-     * the server) mapped by the handshake protocol. Each handshake security
-     * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-     * identities. Since protobuf does not support enum as key to the map, the key
-     * to handshake_parameters is the integer value of HandshakeProtocol enum.
-     * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - public Builder putAllHandshakeParameters( - java.util.Map values) { - internalGetMutableHandshakeParameters().getMutableMap() - .putAll(values); - return this; - } - - private com.google.protobuf.ByteString inBytes_ = com.google.protobuf.ByteString.EMPTY; - /** - *
-     * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-     * that the peer's out_frames are split into multiple HandshakReq messages.
-     * 
- * - * bytes in_bytes = 3; - */ - public com.google.protobuf.ByteString getInBytes() { - return inBytes_; - } - /** - *
-     * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-     * that the peer's out_frames are split into multiple HandshakReq messages.
-     * 
- * - * bytes in_bytes = 3; - */ - public Builder setInBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - inBytes_ = value; - onChanged(); - return this; - } - /** - *
-     * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-     * that the peer's out_frames are split into multiple HandshakReq messages.
-     * 
- * - * bytes in_bytes = 3; - */ - public Builder clearInBytes() { - - inBytes_ = getDefaultInstance().getInBytes(); - onChanged(); - return this; - } - - private io.grpc.alts.internal.Endpoint localEndpoint_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> localEndpointBuilder_; - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public boolean hasLocalEndpoint() { - return localEndpointBuilder_ != null || localEndpoint_ != null; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public io.grpc.alts.internal.Endpoint getLocalEndpoint() { - if (localEndpointBuilder_ == null) { - return localEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : localEndpoint_; - } else { - return localEndpointBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public Builder setLocalEndpoint(io.grpc.alts.internal.Endpoint value) { - if (localEndpointBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - localEndpoint_ = value; - onChanged(); - } else { - localEndpointBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public Builder setLocalEndpoint( - io.grpc.alts.internal.Endpoint.Builder builderForValue) { - if (localEndpointBuilder_ == null) { - localEndpoint_ = builderForValue.build(); - onChanged(); - } else { - localEndpointBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public Builder mergeLocalEndpoint(io.grpc.alts.internal.Endpoint value) { - if (localEndpointBuilder_ == null) { - if (localEndpoint_ != null) { - localEndpoint_ = - io.grpc.alts.internal.Endpoint.newBuilder(localEndpoint_).mergeFrom(value).buildPartial(); - } else { - localEndpoint_ = value; - } - onChanged(); - } else { - localEndpointBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public Builder clearLocalEndpoint() { - if (localEndpointBuilder_ == null) { - localEndpoint_ = null; - onChanged(); - } else { - localEndpoint_ = null; - localEndpointBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public io.grpc.alts.internal.Endpoint.Builder getLocalEndpointBuilder() { - - onChanged(); - return getLocalEndpointFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - public io.grpc.alts.internal.EndpointOrBuilder getLocalEndpointOrBuilder() { - if (localEndpointBuilder_ != null) { - return localEndpointBuilder_.getMessageOrBuilder(); - } else { - return localEndpoint_ == null ? - io.grpc.alts.internal.Endpoint.getDefaultInstance() : localEndpoint_; - } - } - /** - *
-     * (Optional) Local endpoint information of the connection to the client,
-     * such as local IP address, port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> - getLocalEndpointFieldBuilder() { - if (localEndpointBuilder_ == null) { - localEndpointBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder>( - getLocalEndpoint(), - getParentForChildren(), - isClean()); - localEndpoint_ = null; - } - return localEndpointBuilder_; - } - - private io.grpc.alts.internal.Endpoint remoteEndpoint_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> remoteEndpointBuilder_; - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public boolean hasRemoteEndpoint() { - return remoteEndpointBuilder_ != null || remoteEndpoint_ != null; - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public io.grpc.alts.internal.Endpoint getRemoteEndpoint() { - if (remoteEndpointBuilder_ == null) { - return remoteEndpoint_ == null ? io.grpc.alts.internal.Endpoint.getDefaultInstance() : remoteEndpoint_; - } else { - return remoteEndpointBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public Builder setRemoteEndpoint(io.grpc.alts.internal.Endpoint value) { - if (remoteEndpointBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - remoteEndpoint_ = value; - onChanged(); - } else { - remoteEndpointBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public Builder setRemoteEndpoint( - io.grpc.alts.internal.Endpoint.Builder builderForValue) { - if (remoteEndpointBuilder_ == null) { - remoteEndpoint_ = builderForValue.build(); - onChanged(); - } else { - remoteEndpointBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public Builder mergeRemoteEndpoint(io.grpc.alts.internal.Endpoint value) { - if (remoteEndpointBuilder_ == null) { - if (remoteEndpoint_ != null) { - remoteEndpoint_ = - io.grpc.alts.internal.Endpoint.newBuilder(remoteEndpoint_).mergeFrom(value).buildPartial(); - } else { - remoteEndpoint_ = value; - } - onChanged(); - } else { - remoteEndpointBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public Builder clearRemoteEndpoint() { - if (remoteEndpointBuilder_ == null) { - remoteEndpoint_ = null; - onChanged(); - } else { - remoteEndpoint_ = null; - remoteEndpointBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public io.grpc.alts.internal.Endpoint.Builder getRemoteEndpointBuilder() { - - onChanged(); - return getRemoteEndpointFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - public io.grpc.alts.internal.EndpointOrBuilder getRemoteEndpointOrBuilder() { - if (remoteEndpointBuilder_ != null) { - return remoteEndpointBuilder_.getMessageOrBuilder(); - } else { - return remoteEndpoint_ == null ? - io.grpc.alts.internal.Endpoint.getDefaultInstance() : remoteEndpoint_; - } - } - /** - *
-     * (Optional) Endpoint information of the remote client, such as IP address,
-     * port number, and network protocol.
-     * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder> - getRemoteEndpointFieldBuilder() { - if (remoteEndpointBuilder_ == null) { - remoteEndpointBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.Endpoint, io.grpc.alts.internal.Endpoint.Builder, io.grpc.alts.internal.EndpointOrBuilder>( - getRemoteEndpoint(), - getParentForChildren(), - isClean()); - remoteEndpoint_ = null; - } - return remoteEndpointBuilder_; - } - - private io.grpc.alts.internal.RpcProtocolVersions rpcVersions_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> rpcVersionsBuilder_; - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public boolean hasRpcVersions() { - return rpcVersionsBuilder_ != null || rpcVersions_ != null; - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersions getRpcVersions() { - if (rpcVersionsBuilder_ == null) { - return rpcVersions_ == null ? io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : rpcVersions_; - } else { - return rpcVersionsBuilder_.getMessage(); - } - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public Builder setRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (rpcVersionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - rpcVersions_ = value; - onChanged(); - } else { - rpcVersionsBuilder_.setMessage(value); - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public Builder setRpcVersions( - io.grpc.alts.internal.RpcProtocolVersions.Builder builderForValue) { - if (rpcVersionsBuilder_ == null) { - rpcVersions_ = builderForValue.build(); - onChanged(); - } else { - rpcVersionsBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public Builder mergeRpcVersions(io.grpc.alts.internal.RpcProtocolVersions value) { - if (rpcVersionsBuilder_ == null) { - if (rpcVersions_ != null) { - rpcVersions_ = - io.grpc.alts.internal.RpcProtocolVersions.newBuilder(rpcVersions_).mergeFrom(value).buildPartial(); - } else { - rpcVersions_ = value; - } - onChanged(); - } else { - rpcVersionsBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public Builder clearRpcVersions() { - if (rpcVersionsBuilder_ == null) { - rpcVersions_ = null; - onChanged(); - } else { - rpcVersions_ = null; - rpcVersionsBuilder_ = null; - } - - return this; - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersions.Builder getRpcVersionsBuilder() { - - onChanged(); - return getRpcVersionsFieldBuilder().getBuilder(); - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - public io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getRpcVersionsOrBuilder() { - if (rpcVersionsBuilder_ != null) { - return rpcVersionsBuilder_.getMessageOrBuilder(); - } else { - return rpcVersions_ == null ? - io.grpc.alts.internal.RpcProtocolVersions.getDefaultInstance() : rpcVersions_; - } - } - /** - *
-     * (Optional) RPC protocol versions supported by the server.
-     * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - private com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder> - getRpcVersionsFieldBuilder() { - if (rpcVersionsBuilder_ == null) { - rpcVersionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - io.grpc.alts.internal.RpcProtocolVersions, io.grpc.alts.internal.RpcProtocolVersions.Builder, io.grpc.alts.internal.RpcProtocolVersionsOrBuilder>( - getRpcVersions(), - getParentForChildren(), - isClean()); - rpcVersions_ = null; - } - return rpcVersionsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:grpc.gcp.StartServerHandshakeReq) - } - - // @@protoc_insertion_point(class_scope:grpc.gcp.StartServerHandshakeReq) - private static final io.grpc.alts.internal.StartServerHandshakeReq DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new io.grpc.alts.internal.StartServerHandshakeReq(); - } - - public static io.grpc.alts.internal.StartServerHandshakeReq getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public StartServerHandshakeReq parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new StartServerHandshakeReq(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public io.grpc.alts.internal.StartServerHandshakeReq getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/StartServerHandshakeReqOrBuilder.java b/alts/src/generated/main/java/io/grpc/alts/internal/StartServerHandshakeReqOrBuilder.java deleted file mode 100644 index 29a607cd7ed..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/StartServerHandshakeReqOrBuilder.java +++ /dev/null @@ -1,213 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/handshaker.proto - -package io.grpc.alts.internal; - -public interface StartServerHandshakeReqOrBuilder extends - // @@protoc_insertion_point(interface_extends:grpc.gcp.StartServerHandshakeReq) - com.google.protobuf.MessageOrBuilder { - - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - java.util.List - getApplicationProtocolsList(); - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - int getApplicationProtocolsCount(); - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - java.lang.String getApplicationProtocols(int index); - /** - *
-   * The application protocols supported by the server, e.g., "h2" (for http2),
-   * "grpc".
-   * 
- * - * repeated string application_protocols = 1; - */ - com.google.protobuf.ByteString - getApplicationProtocolsBytes(int index); - - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - int getHandshakeParametersCount(); - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - boolean containsHandshakeParameters( - int key); - /** - * Use {@link #getHandshakeParametersMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getHandshakeParameters(); - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - java.util.Map - getHandshakeParametersMap(); - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - io.grpc.alts.internal.ServerHandshakeParameters getHandshakeParametersOrDefault( - int key, - io.grpc.alts.internal.ServerHandshakeParameters defaultValue); - /** - *
-   * Handshake parameters (record protocols and local identities supported by
-   * the server) mapped by the handshake protocol. Each handshake security
-   * protocol (e.g., TLS or ALTS) has its own set of record protocols and local
-   * identities. Since protobuf does not support enum as key to the map, the key
-   * to handshake_parameters is the integer value of HandshakeProtocol enum.
-   * 
- * - * map<int32, .grpc.gcp.ServerHandshakeParameters> handshake_parameters = 2; - */ - - io.grpc.alts.internal.ServerHandshakeParameters getHandshakeParametersOrThrow( - int key); - - /** - *
-   * Bytes in out_frames returned from the peer's HandshakerResp. It is possible
-   * that the peer's out_frames are split into multiple HandshakReq messages.
-   * 
- * - * bytes in_bytes = 3; - */ - com.google.protobuf.ByteString getInBytes(); - - /** - *
-   * (Optional) Local endpoint information of the connection to the client,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - boolean hasLocalEndpoint(); - /** - *
-   * (Optional) Local endpoint information of the connection to the client,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - io.grpc.alts.internal.Endpoint getLocalEndpoint(); - /** - *
-   * (Optional) Local endpoint information of the connection to the client,
-   * such as local IP address, port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint local_endpoint = 4; - */ - io.grpc.alts.internal.EndpointOrBuilder getLocalEndpointOrBuilder(); - - /** - *
-   * (Optional) Endpoint information of the remote client, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - boolean hasRemoteEndpoint(); - /** - *
-   * (Optional) Endpoint information of the remote client, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - io.grpc.alts.internal.Endpoint getRemoteEndpoint(); - /** - *
-   * (Optional) Endpoint information of the remote client, such as IP address,
-   * port number, and network protocol.
-   * 
- * - * .grpc.gcp.Endpoint remote_endpoint = 5; - */ - io.grpc.alts.internal.EndpointOrBuilder getRemoteEndpointOrBuilder(); - - /** - *
-   * (Optional) RPC protocol versions supported by the server.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - boolean hasRpcVersions(); - /** - *
-   * (Optional) RPC protocol versions supported by the server.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - io.grpc.alts.internal.RpcProtocolVersions getRpcVersions(); - /** - *
-   * (Optional) RPC protocol versions supported by the server.
-   * 
- * - * .grpc.gcp.RpcProtocolVersions rpc_versions = 6; - */ - io.grpc.alts.internal.RpcProtocolVersionsOrBuilder getRpcVersionsOrBuilder(); -} diff --git a/alts/src/generated/main/java/io/grpc/alts/internal/TransportSecurityCommonProto.java b/alts/src/generated/main/java/io/grpc/alts/internal/TransportSecurityCommonProto.java deleted file mode 100644 index 878b8052963..00000000000 --- a/alts/src/generated/main/java/io/grpc/alts/internal/TransportSecurityCommonProto.java +++ /dev/null @@ -1,76 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/gcp/transport_security_common.proto - -package io.grpc.alts.internal; - -public final class TransportSecurityCommonProto { - private TransportSecurityCommonProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_RpcProtocolVersions_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_RpcProtocolVersions_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_grpc_gcp_RpcProtocolVersions_Version_descriptor; - static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_grpc_gcp_RpcProtocolVersions_Version_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n(grpc/gcp/transport_security_common.pro" + - "to\022\010grpc.gcp\"\276\001\n\023RpcProtocolVersions\022>\n\017" + - "max_rpc_version\030\001 \001(\0132%.grpc.gcp.RpcProt" + - "ocolVersions.Version\022>\n\017min_rpc_version\030" + - "\002 \001(\0132%.grpc.gcp.RpcProtocolVersions.Ver" + - "sion\032\'\n\007Version\022\r\n\005major\030\001 \001(\r\022\r\n\005minor\030" + - "\002 \001(\r*Q\n\rSecurityLevel\022\021\n\rSECURITY_NONE\020" + - "\000\022\022\n\016INTEGRITY_ONLY\020\001\022\031\n\025INTEGRITY_AND_P" + - "RIVACY\020\002Bx\n\025io.grpc.alts.internalB\034Trans" + - "portSecurityCommonProtoP\001Z?google.golang" + - ".org/grpc/credentials/alts/internal/prot" + - "o/grpc_gcpb\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_grpc_gcp_RpcProtocolVersions_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_grpc_gcp_RpcProtocolVersions_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_RpcProtocolVersions_descriptor, - new java.lang.String[] { "MaxRpcVersion", "MinRpcVersion", }); - internal_static_grpc_gcp_RpcProtocolVersions_Version_descriptor = - internal_static_grpc_gcp_RpcProtocolVersions_descriptor.getNestedTypes().get(0); - internal_static_grpc_gcp_RpcProtocolVersions_Version_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_grpc_gcp_RpcProtocolVersions_Version_descriptor, - new java.lang.String[] { "Major", "Minor", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/alts/src/main/java/io/grpc/alts/AltsChannelBuilder.java b/alts/src/main/java/io/grpc/alts/AltsChannelBuilder.java index 6fb41d12a8c..ca33f8b00b9 100644 --- a/alts/src/main/java/io/grpc/alts/AltsChannelBuilder.java +++ b/alts/src/main/java/io/grpc/alts/AltsChannelBuilder.java @@ -17,53 +17,28 @@ package io.grpc.alts; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; import io.grpc.ExperimentalApi; -import io.grpc.ForwardingChannelBuilder; +import io.grpc.ForwardingChannelBuilder2; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; -import io.grpc.MethodDescriptor; -import io.grpc.Status; -import io.grpc.alts.internal.AltsClientOptions; -import io.grpc.alts.internal.AltsProtocolNegotiator; -import io.grpc.alts.internal.AltsTsiHandshaker; -import io.grpc.alts.internal.HandshakerServiceGrpc; -import io.grpc.alts.internal.RpcProtocolVersionsUtil; -import io.grpc.alts.internal.TsiHandshaker; -import io.grpc.alts.internal.TsiHandshakerFactory; import io.grpc.internal.GrpcUtil; -import io.grpc.internal.ObjectPool; -import io.grpc.internal.SharedResourcePool; import io.grpc.netty.InternalNettyChannelBuilder; +import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator; import io.grpc.netty.NettyChannelBuilder; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.annotation.Nullable; /** * ALTS version of {@code ManagedChannelBuilder}. This class sets up a secure and authenticated - * commmunication between two cloud VMs using ALTS. + * communication between two cloud VMs using ALTS. */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4151") -public final class AltsChannelBuilder extends ForwardingChannelBuilder { - - private static final Logger logger = Logger.getLogger(AltsChannelBuilder.class.getName()); +public final class AltsChannelBuilder extends ForwardingChannelBuilder2 { private final NettyChannelBuilder delegate; - private final ImmutableList.Builder targetServiceAccountsBuilder = - ImmutableList.builder(); - private ObjectPool handshakerChannelPool = - SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL); - private boolean enableUntrustedAlts; - - private AltsProtocolNegotiator negotiatorForTest; + private final AltsChannelCredentials.Builder credentialsBuilder = + new AltsChannelCredentials.Builder(); /** "Overrides" the static method in {@link ManagedChannelBuilder}. */ - public static final AltsChannelBuilder forTarget(String target) { + public static AltsChannelBuilder forTarget(String target) { return new AltsChannelBuilder(target); } @@ -73,13 +48,7 @@ public static AltsChannelBuilder forAddress(String name, int port) { } private AltsChannelBuilder(String target) { - delegate = - NettyChannelBuilder.forTarget(target) - .keepAliveTime(20, TimeUnit.SECONDS) - .keepAliveTimeout(10, TimeUnit.SECONDS) - .keepAliveWithoutCalls(true); - InternalNettyChannelBuilder.setProtocolNegotiatorFactory( - delegate(), new ProtocolNegotiatorFactory()); + delegate = NettyChannelBuilder.forTarget(target); } /** @@ -87,7 +56,7 @@ private AltsChannelBuilder(String target) { * service account in the handshaker result. Otherwise, the handshake fails. */ public AltsChannelBuilder addTargetServiceAccount(String targetServiceAccount) { - targetServiceAccountsBuilder.add(targetServiceAccount); + credentialsBuilder.addTargetServiceAccount(targetServiceAccount); return this; } @@ -96,16 +65,13 @@ public AltsChannelBuilder addTargetServiceAccount(String targetServiceAccount) { * is running on Google Cloud Platform. */ public AltsChannelBuilder enableUntrustedAltsForTesting() { - enableUntrustedAlts = true; + credentialsBuilder.enableUntrustedAltsForTesting(); return this; } /** Sets a new handshaker service address for testing. */ public AltsChannelBuilder setHandshakerAddressForTesting(String handshakerAddress) { - // Instead of using the default shared channel to the handshaker service, create a separate - // resource to the test address. - handshakerChannelPool = SharedResourcePool.forResource( - HandshakerServiceChannel.getHandshakerChannelForTesting(handshakerAddress)); + credentialsBuilder.setHandshakerAddressForTesting(handshakerAddress); return this; } @@ -116,70 +82,16 @@ protected NettyChannelBuilder delegate() { @Override public ManagedChannel build() { - if (!CheckGcpEnvironment.isOnGcp()) { - if (enableUntrustedAlts) { - logger.log( - Level.WARNING, - "Untrusted ALTS mode is enabled and we cannot guarantee the trustworthiness of the " - + "ALTS handshaker service"); - } else { - Status status = - Status.INTERNAL.withDescription("ALTS is only allowed to run on Google Cloud Platform"); - delegate().intercept(new FailingClientInterceptor(status)); - } - } + InternalNettyChannelBuilder.setProtocolNegotiatorFactory( + delegate(), + credentialsBuilder.buildProtocolNegotiatorFactory()); return delegate().build(); } @VisibleForTesting @Nullable - AltsProtocolNegotiator getProtocolNegotiatorForTest() { - return negotiatorForTest; - } - - private final class ProtocolNegotiatorFactory - implements InternalNettyChannelBuilder.ProtocolNegotiatorFactory { - - @Override - public AltsProtocolNegotiator buildProtocolNegotiator() { - final ImmutableList targetServiceAccounts = targetServiceAccountsBuilder.build(); - TsiHandshakerFactory altsHandshakerFactory = - new TsiHandshakerFactory() { - @Override - public TsiHandshaker newHandshaker(String authority) { - // Used the shared grpc channel to connecting to the ALTS handshaker service. - // TODO: Release the channel if it is not used. - // https://github.com/grpc/grpc-java/issues/4755. - AltsClientOptions handshakerOptions = - new AltsClientOptions.Builder() - .setRpcProtocolVersions(RpcProtocolVersionsUtil.getRpcProtocolVersions()) - .setTargetServiceAccounts(targetServiceAccounts) - .setTargetName(authority) - .build(); - return AltsTsiHandshaker.newClient( - HandshakerServiceGrpc.newStub(handshakerChannelPool.getObject()), - handshakerOptions); - } - }; - return negotiatorForTest = - AltsProtocolNegotiator.createClientNegotiator(altsHandshakerFactory); - } - } - - /** An implementation of {@link ClientInterceptor} that fails each call. */ - static final class FailingClientInterceptor implements ClientInterceptor { - - private final Status status; - - public FailingClientInterceptor(Status status) { - this.status = status; - } - - @Override - public ClientCall interceptCall( - MethodDescriptor method, CallOptions callOptions, Channel next) { - return new FailingClientCall<>(status); - } + ProtocolNegotiator getProtocolNegotiatorForTest() { + return credentialsBuilder.buildProtocolNegotiatorFactory().newNegotiator(); } } diff --git a/alts/src/main/java/io/grpc/alts/AltsChannelCredentials.java b/alts/src/main/java/io/grpc/alts/AltsChannelCredentials.java new file mode 100644 index 00000000000..e12344f73d7 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/AltsChannelCredentials.java @@ -0,0 +1,159 @@ +/* + * Copyright 2020 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import com.google.common.collect.ImmutableList; +import io.grpc.Channel; +import io.grpc.ChannelCredentials; +import io.grpc.ExperimentalApi; +import io.grpc.Status; +import io.grpc.alts.internal.AltsProtocolNegotiator.ClientAltsProtocolNegotiatorFactory; +import io.grpc.internal.ObjectPool; +import io.grpc.internal.SharedResourcePool; +import io.grpc.netty.GrpcHttp2ConnectionHandler; +import io.grpc.netty.InternalNettyChannelCredentials; +import io.grpc.netty.InternalProtocolNegotiator; +import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerAdapter; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.AsciiString; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Provides secure and authenticated communication between two cloud VMs using ALTS. + */ +@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4151") +public final class AltsChannelCredentials { + private static final Logger logger = Logger.getLogger(AltsChannelCredentials.class.getName()); + + private AltsChannelCredentials() {} + + public static ChannelCredentials create() { + return newBuilder().build(); + } + + public static Builder newBuilder() { + return new Builder(); + } + + @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4151") + public static final class Builder { + private final ImmutableList.Builder targetServiceAccountsBuilder = + ImmutableList.builder(); + private ObjectPool handshakerChannelPool = + SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL); + private boolean enableUntrustedAlts; + + /** + * Adds an expected target service accounts. One of the added service accounts should match peer + * service account in the handshaker result. Otherwise, the handshake fails. + */ + public Builder addTargetServiceAccount(String targetServiceAccount) { + targetServiceAccountsBuilder.add(targetServiceAccount); + return this; + } + + /** + * Enables untrusted ALTS for testing. If this function is called, we will not check whether + * ALTS is running on Google Cloud Platform. + */ + public Builder enableUntrustedAltsForTesting() { + enableUntrustedAlts = true; + return this; + } + + /** Sets a new handshaker service address for testing. */ + public Builder setHandshakerAddressForTesting(String handshakerAddress) { + // Instead of using the default shared channel to the handshaker service, create a separate + // resource to the test address. + handshakerChannelPool = + SharedResourcePool.forResource( + HandshakerServiceChannel.getHandshakerChannelForTesting(handshakerAddress)); + return this; + } + + public ChannelCredentials build() { + return InternalNettyChannelCredentials.create(buildProtocolNegotiatorFactory()); + } + + InternalProtocolNegotiator.ClientFactory buildProtocolNegotiatorFactory() { + if (!InternalCheckGcpEnvironment.isOnGcp()) { + if (enableUntrustedAlts) { + logger.log( + Level.WARNING, + "Untrusted ALTS mode is enabled and we cannot guarantee the trustworthiness of the " + + "ALTS handshaker service"); + } else { + Status status = Status.INTERNAL.withDescription( + "ALTS is only allowed to run on Google Cloud Platform"); + return new FailingProtocolNegotiatorFactory(status); + } + } + + return new ClientAltsProtocolNegotiatorFactory( + targetServiceAccountsBuilder.build(), handshakerChannelPool); + } + } + + private static final class FailingProtocolNegotiatorFactory + implements InternalProtocolNegotiator.ClientFactory { + private final Status status; + + public FailingProtocolNegotiatorFactory(Status status) { + this.status = status; + } + + @Override + public ProtocolNegotiator newNegotiator() { + return new FailingProtocolNegotiator(status); + } + + @Override + public int getDefaultPort() { + return 443; + } + } + + private static final AsciiString SCHEME = AsciiString.of("https"); + + static final class FailingProtocolNegotiator implements ProtocolNegotiator { + private final Status status; + + public FailingProtocolNegotiator(Status status) { + this.status = status; + } + + @Override + public AsciiString scheme() { + return SCHEME; + } + + @Override + public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { + return new ChannelHandlerAdapter() { + @Override public void handlerAdded(ChannelHandlerContext ctx) { + ctx.fireExceptionCaught(status.asRuntimeException()); + } + }; + } + + @Override + public void close() {} + } +} diff --git a/alts/src/main/java/io/grpc/alts/AltsContext.java b/alts/src/main/java/io/grpc/alts/AltsContext.java new file mode 100644 index 00000000000..7680de4160e --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/AltsContext.java @@ -0,0 +1,91 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import io.grpc.ExperimentalApi; +import io.grpc.alts.internal.AltsInternalContext; +import io.grpc.alts.internal.HandshakerResult; +import io.grpc.alts.internal.Identity; + +/** {@code AltsContext} contains security-related information on the ALTS channel. */ +@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7864") +public final class AltsContext { + + private final AltsInternalContext wrapped; + + AltsContext(AltsInternalContext wrapped) { + this.wrapped = wrapped; + } + + /** + * Creates an {@code AltsContext} for testing purposes. + * @param peerServiceAccount the peer service account of the to be created {@code AltsContext} + * @param localServiceAccount the local service account of the to be created {@code AltsContext} + * @return the created {@code AltsContext} + */ + public static AltsContext createTestInstance(String peerServiceAccount, + String localServiceAccount) { + return new AltsContext(new AltsInternalContext(HandshakerResult.newBuilder() + .setPeerIdentity(Identity.newBuilder().setServiceAccount(peerServiceAccount).build()) + .setLocalIdentity(Identity.newBuilder().setServiceAccount(localServiceAccount).build()) + .build())); + } + + /** + * Get security level. + * + * @return the context's security level. + */ + public SecurityLevel getSecurityLevel() { + switch (wrapped.getSecurityLevel()) { + case SECURITY_NONE: + return SecurityLevel.SECURITY_NONE; + case INTEGRITY_ONLY: + return SecurityLevel.INTEGRITY_ONLY; + case INTEGRITY_AND_PRIVACY: + return SecurityLevel.INTEGRITY_AND_PRIVACY; + default: + return SecurityLevel.UNKNOWN; + } + } + + /** + * Get peer service account. + * + * @return the context's peer service account. + */ + public String getPeerServiceAccount() { + return wrapped.getPeerServiceAccount(); + } + + /** + * Get local service account. + * + * @return the context's local service account. + */ + public String getLocalServiceAccount() { + return wrapped.getLocalServiceAccount(); + } + + /** SecurityLevel of the ALTS channel. */ + public enum SecurityLevel { + UNKNOWN, + SECURITY_NONE, + INTEGRITY_ONLY, + INTEGRITY_AND_PRIVACY, + } +} diff --git a/alts/src/main/java/io/grpc/alts/AltsContextUtil.java b/alts/src/main/java/io/grpc/alts/AltsContextUtil.java new file mode 100644 index 00000000000..f45179bbd91 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/AltsContextUtil.java @@ -0,0 +1,99 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import io.grpc.Attributes; +import io.grpc.ClientCall; +import io.grpc.ExperimentalApi; +import io.grpc.ServerCall; +import io.grpc.alts.internal.AltsInternalContext; +import io.grpc.alts.internal.AltsProtocolNegotiator; + +/** Utility class for {@link AltsContext}. */ +@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7864") +public final class AltsContextUtil { + + private AltsContextUtil() {} + + /** + * Creates an {@link AltsContext} from ALTS context information in the {@link ServerCall}. + * + * @param call the {@link ServerCall} containing the ALTS information + * @return the created {@link AltsContext} + * @throws IllegalArgumentException if the {@link ServerCall} has no ALTS information. + */ + public static AltsContext createFrom(ServerCall call) { + return createFrom(call.getAttributes()); + } + + /** + * Creates an {@link AltsContext} from ALTS context information in the {@link ClientCall}. + * + * @param call the {@link ClientCall} containing the ALTS information + * @return the created {@link AltsContext} + * @throws IllegalArgumentException if the {@link ClientCall} has no ALTS information. + */ + public static AltsContext createFrom(ClientCall call) { + return createFrom(call.getAttributes()); + } + + /** + * Creates an {@link AltsContext} from ALTS context information in the {@link Attributes}. + * + * @param attributes the {@link Attributes} containing the ALTS information + * @return the created {@link AltsContext} + * @throws IllegalArgumentException if the {@link Attributes} has no ALTS information. + */ + public static AltsContext createFrom(Attributes attributes) { + Object authContext = attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY); + if (!(authContext instanceof AltsInternalContext)) { + throw new IllegalArgumentException("No ALTS context information found"); + } + return new AltsContext((AltsInternalContext) authContext); + } + + /** + * Checks if the {@link ServerCall} contains ALTS information. + * + * @param call the {@link ServerCall} to check + * @return true, if the {@link ServerCall} contains ALTS information and false otherwise. + */ + public static boolean check(ServerCall call) { + return check(call.getAttributes()); + } + + /** + * Checks if the {@link ClientCall} contains ALTS information. + * + * @param call the {@link ClientCall} to check + * @return true, if the {@link ClientCall} contains ALTS information and false otherwise. + */ + public static boolean check(ClientCall call) { + return check(call.getAttributes()); + } + + /** + * Checks if the {@link Attributes} contains ALTS information. + * + * @param attributes the {@link Attributes} to check + * @return true, if the {@link Attributes} contains ALTS information and false otherwise. + */ + public static boolean check(Attributes attributes) { + Object authContext = attributes.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY); + return authContext instanceof AltsInternalContext; + } +} diff --git a/alts/src/main/java/io/grpc/alts/AltsServerBuilder.java b/alts/src/main/java/io/grpc/alts/AltsServerBuilder.java index 5ca1f51b4aa..e307fd1c63a 100644 --- a/alts/src/main/java/io/grpc/alts/AltsServerBuilder.java +++ b/alts/src/main/java/io/grpc/alts/AltsServerBuilder.java @@ -17,51 +17,32 @@ package io.grpc.alts; import io.grpc.BindableService; -import io.grpc.Channel; import io.grpc.CompressorRegistry; import io.grpc.DecompressorRegistry; import io.grpc.ExperimentalApi; +import io.grpc.ForwardingServerBuilder; import io.grpc.HandlerRegistry; -import io.grpc.Metadata; import io.grpc.Server; import io.grpc.ServerBuilder; -import io.grpc.ServerCall; -import io.grpc.ServerCall.Listener; -import io.grpc.ServerCallHandler; import io.grpc.ServerInterceptor; import io.grpc.ServerServiceDefinition; -import io.grpc.ServerStreamTracer.Factory; +import io.grpc.ServerStreamTracer; import io.grpc.ServerTransportFilter; -import io.grpc.Status; -import io.grpc.alts.internal.AltsHandshakerOptions; -import io.grpc.alts.internal.AltsProtocolNegotiator; -import io.grpc.alts.internal.AltsTsiHandshaker; -import io.grpc.alts.internal.HandshakerServiceGrpc; -import io.grpc.alts.internal.RpcProtocolVersionsUtil; -import io.grpc.alts.internal.TsiHandshaker; -import io.grpc.alts.internal.TsiHandshakerFactory; -import io.grpc.internal.ObjectPool; -import io.grpc.internal.SharedResourcePool; import io.grpc.netty.NettyServerBuilder; import java.io.File; import java.net.InetSocketAddress; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; /** * gRPC secure server builder used for ALTS. This class adds on the necessary ALTS support to create * a production server on Google Cloud Platform. */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4151") -public final class AltsServerBuilder extends ServerBuilder { - - private static final Logger logger = Logger.getLogger(AltsServerBuilder.class.getName()); +public final class AltsServerBuilder extends ForwardingServerBuilder { private final NettyServerBuilder delegate; - private ObjectPool handshakerChannelPool = - SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL); - private boolean enableUntrustedAlts; + private final AltsServerCredentials.Builder credentialsBuilder = + new AltsServerCredentials.Builder(); private AltsServerBuilder(NettyServerBuilder nettyDelegate) { this.delegate = nettyDelegate; @@ -69,13 +50,7 @@ private AltsServerBuilder(NettyServerBuilder nettyDelegate) { /** Creates a gRPC server builder for the given port. */ public static AltsServerBuilder forPort(int port) { - NettyServerBuilder nettyDelegate = - NettyServerBuilder.forAddress(new InetSocketAddress(port)) - .maxConnectionIdle(1, TimeUnit.HOURS) - .keepAliveTime(270, TimeUnit.SECONDS) - .keepAliveTimeout(20, TimeUnit.SECONDS) - .permitKeepAliveTime(10, TimeUnit.SECONDS) - .permitKeepAliveWithoutCalls(true); + NettyServerBuilder nettyDelegate = NettyServerBuilder.forAddress(new InetSocketAddress(port)); return new AltsServerBuilder(nettyDelegate); } @@ -84,19 +59,21 @@ public static AltsServerBuilder forPort(int port) { * is running on Google Cloud Platform. */ public AltsServerBuilder enableUntrustedAltsForTesting() { - enableUntrustedAlts = true; + credentialsBuilder.enableUntrustedAltsForTesting(); return this; } /** Sets a new handshaker service address for testing. */ public AltsServerBuilder setHandshakerAddressForTesting(String handshakerAddress) { - // Instead of using the default shared channel to the handshaker service, create a separate - // resource to the test address. - handshakerChannelPool = SharedResourcePool.forResource( - HandshakerServiceChannel.getHandshakerChannelForTesting(handshakerAddress)); + credentialsBuilder.setHandshakerAddressForTesting(handshakerAddress); return this; } + @Override + protected ServerBuilder delegate() { + return delegate; + } + /** {@inheritDoc} */ @Override public AltsServerBuilder handshakeTimeout(long timeout, TimeUnit unit) { @@ -113,7 +90,7 @@ public AltsServerBuilder directExecutor() { /** {@inheritDoc} */ @Override - public AltsServerBuilder addStreamTracerFactory(Factory factory) { + public AltsServerBuilder addStreamTracerFactory(ServerStreamTracer.Factory factory) { delegate.addStreamTracerFactory(factory); return this; } @@ -183,51 +160,7 @@ public AltsServerBuilder intercept(ServerInterceptor interceptor) { /** {@inheritDoc} */ @Override public Server build() { - if (!CheckGcpEnvironment.isOnGcp()) { - if (enableUntrustedAlts) { - logger.log( - Level.WARNING, - "Untrusted ALTS mode is enabled and we cannot guarantee the trustworthiness of the " - + "ALTS handshaker service"); - } else { - Status status = - Status.INTERNAL.withDescription("ALTS is only allowed to run on Google Cloud Platform"); - delegate.intercept(new FailingServerInterceptor(status)); - } - } - - delegate.protocolNegotiator( - AltsProtocolNegotiator.createServerNegotiator( - new TsiHandshakerFactory() { - @Override - public TsiHandshaker newHandshaker(String authority) { - // Used the shared grpc channel to connecting to the ALTS handshaker service. - // TODO: Release the channel if it is not used. - // https://github.com/grpc/grpc-java/issues/4755. - return AltsTsiHandshaker.newServer( - HandshakerServiceGrpc.newStub(handshakerChannelPool.getObject()), - new AltsHandshakerOptions(RpcProtocolVersionsUtil.getRpcProtocolVersions())); - } - })); + delegate.protocolNegotiator(credentialsBuilder.buildProtocolNegotiator()); return delegate.build(); } - - /** An implementation of {@link ServerInterceptor} that fails each call. */ - static final class FailingServerInterceptor implements ServerInterceptor { - - private final Status status; - - public FailingServerInterceptor(Status status) { - this.status = status; - } - - @Override - public Listener interceptCall( - ServerCall serverCall, - Metadata metadata, - ServerCallHandler nextHandler) { - serverCall.close(status, new Metadata()); - return new Listener() {}; - } - } } diff --git a/alts/src/main/java/io/grpc/alts/AltsServerCredentials.java b/alts/src/main/java/io/grpc/alts/AltsServerCredentials.java new file mode 100644 index 00000000000..36dc9f6a4ae --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/AltsServerCredentials.java @@ -0,0 +1,95 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import io.grpc.Channel; +import io.grpc.ExperimentalApi; +import io.grpc.ServerCredentials; +import io.grpc.Status; +import io.grpc.alts.internal.AltsProtocolNegotiator; +import io.grpc.internal.ObjectPool; +import io.grpc.internal.SharedResourcePool; +import io.grpc.netty.InternalNettyServerCredentials; +import io.grpc.netty.InternalProtocolNegotiator; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * gRPC secure server builder used for ALTS. This class adds on the necessary ALTS support to create + * a production server on Google Cloud Platform. + */ +@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4151") +public final class AltsServerCredentials { + private static final Logger logger = Logger.getLogger(AltsServerCredentials.class.getName()); + + private AltsServerCredentials() {} + + public static ServerCredentials create() { + return newBuilder().build(); + } + + public static Builder newBuilder() { + return new Builder(); + } + + @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4151") + public static final class Builder { + private ObjectPool handshakerChannelPool = + SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL); + private boolean enableUntrustedAlts; + + /** + * Enables untrusted ALTS for testing. If this function is called, we will not check whether + * ALTS is running on Google Cloud Platform. + */ + public Builder enableUntrustedAltsForTesting() { + enableUntrustedAlts = true; + return this; + } + + /** Sets a new handshaker service address for testing. */ + public Builder setHandshakerAddressForTesting(String handshakerAddress) { + // Instead of using the default shared channel to the handshaker service, create a separate + // resource to the test address. + handshakerChannelPool = + SharedResourcePool.forResource( + HandshakerServiceChannel.getHandshakerChannelForTesting(handshakerAddress)); + return this; + } + + public ServerCredentials build() { + return InternalNettyServerCredentials.create(buildProtocolNegotiator()); + } + + InternalProtocolNegotiator.ProtocolNegotiator buildProtocolNegotiator() { + if (!InternalCheckGcpEnvironment.isOnGcp()) { + if (enableUntrustedAlts) { + logger.log( + Level.WARNING, + "Untrusted ALTS mode is enabled and we cannot guarantee the trustworthiness of the " + + "ALTS handshaker service"); + } else { + Status status = Status.INTERNAL.withDescription( + "ALTS is only allowed to run on Google Cloud Platform"); + return new AltsChannelCredentials.FailingProtocolNegotiator(status); + } + } + + return AltsProtocolNegotiator.serverAltsProtocolNegotiator(handshakerChannelPool); + } + } +} diff --git a/alts/src/main/java/io/grpc/alts/AuthorizationUtil.java b/alts/src/main/java/io/grpc/alts/AuthorizationUtil.java new file mode 100644 index 00000000000..53e45105d9b --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/AuthorizationUtil.java @@ -0,0 +1,48 @@ +/* + * Copyright 2019 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import io.grpc.ServerCall; +import io.grpc.Status; +import io.grpc.alts.internal.AltsInternalContext; +import io.grpc.alts.internal.AltsProtocolNegotiator; +import java.util.Collection; + +/** Utility class for ALTS client authorization. */ +public final class AuthorizationUtil { + + private AuthorizationUtil() {} + + /** + * Given a server call, performs client authorization check, i.e., checks if the client service + * account matches one of the expected service accounts. It returns OK if client is authorized and + * an error otherwise. + */ + public static Status clientAuthorizationCheck( + ServerCall call, Collection expectedServiceAccounts) { + AltsInternalContext altsContext = + (AltsInternalContext) call.getAttributes().get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY); + if (altsContext == null) { + return Status.PERMISSION_DENIED.withDescription("Peer ALTS AuthContext not found"); + } + if (expectedServiceAccounts.contains(altsContext.getPeerServiceAccount())) { + return Status.OK; + } + return Status.PERMISSION_DENIED.withDescription( + "Client " + altsContext.getPeerServiceAccount() + " is not authorized"); + } +} diff --git a/alts/src/main/java/io/grpc/alts/CheckGcpEnvironment.java b/alts/src/main/java/io/grpc/alts/CheckGcpEnvironment.java deleted file mode 100644 index 1533415f6b0..00000000000 --- a/alts/src/main/java/io/grpc/alts/CheckGcpEnvironment.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2018 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.alts; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import com.google.common.annotations.VisibleForTesting; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.apache.commons.lang3.SystemUtils; - -/** Class for checking if the system is running on Google Cloud Platform (GCP). */ -final class CheckGcpEnvironment { - - private static final Logger logger = Logger.getLogger(CheckGcpEnvironment.class.getName()); - private static final String DMI_PRODUCT_NAME = "/sys/class/dmi/id/product_name"; - private static final String WINDOWS_COMMAND = "powershell.exe"; - private static Boolean cachedResult = null; - - // Construct me not! - private CheckGcpEnvironment() {} - - static synchronized boolean isOnGcp() { - if (cachedResult == null) { - cachedResult = isRunningOnGcp(); - } - return cachedResult; - } - - @VisibleForTesting - static boolean checkProductNameOnLinux(BufferedReader reader) throws IOException { - String name = reader.readLine().trim(); - return name.equals("Google") || name.equals("Google Compute Engine"); - } - - @VisibleForTesting - static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { - String line; - while ((line = reader.readLine()) != null) { - if (line.startsWith("Manufacturer")) { - String name = line.substring(line.indexOf(':') + 1).trim(); - return name.equals("Google"); - } - } - return false; - } - - private static boolean isRunningOnGcp() { - try { - if (SystemUtils.IS_OS_LINUX) { - // Checks GCE residency on Linux platform. - return checkProductNameOnLinux(Files.newBufferedReader(Paths.get(DMI_PRODUCT_NAME), UTF_8)); - } else if (SystemUtils.IS_OS_WINDOWS) { - // Checks GCE residency on Windows platform. - Process p = - new ProcessBuilder() - .command(WINDOWS_COMMAND, "Get-WmiObject", "-Class", "Win32_BIOS") - .start(); - return checkBiosDataOnWindows( - new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))); - } - } catch (IOException e) { - logger.log(Level.WARNING, "Fail to read platform information: ", e); - return false; - } - // Platforms other than Linux and Windows are not supported. - return false; - } -} diff --git a/alts/src/main/java/io/grpc/alts/ComputeEngineChannelBuilder.java b/alts/src/main/java/io/grpc/alts/ComputeEngineChannelBuilder.java new file mode 100644 index 00000000000..b5ee6a8d362 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/ComputeEngineChannelBuilder.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import io.grpc.ForwardingChannelBuilder; +import io.grpc.ManagedChannelBuilder; +import io.grpc.internal.GrpcUtil; +import io.grpc.netty.NettyChannelBuilder; + +/** + * {@code ManagedChannelBuilder} for Google Compute Engine. This class sets up a secure channel + * using ALTS if applicable and using TLS as fallback. + */ +public final class ComputeEngineChannelBuilder + extends ForwardingChannelBuilder { + + private final NettyChannelBuilder delegate; + + private ComputeEngineChannelBuilder(String target) { + delegate = NettyChannelBuilder.forTarget(target, ComputeEngineChannelCredentials.create()); + } + + /** "Overrides" the static method in {@link ManagedChannelBuilder}. */ + public static ComputeEngineChannelBuilder forTarget(String target) { + return new ComputeEngineChannelBuilder(target); + } + + /** "Overrides" the static method in {@link ManagedChannelBuilder}. */ + public static ComputeEngineChannelBuilder forAddress(String name, int port) { + return forTarget(GrpcUtil.authorityFromHostAndPort(name, port)); + } + + @Override + @SuppressWarnings("deprecation") // Not extending ForwardingChannelBuilder2 to preserve ABI. + protected NettyChannelBuilder delegate() { + return delegate; + } +} diff --git a/alts/src/main/java/io/grpc/alts/ComputeEngineChannelCredentials.java b/alts/src/main/java/io/grpc/alts/ComputeEngineChannelCredentials.java new file mode 100644 index 00000000000..518642a675d --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/ComputeEngineChannelCredentials.java @@ -0,0 +1,72 @@ +/* + * Copyright 2020 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import com.google.auth.oauth2.ComputeEngineCredentials; +import com.google.common.collect.ImmutableList; +import io.grpc.CallCredentials; +import io.grpc.ChannelCredentials; +import io.grpc.CompositeChannelCredentials; +import io.grpc.Status; +import io.grpc.alts.internal.AltsProtocolNegotiator.GoogleDefaultProtocolNegotiatorFactory; +import io.grpc.auth.MoreCallCredentials; +import io.grpc.internal.SharedResourcePool; +import io.grpc.netty.GrpcSslContexts; +import io.grpc.netty.InternalNettyChannelCredentials; +import io.grpc.netty.InternalProtocolNegotiator; +import io.netty.handler.ssl.SslContext; +import javax.net.ssl.SSLException; + +/** + * Credentials appropriate to contact Google services when running on Google Compute Engine. This + * class sets up a secure channel using ALTS if applicable and using TLS as fallback. It is a subset + * of the functionality provided by {@link GoogleDefaultChannelCredentials}. + */ +public final class ComputeEngineChannelCredentials { + private ComputeEngineChannelCredentials() {} + + /** + * Creates credentials for Google Compute Engine. This class sets up a secure channel using ALTS + * if applicable and using TLS as fallback. + */ + public static ChannelCredentials create() { + ChannelCredentials nettyCredentials = + InternalNettyChannelCredentials.create(createClientFactory()); + CallCredentials callCredentials; + if (InternalCheckGcpEnvironment.isOnGcp()) { + callCredentials = MoreCallCredentials.from(ComputeEngineCredentials.create()); + } else { + callCredentials = new FailingCallCredentials( + Status.INTERNAL.withDescription( + "Compute Engine Credentials can only be used on Google Cloud Platform")); + } + return CompositeChannelCredentials.create(nettyCredentials, callCredentials); + } + + private static InternalProtocolNegotiator.ClientFactory createClientFactory() { + SslContext sslContext; + try { + sslContext = GrpcSslContexts.forClient().build(); + } catch (SSLException e) { + throw new RuntimeException(e); + } + return new GoogleDefaultProtocolNegotiatorFactory( + /* targetServiceAccounts= */ ImmutableList.of(), + SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL), + sslContext); + } +} diff --git a/alts/src/main/java/io/grpc/alts/DualCallCredentials.java b/alts/src/main/java/io/grpc/alts/DualCallCredentials.java new file mode 100644 index 00000000000..08104712e65 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/DualCallCredentials.java @@ -0,0 +1,46 @@ +/* + * Copyright 2024 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import io.grpc.CallCredentials; +import java.util.concurrent.Executor; + +/** + * {@code CallCredentials} that will pick the right credentials based on whether the established + * connection is ALTS or TLS. + */ +final class DualCallCredentials extends CallCredentials { + private final CallCredentials tlsCallCredentials; + private final CallCredentials altsCallCredentials; + + public DualCallCredentials(CallCredentials tlsCallCreds, CallCredentials altsCallCreds) { + tlsCallCredentials = tlsCallCreds; + altsCallCredentials = altsCallCreds; + } + + @Override + public void applyRequestMetadata( + CallCredentials.RequestInfo requestInfo, + Executor appExecutor, + CallCredentials.MetadataApplier applier) { + if (AltsContextUtil.check(requestInfo.getTransportAttrs())) { + altsCallCredentials.applyRequestMetadata(requestInfo, appExecutor, applier); + } else { + tlsCallCredentials.applyRequestMetadata(requestInfo, appExecutor, applier); + } + } +} diff --git a/alts/src/main/java/io/grpc/alts/FailingCallCredentials.java b/alts/src/main/java/io/grpc/alts/FailingCallCredentials.java new file mode 100644 index 00000000000..3c59c5b6d09 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/FailingCallCredentials.java @@ -0,0 +1,41 @@ +/* + * Copyright 2020 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import com.google.common.base.Preconditions; +import io.grpc.CallCredentials; +import io.grpc.Status; +import java.util.concurrent.Executor; + +/** + * {@code CallCredentials} that always fail the RPC. + */ +final class FailingCallCredentials extends CallCredentials { + private final Status status; + + public FailingCallCredentials(Status status) { + this.status = Preconditions.checkNotNull(status, "status"); + } + + @Override + public void applyRequestMetadata( + CallCredentials.RequestInfo requestInfo, + Executor appExecutor, + CallCredentials.MetadataApplier applier) { + applier.fail(status); + } +} diff --git a/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelBuilder.java b/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelBuilder.java index ccd5104ce8f..c78b94417c4 100644 --- a/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelBuilder.java +++ b/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelBuilder.java @@ -16,34 +16,10 @@ package io.grpc.alts; -import com.google.auth.oauth2.GoogleCredentials; -import com.google.common.annotations.VisibleForTesting; -import io.grpc.CallCredentials; -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; import io.grpc.ForwardingChannelBuilder; import io.grpc.ManagedChannelBuilder; -import io.grpc.MethodDescriptor; -import io.grpc.Status; -import io.grpc.alts.internal.AltsClientOptions; -import io.grpc.alts.internal.AltsTsiHandshaker; -import io.grpc.alts.internal.GoogleDefaultProtocolNegotiator; -import io.grpc.alts.internal.HandshakerServiceGrpc; -import io.grpc.alts.internal.RpcProtocolVersionsUtil; -import io.grpc.alts.internal.TsiHandshaker; -import io.grpc.alts.internal.TsiHandshakerFactory; -import io.grpc.auth.MoreCallCredentials; import io.grpc.internal.GrpcUtil; -import io.grpc.internal.SharedResourceHolder; -import io.grpc.netty.GrpcSslContexts; -import io.grpc.netty.InternalNettyChannelBuilder; import io.grpc.netty.NettyChannelBuilder; -import io.netty.handler.ssl.SslContext; -import java.io.IOException; -import javax.annotation.Nullable; -import javax.net.ssl.SSLException; /** * Google default version of {@code ManagedChannelBuilder}. This class sets up a secure channel @@ -53,27 +29,13 @@ public final class GoogleDefaultChannelBuilder extends ForwardingChannelBuilder { private final NettyChannelBuilder delegate; - private GoogleDefaultProtocolNegotiator negotiatorForTest; private GoogleDefaultChannelBuilder(String target) { - delegate = NettyChannelBuilder.forTarget(target); - InternalNettyChannelBuilder.setProtocolNegotiatorFactory( - delegate(), new ProtocolNegotiatorFactory()); - @Nullable CallCredentials credentials = null; - Status status = Status.OK; - try { - credentials = MoreCallCredentials.from(GoogleCredentials.getApplicationDefault()); - } catch (IOException e) { - status = - Status.UNAUTHENTICATED - .withDescription("Failed to get Google default credentials") - .withCause(e); - } - delegate().intercept(new GoogleDefaultInterceptor(credentials, status)); + delegate = NettyChannelBuilder.forTarget(target, GoogleDefaultChannelCredentials.create()); } /** "Overrides" the static method in {@link ManagedChannelBuilder}. */ - public static final GoogleDefaultChannelBuilder forTarget(String target) { + public static GoogleDefaultChannelBuilder forTarget(String target) { return new GoogleDefaultChannelBuilder(target); } @@ -83,68 +45,8 @@ public static GoogleDefaultChannelBuilder forAddress(String name, int port) { } @Override + @SuppressWarnings("deprecation") // Not extending ForwardingChannelBuilder2 to preserve ABI. protected NettyChannelBuilder delegate() { return delegate; } - - @VisibleForTesting - GoogleDefaultProtocolNegotiator getProtocolNegotiatorForTest() { - return negotiatorForTest; - } - - private final class ProtocolNegotiatorFactory - implements InternalNettyChannelBuilder.ProtocolNegotiatorFactory { - @Override - public GoogleDefaultProtocolNegotiator buildProtocolNegotiator() { - TsiHandshakerFactory altsHandshakerFactory = - new TsiHandshakerFactory() { - @Override - public TsiHandshaker newHandshaker(String authority) { - // Used the shared grpc channel to connecting to the ALTS handshaker service. - // TODO: Release the channel if it is not used. - // https://github.com/grpc/grpc-java/issues/4755. - Channel channel = - SharedResourceHolder.get(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL); - AltsClientOptions handshakerOptions = - new AltsClientOptions.Builder() - .setRpcProtocolVersions(RpcProtocolVersionsUtil.getRpcProtocolVersions()) - .setTargetName(authority) - .build(); - return AltsTsiHandshaker.newClient( - HandshakerServiceGrpc.newStub(channel), handshakerOptions); - } - }; - SslContext sslContext; - try { - sslContext = GrpcSslContexts.forClient().build(); - } catch (SSLException ex) { - throw new RuntimeException(ex); - } - return negotiatorForTest = - new GoogleDefaultProtocolNegotiator(altsHandshakerFactory, sslContext); - } - } - - /** - * An implementation of {@link ClientInterceptor} that adds Google call credentials on each call. - */ - static final class GoogleDefaultInterceptor implements ClientInterceptor { - - @Nullable private final CallCredentials credentials; - private final Status status; - - public GoogleDefaultInterceptor(@Nullable CallCredentials credentials, Status status) { - this.credentials = credentials; - this.status = status; - } - - @Override - public ClientCall interceptCall( - MethodDescriptor method, CallOptions callOptions, Channel next) { - if (!status.isOk()) { - return new FailingClientCall<>(status); - } - return next.newCall(method, callOptions.withCallCredentials(credentials)); - } - } } diff --git a/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelCredentials.java b/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelCredentials.java new file mode 100644 index 00000000000..1b5880120a4 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/GoogleDefaultChannelCredentials.java @@ -0,0 +1,118 @@ +/* + * Copyright 2020 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import com.google.auth.oauth2.GoogleCredentials; +import com.google.common.collect.ImmutableList; +import io.grpc.CallCredentials; +import io.grpc.ChannelCredentials; +import io.grpc.CompositeChannelCredentials; +import io.grpc.Status; +import io.grpc.alts.internal.AltsProtocolNegotiator.GoogleDefaultProtocolNegotiatorFactory; +import io.grpc.auth.MoreCallCredentials; +import io.grpc.internal.SharedResourcePool; +import io.grpc.netty.GrpcSslContexts; +import io.grpc.netty.InternalNettyChannelCredentials; +import io.grpc.netty.InternalProtocolNegotiator; +import io.netty.handler.ssl.SslContext; +import java.io.IOException; +import javax.net.ssl.SSLException; + +/** + * Credentials appropriate to contact Google services. This class sets up a secure channel using + * ALTS if applicable and uses TLS as fallback. + */ +public final class GoogleDefaultChannelCredentials { + private GoogleDefaultChannelCredentials() {} + + /** + * Creates Google default credentials uses a secure channel with ALTS if applicable and uses TLS + * as fallback. + */ + public static ChannelCredentials create() { + return newBuilder().build(); + } + + /** + * Returns a new instance of {@link Builder}. + * + * @since 1.43.0 + */ + public static Builder newBuilder() { + return new Builder(); + } + + /** + * Builder for {@link GoogleDefaultChannelCredentials} instances. + * + * @since 1.43.0 + */ + public static final class Builder { + private CallCredentials callCredentials; + private CallCredentials altsCallCredentials; + + private Builder() {} + + /** Constructs GoogleDefaultChannelCredentials with a given call credential. */ + public Builder callCredentials(CallCredentials callCreds) { + callCredentials = callCreds; + return this; + } + + /** Constructs GoogleDefaultChannelCredentials with an ALTS-specific call credential. */ + public Builder altsCallCredentials(CallCredentials callCreds) { + altsCallCredentials = callCreds; + return this; + } + + /** Builds a GoogleDefaultChannelCredentials instance. */ + public ChannelCredentials build() { + ChannelCredentials nettyCredentials = + InternalNettyChannelCredentials.create(createClientFactory()); + CallCredentials tlsCallCreds = callCredentials; + if (tlsCallCreds == null) { + try { + tlsCallCreds = MoreCallCredentials.from(GoogleCredentials.getApplicationDefault()); + } catch (IOException e) { + tlsCallCreds = + new FailingCallCredentials( + Status.UNAUTHENTICATED + .withDescription("Failed to get Google default credentials") + .withCause(e)); + } + } + CallCredentials callCreds = + altsCallCredentials == null + ? tlsCallCreds + : new DualCallCredentials(tlsCallCreds, altsCallCredentials); + return CompositeChannelCredentials.create(nettyCredentials, callCreds); + } + + private static InternalProtocolNegotiator.ClientFactory createClientFactory() { + SslContext sslContext; + try { + sslContext = GrpcSslContexts.forClient().build(); + } catch (SSLException e) { + throw new RuntimeException(e); + } + return new GoogleDefaultProtocolNegotiatorFactory( + /* targetServiceAccounts= */ ImmutableList.of(), + SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL), + sslContext); + } + } +} diff --git a/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java b/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java index 078b865026b..5e32d22d901 100644 --- a/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java +++ b/alts/src/main/java/io/grpc/alts/HandshakerServiceChannel.java @@ -21,11 +21,14 @@ import io.grpc.ClientCall; import io.grpc.ManagedChannel; import io.grpc.MethodDescriptor; +import io.grpc.internal.GrpcUtil; import io.grpc.internal.SharedResourceHolder.Resource; import io.grpc.netty.NettyChannelBuilder; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.concurrent.DefaultThreadFactory; +import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; /** @@ -34,15 +37,37 @@ * application will have at most one connection to the handshaker service. */ final class HandshakerServiceChannel { + // Port 8080 is necessary for ALTS handshake. + private static final int ALTS_PORT = 8080; + private static final String DEFAULT_TARGET = "metadata.google.internal.:8080"; static final Resource SHARED_HANDSHAKER_CHANNEL = - new ChannelResource("metadata.google.internal:8080"); - + new ChannelResource(getHandshakerTarget(System.getenv("GCE_METADATA_HOST"))); + + /** + * Returns handshaker target. When GCE_METADATA_HOST is provided, it might contain port which we + * will discard and use ALTS_PORT instead. + */ + static String getHandshakerTarget(String envValue) { + if (envValue == null || envValue.isEmpty()) { + return DEFAULT_TARGET; + } + String host = envValue; + int portIndex = host.lastIndexOf(':'); + if (portIndex != -1) { + host = host.substring(0, portIndex); // Discard port if specified + } + return host + ":" + ALTS_PORT; // Utilize ALTS port in all cases + } + /** Returns a resource of handshaker service channel for testing only. */ static Resource getHandshakerChannelForTesting(String handshakerAddress) { return new ChannelResource(handshakerAddress); } + private static final boolean EXPERIMENTAL_ALTS_HANDSHAKER_KEEPALIVE_PARAMS = + GrpcUtil.getFlag("GRPC_EXPERIMENTAL_ALTS_HANDSHAKER_KEEPALIVE_PARAMS", false); + private static class ChannelResource implements Resource { private final String target; @@ -55,11 +80,16 @@ public Channel create() { /* Use its own event loop thread pool to avoid blocking. */ EventLoopGroup eventGroup = new NioEventLoopGroup(1, new DefaultThreadFactory("handshaker pool", true)); - ManagedChannel channel = NettyChannelBuilder.forTarget(target) + NettyChannelBuilder channelBuilder = + NettyChannelBuilder.forTarget(target) + .channelType(NioSocketChannel.class, InetSocketAddress.class) .directExecutor() .eventLoopGroup(eventGroup) - .usePlaintext() - .build(); + .usePlaintext(); + if (EXPERIMENTAL_ALTS_HANDSHAKER_KEEPALIVE_PARAMS) { + channelBuilder.keepAliveTime(10, TimeUnit.MINUTES).keepAliveTimeout(10, TimeUnit.SECONDS); + } + ManagedChannel channel = channelBuilder.build(); return new EventLoopHoldingChannel(channel, eventGroup); } diff --git a/alts/src/main/java/io/grpc/alts/InternalCheckGcpEnvironment.java b/alts/src/main/java/io/grpc/alts/InternalCheckGcpEnvironment.java new file mode 100644 index 00000000000..aae4a45d530 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/InternalCheckGcpEnvironment.java @@ -0,0 +1,97 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.google.common.annotations.VisibleForTesting; +import io.grpc.Internal; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Class for checking if the system is running on Google Cloud Platform (GCP). This is intended for + * usage internal to the gRPC team. If you *really* think you need to use this, contact the gRPC + * team first. + */ +@Internal +public final class InternalCheckGcpEnvironment { + + private static final Logger logger = + Logger.getLogger(InternalCheckGcpEnvironment.class.getName()); + private static final String WINDOWS_COMMAND = "powershell.exe"; + private static Boolean cachedResult = null; + + // Construct me not! + private InternalCheckGcpEnvironment() {} + + /** Returns {@code true} if currently running on Google Cloud Platform (GCP). */ + public static synchronized boolean isOnGcp() { + if (cachedResult == null) { + cachedResult = isRunningOnGcp(); + } + return cachedResult; + } + + @VisibleForTesting + static boolean checkProductNameOnLinux(BufferedReader reader) throws IOException { + String name = reader.readLine().trim(); + return name.equals("Google") || name.equals("Google Compute Engine"); + } + + @VisibleForTesting + static boolean checkBiosDataOnWindows(BufferedReader reader) throws IOException { + String line; + while ((line = reader.readLine()) != null) { + if (line.startsWith("Manufacturer")) { + String name = line.substring(line.indexOf(':') + 1).trim(); + return name.equals("Google"); + } + } + return false; + } + + private static boolean isRunningOnGcp() { + String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); + try { + if (osName.startsWith("linux")) { + // Checks GCE residency on Linux platform. + return checkProductNameOnLinux( + Files.newBufferedReader(Paths.get("/sys/class/dmi/id/product_name"), UTF_8)); + } else if (osName.startsWith("windows")) { + // Checks GCE residency on Windows platform. + Process p = + new ProcessBuilder() + .command(WINDOWS_COMMAND, "Get-WmiObject", "-Class", "Win32_BIOS") + .start(); + return checkBiosDataOnWindows( + new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))); + } + } catch (IOException e) { + logger.log(Level.WARNING, "Fail to read platform information: ", e); + return false; + } + // Platforms other than Linux and Windows are not supported. + return false; + } +} diff --git a/alts/src/main/java/io/grpc/alts/internal/AesGcmAeadCrypter.java b/alts/src/main/java/io/grpc/alts/internal/AesGcmAeadCrypter.java index f3b968f1312..e3e6302b591 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AesGcmAeadCrypter.java +++ b/alts/src/main/java/io/grpc/alts/internal/AesGcmAeadCrypter.java @@ -18,8 +18,13 @@ import static com.google.common.base.Preconditions.checkArgument; +import com.google.common.annotations.VisibleForTesting; +import io.grpc.internal.ConscryptLoader; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; +import java.security.Provider; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.annotation.Nullable; import javax.crypto.Cipher; import javax.crypto.spec.GCMParameterSpec; @@ -27,12 +32,15 @@ /** AES128-GCM implementation of {@link AeadCrypter} that uses default JCE provider. */ final class AesGcmAeadCrypter implements AeadCrypter { + private static final Logger logger = Logger.getLogger(AesGcmAeadCrypter.class.getName()); private static final int KEY_LENGTH = 16; private static final int TAG_LENGTH = 16; static final int NONCE_LENGTH = 12; private static final String AES = "AES"; private static final String AES_GCM = AES + "/GCM/NoPadding"; + // Conscrypt if available, otherwise null. Conscrypt is much faster than Java 8's JSSE + private static final Provider CONSCRYPT = getConscrypt(); private final byte[] key; private final Cipher cipher; @@ -40,7 +48,11 @@ final class AesGcmAeadCrypter implements AeadCrypter { AesGcmAeadCrypter(byte[] key) throws GeneralSecurityException { checkArgument(key.length == KEY_LENGTH); this.key = key; - cipher = Cipher.getInstance(AES_GCM); + if (CONSCRYPT != null) { + cipher = Cipher.getInstance(AES_GCM, CONSCRYPT); + } else { + cipher = Cipher.getInstance(AES_GCM); + } } private int encryptAad( @@ -98,4 +110,49 @@ public void decrypt(ByteBuffer plaintext, ByteBuffer ciphertext, ByteBuffer aad, static int getKeyLength() { return KEY_LENGTH; } + + @VisibleForTesting + static Provider getConscrypt() { + if (!ConscryptLoader.isPresent()) { + return null; + } + // Conscrypt 2.1.0 or later is required. If an older version is used, it will fail with these + // sorts of errors: + // "The underlying Cipher implementation does not support this method" + // "error:1e000067:Cipher functions:OPENSSL_internal:BUFFER_TOO_SMALL" + // + // While we could use Conscrypt.version() to check compatibility, that is _very_ verbose via + // reflection. In practice, old conscrypts are probably not much of a problem. + Provider provider; + try { + provider = ConscryptLoader.newProvider(); + } catch (Throwable t) { + logger.log(Level.INFO, "Could not load Conscrypt. Will use slower JDK implementation", t); + return null; + } + try { + Cipher.getInstance(AES_GCM, provider); + } catch (SecurityException t) { + // Pre-Java 7u121/Java 8u111 fails with SecurityException: + // JCE cannot authenticate the provider Conscrypt + // + // This is because Conscrypt uses a newer (more secure) signing CA than the earlier Java + // supported. https://www.oracle.com/technetwork/java/javase/8u111-relnotes-3124969.html + // https://www.oracle.com/technetwork/java/javase/documentation/javase7supportreleasenotes-1601161.html#R170_121 + // + // Use WARNING instead of INFO in this case because it is unlikely to be a supported + // environment. In the other cases we might be on Java 9+; it seems unlikely in this case. + // Note that on Java 7, we're likely to crash later because GCM is unsupported. + logger.log( + Level.WARNING, + "Could not load Conscrypt. Will try slower JDK implementation. This may be because the " + + "JDK is older than Java 7 update 121 or Java 8 update 111. If so, please update", + t); + return null; + } catch (Throwable t) { + logger.log(Level.INFO, "Could not load Conscrypt. Will use slower JDK implementation", t); + return null; + } + return provider; + } } diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsAuthContext.java b/alts/src/main/java/io/grpc/alts/internal/AltsAuthContext.java deleted file mode 100644 index ac0cd36c81a..00000000000 --- a/alts/src/main/java/io/grpc/alts/internal/AltsAuthContext.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2018 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.alts.internal; - -import com.google.common.annotations.VisibleForTesting; - -/** AltsAuthContext contains security-related context information about an ALTs connection. */ -public final class AltsAuthContext { - final AltsContext context; - - /** Create a new AltsAuthContext. */ - public AltsAuthContext(HandshakerResult result) { - context = - AltsContext.newBuilder() - .setApplicationProtocol(result.getApplicationProtocol()) - .setRecordProtocol(result.getRecordProtocol()) - // TODO: Set security level based on the handshaker result. - .setSecurityLevel(SecurityLevel.INTEGRITY_AND_PRIVACY) - .setPeerServiceAccount(result.getPeerIdentity().getServiceAccount()) - .setLocalServiceAccount(result.getLocalIdentity().getServiceAccount()) - .setPeerRpcVersions(result.getPeerRpcVersions()) - .build(); - } - - @VisibleForTesting - public static AltsAuthContext getDefaultInstance() { - return new AltsAuthContext(HandshakerResult.newBuilder().build()); - } - - /** - * Get application protocol. - * - * @return the context's application protocol. - */ - public String getApplicationProtocol() { - return context.getApplicationProtocol(); - } - - /** - * Get negotiated record protocol. - * - * @return the context's negotiated record protocol. - */ - public String getRecordProtocol() { - return context.getRecordProtocol(); - } - - /** - * Get security level. - * - * @return the context's security level. - */ - public SecurityLevel getSecurityLevel() { - return context.getSecurityLevel(); - } - - /** - * Get peer service account. - * - * @return the context's peer service account. - */ - public String getPeerServiceAccount() { - return context.getPeerServiceAccount(); - } - - /** - * Get local service account. - * - * @return the context's local service account. - */ - public String getLocalServiceAccount() { - return context.getLocalServiceAccount(); - } - - /** - * Get peer RPC versions. - * - * @return the context's peer RPC versions. - */ - public RpcProtocolVersions getPeerRpcVersions() { - return context.getPeerRpcVersions(); - } -} diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsChannelCrypter.java b/alts/src/main/java/io/grpc/alts/internal/AltsChannelCrypter.java index 3e999fa63b4..5e4c6fec301 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsChannelCrypter.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsChannelCrypter.java @@ -54,7 +54,6 @@ static int getCounterLength() { return COUNTER_LENGTH; } - @SuppressWarnings("BetaApi") // verify is stable in Guava @Override public void encrypt(ByteBuf outBuf, List plainBufs) throws GeneralSecurityException { checkArgument(outBuf.nioBufferCount() == 1); @@ -93,7 +92,6 @@ public void decrypt(ByteBuf out, ByteBuf tag, List ciphertextBufs) decrypt(out, cipherTextAndTag); } - @SuppressWarnings("BetaApi") // verify is stable in Guava @Override public void decrypt(ByteBuf out, ByteBuf ciphertextAndTag) throws GeneralSecurityException { int bytesRead = ciphertextAndTag.readableBytes(); diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsFraming.java b/alts/src/main/java/io/grpc/alts/internal/AltsFraming.java index d243d95f4ab..2571f937225 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsFraming.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsFraming.java @@ -17,6 +17,7 @@ package io.grpc.alts.internal; import com.google.common.base.Preconditions; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.security.GeneralSecurityException; @@ -63,10 +64,10 @@ static ByteBuffer toFrame(ByteBuffer input, int dataSize) throws GeneralSecurity } Producer producer = new Producer(); ByteBuffer inputAlias = input.duplicate(); - inputAlias.limit(input.position() + dataSize); + ((Buffer) inputAlias).limit(input.position() + dataSize); producer.readBytes(inputAlias); producer.flush(); - input.position(inputAlias.position()); + ((Buffer) input).position(inputAlias.position()); ByteBuffer output = producer.getRawFrame(); return output; } @@ -166,10 +167,10 @@ void flush() throws GeneralSecurityException { int frameLength = buffer.position() + getFrameSuffixLength(); // Set the limit and move to the start. - buffer.flip(); + ((Buffer) buffer).flip(); // Advance the limit to allow a crypto suffix. - buffer.limit(buffer.limit() + getFrameSuffixLength()); + ((Buffer) buffer).limit(buffer.limit() + getFrameSuffixLength()); // Write the data length and the message type. int dataLength = frameLength - FRAME_LENGTH_HEADER_SIZE; @@ -178,17 +179,17 @@ void flush() throws GeneralSecurityException { buffer.putInt(MESSAGE_TYPE); // Move the position back to 0, the frame is ready. - buffer.position(0); + ((Buffer) buffer).position(0); isComplete = true; } /** Resets the state, preparing to construct a new frame. Must be called between frames. */ private void reset() { - buffer.clear(); + ((Buffer) buffer).clear(); // Save some space for framing, we'll fill that in later. - buffer.position(getFramePrefixLength()); - buffer.limit(buffer.limit() - getFrameSuffixLength()); + ((Buffer) buffer).position(getFramePrefixLength()); + ((Buffer) buffer).limit(buffer.limit() - getFrameSuffixLength()); isComplete = false; } @@ -279,7 +280,7 @@ public boolean readBytes(ByteBuffer input) throws GeneralSecurityException { // internal buffer is large enough. if (buffer.position() == FRAME_LENGTH_HEADER_SIZE && input.hasRemaining()) { ByteBuffer bufferAlias = buffer.duplicate(); - bufferAlias.flip(); + ((Buffer) bufferAlias).flip(); bufferAlias.order(ByteOrder.LITTLE_ENDIAN); int dataLength = bufferAlias.getInt(); if (dataLength < FRAME_MESSAGE_TYPE_HEADER_SIZE || dataLength > MAX_DATA_LENGTH) { @@ -292,7 +293,7 @@ public boolean readBytes(ByteBuffer input) throws GeneralSecurityException { buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(dataLength); } - buffer.limit(frameLength); + ((Buffer) buffer).limit(frameLength); } // TODO: Similarly extract and check message type. @@ -300,7 +301,7 @@ public boolean readBytes(ByteBuffer input) throws GeneralSecurityException { // Read the remaining data into the internal buffer. copy(buffer, input); if (!buffer.hasRemaining()) { - buffer.flip(); + ((Buffer) buffer).flip(); isComplete = true; } return isComplete; @@ -323,7 +324,7 @@ public boolean isComplete() { /** Resets the state, preparing to parse a new frame. Must be called between frames. */ private void reset() { - buffer.clear(); + ((Buffer) buffer).clear(); isComplete = false; } @@ -356,9 +357,9 @@ private static void copy(ByteBuffer dst, ByteBuffer src) { } else { int count = Math.min(dst.remaining(), src.remaining()); ByteBuffer slice = src.slice(); - slice.limit(count); + ((Buffer) slice).limit(count); dst.put(slice); - src.position(src.position() + count); + ((Buffer) src).position(src.position() + count); } } } diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java index 26dcde3873c..9eb07f3e86d 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerClient.java @@ -20,18 +20,17 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.protobuf.ByteString; +import io.grpc.ChannelLogger; +import io.grpc.ChannelLogger.ChannelLogLevel; import io.grpc.Status; import io.grpc.alts.internal.HandshakerServiceGrpc.HandshakerServiceStub; import java.io.IOException; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; -import java.util.logging.Level; -import java.util.logging.Logger; /** An API for conducting handshakes via ALTS handshaker service. */ class AltsHandshakerClient { - private static final Logger logger = Logger.getLogger(AltsHandshakerClient.class.getName()); - private static final String APPLICATION_PROTOCOL = "grpc"; private static final String RECORD_PROTOCOL = "ALTSRP_GCM_AES128_REKEY"; private static final int KEY_LENGTH = AltsChannelCrypter.getKeyLength(); @@ -40,17 +39,22 @@ class AltsHandshakerClient { private final AltsHandshakerOptions handshakerOptions; private HandshakerResult result; private HandshakerStatus status; + private final ChannelLogger logger; /** Starts a new handshake interacting with the handshaker service. */ - AltsHandshakerClient(HandshakerServiceStub stub, AltsHandshakerOptions options) { + AltsHandshakerClient( + HandshakerServiceStub stub, AltsHandshakerOptions options, ChannelLogger logger) { handshakerStub = new AltsHandshakerStub(stub); handshakerOptions = options; + this.logger = logger; } @VisibleForTesting - AltsHandshakerClient(AltsHandshakerStub handshakerStub, AltsHandshakerOptions options) { + AltsHandshakerClient( + AltsHandshakerStub handshakerStub, AltsHandshakerOptions options, ChannelLogger logger) { this.handshakerStub = handshakerStub; handshakerOptions = options; + this.logger = logger; } static String getApplicationProtocol() { @@ -82,6 +86,7 @@ private void setStartClientFields(HandshakerReq.Builder req) { startClientReq.addTargetIdentitiesBuilder().setServiceAccount(serviceAccount); } } + startClientReq.setMaxFrameSize(AltsTsiFrameProtector.getMaxFrameSize()); req.setClientStart(startClientReq); } @@ -97,6 +102,7 @@ private void setStartServerFields(HandshakerReq.Builder req, ByteBuffer inBytes) if (handshakerOptions.getRpcProtocolVersions() != null) { startServerReq.setRpcVersions(handshakerOptions.getRpcProtocolVersions()); } + startServerReq.setMaxFrameSize(AltsTsiFrameProtector.getMaxFrameSize()); req.setServerStart(startServerReq); } @@ -136,7 +142,7 @@ public byte[] getKey() { throw new IllegalStateException("Could not get enough key data from the handshake."); } byte[] key = new byte[KEY_LENGTH]; - result.getKeyData().copyTo(key, 0, 0, KEY_LENGTH); + result.getKeyData().substring(0, KEY_LENGTH).copyTo(key, 0); return key; } @@ -151,7 +157,7 @@ private void handleResponse(HandshakerResp resp) throws GeneralSecurityException } if (status.getCode() != Status.Code.OK.value()) { String error = "Handshaker service error: " + status.getDetails(); - logger.log(Level.INFO, error); + logger.log(ChannelLogLevel.DEBUG, error); close(); throw new GeneralSecurityException(error); } @@ -170,7 +176,9 @@ public ByteBuffer startClientHandshake() throws GeneralSecurityException { setStartClientFields(req); HandshakerResp resp; try { + logger.log(ChannelLogLevel.DEBUG, "Send ALTS handshake request to upstream"); resp = handshakerStub.send(req.build()); + logger.log(ChannelLogLevel.DEBUG, "Receive ALTS handshake response from upstream"); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } @@ -197,7 +205,7 @@ public ByteBuffer startServerHandshake(ByteBuffer inBytes) throws GeneralSecurit throw new GeneralSecurityException(e); } handleResponse(resp); - inBytes.position(inBytes.position() + resp.getBytesConsumed()); + ((Buffer) inBytes).position(inBytes.position() + resp.getBytesConsumed()); return resp.getOutFrames().asReadOnlyByteBuffer(); } @@ -220,17 +228,25 @@ public ByteBuffer next(ByteBuffer inBytes) throws GeneralSecurityException { .build()); HandshakerResp resp; try { + logger.log(ChannelLogLevel.DEBUG, "Send ALTS handshake request to upstream"); resp = handshakerStub.send(req.build()); + logger.log(ChannelLogLevel.DEBUG, "Receive ALTS handshake response from upstream"); } catch (IOException | InterruptedException e) { throw new GeneralSecurityException(e); } handleResponse(resp); - inBytes.position(inBytes.position() + resp.getBytesConsumed()); + ((Buffer) inBytes).position(inBytes.position() + resp.getBytesConsumed()); return resp.getOutFrames().asReadOnlyByteBuffer(); } + private boolean closed = false; + /** Closes the connection. */ public void close() { + if (closed) { + return; + } + closed = true; handshakerStub.close(); } } diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java index 5dc31919fe5..6c2748dcc9c 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java @@ -16,6 +16,8 @@ package io.grpc.alts.internal; +import static java.util.concurrent.TimeUnit.SECONDS; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import io.grpc.alts.internal.HandshakerServiceGrpc.HandshakerServiceStub; @@ -27,23 +29,27 @@ /** An interface to the ALTS handshaker service. */ class AltsHandshakerStub { private final StreamObserver reader = new Reader(); - private final StreamObserver writer; + private StreamObserver writer; + private final HandshakerServiceStub serviceStub; private final ArrayBlockingQueue> responseQueue = - new ArrayBlockingQueue>(1); - private final AtomicReference exceptionMessage = new AtomicReference<>(); + new ArrayBlockingQueue<>(1); + private final AtomicReference exceptionMessage = new AtomicReference<>(); + + private static final long HANDSHAKE_RPC_DEADLINE_SECS = 20; AltsHandshakerStub(HandshakerServiceStub serviceStub) { - this.writer = serviceStub.doHandshake(this.reader); + this.serviceStub = serviceStub; } @VisibleForTesting AltsHandshakerStub() { - writer = null; + serviceStub = null; } @VisibleForTesting AltsHandshakerStub(StreamObserver writer) { this.writer = writer; + serviceStub = null; } @VisibleForTesting @@ -53,28 +59,45 @@ StreamObserver getReaderForTest() { /** Send a handshaker request and return the handshaker response. */ public HandshakerResp send(HandshakerReq req) throws InterruptedException, IOException { + createWriterIfNull(); maybeThrowIoException(); if (!responseQueue.isEmpty()) { throw new IOException("Received an unexpected response."); } + writer.onNext(req); Optional result = responseQueue.take(); - if (!result.isPresent()) { - maybeThrowIoException(); + if (result.isPresent()) { + return result.get(); + } + + if (exceptionMessage.get() != null) { + throw new IOException(exceptionMessage.get().info, exceptionMessage.get().throwable); + } else { + throw new IOException("No handshaker response received"); + } + } + + /** Create a new writer if the writer is null. */ + private void createWriterIfNull() { + if (writer == null) { + writer = + serviceStub.withDeadlineAfter(HANDSHAKE_RPC_DEADLINE_SECS, SECONDS).doHandshake(reader); } - return result.get(); } /** Throw exception if there is an outstanding exception. */ private void maybeThrowIoException() throws IOException { if (exceptionMessage.get() != null) { - throw new IOException(exceptionMessage.get()); + throw new IOException(exceptionMessage.get().info, exceptionMessage.get().throwable); } } /** Close the connection. */ public void close() { - writer.onCompleted(); + if (writer != null) { + writer.onCompleted(); + } } private class Reader implements StreamObserver { @@ -85,7 +108,7 @@ public void onNext(HandshakerResp resp) { AltsHandshakerStub.this.responseQueue.add(Optional.of(resp)); } catch (IllegalStateException e) { AltsHandshakerStub.this.exceptionMessage.compareAndSet( - null, "Received an unexpected response."); + null, new ThrowableInfo(e, "Received an unexpected response.")); AltsHandshakerStub.this.close(); } } @@ -94,7 +117,7 @@ public void onNext(HandshakerResp resp) { @Override public void onError(Throwable t) { AltsHandshakerStub.this.exceptionMessage.compareAndSet( - null, "Received a terminating error: " + t.toString()); + null, new ThrowableInfo(t, "Received a terminating error.")); // Trigger the release of any blocked send. Optional result = Optional.absent(); AltsHandshakerStub.this.responseQueue.offer(result); @@ -103,10 +126,22 @@ public void onError(Throwable t) { /** Receive the closing message from the server. */ @Override public void onCompleted() { - AltsHandshakerStub.this.exceptionMessage.compareAndSet(null, "Response stream closed."); + AltsHandshakerStub.this.exceptionMessage.compareAndSet( + null, new ThrowableInfo(null, "Response stream closed.")); // Trigger the release of any blocked send. Optional result = Optional.absent(); AltsHandshakerStub.this.responseQueue.offer(result); } } + + private static class ThrowableInfo { + + private final Throwable throwable; + private final String info; + + private ThrowableInfo(Throwable throwable, String info) { + this.throwable = throwable; + this.info = info; + } + } } diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsInternalContext.java b/alts/src/main/java/io/grpc/alts/internal/AltsInternalContext.java new file mode 100644 index 00000000000..a70c67b2933 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/internal/AltsInternalContext.java @@ -0,0 +1,108 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts.internal; + +import com.google.common.annotations.VisibleForTesting; +import java.util.Map; + +/** AltsInternalContext contains security-related context information about an ALTs connection. */ +public final class AltsInternalContext { + final AltsContext context; + + /** Create a new AltsInternalContext. */ + public AltsInternalContext(HandshakerResult result) { + context = + AltsContext.newBuilder() + .setApplicationProtocol(result.getApplicationProtocol()) + .setRecordProtocol(result.getRecordProtocol()) + // TODO: Set security level based on the handshaker result. + .setSecurityLevel(SecurityLevel.INTEGRITY_AND_PRIVACY) + .setPeerServiceAccount(result.getPeerIdentity().getServiceAccount()) + .setLocalServiceAccount(result.getLocalIdentity().getServiceAccount()) + .setPeerRpcVersions(result.getPeerRpcVersions()) + .putAllPeerAttributes(result.getPeerIdentity().getAttributesMap()) + .build(); + } + + @VisibleForTesting + public static AltsInternalContext getDefaultInstance() { + return new AltsInternalContext(HandshakerResult.newBuilder().build()); + } + + /** + * Get application protocol. + * + * @return the context's application protocol. + */ + public String getApplicationProtocol() { + return context.getApplicationProtocol(); + } + + /** + * Get negotiated record protocol. + * + * @return the context's negotiated record protocol. + */ + public String getRecordProtocol() { + return context.getRecordProtocol(); + } + + /** + * Get security level. + * + * @return the context's security level. + */ + public SecurityLevel getSecurityLevel() { + return context.getSecurityLevel(); + } + + /** + * Get peer service account. + * + * @return the context's peer service account. + */ + public String getPeerServiceAccount() { + return context.getPeerServiceAccount(); + } + + /** + * Get local service account. + * + * @return the context's local service account. + */ + public String getLocalServiceAccount() { + return context.getLocalServiceAccount(); + } + + /** + * Get peer RPC versions. + * + * @return the context's peer RPC versions. + */ + public RpcProtocolVersions getPeerRpcVersions() { + return context.getPeerRpcVersions(); + } + + /** + * Get peer attributes. + * + * @return the context's peer attributes. + */ + public Map getPeerAttributes() { + return context.getPeerAttributesMap(); + } +} diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java b/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java index bebf968eac2..9c51cf6a053 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java @@ -16,168 +16,437 @@ package io.grpc.alts.internal; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.google.protobuf.Any; import io.grpc.Attributes; -import io.grpc.CallCredentials; +import io.grpc.Channel; +import io.grpc.ChannelLogger; import io.grpc.Grpc; import io.grpc.InternalChannelz.OtherSecurity; import io.grpc.InternalChannelz.Security; import io.grpc.SecurityLevel; import io.grpc.Status; import io.grpc.alts.internal.RpcProtocolVersionsUtil.RpcVersionsCheckResult; -import io.grpc.alts.internal.TsiHandshakeHandler.TsiHandshakeCompletionEvent; +import io.grpc.internal.ObjectPool; import io.grpc.netty.GrpcHttp2ConnectionHandler; -import io.grpc.netty.ProtocolNegotiator; -import io.grpc.netty.ProtocolNegotiators.AbstractBufferingHandler; +import io.grpc.netty.InternalProtocolNegotiator; +import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator; +import io.grpc.netty.InternalProtocolNegotiators; import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.ssl.SslContext; import io.netty.util.AsciiString; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.GeneralSecurityException; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Nullable; /** - * A GRPC {@link ProtocolNegotiator} for ALTS. This class creates a Netty handler that provides ALTS + * A gRPC {@link ProtocolNegotiator} for ALTS. This class creates a Netty handler that provides ALTS * security on the wire, similar to Netty's {@code SslHandler}. */ -public abstract class AltsProtocolNegotiator implements ProtocolNegotiator { - +// TODO(carl-mastrangelo): rename this AltsProtocolNegotiators. +public final class AltsProtocolNegotiator { private static final Logger logger = Logger.getLogger(AltsProtocolNegotiator.class.getName()); + static final String ALTS_MAX_CONCURRENT_HANDSHAKES_ENV_VARIABLE = + "GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES"; + @VisibleForTesting static final int DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES = 32; + private static final AsyncSemaphore handshakeSemaphore = + new AsyncSemaphore(getAltsMaxConcurrentHandshakes()); + @Grpc.TransportAttr - public static final Attributes.Key TSI_PEER_KEY = Attributes.Key.create("TSI_PEER"); + public static final Attributes.Key TSI_PEER_KEY = + Attributes.Key.create("internal:TSI_PEER"); @Grpc.TransportAttr - public static final Attributes.Key ALTS_CONTEXT_KEY = - Attributes.Key.create("ALTS_CONTEXT_KEY"); - private static final AsciiString scheme = AsciiString.of("https"); - - /** Creates a negotiator used for ALTS client. */ - public static AltsProtocolNegotiator createClientNegotiator( - final TsiHandshakerFactory handshakerFactory) { - final class ClientAltsProtocolNegotiator extends AltsProtocolNegotiator { - @Override - public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { - TsiHandshaker handshaker = handshakerFactory.newHandshaker(grpcHandler.getAuthority()); - return new BufferUntilAltsNegotiatedHandler( - grpcHandler, - new TsiHandshakeHandler(new NettyTsiHandshaker(handshaker)), - new TsiFrameHandler()); - } + public static final Attributes.Key AUTH_CONTEXT_KEY = + Attributes.Key.create("internal:AUTH_CONTEXT_KEY"); - @Override - public void close() { - logger.finest("ALTS Client ProtocolNegotiator Closed"); - // TODO(jiangtaoli2016): release resources - } + private static final AsciiString SCHEME = AsciiString.of("https"); + + private static final String DIRECT_PATH_SERVICE_CFE_CLUSTER_PREFIX = "google_cfe_"; + private static final String CFE_CLUSTER_RESOURCE_NAME_PREFIX = + "/envoy.config.cluster.v3.Cluster/google_cfe_"; + private static final String CFE_CLUSTER_AUTHORITY_NAME = + "traffic-director-c2p.xds.googleapis.com"; + + /** + * ClientAltsProtocolNegotiatorFactory is a factory for doing client side negotiation of an ALTS + * channel. + */ + public static final class ClientAltsProtocolNegotiatorFactory + implements InternalProtocolNegotiator.ClientFactory { + + private final ImmutableList targetServiceAccounts; + private final ObjectPool handshakerChannelPool; + + public ClientAltsProtocolNegotiatorFactory( + List targetServiceAccounts, + ObjectPool handshakerChannelPool) { + this.targetServiceAccounts = ImmutableList.copyOf(targetServiceAccounts); + this.handshakerChannelPool = checkNotNull(handshakerChannelPool, "handshakerChannelPool"); + } + + @Override + public ProtocolNegotiator newNegotiator() { + return new ClientAltsProtocolNegotiator( + targetServiceAccounts, + handshakerChannelPool); + } + + @Override + public int getDefaultPort() { + return 443; } - - return new ClientAltsProtocolNegotiator(); } - /** Creates a negotiator used for ALTS server. */ - public static AltsProtocolNegotiator createServerNegotiator( - final TsiHandshakerFactory handshakerFactory) { - final class ServerAltsProtocolNegotiator extends AltsProtocolNegotiator { - @Override - public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { - TsiHandshaker handshaker = handshakerFactory.newHandshaker(/*authority=*/ null); - return new BufferUntilAltsNegotiatedHandler( - grpcHandler, - new TsiHandshakeHandler(new NettyTsiHandshaker(handshaker)), - new TsiFrameHandler()); - } + private static final class ClientAltsProtocolNegotiator implements ProtocolNegotiator { + private final TsiHandshakerFactory handshakerFactory; + private final LazyChannel lazyHandshakerChannel; + + ClientAltsProtocolNegotiator( + ImmutableList targetServiceAccounts, ObjectPool handshakerChannelPool) { + this.lazyHandshakerChannel = new LazyChannel(handshakerChannelPool); + this.handshakerFactory = + new ClientTsiHandshakerFactory(targetServiceAccounts, lazyHandshakerChannel); + } + + @Override + public AsciiString scheme() { + return SCHEME; + } + + @Override + public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { + ChannelLogger negotiationLogger = grpcHandler.getNegotiationLogger(); + TsiHandshaker handshaker = + handshakerFactory.newHandshaker(grpcHandler.getAuthority(), negotiationLogger); + NettyTsiHandshaker nettyHandshaker = new NettyTsiHandshaker(handshaker); + ChannelHandler gnh = InternalProtocolNegotiators.grpcNegotiationHandler(grpcHandler); + ChannelHandler thh = new TsiHandshakeHandler( + gnh, nettyHandshaker, new AltsHandshakeValidator(), handshakeSemaphore, + negotiationLogger); + ChannelHandler wuah = InternalProtocolNegotiators.waitUntilActiveHandler(thh, + negotiationLogger); + return wuah; + } + + @Override + public void close() { + lazyHandshakerChannel.close(); + } + } + + /** + * Creates a protocol negotiator for ALTS on the server side. + */ + public static ProtocolNegotiator serverAltsProtocolNegotiator( + ObjectPool handshakerChannelPool) { + final LazyChannel lazyHandshakerChannel = new LazyChannel(handshakerChannelPool); + final class ServerTsiHandshakerFactory implements TsiHandshakerFactory { @Override - public void close() { - logger.finest("ALTS Server ProtocolNegotiator Closed"); - // TODO(jiangtaoli2016): release resources + public TsiHandshaker newHandshaker( + @Nullable String authority, ChannelLogger negotiationLogger) { + assert authority == null; + return AltsTsiHandshaker.newServer( + HandshakerServiceGrpc.newStub(lazyHandshakerChannel.get()), + new AltsHandshakerOptions(RpcProtocolVersionsUtil.getRpcProtocolVersions()), + negotiationLogger); } } - return new ServerAltsProtocolNegotiator(); + return new ServerAltsProtocolNegotiator( + new ServerTsiHandshakerFactory(), lazyHandshakerChannel); } - /** Buffers all writes until the ALTS handshake is complete. */ @VisibleForTesting - static final class BufferUntilAltsNegotiatedHandler extends AbstractBufferingHandler - implements ProtocolNegotiator.Handler { + static final class ServerAltsProtocolNegotiator implements ProtocolNegotiator { + private final TsiHandshakerFactory handshakerFactory; + private final LazyChannel lazyHandshakerChannel; + + @VisibleForTesting + ServerAltsProtocolNegotiator( + TsiHandshakerFactory handshakerFactory, LazyChannel lazyHandshakerChannel) { + this.handshakerFactory = checkNotNull(handshakerFactory, "handshakerFactory"); + this.lazyHandshakerChannel = checkNotNull(lazyHandshakerChannel, "lazyHandshakerChannel"); + } + + @Override + public AsciiString scheme() { + return SCHEME; + } + + @Override + public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { + ChannelLogger negotiationLogger = grpcHandler.getNegotiationLogger(); + TsiHandshaker handshaker = + handshakerFactory.newHandshaker(/* authority= */ null, negotiationLogger); + NettyTsiHandshaker nettyHandshaker = new NettyTsiHandshaker(handshaker); + ChannelHandler gnh = InternalProtocolNegotiators.grpcNegotiationHandler(grpcHandler); + ChannelHandler thh = new TsiHandshakeHandler( + gnh, nettyHandshaker, new AltsHandshakeValidator(), handshakeSemaphore, + negotiationLogger); + ChannelHandler wuah = InternalProtocolNegotiators.waitUntilActiveHandler(thh, + negotiationLogger); + return wuah; + } + + @Override + public void close() { + logger.finest("ALTS Server ProtocolNegotiator Closed"); + lazyHandshakerChannel.close(); + } + } - private final GrpcHttp2ConnectionHandler grpcHandler; + /** + * A Protocol Negotiator factory which can switch between ALTS and TLS based on EAG Attrs. + */ + public static final class GoogleDefaultProtocolNegotiatorFactory + implements InternalProtocolNegotiator.ClientFactory { + @VisibleForTesting + @Nullable + static Attributes.Key clusterNameAttrKey = loadClusterNameAttrKey(); + private final ImmutableList targetServiceAccounts; + private final ObjectPool handshakerChannelPool; + private final SslContext sslContext; - BufferUntilAltsNegotiatedHandler( - GrpcHttp2ConnectionHandler grpcHandler, ChannelHandler... negotiationhandlers) { - super(negotiationhandlers); - // Save the gRPC handler. The ALTS handler doesn't support buffering before the handshake - // completes, so we wait until the handshake was successful before adding the grpc handler. - this.grpcHandler = grpcHandler; + /** + * Creates Negotiator Factory, which will either use the targetServiceAccounts and + * handshakerChannelPool, or the sslContext. + */ + public GoogleDefaultProtocolNegotiatorFactory( + List targetServiceAccounts, + ObjectPool handshakerChannelPool, + SslContext sslContext) { + this.targetServiceAccounts = ImmutableList.copyOf(targetServiceAccounts); + this.handshakerChannelPool = checkNotNull(handshakerChannelPool, "handshakerChannelPool"); + this.sslContext = checkNotNull(sslContext, "sslContext"); } - // TODO: Remove this once https://github.com/grpc/grpc-java/pull/3715 is in. @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { - logger.log(Level.FINEST, "Exception while buffering for ALTS Negotiation", cause); - fail(ctx, cause); - ctx.fireExceptionCaught(cause); + public ProtocolNegotiator newNegotiator() { + return new GoogleDefaultProtocolNegotiator( + targetServiceAccounts, + handshakerChannelPool, + sslContext, + clusterNameAttrKey); + } + + @Override + public int getDefaultPort() { + return 443; + } + + @SuppressWarnings("unchecked") + @Nullable + private static Attributes.Key loadClusterNameAttrKey() { + Attributes.Key key = null; + try { + Class klass = Class.forName("io.grpc.xds.InternalXdsAttributes"); + key = (Attributes.Key) klass.getField("ATTR_CLUSTER_NAME").get(null); + } catch (ClassNotFoundException e) { + logger.log(Level.FINE, + "Unable to load xDS endpoint cluster name key, this may be expected", e); + } catch (NoSuchFieldException e) { + logger.log(Level.FINE, + "Unable to load xDS endpoint cluster name key, this may be expected", e); + } catch (IllegalAccessException e) { + logger.log(Level.FINE, + "Unable to load xDS endpoint cluster name key, this may be expected", e); + } + return key; + } + } + + private static final class GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { + private final TsiHandshakerFactory handshakerFactory; + private final LazyChannel lazyHandshakerChannel; + private final SslContext sslContext; + @Nullable + private final Attributes.Key clusterNameAttrKey; + + GoogleDefaultProtocolNegotiator( + ImmutableList targetServiceAccounts, + ObjectPool handshakerChannelPool, + SslContext sslContext, + @Nullable Attributes.Key clusterNameAttrKey) { + this.lazyHandshakerChannel = new LazyChannel(handshakerChannelPool); + this.handshakerFactory = + new ClientTsiHandshakerFactory(targetServiceAccounts, lazyHandshakerChannel); + this.sslContext = checkNotNull(sslContext, "checkNotNull"); + this.clusterNameAttrKey = clusterNameAttrKey; } @Override public AsciiString scheme() { - return scheme; + return SCHEME; + } + + @Override + public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { + ChannelHandler gnh = InternalProtocolNegotiators.grpcNegotiationHandler(grpcHandler); + ChannelLogger negotiationLogger = grpcHandler.getNegotiationLogger(); + ChannelHandler securityHandler; + boolean isXdsDirectPath = false; + if (clusterNameAttrKey != null) { + isXdsDirectPath = isDirectPathCluster( + grpcHandler.getEagAttributes().get(clusterNameAttrKey)); + } + if (isXdsDirectPath) { + TsiHandshaker handshaker = + handshakerFactory.newHandshaker(grpcHandler.getAuthority(), negotiationLogger); + NettyTsiHandshaker nettyHandshaker = new NettyTsiHandshaker(handshaker); + securityHandler = new TsiHandshakeHandler( + gnh, nettyHandshaker, new AltsHandshakeValidator(), handshakeSemaphore, + negotiationLogger); + } else { + securityHandler = InternalProtocolNegotiators.clientTlsHandler( + gnh, sslContext, grpcHandler.getAuthority(), negotiationLogger); + } + ChannelHandler wuah = InternalProtocolNegotiators.waitUntilActiveHandler(securityHandler, + negotiationLogger); + return wuah; + } + + private boolean isDirectPathCluster(String clusterName) { + if (clusterName == null) { + return false; + } + if (clusterName.startsWith(DIRECT_PATH_SERVICE_CFE_CLUSTER_PREFIX)) { + return false; + } + if (!clusterName.startsWith("xdstp:")) { + return true; + } + try { + URI uri = new URI(clusterName); + // If authority AND path match our CFE checks, use TLS; otherwise use ALTS. + return !CFE_CLUSTER_AUTHORITY_NAME.equals(uri.getHost()) + || !uri.getPath().startsWith(CFE_CLUSTER_RESOURCE_NAME_PREFIX); + } catch (URISyntaxException e) { + return true; // Shouldn't happen, but assume ALTS. + } + } + + @Override + public void close() { + logger.finest("ALTS Server ProtocolNegotiator Closed"); + lazyHandshakerChannel.close(); + } + } + + private static final class ClientTsiHandshakerFactory implements TsiHandshakerFactory { + + private final ImmutableList targetServiceAccounts; + private final LazyChannel lazyHandshakerChannel; + + ClientTsiHandshakerFactory( + ImmutableList targetServiceAccounts, LazyChannel lazyHandshakerChannel) { + this.targetServiceAccounts = checkNotNull(targetServiceAccounts, "targetServiceAccounts"); + this.lazyHandshakerChannel = checkNotNull(lazyHandshakerChannel, "lazyHandshakerChannel"); } @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { - if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, "User Event triggered while negotiating ALTS", new Object[]{evt}); + public TsiHandshaker newHandshaker( + @Nullable String authority, ChannelLogger negotiationLogger) { + AltsClientOptions handshakerOptions = + new AltsClientOptions.Builder() + .setRpcProtocolVersions(RpcProtocolVersionsUtil.getRpcProtocolVersions()) + .setTargetServiceAccounts(targetServiceAccounts) + .setTargetName(authority) + .build(); + return AltsTsiHandshaker.newClient( + HandshakerServiceGrpc.newStub(lazyHandshakerChannel.get()), + handshakerOptions, + negotiationLogger); + } + } + + /** Channel created from a channel pool lazily. */ + @VisibleForTesting + static final class LazyChannel { + private final ObjectPool channelPool; + private Channel channel; + + @VisibleForTesting + LazyChannel(ObjectPool channelPool) { + this.channelPool = checkNotNull(channelPool, "channelPool"); + } + + /** + * If channel is null, gets a channel from the channel pool, otherwise, returns the cached + * channel. + */ + synchronized Channel get() { + if (channel == null) { + channel = channelPool.getObject(); + } + return channel; + } + + /** Returns the cached channel to the channel pool. */ + synchronized void close() { + if (channel != null) { + channel = channelPool.returnObject(channel); } - if (evt instanceof TsiHandshakeCompletionEvent) { - TsiHandshakeCompletionEvent altsEvt = (TsiHandshakeCompletionEvent) evt; - if (altsEvt.isSuccess()) { - // Add the gRPC handler just before this handler. We only allow the grpcHandler to be - // null to support testing. In production, a grpc handler will always be provided. - if (grpcHandler != null) { - ctx.pipeline().addBefore(ctx.name(), null, grpcHandler); - AltsAuthContext altsContext = (AltsAuthContext) altsEvt.context(); - Preconditions.checkNotNull(altsContext); - // Checks peer Rpc Protocol Versions in the ALTS auth context. Fails the connection if - // Rpc Protocol Versions mismatch. - RpcVersionsCheckResult checkResult = - RpcProtocolVersionsUtil.checkRpcProtocolVersions( - RpcProtocolVersionsUtil.getRpcProtocolVersions(), - altsContext.getPeerRpcVersions()); - if (!checkResult.getResult()) { - String errorMessage = - "Local Rpc Protocol Versions " - + RpcProtocolVersionsUtil.getRpcProtocolVersions().toString() - + "are not compatible with peer Rpc Protocol Versions " - + altsContext.getPeerRpcVersions().toString(); - logger.finest(errorMessage); - fail(ctx, Status.UNAVAILABLE.withDescription(errorMessage).asRuntimeException()); - } - grpcHandler.handleProtocolNegotiationCompleted( - Attributes.newBuilder() - .set(TSI_PEER_KEY, altsEvt.peer()) - .set(ALTS_CONTEXT_KEY, altsContext) - .set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress()) - .set(Grpc.TRANSPORT_ATTR_LOCAL_ADDR, ctx.channel().localAddress()) - .set(CallCredentials.ATTR_SECURITY_LEVEL, SecurityLevel.PRIVACY_AND_INTEGRITY) - .build(), - new Security(new OtherSecurity("alts", Any.pack(altsContext.context)))); - } - logger.finest("Flushing ALTS buffered data"); - // Now write any buffered data and remove this handler. - writeBufferedAndRemove(ctx); - } else { - logger.log(Level.FINEST, "ALTS handshake failed", altsEvt.cause()); - fail(ctx, unavailableException("ALTS handshake failed", altsEvt.cause())); - } + } + } + + private static final class AltsHandshakeValidator extends TsiHandshakeHandler.HandshakeValidator { + + @Override + public SecurityDetails validatePeerObject(Object peerObject) throws GeneralSecurityException { + AltsInternalContext altsContext = (AltsInternalContext) peerObject; + // Checks peer Rpc Protocol Versions in the ALTS auth context. Fails the connection if + // Rpc Protocol Versions mismatch. + RpcVersionsCheckResult checkResult = + RpcProtocolVersionsUtil.checkRpcProtocolVersions( + RpcProtocolVersionsUtil.getRpcProtocolVersions(), + altsContext.getPeerRpcVersions()); + if (!checkResult.getResult()) { + String errorMessage = + "Local Rpc Protocol Versions " + + RpcProtocolVersionsUtil.getRpcProtocolVersions() + + " are not compatible with peer Rpc Protocol Versions " + + altsContext.getPeerRpcVersions(); + throw Status.UNAVAILABLE.withDescription(errorMessage).asRuntimeException(); } - super.userEventTriggered(ctx, evt); + return new SecurityDetails( + SecurityLevel.PRIVACY_AND_INTEGRITY, + new Security(new OtherSecurity("alts", Any.pack(altsContext.context)))); } + } - private static RuntimeException unavailableException(String msg, Throwable cause) { - return Status.UNAVAILABLE.withCause(cause).withDescription(msg).asRuntimeException(); + @VisibleForTesting + static int getAltsMaxConcurrentHandshakes(String altsMaxConcurrentHandshakes) { + if (altsMaxConcurrentHandshakes == null) { + return DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES; + } + try { + int effectiveMaxConcurrentHandshakes = Integer.parseInt(altsMaxConcurrentHandshakes); + if (effectiveMaxConcurrentHandshakes < 0) { + logger.warning( + "GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES environment variable set to invalid value."); + return DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES; + } + return effectiveMaxConcurrentHandshakes; + } catch (NumberFormatException e) { + logger.warning( + "GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES environment variable set to invalid value."); + return DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES; } } + + private static int getAltsMaxConcurrentHandshakes() { + return getAltsMaxConcurrentHandshakes( + System.getenv(ALTS_MAX_CONCURRENT_HANDSHAKES_ENV_VARIABLE)); + } + + private AltsProtocolNegotiator() {} } diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsTsiFrameProtector.java b/alts/src/main/java/io/grpc/alts/internal/AltsTsiFrameProtector.java index c112c319b8c..67d6637a130 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsTsiFrameProtector.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsTsiFrameProtector.java @@ -33,9 +33,10 @@ public final class AltsTsiFrameProtector implements TsiFrameProtector { private static final int HEADER_TYPE_FIELD_BYTES = 4; private static final int HEADER_BYTES = HEADER_LEN_FIELD_BYTES + HEADER_TYPE_FIELD_BYTES; private static final int HEADER_TYPE_DEFAULT = 6; - // Total frame size including full header and tag. - private static final int MAX_ALLOWED_FRAME_BYTES = 16 * 1024; - private static final int LIMIT_MAX_ALLOWED_FRAME_BYTES = 1024 * 1024; + private static final int LIMIT_MAX_ALLOWED_FRAME_SIZE = 1024 * 1024; + // Frame size negotiation extends frame size range to [MIN_FRAME_SIZE, MAX_FRAME_SIZE]. + private static final int MIN_FRAME_SIZE = 16 * 1024; + private static final int MAX_FRAME_SIZE = 128 * 1024; private final Protector protector; private final Unprotector unprotector; @@ -44,7 +45,7 @@ public final class AltsTsiFrameProtector implements TsiFrameProtector { public AltsTsiFrameProtector( int maxProtectedFrameBytes, ChannelCrypterNetty crypter, ByteBufAllocator alloc) { checkArgument(maxProtectedFrameBytes > HEADER_BYTES + crypter.getSuffixLength()); - maxProtectedFrameBytes = Math.min(LIMIT_MAX_ALLOWED_FRAME_BYTES, maxProtectedFrameBytes); + maxProtectedFrameBytes = Math.min(LIMIT_MAX_ALLOWED_FRAME_SIZE, maxProtectedFrameBytes); protector = new Protector(maxProtectedFrameBytes, crypter); unprotector = new Unprotector(crypter, alloc); } @@ -65,12 +66,16 @@ static int getHeaderTypeDefault() { return HEADER_TYPE_DEFAULT; } - public static int getMaxAllowedFrameBytes() { - return MAX_ALLOWED_FRAME_BYTES; + static int getLimitMaxAllowedFrameSize() { + return LIMIT_MAX_ALLOWED_FRAME_SIZE; } - static int getLimitMaxAllowedFrameBytes() { - return LIMIT_MAX_ALLOWED_FRAME_BYTES; + public static int getMinFrameSize() { + return MIN_FRAME_SIZE; + } + + public static int getMaxFrameSize() { + return MAX_FRAME_SIZE; } @Override @@ -128,7 +133,6 @@ void protectFlush( } } - @SuppressWarnings("BetaApi") // verify is stable in Guava private ByteBuf handleUnprotected(List unprotectedBufs, ByteBufAllocator alloc) throws GeneralSecurityException { long unprotectedBytes = 0; @@ -263,14 +267,13 @@ private void handleHeader() { checkArgument( requiredProtectedBytes >= suffixBytes, "Invalid header field: frame size too small"); checkArgument( - requiredProtectedBytes <= LIMIT_MAX_ALLOWED_FRAME_BYTES - HEADER_BYTES, + requiredProtectedBytes <= LIMIT_MAX_ALLOWED_FRAME_SIZE - HEADER_BYTES, "Invalid header field: frame size too large"); int frameType = header.readIntLE(); checkArgument(frameType == HEADER_TYPE_DEFAULT, "Invalid header field: frame type"); state = DeframerState.READ_PROTECTED_PAYLOAD; } - @SuppressWarnings("BetaApi") // verify is stable in Guava private ByteBuf handlePayload(ByteBufAllocator alloc) throws GeneralSecurityException { int requiredCiphertextBytes = requiredProtectedBytes - suffixBytes; int firstFrameUnprotectedLen = requiredCiphertextBytes; diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java b/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java index 3699abb8d5e..2d6c322c1b1 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsTsiHandshaker.java @@ -20,8 +20,11 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; +import io.grpc.ChannelLogger; +import io.grpc.ChannelLogger.ChannelLogLevel; import io.grpc.alts.internal.HandshakerServiceGrpc.HandshakerServiceStub; import io.netty.buffer.ByteBufAllocator; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import java.util.ArrayList; @@ -31,6 +34,8 @@ * Negotiates a grpc channel key to be used by the TsiFrameProtector, using ALTs handshaker service. */ public final class AltsTsiHandshaker implements TsiHandshaker { + private final ChannelLogger logger; + public static final String TSI_SERVICE_ACCOUNT_PEER_PROPERTY = "service_account"; private final boolean isClient; @@ -40,15 +45,20 @@ public final class AltsTsiHandshaker implements TsiHandshaker { /** Starts a new TSI handshaker with client options. */ private AltsTsiHandshaker( - boolean isClient, HandshakerServiceStub stub, AltsHandshakerOptions options) { + boolean isClient, + HandshakerServiceStub stub, + AltsHandshakerOptions options, + ChannelLogger logger) { this.isClient = isClient; - handshaker = new AltsHandshakerClient(stub, options); + this.logger = logger; + handshaker = new AltsHandshakerClient(stub, options, logger); } @VisibleForTesting - AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker) { + AltsTsiHandshaker(boolean isClient, AltsHandshakerClient handshaker, ChannelLogger logger) { this.isClient = isClient; this.handshaker = handshaker; + this.logger = logger; } /** @@ -70,11 +80,12 @@ public boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityExce return true; } int remaining = bytes.remaining(); - // Call handshaker service to proceess the bytes. + // Call handshaker service to process the bytes. if (outputFrame == null) { checkState(!isClient, "Client handshaker should not process any frame at the beginning."); outputFrame = handshaker.startServerHandshake(bytes); } else { + logger.log(ChannelLogLevel.DEBUG, "Receive ALTS handshake from downstream"); outputFrame = handshaker.next(bytes); } // If handshake has finished or we already have bytes to write, just return true. @@ -99,7 +110,7 @@ public boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityExce @Override public TsiPeer extractPeer() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); - List> peerProperties = new ArrayList>(); + List> peerProperties = new ArrayList<>(); peerProperties.add( new TsiPeer.StringProperty( TSI_SERVICE_ACCOUNT_PEER_PROPERTY, @@ -115,17 +126,19 @@ public TsiPeer extractPeer() throws GeneralSecurityException { @Override public Object extractPeerObject() throws GeneralSecurityException { Preconditions.checkState(!isInProgress(), "Handshake is not complete."); - return new AltsAuthContext(handshaker.getResult()); + return new AltsInternalContext(handshaker.getResult()); } /** Creates a new TsiHandshaker for use by the client. */ - public static TsiHandshaker newClient(HandshakerServiceStub stub, AltsHandshakerOptions options) { - return new AltsTsiHandshaker(true, stub, options); + public static TsiHandshaker newClient( + HandshakerServiceStub stub, AltsHandshakerOptions options, ChannelLogger logger) { + return new AltsTsiHandshaker(true, stub, options, logger); } /** Creates a new TsiHandshaker for use by the server. */ - public static TsiHandshaker newServer(HandshakerServiceStub stub, AltsHandshakerOptions options) { - return new AltsTsiHandshaker(false, stub, options); + public static TsiHandshaker newServer( + HandshakerServiceStub stub, AltsHandshakerOptions options, ChannelLogger logger) { + return new AltsTsiHandshaker(false, stub, options, logger); } /** @@ -137,24 +150,26 @@ public static TsiHandshaker newServer(HandshakerServiceStub stub, AltsHandshaker public void getBytesToSendToPeer(ByteBuffer bytes) throws GeneralSecurityException { if (outputFrame == null) { // A null outputFrame indicates we haven't started the handshake. if (isClient) { + logger.log(ChannelLogLevel.DEBUG, "Initial ALTS handshake to downstream"); outputFrame = handshaker.startClientHandshake(); } else { // The server needs bytes to process before it can start the handshake. return; } } + logger.log(ChannelLogLevel.DEBUG, "Send ALTS request to downstream"); // Write as many bytes as we are able. ByteBuffer outputFrameAlias = outputFrame; if (outputFrame.remaining() > bytes.remaining()) { outputFrameAlias = outputFrame.duplicate(); - outputFrameAlias.limit(outputFrameAlias.position() + bytes.remaining()); + ((Buffer) outputFrameAlias).limit(outputFrameAlias.position() + bytes.remaining()); } bytes.put(outputFrameAlias); - outputFrame.position(outputFrameAlias.position()); + ((Buffer) outputFrame).position(outputFrameAlias.position()); } /** - * Returns true if and only if the handshake is still in progress + * Returns true if and only if the handshake is still in progress. * * @return true, if the handshake is still in progress, false otherwise. */ @@ -178,6 +193,14 @@ public TsiFrameProtector createFrameProtector(int maxFrameSize, ByteBufAllocator byte[] key = handshaker.getKey(); Preconditions.checkState(key.length == AltsChannelCrypter.getKeyLength(), "Bad key length."); + // Frame size negotiation is not performed if the peer does not send max frame size (e.g. peer + // is gRPC Go or peer uses an old binary). + int peerMaxFrameSize = handshaker.getResult().getMaxFrameSize(); + if (peerMaxFrameSize != 0) { + maxFrameSize = Math.min(peerMaxFrameSize, AltsTsiFrameProtector.getMaxFrameSize()); + maxFrameSize = Math.max(AltsTsiFrameProtector.getMinFrameSize(), maxFrameSize); + } + logger.log(ChannelLogLevel.INFO, "Maximum frame size value is {0}.", maxFrameSize); return new AltsTsiFrameProtector(maxFrameSize, new AltsChannelCrypter(key, isClient), alloc); } @@ -190,6 +213,11 @@ public TsiFrameProtector createFrameProtector(int maxFrameSize, ByteBufAllocator */ @Override public TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) { - return createFrameProtector(AltsTsiFrameProtector.getMaxAllowedFrameBytes(), alloc); + return createFrameProtector(AltsTsiFrameProtector.getMinFrameSize(), alloc); + } + + @Override + public void close() { + handshaker.close(); } } diff --git a/alts/src/main/java/io/grpc/alts/internal/AsyncSemaphore.java b/alts/src/main/java/io/grpc/alts/internal/AsyncSemaphore.java new file mode 100644 index 00000000000..a8251c7fbd3 --- /dev/null +++ b/alts/src/main/java/io/grpc/alts/internal/AsyncSemaphore.java @@ -0,0 +1,61 @@ +/* + * Copyright 2021 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts.internal; + +import com.google.errorprone.annotations.concurrent.GuardedBy; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import java.util.LinkedList; +import java.util.Queue; + +/** Provides a semaphore primitive, without blocking waiting on permits. */ +final class AsyncSemaphore { + private final Object lock = new Object(); + @SuppressWarnings("JdkObsolete") // LinkedList avoids high watermark memory issues + private final Queue queue = new LinkedList<>(); + @GuardedBy("lock") + private int permits; + + public AsyncSemaphore(int permits) { + this.permits = permits; + } + + public ChannelFuture acquire(ChannelHandlerContext ctx) { + synchronized (lock) { + if (permits > 0) { + permits--; + return ctx.newSucceededFuture(); + } + ChannelPromise promise = ctx.newPromise(); + queue.add(promise); + return promise; + } + } + + public void release() { + ChannelPromise next; + synchronized (lock) { + next = queue.poll(); + if (next == null) { + permits++; + return; + } + } + next.setSuccess(); + } +} diff --git a/alts/src/main/java/io/grpc/alts/internal/ChannelCrypterNetty.java b/alts/src/main/java/io/grpc/alts/internal/ChannelCrypterNetty.java index 4164560e7a0..e2e7d4046fb 100644 --- a/alts/src/main/java/io/grpc/alts/internal/ChannelCrypterNetty.java +++ b/alts/src/main/java/io/grpc/alts/internal/ChannelCrypterNetty.java @@ -21,8 +21,8 @@ import java.util.List; /** - * A @{code ChannelCrypterNetty} performs stateful encryption and decryption of independent input - * and output streams. Both decrypt and encrypt gather their input from a list of Netty @{link + * A {@code ChannelCrypterNetty} performs stateful encryption and decryption of independent input + * and output streams. Both decrypt and encrypt gather their input from a list of Netty {@link * ByteBuf} instances. * *

Note that we provide implementations of this interface that provide integrity only and diff --git a/alts/src/main/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiator.java b/alts/src/main/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiator.java deleted file mode 100644 index b08453452cd..00000000000 --- a/alts/src/main/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2018 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.alts.internal; - -import com.google.common.annotations.VisibleForTesting; -import io.grpc.internal.GrpcAttributes; -import io.grpc.netty.GrpcHttp2ConnectionHandler; -import io.grpc.netty.ProtocolNegotiator; -import io.grpc.netty.ProtocolNegotiators; -import io.netty.handler.ssl.SslContext; - -/** A client-side GPRC {@link ProtocolNegotiator} for Google Default Channel. */ -public final class GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { - private final ProtocolNegotiator altsProtocolNegotiator; - private final ProtocolNegotiator tlsProtocolNegotiator; - - public GoogleDefaultProtocolNegotiator(TsiHandshakerFactory altsFactory, SslContext sslContext) { - altsProtocolNegotiator = AltsProtocolNegotiator.createClientNegotiator(altsFactory); - tlsProtocolNegotiator = ProtocolNegotiators.tls(sslContext); - } - - @VisibleForTesting - GoogleDefaultProtocolNegotiator( - ProtocolNegotiator altsProtocolNegotiator, ProtocolNegotiator tlsProtocolNegotiator) { - this.altsProtocolNegotiator = altsProtocolNegotiator; - this.tlsProtocolNegotiator = tlsProtocolNegotiator; - } - - @Override - public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { - if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null - || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { - return altsProtocolNegotiator.newHandler(grpcHandler); - } else { - return tlsProtocolNegotiator.newHandler(grpcHandler); - } - } - - @Override - public void close() { - altsProtocolNegotiator.close(); - tlsProtocolNegotiator.close(); - } -} diff --git a/alts/src/main/java/io/grpc/alts/internal/NettyTsiHandshaker.java b/alts/src/main/java/io/grpc/alts/internal/NettyTsiHandshaker.java index 8d4bbd1a21e..b91cfdad08c 100644 --- a/alts/src/main/java/io/grpc/alts/internal/NettyTsiHandshaker.java +++ b/alts/src/main/java/io/grpc/alts/internal/NettyTsiHandshaker.java @@ -99,7 +99,7 @@ boolean processBytesFromPeer(ByteBuf data) throws GeneralSecurityException { } /** - * Returns true if and only if the handshake is still in progress + * Returns true if and only if the handshake is still in progress. * * @return true, if the handshake is still in progress, false otherwise. */ @@ -149,4 +149,8 @@ TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) { unwrapper = null; return internalHandshaker.createFrameProtector(alloc); } + + void close() { + internalHandshaker.close(); + } } diff --git a/alts/src/main/java/io/grpc/alts/internal/ProtectedPromise.java b/alts/src/main/java/io/grpc/alts/internal/ProtectedPromise.java index a19a8160f58..871a51f1bea 100644 --- a/alts/src/main/java/io/grpc/alts/internal/ProtectedPromise.java +++ b/alts/src/main/java/io/grpc/alts/internal/ProtectedPromise.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState; +import io.grpc.Internal; import io.netty.channel.Channel; import io.netty.channel.ChannelPromise; import io.netty.channel.DefaultChannelPromise; @@ -34,14 +35,15 @@ * *

NOTE: this code is based on code in Netty's {@code Http2CodecUtil}. */ -final class ProtectedPromise extends DefaultChannelPromise { +@Internal +public final class ProtectedPromise extends DefaultChannelPromise { private final List unprotectedPromises; private int expectedCount; private int successfulCount; private int failureCount; private boolean doneAllocating; - ProtectedPromise(Channel channel, EventExecutor executor, int numUnprotectedPromises) { + public ProtectedPromise(Channel channel, EventExecutor executor, int numUnprotectedPromises) { super(channel, executor); unprotectedPromises = new ArrayList<>(numUnprotectedPromises); } @@ -50,7 +52,7 @@ final class ProtectedPromise extends DefaultChannelPromise { * Adds a promise for a pending unprotected write. This will be notified after all of the writes * complete. */ - void addUnprotectedPromise(ChannelPromise promise) { + public void addUnprotectedPromise(ChannelPromise promise) { unprotectedPromises.add(promise); } @@ -60,7 +62,7 @@ void addUnprotectedPromise(ChannelPromise promise) { * * @return {@code this} promise. */ - ChannelPromise newPromise() { + public ChannelPromise newPromise() { checkState(!doneAllocating, "Done allocating. No more promises can be allocated."); expectedCount++; return this; @@ -72,11 +74,11 @@ ChannelPromise newPromise() { * * @return {@code this} promise. */ - ChannelPromise doneAllocatingPromises() { + public ChannelPromise doneAllocatingPromises() { if (!doneAllocating) { doneAllocating = true; if (successfulCount == expectedCount) { - trySuccessInternal(null); + trySuccessInternal(); return super.setSuccess(null); } } @@ -115,18 +117,18 @@ private boolean awaitingPromises() { } @Override - public ChannelPromise setSuccess(Void result) { - trySuccess(result); + public ChannelPromise setSuccess(Void unused) { + trySuccess(null); return this; } @Override - public boolean trySuccess(Void result) { + public boolean trySuccess(Void unused) { if (awaitingPromises()) { ++successfulCount; if (successfulCount == expectedCount && doneAllocating) { - trySuccessInternal(result); - return super.trySuccess(result); + trySuccessInternal(); + return super.trySuccess(null); } // TODO: We break the interface a bit here. // Multiple success events can be processed without issue because this is an aggregation. @@ -135,9 +137,9 @@ public boolean trySuccess(Void result) { return false; } - private void trySuccessInternal(Void result) { + private void trySuccessInternal() { for (int i = 0; i < unprotectedPromises.size(); ++i) { - unprotectedPromises.get(i).trySuccess(result); + unprotectedPromises.get(i).trySuccess(null); } } diff --git a/alts/src/main/java/io/grpc/alts/internal/TsiFrameHandler.java b/alts/src/main/java/io/grpc/alts/internal/TsiFrameHandler.java index 264541223b4..2294d7a07e6 100644 --- a/alts/src/main/java/io/grpc/alts/internal/TsiFrameHandler.java +++ b/alts/src/main/java/io/grpc/alts/internal/TsiFrameHandler.java @@ -19,9 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import com.google.common.annotations.VisibleForTesting; import io.grpc.alts.internal.TsiFrameProtector.Consumer; -import io.grpc.alts.internal.TsiHandshakeHandler.TsiHandshakeCompletionEvent; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelException; import io.netty.channel.ChannelHandlerContext; @@ -33,7 +31,6 @@ import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; @@ -47,72 +44,36 @@ public final class TsiFrameHandler extends ByteToMessageDecoder implements Chann private TsiFrameProtector protector; private PendingWriteQueue pendingUnprotectedWrites; - private State state = State.HANDSHAKE_NOT_FINISHED; - private boolean closeInitiated = false; - - @VisibleForTesting - enum State { - HANDSHAKE_NOT_FINISHED, - PROTECTED, - CLOSED, - HANDSHAKE_FAILED - } + private boolean closeInitiated; - public TsiFrameHandler() {} + public TsiFrameHandler(TsiFrameProtector protector) { + this.protector = checkNotNull(protector, "protector"); + } @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { - logger.finest("TsiFrameHandler added"); super.handlerAdded(ctx); assert pendingUnprotectedWrites == null; pendingUnprotectedWrites = new PendingWriteQueue(checkNotNull(ctx)); } - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object event) throws Exception { - if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, "TsiFrameHandler user event triggered", new Object[]{event}); - } - if (event instanceof TsiHandshakeCompletionEvent) { - TsiHandshakeCompletionEvent tsiEvent = (TsiHandshakeCompletionEvent) event; - if (tsiEvent.isSuccess()) { - setProtector(tsiEvent.protector()); - } else { - state = State.HANDSHAKE_FAILED; - } - // Ignore errors. Another handler in the pipeline must handle TSI Errors. - } - // Keep propagating the message, as others may want to read it. - super.userEventTriggered(ctx, event); - } - - @VisibleForTesting - void setProtector(TsiFrameProtector protector) { - logger.finest("TsiFrameHandler protector set"); - checkState(this.protector == null); - this.protector = checkNotNull(protector); - this.state = State.PROTECTED; - } - @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { - checkState( - state == State.PROTECTED, - "Cannot read frames while the TSI handshake is %s", state); + checkState(protector != null, "decode() called after close()"); protector.unprotect(in, out, ctx.alloc()); } @Override - public void write(ChannelHandlerContext ctx, Object message, ChannelPromise promise) - throws Exception { - checkState( - state == State.PROTECTED, - "Cannot write frames while the TSI handshake state is %s", state); + @SuppressWarnings("FutureReturnValueIgnored") // for setSuccess + public void write(ChannelHandlerContext ctx, Object message, ChannelPromise promise) { + if (protector == null) { + promise.setFailure(new IllegalStateException("write() called after close()")); + return; + } ByteBuf msg = (ByteBuf) message; if (!msg.isReadable()) { // Nothing to encode. - @SuppressWarnings("unused") // go/futurereturn-lsc - Future possiblyIgnoredError = promise.setSuccess(); + promise.setSuccess(); return; } @@ -122,36 +83,19 @@ public void write(ChannelHandlerContext ctx, Object message, ChannelPromise prom @Override public void handlerRemoved0(ChannelHandlerContext ctx) throws Exception { - if (!pendingUnprotectedWrites.isEmpty()) { - pendingUnprotectedWrites.removeAndFailAll( - new ChannelException("Pending write on removal of TSI handler")); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - pendingUnprotectedWrites.removeAndFailAll(cause); - super.exceptionCaught(ctx, cause); + destroyProtectorAndWrites(); } @Override - public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) { - ctx.bind(localAddress, promise); - } - - @Override - public void connect( - ChannelHandlerContext ctx, - SocketAddress remoteAddress, - SocketAddress localAddress, - ChannelPromise promise) { - ctx.connect(remoteAddress, localAddress, promise); + public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) { + doClose(ctx); + ctx.disconnect(promise); } @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) { + public void close(ChannelHandlerContext ctx, ChannelPromise promise) { doClose(ctx); - ctx.disconnect(promise); + ctx.close(promise); } private void doClose(ChannelHandlerContext ctx) { @@ -165,51 +109,27 @@ private void doClose(ChannelHandlerContext ctx) { flush(ctx); } } catch (GeneralSecurityException e) { - logger.log(Level.FINE, "Ignoring error on flush before close", e); + logger.log(Level.FINE, "Ignored error on flush before close", e); } finally { - state = State.CLOSED; - release(); + destroyProtectorAndWrites(); } } @Override - public void close(ChannelHandlerContext ctx, ChannelPromise promise) { - doClose(ctx); - ctx.close(promise); - } - - @Override - public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) { - doClose(ctx); - ctx.deregister(promise); - } - - @Override - public void read(ChannelHandlerContext ctx) { - ctx.read(); - } - - @Override + @SuppressWarnings("FutureReturnValueIgnored") // for aggregatePromise.doneAllocatingPromises public void flush(final ChannelHandlerContext ctx) throws GeneralSecurityException { - if (state == State.CLOSED || state == State.HANDSHAKE_FAILED) { - logger.fine( - String.format("FrameHandler is inactive(%s), channel id: %s", - state, ctx.channel().id().asShortText())); + if (pendingUnprotectedWrites == null || pendingUnprotectedWrites.isEmpty()) { + // Return early if there's nothing to write. Otherwise protector.protectFlush() below may + // not check for "no-data" and go on writing the 0-byte "data" to the socket with the + // protection framing. return; } - checkState( - state == State.PROTECTED, "Cannot write frames while the TSI handshake state is %s", state); + // Flushes can happen after close, but only when there are no pending writes. + checkState(protector != null, "flush() called after close()"); final ProtectedPromise aggregatePromise = new ProtectedPromise(ctx.channel(), ctx.executor(), pendingUnprotectedWrites.size()); - List bufs = new ArrayList<>(pendingUnprotectedWrites.size()); - if (pendingUnprotectedWrites.isEmpty()) { - // Return early if there's nothing to write. Otherwise protector.protectFlush() below may - // not check for "no-data" and go on writing the 0-byte "data" to the socket with the - // protection framing. - return; - } // Drain the unprotected writes. while (!pendingUnprotectedWrites.isEmpty()) { ByteBuf in = (ByteBuf) pendingUnprotectedWrites.current(); @@ -218,25 +138,62 @@ public void flush(final ChannelHandlerContext ctx) throws GeneralSecurityExcepti aggregatePromise.addUnprotectedPromise(pendingUnprotectedWrites.remove()); } - protector.protectFlush( - bufs, - new Consumer() { - @Override - public void accept(ByteBuf b) { - ctx.writeAndFlush(b, aggregatePromise.newPromise()); - } - }, - ctx.alloc()); + final class ProtectedFrameWriteFlusher implements Consumer { + + @Override + public void accept(ByteBuf byteBuf) { + ctx.writeAndFlush(byteBuf, aggregatePromise.newPromise()); + } + } + protector.protectFlush(bufs, new ProtectedFrameWriteFlusher(), ctx.alloc()); // We're done writing, start the flow of promise events. - @SuppressWarnings("unused") // go/futurereturn-lsc - Future possiblyIgnoredError = aggregatePromise.doneAllocatingPromises(); + aggregatePromise.doneAllocatingPromises(); + } + + // Only here to fulfill ChannelOutboundHandler + @Override + public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) { + ctx.bind(localAddress, promise); + } + + // Only here to fulfill ChannelOutboundHandler + @Override + public void connect( + ChannelHandlerContext ctx, + SocketAddress remoteAddress, + SocketAddress localAddress, + ChannelPromise promise) { + ctx.connect(remoteAddress, localAddress, promise); } - private void release() { + // Only here to fulfill ChannelOutboundHandler + @Override + public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) { + ctx.deregister(promise); + } + + // Only here to fulfill ChannelOutboundHandler + @Override + public void read(ChannelHandlerContext ctx) { + ctx.read(); + } + + private void destroyProtectorAndWrites() { + try { + if (pendingUnprotectedWrites != null && !pendingUnprotectedWrites.isEmpty()) { + pendingUnprotectedWrites.removeAndFailAll( + new ChannelException("Pending write on teardown of TSI handler")); + } + } finally { + pendingUnprotectedWrites = null; + } if (protector != null) { - protector.destroy(); - protector = null; + try { + protector.destroy(); + } finally { + protector = null; + } } } } diff --git a/alts/src/main/java/io/grpc/alts/internal/TsiHandshakeHandler.java b/alts/src/main/java/io/grpc/alts/internal/TsiHandshakeHandler.java index 98dd1f90908..7964b122f8c 100644 --- a/alts/src/main/java/io/grpc/alts/internal/TsiHandshakeHandler.java +++ b/alts/src/main/java/io/grpc/alts/internal/TsiHandshakeHandler.java @@ -17,139 +17,99 @@ package io.grpc.alts.internal; import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.MoreObjects; +import static com.google.common.base.Preconditions.checkState; +import static io.grpc.alts.internal.AltsProtocolNegotiator.AUTH_CONTEXT_KEY; +import static io.grpc.alts.internal.AltsProtocolNegotiator.TSI_PEER_KEY; + +import io.grpc.Attributes; +import io.grpc.ChannelLogger; +import io.grpc.ChannelLogger.ChannelLogLevel; +import io.grpc.InternalChannelz.Security; +import io.grpc.SecurityLevel; +import io.grpc.alts.internal.TsiHandshakeHandler.HandshakeValidator.SecurityDetails; +import io.grpc.internal.GrpcAttributes; +import io.grpc.netty.InternalProtocolNegotiationEvent; +import io.grpc.netty.ProtocolNegotiationEvent; import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufAllocator; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; -import io.netty.util.ReferenceCountUtil; import java.security.GeneralSecurityException; import java.util.List; -import java.util.concurrent.Future; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.annotation.Nullable; /** - * Performs The TSI Handshake. When the handshake is complete, it fires a user event with a {@link - * TsiHandshakeCompletionEvent} indicating the result of the handshake. + * Performs The TSI Handshake. */ public final class TsiHandshakeHandler extends ByteToMessageDecoder { - - private static final Logger logger = Logger.getLogger(TsiHandshakeHandler.class.getName()); - - private static final int HANDSHAKE_FRAME_SIZE = 1024; - - private final NettyTsiHandshaker handshaker; - private boolean started; - /** - * This buffer doesn't store any state. We just hold onto it in case we end up allocating a buffer - * that ends up being unused. + * Validates a Tsi Peer object. */ - private ByteBuf buffer; + public abstract static class HandshakeValidator { - public TsiHandshakeHandler(NettyTsiHandshaker handshaker) { - this.handshaker = checkNotNull(handshaker); - } + public static final class SecurityDetails { - /** - * Event that is fired once the TSI handshake is complete, which may be because it was successful - * or there was an error. - */ - public static final class TsiHandshakeCompletionEvent { - - private final Throwable cause; - private final TsiPeer peer; - private final Object context; - private final TsiFrameProtector protector; - - /** Creates a new event that indicates a successful handshake. */ - @VisibleForTesting - TsiHandshakeCompletionEvent( - TsiFrameProtector protector, TsiPeer peer, @Nullable Object peerObject) { - this.cause = null; - this.peer = checkNotNull(peer); - this.protector = checkNotNull(protector); - this.context = peerObject; - } + private final SecurityLevel securityLevel; + private final Security security; - /** Creates a new event that indicates an unsuccessful handshake/. */ - TsiHandshakeCompletionEvent(Throwable cause) { - this.cause = checkNotNull(cause); - this.peer = null; - this.protector = null; - this.context = null; - } + /** + * Constructs SecurityDetails. + */ + public SecurityDetails(io.grpc.SecurityLevel securityLevel, @Nullable Security security) { + this.securityLevel = checkNotNull(securityLevel, "securityLevel"); + this.security = security; + } - /** Return {@code true} if the handshake was successful. */ - public boolean isSuccess() { - return cause == null; + public Security getSecurity() { + return security; + } + + public SecurityLevel getSecurityLevel() { + return securityLevel; + } } /** - * Return the {@link Throwable} if {@link #isSuccess()} returns {@code false} and so the - * handshake failed. + * Validates a Tsi Peer object. */ - @Nullable - public Throwable cause() { - return cause; - } - - @Nullable - public TsiPeer peer() { - return peer; - } - - @Nullable - public Object context() { - return context; - } - - @Nullable - TsiFrameProtector protector() { - return protector; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("peer", peer) - .add("protector", protector) - .add("context", context) - .add("cause", cause) - .toString(); - } + public abstract SecurityDetails validatePeerObject(Object peerObject) + throws GeneralSecurityException; } - @Override - public void handlerAdded(ChannelHandlerContext ctx) throws Exception { - logger.finest("TsiHandshakeHandler added"); - maybeStart(ctx); - super.handlerAdded(ctx); - } + private static final int HANDSHAKE_FRAME_SIZE = 1024; - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - logger.finest("TsiHandshakeHandler channel active"); - maybeStart(ctx); - super.channelActive(ctx); - } + private final NettyTsiHandshaker handshaker; + private final HandshakeValidator handshakeValidator; + private final ChannelHandler next; + private final AsyncSemaphore semaphore; - @Override - public void handlerRemoved0(ChannelHandlerContext ctx) throws Exception { - logger.finest("TsiHandshakeHandler handler removed"); - close(); - super.handlerRemoved0(ctx); + private ProtocolNegotiationEvent pne; + private boolean semaphoreAcquired; + private final ChannelLogger negotiationLogger; + + /** + * Constructs a TsiHandshakeHandler. + */ + public TsiHandshakeHandler( + ChannelHandler next, NettyTsiHandshaker handshaker, HandshakeValidator handshakeValidator, + ChannelLogger negotiationLogger) { + this(next, handshaker, handshakeValidator, null, negotiationLogger); } - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - logger.log(Level.FINEST, "Exception in TsiHandshakeHandler", cause); - ctx.fireUserEventTriggered(new TsiHandshakeCompletionEvent(cause)); - super.exceptionCaught(ctx, cause); + /** + * Constructs a TsHandshakeHandler. If a semaphore is provided, a permit from the semaphore is + * required to start the handshake and is returned when the handshake ends. + */ + public TsiHandshakeHandler( + ChannelHandler next, NettyTsiHandshaker handshaker, HandshakeValidator handshakeValidator, + AsyncSemaphore semaphore, ChannelLogger negotiationLogger) { + this.handshaker = checkNotNull(handshaker, "handshaker"); + this.handshakeValidator = checkNotNull(handshakeValidator, "handshakeValidator"); + this.next = checkNotNull(next, "next"); + this.semaphore = semaphore; + this.negotiationLogger = negotiationLogger; } @Override @@ -168,71 +128,123 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) t // If the handshake is complete, transition to the framing state. if (!handshaker.isInProgress()) { - TsiFrameProtector protector = null; + TsiPeer peer = handshaker.extractPeer(); + Object authContext = handshaker.extractPeerObject(); + SecurityDetails details = handshakeValidator.validatePeerObject(authContext); + // createFrameProtector must be called last. + TsiFrameProtector protector = handshaker.createFrameProtector(ctx.alloc()); + TsiFrameHandler framer; + boolean success = false; try { - ctx.pipeline().remove(this); - protector = handshaker.createFrameProtector(ctx.alloc()); - TsiHandshakeCompletionEvent evt = new TsiHandshakeCompletionEvent( - protector, - handshaker.extractPeer(), - handshaker.extractPeerObject()); - protector = null; - ctx.fireUserEventTriggered(evt); - // No need to do anything with the in buffer, it will be re added to the pipeline when this - // handler is removed. + framer = new TsiFrameHandler(protector); + // adding framer and next handler after this handler before removing Decoder (current + // handler). This will prevents any missing read from decoder and/or unframed write from + // next handler. + ctx.pipeline().addAfter(ctx.name(), null, framer); + ctx.pipeline().addAfter(ctx.pipeline().context(framer).name(), null, next); + ctx.pipeline().remove(ctx.name()); + fireProtocolNegotiationEvent(ctx, peer, authContext, details); + success = true; } finally { - if (protector != null) { + if (!success && protector != null) { protector.destroy(); } - close(); } } } - private void maybeStart(ChannelHandlerContext ctx) { - if (!started && ctx.channel().isActive()) { - started = true; - sendHandshake(ctx); + @Override + public void userEventTriggered(final ChannelHandlerContext ctx, Object evt) throws Exception { + if (evt instanceof ProtocolNegotiationEvent) { + checkState(pne == null, "negotiation already started"); + pne = (ProtocolNegotiationEvent) evt; + negotiationLogger.log(ChannelLogLevel.INFO, "TsiHandshake started"); + ChannelFuture acquire = semaphoreAcquire(ctx); + if (acquire.isSuccess()) { + semaphoreAcquired = true; + sendHandshake(ctx); + } else { + acquire.addListener(new ChannelFutureListener() { + @Override public void operationComplete(ChannelFuture future) { + if (!future.isSuccess()) { + ctx.fireExceptionCaught(future.cause()); + return; + } + if (ctx.isRemoved()) { + semaphoreRelease(); + return; + } + semaphoreAcquired = true; + try { + sendHandshake(ctx); + } catch (Exception ex) { + ctx.fireExceptionCaught(ex); + } + ctx.flush(); + } + }); + } + } else { + super.userEventTriggered(ctx, evt); } } - /** Sends as many bytes as are available from the handshaker to the remote peer. */ - private void sendHandshake(ChannelHandlerContext ctx) { - boolean needToFlush = false; + private void fireProtocolNegotiationEvent( + ChannelHandlerContext ctx, TsiPeer peer, Object authContext, SecurityDetails details) { + checkState(pne != null, "negotiation not yet complete"); + negotiationLogger.log(ChannelLogLevel.INFO, "TsiHandshake finished"); + ProtocolNegotiationEvent localPne = pne; + Attributes.Builder attrs = InternalProtocolNegotiationEvent.getAttributes(localPne).toBuilder() + .set(TSI_PEER_KEY, peer) + .set(AUTH_CONTEXT_KEY, authContext) + .set(GrpcAttributes.ATTR_SECURITY_LEVEL, details.getSecurityLevel()); + localPne = InternalProtocolNegotiationEvent.withAttributes(localPne, attrs.build()); + localPne = InternalProtocolNegotiationEvent.withSecurity(localPne, details.getSecurity()); + ctx.fireUserEventTriggered(localPne); + } - // Iterate until there is nothing left to write. + /** Sends as many bytes as are available from the handshaker to the remote peer. */ + @SuppressWarnings("FutureReturnValueIgnored") // for addListener + private void sendHandshake(ChannelHandlerContext ctx) throws GeneralSecurityException { while (true) { - buffer = getOrCreateBuffer(ctx.alloc()); + boolean written = false; + ByteBuf buf = ctx.alloc().buffer(HANDSHAKE_FRAME_SIZE).retain(); // refcnt = 2 try { - handshaker.getBytesToSendToPeer(buffer); + handshaker.getBytesToSendToPeer(buf); + if (buf.isReadable()) { + ctx.writeAndFlush(buf).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + written = true; + } else { + break; + } } catch (GeneralSecurityException e) { - throw new RuntimeException(e); - } - if (!buffer.isReadable()) { - break; + throw new GeneralSecurityException("TsiHandshakeHandler encountered exception", e); + } finally { + buf.release(written ? 1 : 2); } - - needToFlush = true; - @SuppressWarnings("unused") // go/futurereturn-lsc - Future possiblyIgnoredError = ctx.write(buffer); - buffer = null; } + } - // If something was written, flush. - if (needToFlush) { - ctx.flush(); + @Override + protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception { + if (semaphoreAcquired) { + semaphoreRelease(); + semaphoreAcquired = false; } + handshaker.close(); } - private ByteBuf getOrCreateBuffer(ByteBufAllocator alloc) { - if (buffer == null) { - buffer = alloc.buffer(HANDSHAKE_FRAME_SIZE); + private ChannelFuture semaphoreAcquire(ChannelHandlerContext ctx) { + if (semaphore == null) { + return ctx.newSucceededFuture(); + } else { + return semaphore.acquire(ctx); } - return buffer; } - private void close() { - ReferenceCountUtil.safeRelease(buffer); - buffer = null; + private void semaphoreRelease() { + if (semaphore != null) { + semaphore.release(); + } } } diff --git a/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java b/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java index 967582aa811..6580a4433c7 100644 --- a/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java +++ b/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java @@ -68,7 +68,7 @@ public interface TsiHandshaker { boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityException; /** - * Returns true if and only if the handshake is still in progress + * Returns true if and only if the handshake is still in progress. * * @return true, if the handshake is still in progress, false otherwise. */ @@ -86,7 +86,7 @@ public interface TsiHandshaker { * * @return the extracted peer. */ - public Object extractPeerObject() throws GeneralSecurityException; + Object extractPeerObject() throws GeneralSecurityException; /** * Creates a frame protector from a completed handshake. No other methods may be called after the @@ -106,4 +106,9 @@ public interface TsiHandshaker { * @return a new TsiFrameProtector. */ TsiFrameProtector createFrameProtector(ByteBufAllocator alloc); + + /** + * Closes resources. + */ + void close(); } diff --git a/alts/src/main/java/io/grpc/alts/internal/TsiHandshakerFactory.java b/alts/src/main/java/io/grpc/alts/internal/TsiHandshakerFactory.java index 996bd003654..7d17a3954c8 100644 --- a/alts/src/main/java/io/grpc/alts/internal/TsiHandshakerFactory.java +++ b/alts/src/main/java/io/grpc/alts/internal/TsiHandshakerFactory.java @@ -16,11 +16,12 @@ package io.grpc.alts.internal; +import io.grpc.ChannelLogger; import javax.annotation.Nullable; /** Factory that manufactures instances of {@link TsiHandshaker}. */ public interface TsiHandshakerFactory { /** Creates a new handshaker. */ - TsiHandshaker newHandshaker(@Nullable String authority); + TsiHandshaker newHandshaker(@Nullable String authority, ChannelLogger logger); } diff --git a/alts/src/main/java/io/grpc/alts/internal/TsiPeer.java b/alts/src/main/java/io/grpc/alts/internal/TsiPeer.java index 990cf0b9c03..c02188c50ac 100644 --- a/alts/src/main/java/io/grpc/alts/internal/TsiPeer.java +++ b/alts/src/main/java/io/grpc/alts/internal/TsiPeer.java @@ -54,7 +54,7 @@ public abstract static class Property { private final String name; private final T value; - public Property(@Nonnull String name, @Nonnull T value) { + protected Property(@Nonnull String name, @Nonnull T value) { this.name = name; this.value = value; } @@ -73,6 +73,13 @@ public String toString() { } } + /** A peer property corresponding to a boolean. */ + public static final class BooleanProperty extends Property { + public BooleanProperty(@Nonnull String name, boolean value) { + super(name, value); + } + } + /** A peer property corresponding to a signed 64-bit integer. */ public static final class SignedInt64Property extends Property { public SignedInt64Property(@Nonnull String name, @Nonnull Long value) { diff --git a/alts/src/main/proto/grpc/gcp/handshaker.proto b/alts/src/main/proto/grpc/gcp/handshaker.proto index 1820dd26dbe..02764ba4c08 100644 --- a/alts/src/main/proto/grpc/gcp/handshaker.proto +++ b/alts/src/main/proto/grpc/gcp/handshaker.proto @@ -105,6 +105,9 @@ message StartClientHandshakeReq { // (Optional) RPC protocol versions supported by the client. RpcProtocolVersions rpc_versions = 9; + + // (Optional) Maximum frame size supported by the client. + uint32 max_frame_size = 10; } message ServerHandshakeParameters { @@ -143,6 +146,9 @@ message StartServerHandshakeReq { // (Optional) RPC protocol versions supported by the server. RpcProtocolVersions rpc_versions = 6; + + // (Optional) Maximum frame size supported by the server. + uint32 max_frame_size = 7; } message NextHandshakeMessageReq { @@ -190,6 +196,9 @@ message HandshakerResult { // The RPC protocol versions supported by the peer. RpcProtocolVersions peer_rpc_versions = 7; + + // The maximum frame size of the peer. + uint32 max_frame_size = 8; } message HandshakerStatus { @@ -229,6 +238,6 @@ service HandshakerService { // service expects to respond. Client does not have to wait for service's // response before sending next request. rpc DoHandshake(stream HandshakerReq) - returns (stream HandshakerResp) { + returns (stream HandshakerResp) { } } diff --git a/alts/src/test/java/io/grpc/alts/AltsChannelBuilderTest.java b/alts/src/test/java/io/grpc/alts/AltsChannelBuilderTest.java index e8cc538b433..a44de19b911 100644 --- a/alts/src/test/java/io/grpc/alts/AltsChannelBuilderTest.java +++ b/alts/src/test/java/io/grpc/alts/AltsChannelBuilderTest.java @@ -18,8 +18,7 @@ import static com.google.common.truth.Truth.assertThat; -import io.grpc.alts.internal.AltsProtocolNegotiator; -import io.grpc.netty.ProtocolNegotiator; +import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -28,17 +27,14 @@ public final class AltsChannelBuilderTest { @Test - public void buildsNettyChannel() throws Exception { + public void buildsNettyChannel() { AltsChannelBuilder builder = AltsChannelBuilder.forTarget("localhost:8080").enableUntrustedAltsForTesting(); ProtocolNegotiator protocolNegotiator = builder.getProtocolNegotiatorForTest(); - assertThat(protocolNegotiator).isNull(); - - builder.build(); - - protocolNegotiator = builder.getProtocolNegotiatorForTest(); assertThat(protocolNegotiator).isNotNull(); - assertThat(protocolNegotiator).isInstanceOf(AltsProtocolNegotiator.class); + // Avoids exposing this class + assertThat(protocolNegotiator.getClass().getSimpleName()) + .isEqualTo("ClientAltsProtocolNegotiator"); } } diff --git a/alts/src/test/java/io/grpc/alts/AltsContextUtilTest.java b/alts/src/test/java/io/grpc/alts/AltsContextUtilTest.java new file mode 100644 index 00000000000..675fa29fc99 --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/AltsContextUtilTest.java @@ -0,0 +1,134 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.grpc.alts; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import io.grpc.Attributes; +import io.grpc.ClientCall; +import io.grpc.ServerCall; +import io.grpc.alts.AltsContext.SecurityLevel; +import io.grpc.alts.internal.AltsInternalContext; +import io.grpc.alts.internal.AltsProtocolNegotiator; +import io.grpc.alts.internal.HandshakerResult; +import io.grpc.alts.internal.Identity; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link AltsContextUtil}. */ +@RunWith(JUnit4.class) +public class AltsContextUtilTest { + @Test + public void check_noAttributeValue() { + assertFalse(AltsContextUtil.check(Attributes.newBuilder().build())); + } + + @Test + public void check_unexpectedAttributeValueType() { + assertFalse(AltsContextUtil.check(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new Object()) + .build())); + } + + @Test + public void check_altsInternalContext() { + assertTrue(AltsContextUtil.check(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, AltsInternalContext.getDefaultInstance()) + .build())); + } + + @Test + public void checkServer_altsInternalContext() { + ServerCall call = mock(ServerCall.class); + when(call.getAttributes()).thenReturn(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, AltsInternalContext.getDefaultInstance()) + .build()); + + assertTrue(AltsContextUtil.check(call)); + } + + @Test + public void checkClient_altsInternalContext() { + ClientCall call = mock(ClientCall.class); + when(call.getAttributes()).thenReturn(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, AltsInternalContext.getDefaultInstance()) + .build()); + + assertTrue(AltsContextUtil.check(call)); + } + + @Test + public void createFrom_altsInternalContext() { + HandshakerResult handshakerResult = + HandshakerResult.newBuilder() + .setPeerIdentity(Identity.newBuilder().setServiceAccount("remote@peer")) + .setLocalIdentity(Identity.newBuilder().setServiceAccount("local@peer")) + .build(); + + AltsContext context = AltsContextUtil.createFrom(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult)) + .build()); + assertEquals("remote@peer", context.getPeerServiceAccount()); + assertEquals("local@peer", context.getLocalServiceAccount()); + assertEquals(SecurityLevel.INTEGRITY_AND_PRIVACY, context.getSecurityLevel()); + } + + @Test(expected = IllegalArgumentException.class) + public void createFrom_noAttributeValue() { + AltsContextUtil.createFrom(Attributes.newBuilder().build()); + } + + @Test + public void createFromServer_altsInternalContext() { + HandshakerResult handshakerResult = + HandshakerResult.newBuilder() + .setPeerIdentity(Identity.newBuilder().setServiceAccount("remote@peer")) + .setLocalIdentity(Identity.newBuilder().setServiceAccount("local@peer")) + .build(); + + ServerCall call = mock(ServerCall.class); + when(call.getAttributes()).thenReturn(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult)) + .build()); + + AltsContext context = AltsContextUtil.createFrom(call); + assertEquals("remote@peer", context.getPeerServiceAccount()); + } + + @Test + public void createFromClient_altsInternalContext() { + HandshakerResult handshakerResult = + HandshakerResult.newBuilder() + .setPeerIdentity(Identity.newBuilder().setServiceAccount("remote@peer")) + .setLocalIdentity(Identity.newBuilder().setServiceAccount("local@peer")) + .build(); + + ClientCall call = mock(ClientCall.class); + when(call.getAttributes()).thenReturn(Attributes.newBuilder() + .set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, new AltsInternalContext(handshakerResult)) + .build()); + + AltsContext context = AltsContextUtil.createFrom(call); + assertEquals("remote@peer", context.getPeerServiceAccount()); + } +} diff --git a/alts/src/test/java/io/grpc/alts/AuthorizationUtilTest.java b/alts/src/test/java/io/grpc/alts/AuthorizationUtilTest.java new file mode 100644 index 00000000000..8b4691df331 --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/AuthorizationUtilTest.java @@ -0,0 +1,114 @@ +/* + * Copyright 2019 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.common.collect.Lists; +import io.grpc.Attributes; +import io.grpc.Metadata; +import io.grpc.MethodDescriptor; +import io.grpc.ServerCall; +import io.grpc.Status; +import io.grpc.alts.internal.AltsInternalContext; +import io.grpc.alts.internal.AltsProtocolNegotiator; +import io.grpc.alts.internal.HandshakerResult; +import io.grpc.alts.internal.Identity; +import javax.annotation.Nullable; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link AuthorizationUtil}. */ +@RunWith(JUnit4.class) +public final class AuthorizationUtilTest { + + @Test + public void altsAuthorizationCheck() throws Exception { + Status status = + AuthorizationUtil.clientAuthorizationCheck( + new FakeServerCall(null), Lists.newArrayList("Alice")); + assertThat(status.getCode()).isEqualTo(Status.Code.PERMISSION_DENIED); + assertThat(status.getDescription()).startsWith("Peer ALTS AuthContext not found"); + status = + AuthorizationUtil.clientAuthorizationCheck( + new FakeServerCall("Alice"), Lists.newArrayList("Alice", "Bob")); + assertThat(status.getCode()).isEqualTo(Status.Code.OK); + status = + AuthorizationUtil.clientAuthorizationCheck( + new FakeServerCall("Alice"), Lists.newArrayList("Bob", "Joe")); + assertThat(status.getCode()).isEqualTo(Status.Code.PERMISSION_DENIED); + assertThat(status.getDescription()).endsWith("not authorized"); + } + + private static class FakeServerCall extends ServerCall { + final Attributes attrs; + + FakeServerCall(@Nullable String peerServiceAccount) { + Attributes.Builder attrsBuilder = Attributes.newBuilder(); + if (peerServiceAccount != null) { + HandshakerResult handshakerResult = + HandshakerResult.newBuilder() + .setPeerIdentity(Identity.newBuilder().setServiceAccount(peerServiceAccount)) + .build(); + AltsInternalContext altsContext = new AltsInternalContext(handshakerResult); + attrsBuilder.set(AltsProtocolNegotiator.AUTH_CONTEXT_KEY, altsContext); + } + attrs = attrsBuilder.build(); + } + + @Override + public void request(int numMessages) { + throw new AssertionError("Should not be called"); + } + + @Override + public void sendHeaders(Metadata headers) { + throw new AssertionError("Should not be called"); + } + + @Override + public void sendMessage(String message) { + throw new AssertionError("Should not be called"); + } + + @Override + public void close(Status status, Metadata trailers) { + throw new AssertionError("Should not be called"); + } + + @Override + public boolean isCancelled() { + throw new AssertionError("Should not be called"); + } + + @Override + public Attributes getAttributes() { + return attrs; + } + + @Override + public String getAuthority() { + throw new AssertionError("Should not be called"); + } + + @Override + public MethodDescriptor getMethodDescriptor() { + throw new AssertionError("Should not be called"); + } + } +} diff --git a/alts/src/test/java/io/grpc/alts/CheckGcpEnvironmentTest.java b/alts/src/test/java/io/grpc/alts/CheckGcpEnvironmentTest.java deleted file mode 100644 index bef16f7776c..00000000000 --- a/alts/src/test/java/io/grpc/alts/CheckGcpEnvironmentTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.alts; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.BufferedReader; -import java.io.StringReader; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public final class CheckGcpEnvironmentTest { - - @Test - public void checkGcpLinuxPlatformData() throws Exception { - BufferedReader reader; - reader = new BufferedReader(new StringReader("HP Z440 Workstation")); - assertFalse(CheckGcpEnvironment.checkProductNameOnLinux(reader)); - reader = new BufferedReader(new StringReader("Google")); - assertTrue(CheckGcpEnvironment.checkProductNameOnLinux(reader)); - reader = new BufferedReader(new StringReader("Google Compute Engine")); - assertTrue(CheckGcpEnvironment.checkProductNameOnLinux(reader)); - reader = new BufferedReader(new StringReader("Google Compute Engine ")); - assertTrue(CheckGcpEnvironment.checkProductNameOnLinux(reader)); - } - - @Test - public void checkGcpWindowsPlatformData() throws Exception { - BufferedReader reader; - reader = new BufferedReader(new StringReader("Product : Google")); - assertFalse(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - reader = new BufferedReader(new StringReader("Manufacturer : LENOVO")); - assertFalse(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - reader = new BufferedReader(new StringReader("Manufacturer : Google Compute Engine")); - assertFalse(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - reader = new BufferedReader(new StringReader("Manufacturer : Google")); - assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - reader = new BufferedReader(new StringReader("Manufacturer:Google")); - assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - reader = new BufferedReader(new StringReader("Manufacturer : Google ")); - assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - reader = new BufferedReader(new StringReader("BIOSVersion : 1.0\nManufacturer : Google\n")); - assertTrue(CheckGcpEnvironment.checkBiosDataOnWindows(reader)); - } -} diff --git a/alts/src/test/java/io/grpc/alts/ComputeEngineChannelBuilderTest.java b/alts/src/test/java/io/grpc/alts/ComputeEngineChannelBuilderTest.java new file mode 100644 index 00000000000..03fd113a65e --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/ComputeEngineChannelBuilderTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class ComputeEngineChannelBuilderTest { + + @Test + public void buildsNettyChannel() throws Exception { + ComputeEngineChannelBuilder builder = ComputeEngineChannelBuilder.forTarget("localhost:8080"); + builder.build(); + } +} diff --git a/alts/src/test/java/io/grpc/alts/DualCallCredentialsTest.java b/alts/src/test/java/io/grpc/alts/DualCallCredentialsTest.java new file mode 100644 index 00000000000..29646191be1 --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/DualCallCredentialsTest.java @@ -0,0 +1,109 @@ +/* + * Copyright 2024 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import io.grpc.Attributes; +import io.grpc.CallCredentials; +import io.grpc.CallCredentials.RequestInfo; +import io.grpc.MethodDescriptor; +import io.grpc.SecurityLevel; +import io.grpc.alts.internal.AltsInternalContext; +import io.grpc.alts.internal.AltsProtocolNegotiator; +import io.grpc.testing.TestMethodDescriptors; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; + +/** Unit tests for {@link DualCallCredentials}. */ +@RunWith(JUnit4.class) +public class DualCallCredentialsTest { + + @Rule public final MockitoRule mocks = MockitoJUnit.rule(); + + @Mock CallCredentials tlsCallCredentials; + + @Mock CallCredentials altsCallCredentials; + + private static final String AUTHORITY = "testauthority"; + private static final SecurityLevel SECURITY_LEVEL = SecurityLevel.PRIVACY_AND_INTEGRITY; + + @Test + public void invokeTlsCallCredentials() { + DualCallCredentials callCredentials = + new DualCallCredentials(tlsCallCredentials, altsCallCredentials); + RequestInfo requestInfo = new RequestInfoImpl(false); + callCredentials.applyRequestMetadata(requestInfo, null, null); + + verify(altsCallCredentials, never()).applyRequestMetadata(any(), any(), any()); + verify(tlsCallCredentials, times(1)).applyRequestMetadata(requestInfo, null, null); + } + + @Test + public void invokeAltsCallCredentials() { + DualCallCredentials callCredentials = + new DualCallCredentials(tlsCallCredentials, altsCallCredentials); + RequestInfo requestInfo = new RequestInfoImpl(true); + callCredentials.applyRequestMetadata(requestInfo, null, null); + + verify(altsCallCredentials, times(1)).applyRequestMetadata(requestInfo, null, null); + verify(tlsCallCredentials, never()).applyRequestMetadata(any(), any(), any()); + } + + private static final class RequestInfoImpl extends CallCredentials.RequestInfo { + private Attributes attrs; + + RequestInfoImpl(boolean hasAltsContext) { + attrs = + hasAltsContext + ? Attributes.newBuilder() + .set( + AltsProtocolNegotiator.AUTH_CONTEXT_KEY, + AltsInternalContext.getDefaultInstance()) + .build() + : Attributes.EMPTY; + } + + @Override + public MethodDescriptor getMethodDescriptor() { + return TestMethodDescriptors.voidMethod(); + } + + @Override + public SecurityLevel getSecurityLevel() { + return SECURITY_LEVEL; + } + + @Override + public String getAuthority() { + return AUTHORITY; + } + + @Override + public Attributes getTransportAttrs() { + return attrs; + } + } +} diff --git a/alts/src/test/java/io/grpc/alts/GoogleDefaultChannelBuilderTest.java b/alts/src/test/java/io/grpc/alts/GoogleDefaultChannelBuilderTest.java index d9bba544ad2..c73ef4444e9 100644 --- a/alts/src/test/java/io/grpc/alts/GoogleDefaultChannelBuilderTest.java +++ b/alts/src/test/java/io/grpc/alts/GoogleDefaultChannelBuilderTest.java @@ -16,10 +16,6 @@ package io.grpc.alts; -import static com.google.common.truth.Truth.assertThat; - -import io.grpc.alts.internal.GoogleDefaultProtocolNegotiator; -import io.grpc.netty.ProtocolNegotiator; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -31,8 +27,5 @@ public final class GoogleDefaultChannelBuilderTest { public void buildsNettyChannel() throws Exception { GoogleDefaultChannelBuilder builder = GoogleDefaultChannelBuilder.forTarget("localhost:8080"); builder.build(); - - ProtocolNegotiator protocolNegotiator = builder.getProtocolNegotiatorForTest(); - assertThat(protocolNegotiator).isInstanceOf(GoogleDefaultProtocolNegotiator.class); } } diff --git a/alts/src/test/java/io/grpc/alts/HandshakerServiceChannelTest.java b/alts/src/test/java/io/grpc/alts/HandshakerServiceChannelTest.java index b31e36aec83..221001157f1 100644 --- a/alts/src/test/java/io/grpc/alts/HandshakerServiceChannelTest.java +++ b/alts/src/test/java/io/grpc/alts/HandshakerServiceChannelTest.java @@ -46,7 +46,7 @@ public void unaryRpc(SimpleRequest request, StreamObserver so) { so.onCompleted(); } }) - .build()); + .build()); private Resource resource; @Before @@ -61,12 +61,30 @@ public void sharedChannel_authority() { resource = HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL; Channel channel = resource.create(); try { - assertThat(channel.authority()).isEqualTo("metadata.google.internal:8080"); + assertThat(channel.authority()).isEqualTo("metadata.google.internal.:8080"); } finally { resource.close(channel); } } + @Test + public void getHandshakerTarget_nullEnvVar() { + assertThat(HandshakerServiceChannel.getHandshakerTarget(null)) + .isEqualTo("metadata.google.internal.:8080"); + } + + @Test + public void getHandshakerTarget_envVarWithPort() { + assertThat(HandshakerServiceChannel.getHandshakerTarget("169.254.169.254:80")) + .isEqualTo("169.254.169.254:8080"); + } + + @Test + public void getHandshakerTarget_envVarWithHostOnly() { + assertThat(HandshakerServiceChannel.getHandshakerTarget("169.254.169.254")) + .isEqualTo("169.254.169.254:8080"); + } + @Test public void resource_works() { Channel channel = resource.create(); diff --git a/alts/src/test/java/io/grpc/alts/InternalCheckGcpEnvironmentTest.java b/alts/src/test/java/io/grpc/alts/InternalCheckGcpEnvironmentTest.java new file mode 100644 index 00000000000..1234cfc49c3 --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/InternalCheckGcpEnvironmentTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.StringReader; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class InternalCheckGcpEnvironmentTest { + + @Test + public void checkGcpLinuxPlatformData() throws Exception { + BufferedReader reader; + reader = new BufferedReader(new StringReader("HP Z440 Workstation")); + assertFalse(InternalCheckGcpEnvironment.checkProductNameOnLinux(reader)); + reader = new BufferedReader(new StringReader("Google")); + assertTrue(InternalCheckGcpEnvironment.checkProductNameOnLinux(reader)); + reader = new BufferedReader(new StringReader("Google Compute Engine")); + assertTrue(InternalCheckGcpEnvironment.checkProductNameOnLinux(reader)); + reader = new BufferedReader(new StringReader("Google Compute Engine ")); + assertTrue(InternalCheckGcpEnvironment.checkProductNameOnLinux(reader)); + } + + @Test + public void checkGcpWindowsPlatformData() throws Exception { + BufferedReader reader; + reader = new BufferedReader(new StringReader("Product : Google")); + assertFalse(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + reader = new BufferedReader(new StringReader("Manufacturer : LENOVO")); + assertFalse(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + reader = new BufferedReader(new StringReader("Manufacturer : Google Compute Engine")); + assertFalse(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + reader = new BufferedReader(new StringReader("Manufacturer : Google")); + assertTrue(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + reader = new BufferedReader(new StringReader("Manufacturer:Google")); + assertTrue(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + reader = new BufferedReader(new StringReader("Manufacturer : Google ")); + assertTrue(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + reader = new BufferedReader(new StringReader("BIOSVersion : 1.0\nManufacturer : Google\n")); + assertTrue(InternalCheckGcpEnvironment.checkBiosDataOnWindows(reader)); + } +} diff --git a/alts/src/test/java/io/grpc/alts/internal/AesGcmAeadCrypterTest.java b/alts/src/test/java/io/grpc/alts/internal/AesGcmAeadCrypterTest.java new file mode 100644 index 00000000000..bcf8c2810ee --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/internal/AesGcmAeadCrypterTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2020 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts.internal; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.TruthJUnit.assume; + +import org.conscrypt.Conscrypt; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class AesGcmAeadCrypterTest { + @Test + public void getConscrypt_worksWhenConscryptIsAvailable() { + assume().that(Conscrypt.isAvailable()).isTrue(); + assertThat(AesGcmAeadCrypter.getConscrypt()).isNotNull(); + } +} diff --git a/alts/src/test/java/io/grpc/alts/internal/AesGcmHkdfAeadCrypterTest.java b/alts/src/test/java/io/grpc/alts/internal/AesGcmHkdfAeadCrypterTest.java index d655a6e8358..06f2ff5365f 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AesGcmHkdfAeadCrypterTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AesGcmHkdfAeadCrypterTest.java @@ -117,7 +117,7 @@ public void testVectorEncrypt() throws GeneralSecurityException { ByteBuffer.wrap(testVector.plaintext), ByteBuffer.wrap(testVector.aad), testVector.nonce); - String msg = "Failure for test vector " + i; + String msg = "Failure for test vector " + i + " " + testVector.comment; assertWithMessage(msg) .that(ciphertextBuffer.remaining()) .isEqualTo(bufferSize - testVector.ciphertext.length); @@ -142,7 +142,7 @@ public void testVectorDecrypt() throws GeneralSecurityException { ByteBuffer.wrap(testVector.ciphertext), ByteBuffer.wrap(testVector.aad), testVector.nonce); - String msg = "Failure for test vector " + i; + String msg = "Failure for test vector " + i + " " + testVector.comment; assertWithMessage(msg) .that(plaintextBuffer.remaining()) .isEqualTo(bufferSize - testVector.plaintext.length); diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsAuthContextTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsAuthContextTest.java deleted file mode 100644 index 2fc2c43464a..00000000000 --- a/alts/src/test/java/io/grpc/alts/internal/AltsAuthContextTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.alts.internal; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Unit tests for {@link AltsAuthContext}. */ -@RunWith(JUnit4.class) -public final class AltsAuthContextTest { - private static final int TEST_MAX_RPC_VERSION_MAJOR = 3; - private static final int TEST_MAX_RPC_VERSION_MINOR = 5; - private static final int TEST_MIN_RPC_VERSION_MAJOR = 2; - private static final int TEST_MIN_RPC_VERSION_MINOR = 1; - private static final SecurityLevel TEST_SECURITY_LEVEL = SecurityLevel.INTEGRITY_AND_PRIVACY; - private static final String TEST_APPLICATION_PROTOCOL = "grpc"; - private static final String TEST_LOCAL_SERVICE_ACCOUNT = "local@gserviceaccount.com"; - private static final String TEST_PEER_SERVICE_ACCOUNT = "peer@gserviceaccount.com"; - private static final String TEST_RECORD_PROTOCOL = "ALTSRP_GCM_AES128"; - - private HandshakerResult handshakerResult; - private RpcProtocolVersions rpcVersions; - - @Before - public void setUp() { - rpcVersions = - RpcProtocolVersions.newBuilder() - .setMaxRpcVersion( - RpcProtocolVersions.Version.newBuilder() - .setMajor(TEST_MAX_RPC_VERSION_MAJOR) - .setMinor(TEST_MAX_RPC_VERSION_MINOR) - .build()) - .setMinRpcVersion( - RpcProtocolVersions.Version.newBuilder() - .setMajor(TEST_MIN_RPC_VERSION_MAJOR) - .setMinor(TEST_MIN_RPC_VERSION_MINOR) - .build()) - .build(); - handshakerResult = - HandshakerResult.newBuilder() - .setApplicationProtocol(TEST_APPLICATION_PROTOCOL) - .setRecordProtocol(TEST_RECORD_PROTOCOL) - .setPeerIdentity(Identity.newBuilder().setServiceAccount(TEST_PEER_SERVICE_ACCOUNT)) - .setLocalIdentity(Identity.newBuilder().setServiceAccount(TEST_LOCAL_SERVICE_ACCOUNT)) - .setPeerRpcVersions(rpcVersions) - .build(); - } - - @Test - public void testAltsAuthContext() { - AltsAuthContext authContext = new AltsAuthContext(handshakerResult); - assertEquals(TEST_APPLICATION_PROTOCOL, authContext.getApplicationProtocol()); - assertEquals(TEST_RECORD_PROTOCOL, authContext.getRecordProtocol()); - assertEquals(TEST_SECURITY_LEVEL, authContext.getSecurityLevel()); - assertEquals(TEST_PEER_SERVICE_ACCOUNT, authContext.getPeerServiceAccount()); - assertEquals(TEST_LOCAL_SERVICE_ACCOUNT, authContext.getLocalServiceAccount()); - assertEquals(rpcVersions, authContext.getPeerRpcVersions()); - } -} diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsClientOptionsTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsClientOptionsTest.java index 47d7fc79ea9..45fac0aa301 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsClientOptionsTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsClientOptionsTest.java @@ -49,7 +49,8 @@ public void setAndGet() throws Exception { .build(); assertThat(options.getTargetName()).isEqualTo(targetName); - assertThat(options.getTargetServiceAccounts()).containsAllOf(serviceAccount1, serviceAccount2); + assertThat(options.getTargetServiceAccounts()) + .containsAtLeast(serviceAccount1, serviceAccount2); assertThat(options.getRpcProtocolVersions()).isEqualTo(rpcVersions); } } diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsFramingTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsFramingTest.java index 5ad250e0621..a4703e052ee 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsFramingTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsFramingTest.java @@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.security.GeneralSecurityException; @@ -38,7 +39,7 @@ public void parserFrameLengthNegativeFails() throws GeneralSecurityException { buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(-1); // write invalid length buffer.put((byte) 0); // write some byte - buffer.flip(); + ((Buffer) buffer).flip(); try { parser.readBytes(buffer); @@ -56,7 +57,7 @@ public void parserFrameLengthSmallerMessageTypeFails() throws GeneralSecurityExc buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(AltsFraming.getFrameMessageTypeHeaderSize() - 1); // write invalid length buffer.put((byte) 0); // write some byte - buffer.flip(); + ((Buffer) buffer).flip(); try { parser.readBytes(buffer); @@ -74,7 +75,7 @@ public void parserFrameLengthTooLargeFails() throws GeneralSecurityException { buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(AltsFraming.getMaxDataLength() + 1); // write invalid length buffer.put((byte) 0); // write some byte - buffer.flip(); + ((Buffer) buffer).flip(); try { parser.readBytes(buffer); @@ -97,7 +98,7 @@ public void parserFrameLengthMaxOk() throws GeneralSecurityException { buffer.putInt(6); // default message type buffer.put(new byte[dataLength - AltsFraming.getFrameMessageTypeHeaderSize()]); // write data buffer.put((byte) 0); - buffer.flip(); + ((Buffer) buffer).flip(); parser.readBytes(buffer); @@ -116,7 +117,7 @@ public void parserFrameLengthZeroOk() throws GeneralSecurityException { buffer.putInt(dataLength); // write invalid length buffer.putInt(6); // default message type buffer.put((byte) 0); - buffer.flip(); + ((Buffer) buffer).flip(); parser.readBytes(buffer); diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerClientTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerClientTest.java index a8eb48ad261..5a41fc0fc4f 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerClientTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerClientTest.java @@ -29,6 +29,8 @@ import com.google.common.collect.ImmutableList; import com.google.protobuf.ByteString; +import io.grpc.internal.TestUtils.NoopChannelLogger; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import org.junit.Before; @@ -36,7 +38,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; /** Unit tests for {@link AltsHandshakerClient}. */ @RunWith(JUnit4.class) @@ -59,12 +61,13 @@ public void setUp() { .setTargetName(TEST_TARGET_NAME) .setTargetServiceAccounts(ImmutableList.of(TEST_TARGET_SERVICE_ACCOUNT)) .build(); - handshaker = new AltsHandshakerClient(mockStub, clientOptions); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + handshaker = new AltsHandshakerClient(mockStub, clientOptions, channelLogger); } @Test public void startClientHandshakeFailure() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getErrorResponse()); try { @@ -77,7 +80,7 @@ public void startClientHandshakeFailure() throws Exception { @Test public void startClientHandshakeSuccess() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(0)); ByteBuffer outFrame = handshaker.startClientHandshake(); @@ -90,7 +93,7 @@ public void startClientHandshakeSuccess() throws Exception { @Test public void startClientHandshakeWithOptions() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(0)); ByteBuffer outFrame = handshaker.startClientHandshake(); @@ -106,6 +109,7 @@ public void startClientHandshakeWithOptions() throws Exception { .setTargetName(TEST_TARGET_NAME) .addTargetIdentities( Identity.newBuilder().setServiceAccount(TEST_TARGET_SERVICE_ACCOUNT)) + .setMaxFrameSize(AltsTsiFrameProtector.getMaxFrameSize()) .build()) .build(); verify(mockStub).send(req); @@ -113,7 +117,7 @@ public void startClientHandshakeWithOptions() throws Exception { @Test public void startServerHandshakeFailure() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getErrorResponse()); try { @@ -127,12 +131,28 @@ public void startServerHandshakeFailure() throws Exception { @Test public void startServerHandshakeSuccess() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(BYTES_CONSUMED)); ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE); ByteBuffer outFrame = handshaker.startServerHandshake(inBytes); + HandshakerReq req = + HandshakerReq.newBuilder() + .setServerStart( + StartServerHandshakeReq.newBuilder() + .addApplicationProtocols(AltsHandshakerClient.getApplicationProtocol()) + .putHandshakeParameters( + HandshakeProtocol.ALTS.getNumber(), + ServerHandshakeParameters.newBuilder() + .addRecordProtocols(AltsHandshakerClient.getRecordProtocol()) + .build()) + .setInBytes(ByteString.copyFrom(ByteBuffer.allocate(IN_BYTES_SIZE))) + .setMaxFrameSize(AltsTsiFrameProtector.getMaxFrameSize()) + .build()) + .build(); + verify(mockStub).send(req); + assertEquals(ByteString.copyFrom(outFrame), MockAltsHandshakerResp.getOutFrame()); assertFalse(handshaker.isFinished()); assertNull(handshaker.getResult()); @@ -142,7 +162,7 @@ public void startServerHandshakeSuccess() throws Exception { @Test public void startServerHandshakeEmptyOutFrame() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getEmptyOutFrameResponse(BYTES_CONSUMED)); ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE); @@ -157,11 +177,11 @@ public void startServerHandshakeEmptyOutFrame() throws Exception { @Test public void startServerHandshakeWithPrefixBuffer() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(BYTES_CONSUMED)); ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE); - inBytes.position(PREFIX_POSITION); + ((Buffer) inBytes).position(PREFIX_POSITION); ByteBuffer outFrame = handshaker.startServerHandshake(inBytes); assertEquals(ByteString.copyFrom(outFrame), MockAltsHandshakerResp.getOutFrame()); @@ -174,7 +194,7 @@ public void startServerHandshakeWithPrefixBuffer() throws Exception { @Test public void nextFailure() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getErrorResponse()); try { @@ -188,7 +208,7 @@ public void nextFailure() throws Exception { @Test public void nextSuccess() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(BYTES_CONSUMED)); ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE); @@ -203,7 +223,7 @@ public void nextSuccess() throws Exception { @Test public void nextEmptyOutFrame() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getEmptyOutFrameResponse(BYTES_CONSUMED)); ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE); @@ -218,7 +238,7 @@ public void nextEmptyOutFrame() throws Exception { @Test public void nextFinished() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getFinishedResponse(BYTES_CONSUMED)); ByteBuffer inBytes = ByteBuffer.allocate(IN_BYTES_SIZE); @@ -232,7 +252,7 @@ public void nextFinished() throws Exception { @Test public void setRpcVersions() throws Exception { - when(mockStub.send(Matchers.any())) + when(mockStub.send(ArgumentMatchers.any())) .thenReturn(MockAltsHandshakerResp.getOkResponse(0)); RpcProtocolVersions rpcVersions = @@ -248,7 +268,8 @@ public void setRpcVersions() throws Exception { .setTargetServiceAccounts(ImmutableList.of(TEST_TARGET_SERVICE_ACCOUNT)) .setRpcProtocolVersions(rpcVersions) .build(); - handshaker = new AltsHandshakerClient(mockStub, clientOptions); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + handshaker = new AltsHandshakerClient(mockStub, clientOptions, channelLogger); handshaker.startClientHandshake(); diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerStubTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerStubTest.java index 2267a765a90..7a6018b5064 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerStubTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsHandshakerStubTest.java @@ -32,7 +32,7 @@ @RunWith(JUnit4.class) public class AltsHandshakerStubTest { /** Mock status of handshaker service. */ - private static enum Status { + private enum Status { OK, ERROR, COMPLETE @@ -68,6 +68,7 @@ private void sendAndExpectError() throws InterruptedException { fail("Exception expected"); } catch (IOException ex) { assertThat(ex).hasMessageThat().contains("Received a terminating error"); + assertThat(ex.getCause()).hasMessageThat().contains("Root cause message"); } } @@ -152,7 +153,7 @@ public void onNext(final HandshakerReq req) { reader.onNext(resp.setOutFrames(req.getNext().getInBytes()).build()); break; case ERROR: - reader.onError(new RuntimeException()); + reader.onError(new RuntimeException("Root cause message")); break; case COMPLETE: reader.onCompleted(); diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsInternalContextTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsInternalContextTest.java new file mode 100644 index 00000000000..87898a3300b --- /dev/null +++ b/alts/src/test/java/io/grpc/alts/internal/AltsInternalContextTest.java @@ -0,0 +1,90 @@ +/* + * Copyright 2018 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.alts.internal; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link AltsInternalContext}. */ +@RunWith(JUnit4.class) +public final class AltsInternalContextTest { + private static final int TEST_MAX_RPC_VERSION_MAJOR = 3; + private static final int TEST_MAX_RPC_VERSION_MINOR = 5; + private static final int TEST_MIN_RPC_VERSION_MAJOR = 2; + private static final int TEST_MIN_RPC_VERSION_MINOR = 1; + private static final SecurityLevel TEST_SECURITY_LEVEL = SecurityLevel.INTEGRITY_AND_PRIVACY; + private static final String TEST_APPLICATION_PROTOCOL = "grpc"; + private static final String TEST_LOCAL_SERVICE_ACCOUNT = "local@gserviceaccount.com"; + private static final String TEST_PEER_SERVICE_ACCOUNT = "peer@gserviceaccount.com"; + private static final String TEST_RECORD_PROTOCOL = "ALTSRP_GCM_AES128"; + private static final String TEST_PEER_ATTRIBUTES_KEY = "peer"; + private static final String TEST_PEER_ATTRIBUTES_VALUE = "attributes"; + + private Map testPeerAttributes; + private HandshakerResult handshakerResult; + private RpcProtocolVersions rpcVersions; + + @Before + public void setUp() { + testPeerAttributes = new HashMap(); + testPeerAttributes.put(TEST_PEER_ATTRIBUTES_KEY, TEST_PEER_ATTRIBUTES_VALUE); + rpcVersions = + RpcProtocolVersions.newBuilder() + .setMaxRpcVersion( + RpcProtocolVersions.Version.newBuilder() + .setMajor(TEST_MAX_RPC_VERSION_MAJOR) + .setMinor(TEST_MAX_RPC_VERSION_MINOR) + .build()) + .setMinRpcVersion( + RpcProtocolVersions.Version.newBuilder() + .setMajor(TEST_MIN_RPC_VERSION_MAJOR) + .setMinor(TEST_MIN_RPC_VERSION_MINOR) + .build()) + .build(); + Identity.Builder peerIdentity = Identity.newBuilder() + .setServiceAccount(TEST_PEER_SERVICE_ACCOUNT); + peerIdentity.putAllAttributes(testPeerAttributes); + handshakerResult = + HandshakerResult.newBuilder() + .setApplicationProtocol(TEST_APPLICATION_PROTOCOL) + .setRecordProtocol(TEST_RECORD_PROTOCOL) + .setPeerIdentity(peerIdentity) + .setLocalIdentity(Identity.newBuilder().setServiceAccount(TEST_LOCAL_SERVICE_ACCOUNT)) + .setPeerRpcVersions(rpcVersions) + .build(); + } + + @Test + public void testAltsInternalContext() { + AltsInternalContext context = new AltsInternalContext(handshakerResult); + assertEquals(TEST_APPLICATION_PROTOCOL, context.getApplicationProtocol()); + assertEquals(TEST_RECORD_PROTOCOL, context.getRecordProtocol()); + assertEquals(TEST_SECURITY_LEVEL, context.getSecurityLevel()); + assertEquals(TEST_PEER_SERVICE_ACCOUNT, context.getPeerServiceAccount()); + assertEquals(TEST_LOCAL_SERVICE_ACCOUNT, context.getLocalServiceAccount()); + assertEquals(rpcVersions, context.getPeerRpcVersions()); + assertEquals(testPeerAttributes, context.getPeerAttributes()); + assertEquals(TEST_PEER_ATTRIBUTES_VALUE, context.getPeerAttributes() + .get(TEST_PEER_ATTRIBUTES_KEY)); + } +} diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java index bc5193665c6..d47607ed90f 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsProtocolNegotiatorTest.java @@ -16,6 +16,7 @@ package io.grpc.alts.internal; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Truth.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; @@ -24,13 +25,23 @@ import static org.junit.Assert.assertTrue; import io.grpc.Attributes; -import io.grpc.CallCredentials; +import io.grpc.Channel; +import io.grpc.ChannelLogger; import io.grpc.Grpc; import io.grpc.InternalChannelz; +import io.grpc.ManagedChannel; import io.grpc.SecurityLevel; +import io.grpc.alts.internal.AltsProtocolNegotiator.LazyChannel; +import io.grpc.alts.internal.AltsProtocolNegotiator.ServerAltsProtocolNegotiator; import io.grpc.alts.internal.TsiFrameProtector.Consumer; import io.grpc.alts.internal.TsiPeer.Property; +import io.grpc.internal.FixedObjectPool; +import io.grpc.internal.GrpcAttributes; +import io.grpc.internal.ObjectPool; +import io.grpc.internal.TestUtils.NoopChannelLogger; import io.grpc.netty.GrpcHttp2ConnectionHandler; +import io.grpc.netty.InternalProtocolNegotiationEvent; +import io.grpc.netty.NettyChannelBuilder; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.CompositeByteBuf; @@ -40,6 +51,7 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.http2.DefaultHttp2Connection; @@ -74,6 +86,7 @@ /** Tests for {@link AltsProtocolNegotiator}. */ @RunWith(JUnit4.class) +@SuppressWarnings("FutureReturnValueIgnored") public class AltsProtocolNegotiatorTest { private final CapturingGrpcHttp2ConnectionHandler grpcHandler = capturingGrpcHandler(); @@ -84,24 +97,21 @@ public class AltsProtocolNegotiatorTest { private EmbeddedChannel channel; private Throwable caughtException; - private volatile TsiHandshakeHandler.TsiHandshakeCompletionEvent tsiEvent; - private ChannelHandler handler; - private TsiPeer mockedTsiPeer = new TsiPeer(Collections.>emptyList()); - private AltsAuthContext mockedAltsContext = - new AltsAuthContext( + private AltsInternalContext mockedAltsContext = + new AltsInternalContext( HandshakerResult.newBuilder() .setPeerRpcVersions(RpcProtocolVersionsUtil.getRpcProtocolVersions()) .build()); private final TsiHandshaker mockHandshaker = new DelegatingTsiHandshaker(FakeTsiHandshaker.newFakeHandshakerServer()) { @Override - public TsiPeer extractPeer() throws GeneralSecurityException { + public TsiPeer extractPeer() { return mockedTsiPeer; } @Override - public Object extractPeerObject() throws GeneralSecurityException { + public Object extractPeerObject() { return mockedAltsContext; } }; @@ -109,32 +119,21 @@ public Object extractPeerObject() throws GeneralSecurityException { @Before public void setup() throws Exception { - ChannelHandler userEventHandler = - new ChannelDuplexHandler() { - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { - if (evt instanceof TsiHandshakeHandler.TsiHandshakeCompletionEvent) { - tsiEvent = (TsiHandshakeHandler.TsiHandshakeCompletionEvent) evt; - } else { - super.userEventTriggered(ctx, evt); - } - } - }; - ChannelHandler uncaughtExceptionHandler = new ChannelDuplexHandler() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { caughtException = cause; super.exceptionCaught(ctx, cause); + ctx.close(); } }; TsiHandshakerFactory handshakerFactory = new DelegatingTsiHandshakerFactory(FakeTsiHandshaker.clientHandshakerFactory()) { @Override - public TsiHandshaker newHandshaker(String authority) { - return new DelegatingTsiHandshaker(super.newHandshaker(authority)) { + public TsiHandshaker newHandshaker(String authority, ChannelLogger logger) { + return new DelegatingTsiHandshaker(super.newHandshaker(authority, logger)) { @Override public TsiPeer extractPeer() throws GeneralSecurityException { return mockedTsiPeer; @@ -147,9 +146,15 @@ public Object extractPeerObject() throws GeneralSecurityException { }; } }; - handler = - AltsProtocolNegotiator.createServerNegotiator(handshakerFactory).newHandler(grpcHandler); - channel = new EmbeddedChannel(uncaughtExceptionHandler, handler, userEventHandler); + ManagedChannel fakeChannel = NettyChannelBuilder.forTarget("localhost:8080").build(); + ObjectPool fakeChannelPool = new FixedObjectPool(fakeChannel); + LazyChannel lazyFakeChannel = new LazyChannel(fakeChannelPool); + ChannelHandler altsServerHandler = new ServerAltsProtocolNegotiator( + handshakerFactory, lazyFakeChannel) + .newHandler(grpcHandler); + // On real server, WBAEH fires default ProtocolNegotiationEvent. KickNH provides this behavior. + ChannelHandler handler = new KickNegotiationHandler(altsServerHandler); + channel = new EmbeddedChannel(uncaughtExceptionHandler, handler); } @After @@ -172,6 +177,8 @@ public void handshakeShouldBeSuccessful() throws Exception { @Test @SuppressWarnings("unchecked") // List cast public void protectShouldRoundtrip() throws Exception { + doHandshake(); + // Write the message 1 character at a time. The message should be buffered // and not interfere with the handshake. final AtomicInteger writeCount = new AtomicInteger(); @@ -194,13 +201,12 @@ public void operationComplete(ChannelFuture future) throws Exception { } channel.flush(); - // Now do the handshake. The buffered message will automatically be protected - // and sent. - doHandshake(); - // Capture the protected data written to the wire. - assertEquals(1, channel.outboundMessages().size()); - ByteBuf protectedData = channel.readOutbound(); + assertThat(channel.outboundMessages()).isNotEmpty(); + ByteBuf protectedData = channel.alloc().buffer(); + while (!channel.outboundMessages().isEmpty()) { + protectedData.writeBytes((ByteBuf) channel.readOutbound()); + } assertEquals(message.length(), writeCount.get()); // Read the protected message at the server and verify it matches the original message. @@ -266,7 +272,7 @@ public void accept(ByteBuf buf) { // Read the protected message at the client and verify that it matches the original message. assertEquals(1, channel.inboundMessages().size()); - ByteBuf receivedData1 = channel.readInbound(); + ByteBuf receivedData1 = channel.readInbound(); int receivedLen1 = receivedData1.readableBytes(); byte[] receivedBytes = new byte[receivedLen1]; receivedData1.readBytes(receivedBytes, 0, receivedLen1); @@ -324,38 +330,62 @@ public void doNotFlushEmptyBuffer() throws Exception { String message = "hello"; ByteBuf in = Unpooled.copiedBuffer(message, UTF_8); - assertEquals(0, protector.flushes.get()); + int flushes = protector.flushes.get(); Future done = channel.write(in); channel.flush(); + flushes++; done.get(5, TimeUnit.SECONDS); - assertEquals(1, protector.flushes.get()); + assertEquals(flushes, protector.flushes.get()); + // Flush does not propagate done = channel.write(Unpooled.EMPTY_BUFFER); channel.flush(); done.get(5, TimeUnit.SECONDS); - assertEquals(1, protector.flushes.get()); + assertEquals(flushes, protector.flushes.get()); } @Test public void peerPropagated() throws Exception { doHandshake(); - assertThat(grpcHandler.attrs.get(AltsProtocolNegotiator.TSI_PEER_KEY)) - .isEqualTo(mockedTsiPeer); - assertThat(grpcHandler.attrs.get(AltsProtocolNegotiator.ALTS_CONTEXT_KEY)) + assertThat(grpcHandler.attrs.get(AltsProtocolNegotiator.TSI_PEER_KEY)).isEqualTo(mockedTsiPeer); + assertThat(grpcHandler.attrs.get(AltsProtocolNegotiator.AUTH_CONTEXT_KEY)) .isEqualTo(mockedAltsContext); assertThat(grpcHandler.attrs.get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR).toString()) .isEqualTo("embedded"); assertThat(grpcHandler.attrs.get(Grpc.TRANSPORT_ATTR_LOCAL_ADDR).toString()) .isEqualTo("embedded"); - assertThat(grpcHandler.attrs.get(CallCredentials.ATTR_SECURITY_LEVEL)) + assertThat(grpcHandler.attrs.get(GrpcAttributes.ATTR_SECURITY_LEVEL)) .isEqualTo(SecurityLevel.PRIVACY_AND_INTEGRITY); } + @Test + public void getAltsMaxConcurrentHandshakes_success() throws Exception { + assertThat(AltsProtocolNegotiator.getAltsMaxConcurrentHandshakes("10")).isEqualTo(10); + } + + @Test + public void getAltsMaxConcurrentHandshakes_envVariableNotSet() throws Exception { + assertThat(AltsProtocolNegotiator.getAltsMaxConcurrentHandshakes(null)) + .isEqualTo(AltsProtocolNegotiator.DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES); + } + + @Test + public void getAltsMaxConcurrentHandshakes_envVariableNotANumber() throws Exception { + assertThat(AltsProtocolNegotiator.getAltsMaxConcurrentHandshakes("not-a-number")) + .isEqualTo(AltsProtocolNegotiator.DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES); + } + + @Test + public void getAltsMaxConcurrentHandshakes_envVariableNegative() throws Exception { + assertThat(AltsProtocolNegotiator.getAltsMaxConcurrentHandshakes("-10")) + .isEqualTo(AltsProtocolNegotiator.DEFAULT_ALTS_MAX_CONCURRENT_HANDSHAKES); + } + private void doHandshake() throws Exception { // Capture the client frame and add to the server. assertEquals(1, channel.outboundMessages().size()); - ByteBuf clientFrame = channel.readOutbound(); + ByteBuf clientFrame = channel.readOutbound(); assertTrue(serverHandshaker.processBytesFromPeer(clientFrame)); // Get the server response handshake frames. @@ -365,7 +395,7 @@ private void doHandshake() throws Exception { // Capture the next client frame and add to the server. assertEquals(1, channel.outboundMessages().size()); - clientFrame = channel.readOutbound(); + clientFrame = channel.readOutbound(); assertTrue(serverHandshaker.processBytesFromPeer(clientFrame)); // Get the server response handshake frames. @@ -379,12 +409,12 @@ private void doHandshake() throws Exception { if (caughtException != null) { throw new RuntimeException(caughtException); } - assertNotNull(tsiEvent); + assertNotNull(grpcHandler.attrs); } private CapturingGrpcHttp2ConnectionHandler capturingGrpcHandler() { // Netty Boilerplate. We don't really need any of this, but there is a tight coupling - // between a Http2ConnectionHandler and its dependencies. + // between an Http2ConnectionHandler and its dependencies. Http2Connection connection = new DefaultHttp2Connection(true); Http2FrameWriter frameWriter = new DefaultHttp2FrameWriter(); Http2FrameReader frameReader = new DefaultHttp2FrameReader(false); @@ -404,12 +434,13 @@ private CapturingGrpcHttp2ConnectionHandler( Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder, Http2Settings initialSettings) { - super(null, decoder, encoder, initialSettings); + super(null, decoder, encoder, initialSettings, new NoopChannelLogger()); } @Override public void handleProtocolNegotiationCompleted( - Attributes attrs, InternalChannelz.Security securityInfo) { + Attributes attrs, + @SuppressWarnings("UnusedVariable") InternalChannelz.Security securityInfo) { // If we are added to the pipeline, we need to remove ourselves. The HTTP2 handler channel.pipeline().remove(this); this.attrs = attrs; @@ -425,8 +456,8 @@ private static class DelegatingTsiHandshakerFactory implements TsiHandshakerFact } @Override - public TsiHandshaker newHandshaker(String authority) { - return delegate.newHandshaker(authority); + public TsiHandshaker newHandshaker(String authority, ChannelLogger logger) { + return delegate.newHandshaker(authority, logger); } } @@ -478,6 +509,11 @@ public TsiFrameProtector createFrameProtector(int maxFrameSize, ByteBufAllocator protectors.add(protector); return protector; } + + @Override + public void close() { + delegate.close(); + } } private static class InterceptingProtector implements TsiFrameProtector { @@ -508,4 +544,21 @@ public void destroy() { delegate.destroy(); } } + + /** Kicks off negotiation of the server. */ + private static final class KickNegotiationHandler extends ChannelInboundHandlerAdapter { + + private final ChannelHandler next; + + KickNegotiationHandler(ChannelHandler next) { + this.next = checkNotNull(next, "next"); + } + + @Override + public void handlerAdded(ChannelHandlerContext ctx) throws Exception { + super.handlerAdded(ctx); + ctx.pipeline().replace(ctx.name(), /*newName= */ null, next); + ctx.pipeline().fireUserEventTriggered(InternalProtocolNegotiationEvent.getDefault()); + } + } } diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsTsiFrameProtectorTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsTsiFrameProtectorTest.java index 4405a99eff0..cbda9dbcdc0 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsTsiFrameProtectorTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsTsiFrameProtectorTest.java @@ -125,7 +125,7 @@ public void parserHeader_frameTooLarge() throws GeneralSecurityException { getDirectBuffer( AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref); in.writeIntLE( - AltsTsiFrameProtector.getLimitMaxAllowedFrameBytes() + AltsTsiFrameProtector.getLimitMaxAllowedFrameSize() - AltsTsiFrameProtector.getHeaderLenFieldBytes() + 1); in.writeIntLE(6); @@ -206,7 +206,7 @@ public void parserHeader_frameMaxOk() throws GeneralSecurityException { getDirectBuffer( AltsTsiFrameProtector.getHeaderBytes() + FakeChannelCrypter.getTagBytes(), ref); in.writeIntLE( - AltsTsiFrameProtector.getLimitMaxAllowedFrameBytes() + AltsTsiFrameProtector.getLimitMaxAllowedFrameSize() - AltsTsiFrameProtector.getHeaderLenFieldBytes()); in.writeIntLE(6); diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsTsiHandshakerTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsTsiHandshakerTest.java index 627e52a6dbc..ae1696401be 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsTsiHandshakerTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsTsiHandshakerTest.java @@ -26,12 +26,14 @@ import static org.mockito.Mockito.when; import com.google.protobuf.ByteString; +import io.grpc.internal.TestUtils.NoopChannelLogger; +import java.nio.Buffer; import java.nio.ByteBuffer; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; /** Unit tests for {@link AltsTsiHandshaker}. */ @RunWith(JUnit4.class) @@ -70,8 +72,9 @@ public class AltsTsiHandshakerTest { public void setUp() throws Exception { mockClient = mock(AltsHandshakerClient.class); mockServer = mock(AltsHandshakerClient.class); - handshakerClient = new AltsTsiHandshaker(true, mockClient); - handshakerServer = new AltsTsiHandshaker(false, mockServer); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + handshakerClient = new AltsTsiHandshaker(true, mockClient, channelLogger); + handshakerServer = new AltsTsiHandshaker(false, mockServer, channelLogger); } private HandshakerResult getHandshakerResult(boolean isClient) { @@ -98,8 +101,8 @@ private HandshakerResult getHandshakerResult(boolean isClient) { @Test public void processBytesFromPeerFalseStart() throws Exception { verify(mockClient, never()).startClientHandshake(); - verify(mockClient, never()).startServerHandshake(Matchers.any()); - verify(mockClient, never()).next(Matchers.any()); + verify(mockClient, never()).startServerHandshake(ArgumentMatchers.any()); + verify(mockClient, never()).next(ArgumentMatchers.any()); ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); assertTrue(handshakerClient.processBytesFromPeer(transportBuffer)); @@ -110,9 +113,9 @@ public void processBytesFromPeerStartServer() throws Exception { ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); ByteBuffer outputFrame = ByteBuffer.allocate(OUT_FRAME_SIZE); verify(mockServer, never()).startClientHandshake(); - verify(mockServer, never()).next(Matchers.any()); + verify(mockServer, never()).next(ArgumentMatchers.any()); // Mock transport buffer all consumed by processBytesFromPeer and there is an output frame. - transportBuffer.position(transportBuffer.limit()); + ((Buffer) transportBuffer).position(transportBuffer.limit()); when(mockServer.startServerHandshake(transportBuffer)).thenReturn(outputFrame); when(mockServer.isFinished()).thenReturn(false); @@ -124,10 +127,10 @@ public void processBytesFromPeerStartServerEmptyOutput() throws Exception { ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); ByteBuffer emptyOutputFrame = ByteBuffer.allocate(0); verify(mockServer, never()).startClientHandshake(); - verify(mockServer, never()).next(Matchers.any()); + verify(mockServer, never()).next(ArgumentMatchers.any()); // Mock transport buffer all consumed by processBytesFromPeer and output frame is empty. // Expect processBytesFromPeer return False, because more data are needed from the peer. - transportBuffer.position(transportBuffer.limit()); + ((Buffer) transportBuffer).position(transportBuffer.limit()); when(mockServer.startServerHandshake(transportBuffer)).thenReturn(emptyOutputFrame); when(mockServer.isFinished()).thenReturn(false); @@ -139,7 +142,7 @@ public void processBytesFromPeerStartServerFinished() throws Exception { ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); ByteBuffer outputFrame = ByteBuffer.allocate(OUT_FRAME_SIZE); verify(mockServer, never()).startClientHandshake(); - verify(mockServer, never()).next(Matchers.any()); + verify(mockServer, never()).next(ArgumentMatchers.any()); // Mock handshake complete after processBytesFromPeer. when(mockServer.startServerHandshake(transportBuffer)).thenReturn(outputFrame); when(mockServer.isFinished()).thenReturn(true); @@ -152,7 +155,7 @@ public void processBytesFromPeerNoBytesConsumed() throws Exception { ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); ByteBuffer emptyOutputFrame = ByteBuffer.allocate(0); verify(mockServer, never()).startClientHandshake(); - verify(mockServer, never()).next(Matchers.any()); + verify(mockServer, never()).next(ArgumentMatchers.any()); when(mockServer.startServerHandshake(transportBuffer)).thenReturn(emptyOutputFrame); when(mockServer.isFinished()).thenReturn(false); @@ -168,13 +171,13 @@ public void processBytesFromPeerNoBytesConsumed() throws Exception { public void processBytesFromPeerClientNext() throws Exception { ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); ByteBuffer outputFrame = ByteBuffer.allocate(OUT_FRAME_SIZE); - verify(mockClient, never()).startServerHandshake(Matchers.any()); + verify(mockClient, never()).startServerHandshake(ArgumentMatchers.any()); when(mockClient.startClientHandshake()).thenReturn(outputFrame); when(mockClient.next(transportBuffer)).thenReturn(outputFrame); when(mockClient.isFinished()).thenReturn(false); handshakerClient.getBytesToSendToPeer(transportBuffer); - transportBuffer.position(transportBuffer.limit()); + ((Buffer) transportBuffer).position(transportBuffer.limit()); assertFalse(handshakerClient.processBytesFromPeer(transportBuffer)); } @@ -182,7 +185,7 @@ public void processBytesFromPeerClientNext() throws Exception { public void processBytesFromPeerClientNextFinished() throws Exception { ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); ByteBuffer outputFrame = ByteBuffer.allocate(OUT_FRAME_SIZE); - verify(mockClient, never()).startServerHandshake(Matchers.any()); + verify(mockClient, never()).startServerHandshake(ArgumentMatchers.any()); when(mockClient.startClientHandshake()).thenReturn(outputFrame); when(mockClient.next(transportBuffer)).thenReturn(outputFrame); when(mockClient.isFinished()).thenReturn(true); @@ -231,7 +234,7 @@ public void extractClientPeerSuccess() throws Exception { TEST_SERVER_SERVICE_ACCOUNT, clientPeer.getProperty(AltsTsiHandshaker.TSI_SERVICE_ACCOUNT_PEER_PROPERTY).getValue()); - AltsAuthContext clientContext = (AltsAuthContext) handshakerClient.extractPeerObject(); + AltsInternalContext clientContext = (AltsInternalContext) handshakerClient.extractPeerObject(); assertEquals(TEST_APPLICATION_PROTOCOL, clientContext.getApplicationProtocol()); assertEquals(TEST_RECORD_PROTOCOL, clientContext.getRecordProtocol()); assertEquals(TEST_SERVER_SERVICE_ACCOUNT, clientContext.getPeerServiceAccount()); @@ -243,7 +246,8 @@ public void extractClientPeerSuccess() throws Exception { public void extractServerPeerSuccess() throws Exception { ByteBuffer outputFrame = ByteBuffer.allocate(OUT_FRAME_SIZE); ByteBuffer transportBuffer = ByteBuffer.allocate(TRANSPORT_BUFFER_SIZE); - when(mockServer.startServerHandshake(Matchers.any())).thenReturn(outputFrame); + when(mockServer.startServerHandshake(ArgumentMatchers.any())) + .thenReturn(outputFrame); when(mockServer.isFinished()).thenReturn(true); when(mockServer.getResult()).thenReturn(getHandshakerResult(/* isClient = */ false)); @@ -256,7 +260,7 @@ public void extractServerPeerSuccess() throws Exception { TEST_CLIENT_SERVICE_ACCOUNT, serverPeer.getProperty(AltsTsiHandshaker.TSI_SERVICE_ACCOUNT_PEER_PROPERTY).getValue()); - AltsAuthContext serverContext = (AltsAuthContext) handshakerServer.extractPeerObject(); + AltsInternalContext serverContext = (AltsInternalContext) handshakerServer.extractPeerObject(); assertEquals(TEST_APPLICATION_PROTOCOL, serverContext.getApplicationProtocol()); assertEquals(TEST_RECORD_PROTOCOL, serverContext.getRecordProtocol()); assertEquals(TEST_CLIENT_SERVICE_ACCOUNT, serverContext.getPeerServiceAccount()); diff --git a/alts/src/test/java/io/grpc/alts/internal/AltsTsiTest.java b/alts/src/test/java/io/grpc/alts/internal/AltsTsiTest.java index a6832ad8de2..cb39abb9ddc 100644 --- a/alts/src/test/java/io/grpc/alts/internal/AltsTsiTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/AltsTsiTest.java @@ -21,6 +21,7 @@ import com.google.common.testing.GcFinalization; import io.grpc.alts.internal.ByteBufTestUtils.RegisterRef; import io.grpc.alts.internal.TsiTest.Handshakers; +import io.grpc.internal.TestUtils.NoopChannelLogger; import io.netty.buffer.ByteBuf; import io.netty.util.ReferenceCounted; import io.netty.util.ResourceLeakDetector; @@ -61,8 +62,9 @@ public void setUp() throws Exception { AltsHandshakerOptions handshakerOptions = new AltsHandshakerOptions(null); MockAltsHandshakerStub clientStub = new MockAltsHandshakerStub(); MockAltsHandshakerStub serverStub = new MockAltsHandshakerStub(); - client = new AltsHandshakerClient(clientStub, handshakerOptions); - server = new AltsHandshakerClient(serverStub, handshakerOptions); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + client = new AltsHandshakerClient(clientStub, handshakerOptions, channelLogger); + server = new AltsHandshakerClient(serverStub, handshakerOptions, channelLogger); } @After @@ -76,8 +78,9 @@ public void tearDown() { } private Handshakers newHandshakers() { - TsiHandshaker clientHandshaker = new AltsTsiHandshaker(true, client); - TsiHandshaker serverHandshaker = new AltsTsiHandshaker(false, server); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + TsiHandshaker clientHandshaker = new AltsTsiHandshaker(true, client, channelLogger); + TsiHandshaker serverHandshaker = new AltsTsiHandshaker(false, server, channelLogger); return new Handshakers(clientHandshaker, serverHandshaker); } diff --git a/alts/src/test/java/io/grpc/alts/internal/ChannelCrypterNettyTestBase.java b/alts/src/test/java/io/grpc/alts/internal/ChannelCrypterNettyTestBase.java index 6de3c59671c..cab0765e7d7 100644 --- a/alts/src/test/java/io/grpc/alts/internal/ChannelCrypterNettyTestBase.java +++ b/alts/src/test/java/io/grpc/alts/internal/ChannelCrypterNettyTestBase.java @@ -35,7 +35,7 @@ /** Abstract class for unit tests of {@link ChannelCrypterNetty}. */ public abstract class ChannelCrypterNettyTestBase { - private static final String DECRYPTION_FAILURE_MESSAGE = "Tag mismatch"; + private static final String DECRYPTION_FAILURE_MESSAGE_RE = "Tag mismatch|BAD_DECRYPT"; protected final List references = new ArrayList<>(); public ChannelCrypterNetty client; @@ -169,7 +169,7 @@ public void reflection() throws GeneralSecurityException { client.decrypt(frameDecrypt.out, frameDecrypt.tag, frameDecrypt.ciphertext); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_MESSAGE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_MESSAGE_RE); } } @@ -186,7 +186,7 @@ public void skipMessage() throws GeneralSecurityException { client.decrypt(frameDecrypt.out, frameDecrypt.tag, frameDecrypt.ciphertext); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_MESSAGE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_MESSAGE_RE); } } @@ -202,7 +202,7 @@ public void corruptMessage() throws GeneralSecurityException { client.decrypt(frameDecrypt.out, frameDecrypt.tag, frameDecrypt.ciphertext); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_MESSAGE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_MESSAGE_RE); } } @@ -220,7 +220,7 @@ public void replayMessage() throws GeneralSecurityException { server.decrypt(frameDecrypt2.out, frameDecrypt2.tag, frameDecrypt2.ciphertext); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_MESSAGE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_MESSAGE_RE); } } } diff --git a/alts/src/test/java/io/grpc/alts/internal/FakeTsiHandshaker.java b/alts/src/test/java/io/grpc/alts/internal/FakeTsiHandshaker.java index d742607618a..7a6119dc0be 100644 --- a/alts/src/test/java/io/grpc/alts/internal/FakeTsiHandshaker.java +++ b/alts/src/test/java/io/grpc/alts/internal/FakeTsiHandshaker.java @@ -19,7 +19,9 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.Preconditions; +import io.grpc.ChannelLogger; import io.grpc.alts.internal.TsiPeer.Property; +import io.grpc.internal.TestUtils.NoopChannelLogger; import io.netty.buffer.ByteBufAllocator; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; @@ -37,7 +39,7 @@ public class FakeTsiHandshaker implements TsiHandshaker { private static final TsiHandshakerFactory clientHandshakerFactory = new TsiHandshakerFactory() { @Override - public TsiHandshaker newHandshaker(String authority) { + public TsiHandshaker newHandshaker(String authority, ChannelLogger logger) { return new FakeTsiHandshaker(true); } }; @@ -45,7 +47,7 @@ public TsiHandshaker newHandshaker(String authority) { private static final TsiHandshakerFactory serverHandshakerFactory = new TsiHandshakerFactory() { @Override - public TsiHandshaker newHandshaker(String authority) { + public TsiHandshaker newHandshaker(String authority, ChannelLogger logger) { return new FakeTsiHandshaker(false); } }; @@ -66,6 +68,7 @@ enum State { SERVER_FINISHED; // Returns the next State. In order to advance to sendState=N, receiveState must be N-1. + @SuppressWarnings("EnumOrdinal") public State next() { if (ordinal() + 1 < values().length) { return values()[ordinal() + 1]; @@ -83,11 +86,13 @@ public static TsiHandshakerFactory serverHandshakerFactory() { } public static TsiHandshaker newFakeHandshakerClient() { - return clientHandshakerFactory.newHandshaker(null); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + return clientHandshakerFactory.newHandshaker(null, channelLogger); } public static TsiHandshaker newFakeHandshakerServer() { - return serverHandshakerFactory.newHandshaker(null); + NoopChannelLogger channelLogger = new NoopChannelLogger(); + return serverHandshakerFactory.newHandshaker(null, channelLogger); } protected FakeTsiHandshaker(boolean isClient) { @@ -143,7 +148,7 @@ public void getBytesToSendToPeer(ByteBuffer bytes) throws GeneralSecurityExcepti return; } - // Prepare the next message, if neeeded. + // Prepare the next message, if needed. if (sendBuffer == null) { if (sendState.next() != receiveState) { // We're still waiting for bytes from the peer, so bail. @@ -210,7 +215,7 @@ public TsiPeer extractPeer() { @Override public Object extractPeerObject() { - return AltsAuthContext.getDefaultInstance(); + return AltsInternalContext.getDefaultInstance(); } @Override @@ -224,6 +229,11 @@ public TsiFrameProtector createFrameProtector(int maxFrameSize, ByteBufAllocator @Override public TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) { - return createFrameProtector(AltsTsiFrameProtector.getMaxAllowedFrameBytes(), alloc); + return createFrameProtector(AltsTsiFrameProtector.getMinFrameSize(), alloc); + } + + @Override + public void close() { + // No-op } } diff --git a/alts/src/test/java/io/grpc/alts/internal/FakeTsiTest.java b/alts/src/test/java/io/grpc/alts/internal/FakeTsiTest.java index cf7c3133e7b..f908160f958 100644 --- a/alts/src/test/java/io/grpc/alts/internal/FakeTsiTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/FakeTsiTest.java @@ -27,6 +27,7 @@ import io.netty.util.ReferenceCounted; import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector.Level; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import java.util.ArrayList; @@ -86,11 +87,11 @@ public void handshakeStateOrderTest() { byte[] transportBufferBytes = new byte[TsiTest.getDefaultTransportBufferSize()]; ByteBuffer transportBuffer = ByteBuffer.wrap(transportBufferBytes); - transportBuffer.limit(0); // Start off with an empty buffer + ((Buffer) transportBuffer).limit(0); // Start off with an empty buffer - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); clientHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertEquals( FakeTsiHandshaker.State.CLIENT_INIT.toString().trim(), new String(transportBufferBytes, 4, transportBuffer.remaining(), UTF_8).trim()); @@ -99,14 +100,14 @@ public void handshakeStateOrderTest() { assertFalse(transportBuffer.hasRemaining()); // client shouldn't offer any more bytes - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); clientHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertFalse(transportBuffer.hasRemaining()); - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); serverHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertEquals( FakeTsiHandshaker.State.SERVER_INIT.toString().trim(), new String(transportBufferBytes, 4, transportBuffer.remaining(), UTF_8).trim()); @@ -115,14 +116,14 @@ public void handshakeStateOrderTest() { assertFalse(transportBuffer.hasRemaining()); // server shouldn't offer any more bytes - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); serverHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertFalse(transportBuffer.hasRemaining()); - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); clientHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertEquals( FakeTsiHandshaker.State.CLIENT_FINISHED.toString().trim(), new String(transportBufferBytes, 4, transportBuffer.remaining(), UTF_8).trim()); @@ -131,14 +132,14 @@ public void handshakeStateOrderTest() { assertFalse(transportBuffer.hasRemaining()); // client shouldn't offer any more bytes - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); clientHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertFalse(transportBuffer.hasRemaining()); - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); serverHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertEquals( FakeTsiHandshaker.State.SERVER_FINISHED.toString().trim(), new String(transportBufferBytes, 4, transportBuffer.remaining(), UTF_8).trim()); @@ -147,9 +148,9 @@ public void handshakeStateOrderTest() { assertFalse(transportBuffer.hasRemaining()); // server shouldn't offer any more bytes - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); serverHandshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); assertFalse(transportBuffer.hasRemaining()); } catch (GeneralSecurityException e) { throw new AssertionError(e); diff --git a/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java b/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java index 74e342ece47..14c19e554ae 100644 --- a/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java @@ -16,54 +16,208 @@ package io.grpc.alts.internal; +import static com.google.common.truth.Truth.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import com.google.common.collect.ImmutableList; import io.grpc.Attributes; -import io.grpc.internal.GrpcAttributes; +import io.grpc.Channel; +import io.grpc.ChannelLogger; +import io.grpc.ChannelLogger.ChannelLogLevel; +import io.grpc.ManagedChannel; +import io.grpc.inprocess.InProcessChannelBuilder; +import io.grpc.internal.ObjectPool; import io.grpc.netty.GrpcHttp2ConnectionHandler; -import io.grpc.netty.ProtocolNegotiator; -import io.grpc.netty.ProtocolNegotiator.Handler; +import io.grpc.netty.GrpcSslContexts; +import io.grpc.netty.InternalProtocolNegotiationEvent; +import io.grpc.netty.InternalProtocolNegotiator.ProtocolNegotiator; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.handler.ssl.SslContext; +import java.util.concurrent.atomic.AtomicReference; +import javax.annotation.Nullable; +import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) +@RunWith(Enclosed.class) public final class GoogleDefaultProtocolNegotiatorTest { - private ProtocolNegotiator altsProtocolNegotiator; - private ProtocolNegotiator tlsProtocolNegotiator; - private GoogleDefaultProtocolNegotiator googleProtocolNegotiator; - - @Before - public void setUp() { - altsProtocolNegotiator = mock(ProtocolNegotiator.class); - tlsProtocolNegotiator = mock(ProtocolNegotiator.class); - googleProtocolNegotiator = - new GoogleDefaultProtocolNegotiator(altsProtocolNegotiator, tlsProtocolNegotiator); + + @RunWith(JUnit4.class) + public abstract static class HandlerSelectionTest { + private ProtocolNegotiator googleProtocolNegotiator; + private Attributes.Key originalClusterNameAttrKey; + private final ObjectPool handshakerChannelPool = new ObjectPool() { + + @Override + public Channel getObject() { + return InProcessChannelBuilder.forName("test").build(); + } + + @Override + public Channel returnObject(Object object) { + ((ManagedChannel) object).shutdownNow(); + return null; + } + }; + + @Before + public void setUp() throws Exception { + SslContext sslContext = GrpcSslContexts.forClient().build(); + originalClusterNameAttrKey = + AltsProtocolNegotiator.GoogleDefaultProtocolNegotiatorFactory.clusterNameAttrKey; + AltsProtocolNegotiator.GoogleDefaultProtocolNegotiatorFactory.clusterNameAttrKey = + getClusterNameAttrKey(); + googleProtocolNegotiator = new AltsProtocolNegotiator.GoogleDefaultProtocolNegotiatorFactory( + ImmutableList.of(), + handshakerChannelPool, + sslContext) + .newNegotiator(); + } + + @After + public void tearDown() { + googleProtocolNegotiator.close(); + AltsProtocolNegotiator.GoogleDefaultProtocolNegotiatorFactory.clusterNameAttrKey = + originalClusterNameAttrKey; + } + + @Nullable + abstract Attributes.Key getClusterNameAttrKey(); + + @Test + public void tlsHandler_emptyAttributes() { + subtest_tlsHandler(Attributes.EMPTY); + } + + void subtest_altsHandler(Attributes eagAttributes) { + GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); + when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); + ChannelLogger logger = mock(ChannelLogger.class); + doNothing().when(logger).log(any(ChannelLogLevel.class), anyString()); + when(mockHandler.getNegotiationLogger()).thenReturn(logger); + + final AtomicReference failure = new AtomicReference<>(); + ChannelHandler exceptionCaught = new ChannelInboundHandlerAdapter() { + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + failure.set(cause); + super.exceptionCaught(ctx, cause); + } + }; + ChannelHandler h = googleProtocolNegotiator.newHandler(mockHandler); + EmbeddedChannel chan = new EmbeddedChannel(exceptionCaught); + // Add the negotiator handler last, but to the front. Putting this in ctor above would make + // it throw early. + chan.pipeline().addFirst(h); + chan.pipeline().fireUserEventTriggered(InternalProtocolNegotiationEvent.getDefault()); + + // Check that the message complained about the ALTS code, rather than SSL. ALTS throws on + // being added, so it's hard to catch it at the right time to make this assertion. + assertThat(failure.get()).hasMessageThat().contains("TsiHandshakeHandler"); + } + + void subtest_tlsHandler(Attributes eagAttributes) { + GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); + when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); + when(mockHandler.getAuthority()).thenReturn("authority"); + ChannelLogger logger = mock(ChannelLogger.class); + doNothing().when(logger).log(any(ChannelLogLevel.class), anyString()); + when(mockHandler.getNegotiationLogger()).thenReturn(logger); + + ChannelHandler h = googleProtocolNegotiator.newHandler(mockHandler); + EmbeddedChannel chan = new EmbeddedChannel(h); + chan.pipeline().fireUserEventTriggered(InternalProtocolNegotiationEvent.getDefault()); + + assertThat(chan.pipeline().first().getClass().getSimpleName()).isEqualTo("SslHandler"); + } } - @Test - public void altsHandler() { - Attributes eagAttributes = - Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND, true).build(); - GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); - when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); - Handler handler = googleProtocolNegotiator.newHandler(mockHandler); - verify(altsProtocolNegotiator, times(1)).newHandler(mockHandler); - verify(tlsProtocolNegotiator, never()).newHandler(mockHandler); + @RunWith(JUnit4.class) + public static class WithoutXdsInClasspath extends HandlerSelectionTest { + + @Nullable + @Override + Attributes.Key getClusterNameAttrKey() { + return null; + } } - @Test - public void tlsHandler() { - Attributes eagAttributes = Attributes.EMPTY; - GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); - when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); - Handler handler = googleProtocolNegotiator.newHandler(mockHandler); - verify(altsProtocolNegotiator, never()).newHandler(mockHandler); - verify(tlsProtocolNegotiator, times(1)).newHandler(mockHandler); + @RunWith(JUnit4.class) + public static class WithXdsInClasspath extends HandlerSelectionTest { + // Same as io.grpc.xds.InternalXdsAttributes.ATTR_CLUSTER_NAME + private static final Attributes.Key XDS_CLUSTER_NAME_ATTR_KEY = + Attributes.Key.create("io.grpc.xds.InternalXdsAttributes.clusterName"); + + @Nullable + @Override + Attributes.Key getClusterNameAttrKey() { + return XDS_CLUSTER_NAME_ATTR_KEY; + } + + @Test + public void altsHandler_xdsCluster() { + Attributes attrs = + Attributes.newBuilder().set(XDS_CLUSTER_NAME_ATTR_KEY, "api.googleapis.com").build(); + subtest_altsHandler(attrs); + } + + @Test + public void tlsHandler_googleCfe() { + Attributes attrs = Attributes.newBuilder().set( + XDS_CLUSTER_NAME_ATTR_KEY, "google_cfe_api.googleapis.com").build(); + subtest_tlsHandler(attrs); + } + + @Test + public void altsHandler_googleCfe_federation() { + Attributes attrs = Attributes.newBuilder().set( + XDS_CLUSTER_NAME_ATTR_KEY, "xdstp1://").build(); + subtest_altsHandler(attrs); + } + + @Test + public void tlsHanlder_googleCfe() { + Attributes attrs = Attributes.newBuilder().set( + XDS_CLUSTER_NAME_ATTR_KEY, + "xdstp://traffic-director-c2p.xds.googleapis.com/" + + "envoy.config.cluster.v3.Cluster/google_cfe_example/apis") + .build(); + subtest_tlsHandler(attrs); + } + + @Test + public void altsHanlder_nonGoogleCfe_authorityNotMatch() { + Attributes attrs = Attributes.newBuilder().set( + XDS_CLUSTER_NAME_ATTR_KEY, + "//example.com/envoy.config.cluster.v3.Cluster/google_cfe_") + .build(); + subtest_altsHandler(attrs); + } + + @Test + public void altsHanlder_nonGoogleCfe_pathNotMatch() { + Attributes attrs = Attributes.newBuilder().set( + XDS_CLUSTER_NAME_ATTR_KEY, + "//traffic-director-c2p.xds.googleapis.com/envoy.config.cluster.v3.Cluster/google_gfe") + .build(); + subtest_altsHandler(attrs); + } + + @Test + public void altsHandler_googleCfe_invalidUri() { + Attributes attrs = Attributes.newBuilder().set( + XDS_CLUSTER_NAME_ATTR_KEY, "//").build(); + subtest_altsHandler(attrs); + } } } diff --git a/alts/src/test/java/io/grpc/alts/internal/MockAltsHandshakerResp.java b/alts/src/test/java/io/grpc/alts/internal/MockAltsHandshakerResp.java index 7843d681208..a21082be41f 100644 --- a/alts/src/test/java/io/grpc/alts/internal/MockAltsHandshakerResp.java +++ b/alts/src/test/java/io/grpc/alts/internal/MockAltsHandshakerResp.java @@ -20,6 +20,7 @@ import com.google.protobuf.ByteString; import io.grpc.Status; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.security.SecureRandom; @@ -62,7 +63,7 @@ static ByteString getOutFrame() { buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(frameSize); buffer.put(TEST_OUT_FRAME.getBytes(UTF_8)); - buffer.flip(); + ((Buffer) buffer).flip(); return ByteString.copyFrom(buffer); } diff --git a/alts/src/test/java/io/grpc/alts/internal/NettyTsiHandshakerTest.java b/alts/src/test/java/io/grpc/alts/internal/NettyTsiHandshakerTest.java index 2ef0ad20dd6..d71ff16f352 100644 --- a/alts/src/test/java/io/grpc/alts/internal/NettyTsiHandshakerTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/NettyTsiHandshakerTest.java @@ -146,7 +146,7 @@ public void handshakerMethodsMatch() { actualMethods.add(m.getName()); } - assertThat(actualMethods).containsAllIn(expectedMethods); + assertThat(actualMethods).containsAtLeastElementsIn(expectedMethods); } static void doHandshake( diff --git a/alts/src/test/java/io/grpc/alts/internal/TsiFrameHandlerTest.java b/alts/src/test/java/io/grpc/alts/internal/TsiFrameHandlerTest.java index efc1f57ba37..f9ed0fa4f97 100644 --- a/alts/src/test/java/io/grpc/alts/internal/TsiFrameHandlerTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/TsiFrameHandlerTest.java @@ -18,18 +18,16 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.Assert.fail; -import io.grpc.alts.internal.TsiFrameHandler.State; -import io.grpc.alts.internal.TsiHandshakeHandler.TsiHandshakeCompletionEvent; -import io.grpc.alts.internal.TsiPeer.Property; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.CharsetUtil; import java.security.GeneralSecurityException; -import java.util.ArrayList; import java.util.List; import org.junit.Rule; import org.junit.Test; @@ -46,32 +44,17 @@ public class TsiFrameHandlerTest { @Rule public final TestRule globalTimeout = new DisableOnDebug(Timeout.seconds(5)); - private final TsiFrameHandler tsiFrameHandler = new TsiFrameHandler(); + private final TsiFrameHandler tsiFrameHandler = new TsiFrameHandler(new IdentityFrameProtector()); private final EmbeddedChannel channel = new EmbeddedChannel(tsiFrameHandler); - @Test - public void writeAndFlush_beforeHandshakeEventShouldBeIgnored() { - ByteBuf msg = Unpooled.copiedBuffer("message before handshake finished", CharsetUtil.UTF_8); - - channel.writeAndFlush(msg); - - assertThat(channel.outboundMessages()).isEmpty(); - try { - channel.checkException(); - fail(); - } catch (IllegalStateException e) { - assertThat(e).hasMessageThat().contains(State.HANDSHAKE_NOT_FINISHED.name()); - } - } - @Test public void writeAndFlush_handshakeSucceed() throws InterruptedException { - channel.pipeline().fireUserEventTriggered(getHandshakeSuccessEvent()); ByteBuf msg = Unpooled.copiedBuffer("message after handshake finished", CharsetUtil.UTF_8); channel.writeAndFlush(msg); + Object actual = channel.readOutbound(); - assertThat((Object) channel.readOutbound()).isEqualTo(msg); + assertThat(actual).isEqualTo(msg); channel.close().sync(); channel.checkException(); } @@ -93,39 +76,43 @@ public void writeAndFlush_shouldBeIgnoredAfterClose() throws InterruptedExceptio } @Test - public void writeAndFlush_handshakeFailed() throws InterruptedException { - channel.pipeline().fireUserEventTriggered(new TsiHandshakeCompletionEvent(new Exception())); + public void close_shouldFlushRemainingMessage() throws InterruptedException { ByteBuf msg = Unpooled.copiedBuffer("message after handshake failed", CharsetUtil.UTF_8); - - channel.writeAndFlush(msg); + channel.write(msg); assertThat(channel.outboundMessages()).isEmpty(); + channel.close().sync(); + Object actual = channel.readOutbound(); + + assertWithMessage("pending write should be flushed on close").that(actual).isEqualTo(msg); channel.checkException(); } @Test - public void close_shouldFlushRemainingMessage() throws InterruptedException { - channel.pipeline().fireUserEventTriggered(getHandshakeSuccessEvent()); - + public void flushAfterCloseShouldWork() throws InterruptedException { ByteBuf msg = Unpooled.copiedBuffer("message after handshake failed", CharsetUtil.UTF_8); channel.write(msg); + channel.pipeline().addFirst(new ChannelOutboundHandlerAdapter() { + @Override + public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + // We have to call flush while doing a close, since close() tears down the pipeline + // immediately after. + channel.flush(); + super.close(ctx, promise); + } + }); + assertThat(channel.outboundMessages()).isEmpty(); channel.close().sync(); + Object actual = channel.readOutbound(); - assertWithMessage("pending write should be flushed on close") - .that((Object) channel.readOutbound()).isEqualTo(msg); + assertWithMessage("pending write should be flushed on close").that(actual).isEqualTo(msg); channel.checkException(); } - private TsiHandshakeCompletionEvent getHandshakeSuccessEvent() { - TsiFrameProtector protector = new IdentityFrameProtector(); - TsiPeer peer = new TsiPeer(new ArrayList>()); - return new TsiHandshakeCompletionEvent(protector, peer, new Object()); - } - private static final class IdentityFrameProtector implements TsiFrameProtector { @Override diff --git a/alts/src/test/java/io/grpc/alts/internal/TsiTest.java b/alts/src/test/java/io/grpc/alts/internal/TsiTest.java index 5c9cf265e25..0241182f2db 100644 --- a/alts/src/test/java/io/grpc/alts/internal/TsiTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/TsiTest.java @@ -26,6 +26,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.buffer.UnpooledByteBufAllocator; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import java.util.ArrayList; @@ -33,13 +34,13 @@ import java.util.List; import javax.crypto.AEADBadTagException; -/** Utility class that provides tests for implementations of @{link TsiHandshaker}. */ +/** Utility class that provides tests for implementations of {@link TsiHandshaker}. */ public final class TsiTest { - private static final String DECRYPTION_FAILURE_RE = "Tag mismatch!"; + private static final String DECRYPTION_FAILURE_RE = "Tag mismatch|BAD_DECRYPT"; private TsiTest() {} - /** A @{code TsiHandshaker} pair for running tests. */ + /** A {@code TsiHandshaker} pair for running tests. */ public static class Handshakers { private final TsiHandshaker client; private final TsiHandshaker server; @@ -83,7 +84,7 @@ static void performHandshake(int transportBufferSize, Handshakers handshakers) byte[] transportBufferBytes = new byte[transportBufferSize]; ByteBuffer transportBuffer = ByteBuffer.wrap(transportBufferBytes); - transportBuffer.limit(0); // Start off with an empty buffer + ((Buffer) transportBuffer).limit(0); // Start off with an empty buffer while (clientHandshaker.isInProgress() || serverHandshaker.isInProgress()) { for (TsiHandshaker handshaker : new TsiHandshaker[] {clientHandshaker, serverHandshaker}) { @@ -94,9 +95,9 @@ static void performHandshake(int transportBufferSize, Handshakers handshakers) } // Put new bytes on the wire, if needed. if (handshaker.isInProgress()) { - transportBuffer.clear(); + ((Buffer) transportBuffer).clear(); handshaker.getBytesToSendToPeer(transportBuffer); - transportBuffer.flip(); + ((Buffer) transportBuffer).flip(); } } } @@ -282,7 +283,7 @@ public void accept(ByteBuf buf) { receiver.unprotect(protect, unprotectOut, alloc); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_RE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_RE); } sender.destroy(); @@ -321,7 +322,7 @@ public void accept(ByteBuf buf) { receiver.unprotect(protect, unprotectOut, alloc); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_RE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_RE); } sender.destroy(); @@ -360,7 +361,7 @@ public void accept(ByteBuf buf) { receiver.unprotect(protect, unprotectOut, alloc); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_RE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_RE); } sender.destroy(); @@ -396,7 +397,7 @@ public void accept(ByteBuf buf) { sender.unprotect(protect.slice(), unprotectOut, alloc); fail("Exception expected"); } catch (AEADBadTagException ex) { - assertThat(ex).hasMessageThat().contains(DECRYPTION_FAILURE_RE); + assertThat(ex).hasMessageThat().containsMatch(DECRYPTION_FAILURE_RE); } sender.destroy(); diff --git a/android-interop-testing/README.md b/android-interop-testing/README.md index c1abcee4d7f..bd7841e7e84 100644 --- a/android-interop-testing/README.md +++ b/android-interop-testing/README.md @@ -3,8 +3,6 @@ gRPC Android test App Implements gRPC integration tests in an Android App. -TODO(madongfly) integrate this App into the gRPC-Java build system. - In order to build this app, you need a local.properties file under this directory which specifies the location of your android sdk: ``` diff --git a/android-interop-testing/app/build.gradle b/android-interop-testing/app/build.gradle deleted file mode 100644 index 85c8b65c5ce..00000000000 --- a/android-interop-testing/app/build.gradle +++ /dev/null @@ -1,89 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'com.google.protobuf' - -android { - sourceSets { - main { - java { - srcDirs += "${projectDir}/../../interop-testing/src/main/java/" - setIncludes(["io/grpc/android/integrationtest/**", - "io/grpc/testing/integration/AbstractInteropTest.java", - "io/grpc/testing/integration/TestServiceImpl.java", - "io/grpc/testing/integration/Util.java"]) - } - proto { - srcDirs += "${projectDir}/../../interop-testing/src/main/proto/" - } - } - } - compileSdkVersion 26 - - defaultConfig { - applicationId "io.grpc.android.integrationtest" - // API level 14+ is required for TLS since Google Play Services v10.2 - minSdkVersion 14 - targetSdkVersion 26 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - multiDexEnabled true - } - buildTypes { - debug { minifyEnabled false } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - lintOptions { disable 'InvalidPackage', 'HardcodedText' } -} - -protobuf { - protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' } - plugins { - javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" } - grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.19.0-SNAPSHOT' // CURRENT_GRPC_VERSION - } - } - generateProtoTasks { - all().each { task -> - task.plugins { - javalite {} - grpc { - // Options added to --grpc_out - option 'lite' - } - } - } - } -} - -dependencies { - implementation 'com.android.support:appcompat-v7:26.1.0' - implementation 'com.android.support:multidex:1.0.3' - implementation 'com.android.support:support-annotations:27.1.1' - implementation 'com.google.android.gms:play-services-base:15.0.1' - implementation ('com.google.auth:google-auth-library-oauth2-http:0.9.0') { - exclude group: 'org.apache.httpcomponents', module: 'httpclient' - } - implementation 'com.google.truth:truth:0.36' - implementation 'javax.annotation:javax.annotation-api:1.2' - implementation 'junit:junit:4.12' - - // You need to build grpc-java to obtain the grpc libraries below. - implementation 'io.grpc:grpc-auth:1.19.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-okhttp:1.19.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-protobuf-lite:1.19.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-stub:1.19.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'io.grpc:grpc-testing:1.19.0-SNAPSHOT' // CURRENT_GRPC_VERSION - - // workaround for https://github.com/google/protobuf/issues/1889 - protobuf 'com.google.protobuf:protobuf-java:3.0.2' - - androidTestImplementation 'androidx.test:rules:1.1.0-alpha1' - androidTestImplementation 'androidx.test:runner:1.1.0-alpha1' -} - -gradle.projectsEvaluated { - tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" } -} diff --git a/android-interop-testing/app/src/androidTest/AndroidManifest.xml b/android-interop-testing/app/src/androidTest/AndroidManifest.xml deleted file mode 100644 index 340300c4c59..00000000000 --- a/android-interop-testing/app/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - diff --git a/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java b/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java deleted file mode 100644 index 47f6fc72dd4..00000000000 --- a/android-interop-testing/app/src/androidTest/java/io/grpc/android/integrationtest/InteropInstrumentationTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2017 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.android.integrationtest; - -import static junit.framework.Assert.assertEquals; - -import android.util.Log; -import androidx.test.InstrumentationRegistry; -import androidx.test.rule.ActivityTestRule; -import androidx.test.runner.AndroidJUnit4; -import com.google.android.gms.common.GooglePlayServicesNotAvailableException; -import com.google.android.gms.common.GooglePlayServicesRepairableException; -import com.google.android.gms.security.ProviderInstaller; -import com.google.common.util.concurrent.SettableFuture; -import io.grpc.ClientInterceptor; -import io.grpc.android.integrationtest.InteropTask.Listener; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -public class InteropInstrumentationTest { - private static final int TIMEOUT_SECONDS = 60; - private static final String LOG_TAG = "GrpcInteropInstrumentationTest"; - - private String host; - private int port; - private boolean useTls; - private String serverHostOverride; - private boolean useTestCa; - private String testCase; - - // Ensures Looper is initialized for tests running on API level 15. Otherwise instantiating an - // AsyncTask throws an exception. - @Rule - public ActivityTestRule activityRule = - new ActivityTestRule(TesterActivity.class); - - @Before - public void setUp() throws Exception { - host = InstrumentationRegistry.getArguments().getString("server_host", "10.0.2.2"); - port = - Integer.parseInt(InstrumentationRegistry.getArguments().getString("server_port", "8080")); - useTls = - Boolean.parseBoolean(InstrumentationRegistry.getArguments().getString("use_tls", "true")); - serverHostOverride = InstrumentationRegistry.getArguments().getString("server_host_override"); - useTestCa = - Boolean.parseBoolean( - InstrumentationRegistry.getArguments().getString("use_test_ca", "false")); - testCase = InstrumentationRegistry.getArguments().getString("test_case", "all"); - - if (useTls) { - try { - ProviderInstaller.installIfNeeded(InstrumentationRegistry.getTargetContext()); - } catch (GooglePlayServicesRepairableException e) { - // The provider is helpful, but it is possible to succeed without it. - // Hope that the system-provided libraries are new enough. - Log.i(LOG_TAG, "Failed installing security provider", e); - } catch (GooglePlayServicesNotAvailableException e) { - // The provider is helpful, but it is possible to succeed without it. - // Hope that the system-provided libraries are new enough. - Log.i(LOG_TAG, "Failed installing security provider", e); - } - } - } - - @Test - public void interopTests() throws Exception { - if (testCase.equals("all")) { - runTest("empty_unary"); - runTest("large_unary"); - runTest("client_streaming"); - runTest("server_streaming"); - runTest("ping_pong"); - runTest("empty_stream"); - runTest("cancel_after_begin"); - runTest("cancel_after_first_response"); - runTest("full_duplex_call_should_succeed"); - runTest("half_duplex_call_should_succeed"); - runTest("server_streaming_should_be_flow_controlled"); - runTest("very_large_request"); - runTest("very_large_response"); - runTest("deadline_not_exceeded"); - runTest("deadline_exceeded"); - runTest("deadline_exceeded_server_streaming"); - runTest("unimplemented_method"); - runTest("timeout_on_sleeping_server"); - runTest("graceful_shutdown"); - } else { - runTest(testCase); - } - } - - private void runTest(String testCase) throws Exception { - final SettableFuture resultFuture = SettableFuture.create(); - InteropTask.Listener listener = - new Listener() { - @Override - public void onComplete(String result) { - resultFuture.set(result); - } - }; - InputStream testCa; - if (useTestCa) { - testCa = InstrumentationRegistry.getTargetContext().getResources().openRawResource(R.raw.ca); - } else { - testCa = null; - } - new InteropTask( - listener, - TesterOkHttpChannelBuilder.build(host, port, serverHostOverride, useTls, testCa), - new ArrayList(), - testCase) - .execute(); - String result = resultFuture.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); - assertEquals(testCase + " failed", InteropTask.SUCCESS_MESSAGE, result); - } -} diff --git a/android-interop-testing/app/src/main/AndroidManifest.xml b/android-interop-testing/app/src/main/AndroidManifest.xml deleted file mode 100644 index cb9f81e2426..00000000000 --- a/android-interop-testing/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java deleted file mode 100644 index d1d181df28c..00000000000 --- a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2018 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.android.integrationtest; - -import android.os.AsyncTask; -import android.util.Log; -import io.grpc.ClientInterceptor; -import io.grpc.ManagedChannel; -import io.grpc.testing.integration.AbstractInteropTest; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.ref.WeakReference; -import java.util.List; -import org.junit.AssumptionViolatedException; - -/** AsyncTask for interop test cases. */ -final class InteropTask extends AsyncTask { - private static final String LOG_TAG = "GrpcInteropTask"; - - interface Listener { - void onComplete(String result); - } - - static final String SUCCESS_MESSAGE = "Success!"; - - private final WeakReference listenerReference; - private final String testCase; - private final Tester tester; - - InteropTask( - Listener listener, - ManagedChannel channel, - List interceptors, - String testCase) { - this.listenerReference = new WeakReference(listener); - this.testCase = testCase; - this.tester = new Tester(channel, interceptors); - } - - @Override - protected void onPreExecute() { - tester.setUp(); - } - - @Override - protected String doInBackground(Void... ignored) { - try { - runTest(testCase); - return SUCCESS_MESSAGE; - } catch (Throwable t) { - // Print the stack trace to logcat. - t.printStackTrace(); - // Then print to the error message. - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - return "Failed... : " + t.getMessage() + "\n" + sw; - } finally { - try { - tester.tearDown(); - } catch (RuntimeException ex) { - throw ex; - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - } - - private void runTest(String testCase) throws Exception { - Log.i(LOG_TAG, "Running test case: " + testCase); - if ("empty_unary".equals(testCase)) { - tester.emptyUnary(); - } else if ("large_unary".equals(testCase)) { - try { - tester.largeUnary(); - } catch (AssumptionViolatedException e) { - // This test case requires more memory than most Android devices have available - Log.w(LOG_TAG, "Skipping " + testCase + " due to assumption violation", e); - } - } else if ("client_streaming".equals(testCase)) { - tester.clientStreaming(); - } else if ("server_streaming".equals(testCase)) { - tester.serverStreaming(); - } else if ("ping_pong".equals(testCase)) { - tester.pingPong(); - } else if ("empty_stream".equals(testCase)) { - tester.emptyStream(); - } else if ("cancel_after_begin".equals(testCase)) { - tester.cancelAfterBegin(); - } else if ("cancel_after_first_response".equals(testCase)) { - tester.cancelAfterFirstResponse(); - } else if ("full_duplex_call_should_succeed".equals(testCase)) { - tester.fullDuplexCallShouldSucceed(); - } else if ("half_duplex_call_should_succeed".equals(testCase)) { - tester.halfDuplexCallShouldSucceed(); - } else if ("server_streaming_should_be_flow_controlled".equals(testCase)) { - tester.serverStreamingShouldBeFlowControlled(); - } else if ("very_large_request".equals(testCase)) { - try { - tester.veryLargeRequest(); - } catch (AssumptionViolatedException e) { - // This test case requires more memory than most Android devices have available - Log.w(LOG_TAG, "Skipping " + testCase + " due to assumption violation", e); - } - } else if ("very_large_response".equals(testCase)) { - try { - tester.veryLargeResponse(); - } catch (AssumptionViolatedException e) { - // This test case requires more memory than most Android devices have available - Log.w(LOG_TAG, "Skipping " + testCase + " due to assumption violation", e); - } - } else if ("deadline_not_exceeded".equals(testCase)) { - tester.deadlineNotExceeded(); - } else if ("deadline_exceeded".equals(testCase)) { - tester.deadlineExceeded(); - } else if ("deadline_exceeded_server_streaming".equals(testCase)) { - tester.deadlineExceededServerStreaming(); - } else if ("unimplemented_method".equals(testCase)) { - tester.unimplementedMethod(); - } else if ("timeout_on_sleeping_server".equals(testCase)) { - tester.timeoutOnSleepingServer(); - } else if ("graceful_shutdown".equals(testCase)) { - tester.gracefulShutdown(); - } else { - throw new IllegalArgumentException("Unimplemented/Unknown test case: " + testCase); - } - } - - @Override - protected void onPostExecute(String result) { - Listener listener = listenerReference.get(); - if (listener != null) { - listener.onComplete(result); - } - } - - private static class Tester extends AbstractInteropTest { - private final ManagedChannel channel; - private final List interceptors; - - private Tester(ManagedChannel channel, List interceptors) { - this.channel = channel; - this.interceptors = interceptors; - } - - @Override - protected ManagedChannel createChannel() { - return channel; - } - - @Override - protected ClientInterceptor[] getAdditionalInterceptors() { - return interceptors.toArray(new ClientInterceptor[0]); - } - - @Override - protected boolean metricsExpected() { - return false; - } - } -} diff --git a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java deleted file mode 100644 index e365f048e51..00000000000 --- a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2015 The gRPC Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.grpc.android.integrationtest; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.text.TextUtils; -import android.util.Log; -import android.view.View; -import android.view.inputmethod.InputMethodManager; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.TextView; -import com.google.android.gms.security.ProviderInstaller; -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; -import io.grpc.ClientInterceptors.CheckedForwardingClientCall; -import io.grpc.ManagedChannel; -import io.grpc.Metadata; -import io.grpc.MethodDescriptor; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -public class TesterActivity extends AppCompatActivity - implements ProviderInstaller.ProviderInstallListener, InteropTask.Listener { - private static final String LOG_TAG = "GrpcTesterActivity"; - - private List