Skip to content

Commit

Permalink
regenerate Java SDK with endpoint to verify HTTP JWT
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 416a1ed6c3cccd39242bbcff03953873c820564c
  • Loading branch information
Ulderico Cirello authored and SupportSDM committed Feb 24, 2021
1 parent 1ee7a6f commit d8b8de5
Show file tree
Hide file tree
Showing 7 changed files with 2,193 additions and 37 deletions.
26 changes: 26 additions & 0 deletions com/strongdm/api/v1/ControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,30 @@ public ControlPanelGetSSHCAPublicKeyResponse getSSHCAPublicKey() throws RpcExcep
}
return Plumbing.convertControlPanelGetSSHCAPublicKeyResponseToPorcelain(plumbingResponse);
}
// VerifyJWT reports whether the given JWT token (x-sdm-token) is valid.
public ControlPanelVerifyJWTResponse verifyJWT(String token) throws RpcException {
ControlPanelPlumbing.ControlPanelVerifyJWTRequest.Builder builder =
ControlPanelPlumbing.ControlPanelVerifyJWTRequest.newBuilder();
builder.setToken((token));
ControlPanelPlumbing.ControlPanelVerifyJWTRequest req = builder.build();
ControlPanelPlumbing.ControlPanelVerifyJWTResponse plumbingResponse;
int tries = 0;
while (true) {
try {
plumbingResponse =
this.stub
.withCallCredentials(this.parent.getCallCredentials("ControlPanel.VerifyJWT", req))
.verifyJWT(req);
} catch (Exception e) {
if (this.parent.shouldRetry(tries, e)) {
tries++;
this.parent.jitterSleep(tries);
continue;
}
throw Plumbing.convertExceptionToPorcelain(e);
}
break;
}
return Plumbing.convertControlPanelVerifyJWTResponseToPorcelain(plumbingResponse);
}
}
51 changes: 51 additions & 0 deletions com/strongdm/api/v1/ControlPanelVerifyJWTResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2020 StrongDM Inc
//
// 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.
//

// This file was generated by protogen. DO NOT EDIT.

package com.strongdm.api.v1;

// ControlPanelVerifyJWTResponse reports whether x-sdm-token is valid.
public class ControlPanelVerifyJWTResponse {
private GetResponseMetadata meta;
// Reserved for future use.
public GetResponseMetadata getMeta() {
return this.meta;
}
// Reserved for future use.
public void setMeta(GetResponseMetadata in) {
this.meta = in;
}

private boolean valid;
// Reports if the given token is valid.
public boolean getValid() {
return this.valid;
}
// Reports if the given token is valid.
public void setValid(boolean in) {
this.valid = in;
}

private RateLimitMetadata rateLimit;
// Rate limit information.
public RateLimitMetadata getRateLimit() {
return this.rateLimit;
}
// Rate limit information.
public void setRateLimit(RateLimitMetadata in) {
this.rateLimit = in;
}
}
56 changes: 28 additions & 28 deletions com/strongdm/api/v1/plumbing/AccountGrantsPlumbing.java
Original file line number Diff line number Diff line change
Expand Up @@ -10055,34 +10055,34 @@ public com.strongdm.api.v1.plumbing.AccountGrantsPlumbing.AccountGrant getDefaul
"ListResponseMetadata\0224\n\016account_grants\030\002" +
" \003(\0132\020.v1.AccountGrantB\n\362\370\263\007\005\270\363\263\007\001\022?\n\nra" +
"te_limit\030\003 \001(\0132\025.v1.RateLimitMetadataB\024\362" +
"\370\263\007\005\260\363\263\007\001\362\370\263\007\005\220\364\263\007\001\"\330\003\n\014AccountGrant\022,\n\002" +
"id\030\001 \001(\tB \362\370\263\007\033\242\363\263\007\002ID\260\363\263\007\001\312\363\263\007\nPermissi" +
"on\022D\n\013resource_id\030\002 \001(\tB/\362\370\263\007*\242\363\263\007\014Datas" +
"ourceID\260\363\263\007\001\300\363\263\007\001\312\363\263\007\nDatasource\0227\n\nacco" +
"unt_id\030\003 \001(\tB#\362\370\263\007\036\242\363\263\007\006UserID\260\363\263\007\001\300\363\263\007\001" +
"\312\363\263\007\004User\022M\n\nstart_from\030\004 \001(\0132\032.google.p" +
"rotobuf.TimestampB\035\362\370\263\007\030\242\363\263\007\tStartFrom\250\363" +
"\263\007\001\260\363\263\007\001\022O\n\013valid_until\030\005 \001(\0132\032.google.p" +
"rotobuf.TimestampB\036\362\370\263\007\031\242\363\263\007\nValidUntil\250" +
"\363\263\007\001\260\363\263\007\001:{\372\370\263\007v\242\363\263\007\016DatasourceUser\250\363\263\007\001" +
"\302\363\263\007Y\242\363\263\007&tf_examples/account_grant_reso" +
"urce.txt\252\363\263\007)tf_examples/account_grant_d" +
"ata_source.txt2\366\003\n\rAccountGrants\022s\n\006Crea" +
"te\022\035.v1.AccountGrantCreateRequest\032\036.v1.A" +
"ccountGrantCreateResponse\"*\202\371\263\007\t\242\363\263\007\004pos" +
"t\202\371\263\007\027\252\363\263\007\022/v1/account-grants\022n\n\003Get\022\032.v" +
"1.AccountGrantGetRequest\032\033.v1.AccountGra" +
"ntGetResponse\".\202\371\263\007\010\242\363\263\007\003get\202\371\263\007\034\252\363\263\007\027/v" +
"1/account-grants/{id}\022z\n\006Delete\022\035.v1.Acc" +
"ountGrantDeleteRequest\032\036.v1.AccountGrant" +
"DeleteResponse\"1\202\371\263\007\013\242\363\263\007\006delete\202\371\263\007\034\252\363\263" +
"\007\027/v1/account-grants/{id}\022l\n\004List\022\033.v1.A" +
"ccountGrantListRequest\032\034.v1.AccountGrant" +
"ListResponse\")\202\371\263\007\010\242\363\263\007\003get\202\371\263\007\027\252\363\263\007\022/v1" +
"/account-grants\032\026\312\371\263\007\021\302\371\263\007\014AccountGrantB" +
"i\n\034com.strongdm.api.v1.plumbingB\025Account" +
"GrantsPlumbingZ2github.com/strongdm/stro" +
"ngdm-sdk-go/internal/v1;v1b\006proto3"
"\370\263\007\005\260\363\263\007\001\362\370\263\007\005\220\364\263\007\001\"\334\003\n\014AccountGrant\0220\n\002" +
"id\030\001 \001(\tB$\362\370\263\007\037\242\363\263\007\002ID\260\363\263\007\001\312\363\263\007\016Datasour" +
"ceUser\022D\n\013resource_id\030\002 \001(\tB/\362\370\263\007*\242\363\263\007\014D" +
"atasourceID\260\363\263\007\001\300\363\263\007\001\312\363\263\007\nDatasource\0227\n\n" +
"account_id\030\003 \001(\tB#\362\370\263\007\036\242\363\263\007\006UserID\260\363\263\007\001\300" +
"\363\263\007\001\312\363\263\007\004User\022M\n\nstart_from\030\004 \001(\0132\032.goog" +
"le.protobuf.TimestampB\035\362\370\263\007\030\242\363\263\007\tStartFr" +
"om\250\363\263\007\001\260\363\263\007\001\022O\n\013valid_until\030\005 \001(\0132\032.goog" +
"le.protobuf.TimestampB\036\362\370\263\007\031\242\363\263\007\nValidUn" +
"til\250\363\263\007\001\260\363\263\007\001:{\372\370\263\007v\242\363\263\007\016DatasourceUser\250" +
"\363\263\007\001\302\363\263\007Y\242\363\263\007&tf_examples/account_grant_" +
"resource.txt\252\363\263\007)tf_examples/account_gra" +
"nt_data_source.txt2\366\003\n\rAccountGrants\022s\n\006" +
"Create\022\035.v1.AccountGrantCreateRequest\032\036." +
"v1.AccountGrantCreateResponse\"*\202\371\263\007\t\242\363\263\007" +
"\004post\202\371\263\007\027\252\363\263\007\022/v1/account-grants\022n\n\003Get" +
"\022\032.v1.AccountGrantGetRequest\032\033.v1.Accoun" +
"tGrantGetResponse\".\202\371\263\007\010\242\363\263\007\003get\202\371\263\007\034\252\363\263" +
"\007\027/v1/account-grants/{id}\022z\n\006Delete\022\035.v1" +
".AccountGrantDeleteRequest\032\036.v1.AccountG" +
"rantDeleteResponse\"1\202\371\263\007\013\242\363\263\007\006delete\202\371\263\007" +
"\034\252\363\263\007\027/v1/account-grants/{id}\022l\n\004List\022\033." +
"v1.AccountGrantListRequest\032\034.v1.AccountG" +
"rantListResponse\")\202\371\263\007\010\242\363\263\007\003get\202\371\263\007\027\252\363\263\007" +
"\022/v1/account-grants\032\026\312\371\263\007\021\302\371\263\007\014AccountGr" +
"antBi\n\034com.strongdm.api.v1.plumbingB\025Acc" +
"ountGrantsPlumbingZ2github.com/strongdm/" +
"strongdm-sdk-go/internal/v1;v1b\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
Expand Down
86 changes: 86 additions & 0 deletions com/strongdm/api/v1/plumbing/ControlPanelGrpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelGetSSHCAPublicKeyR
return getGetSSHCAPublicKeyMethod;
}

private static volatile io.grpc.MethodDescriptor<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest,
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse> getVerifyJWTMethod;

@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "VerifyJWT",
requestType = com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest.class,
responseType = com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest,
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse> getVerifyJWTMethod() {
io.grpc.MethodDescriptor<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest, com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse> getVerifyJWTMethod;
if ((getVerifyJWTMethod = ControlPanelGrpc.getVerifyJWTMethod) == null) {
synchronized (ControlPanelGrpc.class) {
if ((getVerifyJWTMethod = ControlPanelGrpc.getVerifyJWTMethod) == null) {
ControlPanelGrpc.getVerifyJWTMethod = getVerifyJWTMethod =
io.grpc.MethodDescriptor.<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest, com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "VerifyJWT"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse.getDefaultInstance()))
.setSchemaDescriptor(new ControlPanelMethodDescriptorSupplier("VerifyJWT"))
.build();
}
}
}
return getVerifyJWTMethod;
}

/**
* Creates a new async stub that supports all call types for the service
*/
Expand Down Expand Up @@ -115,6 +146,16 @@ public void getSSHCAPublicKey(com.strongdm.api.v1.plumbing.ControlPanelPlumbing.
asyncUnimplementedUnaryCall(getGetSSHCAPublicKeyMethod(), responseObserver);
}

/**
* <pre>
* VerifyJWT reports whether the given JWT token (x-sdm-token) is valid.
* </pre>
*/
public void verifyJWT(com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest request,
io.grpc.stub.StreamObserver<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse> responseObserver) {
asyncUnimplementedUnaryCall(getVerifyJWTMethod(), responseObserver);
}

@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
Expand All @@ -124,6 +165,13 @@ public void getSSHCAPublicKey(com.strongdm.api.v1.plumbing.ControlPanelPlumbing.
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelGetSSHCAPublicKeyRequest,
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelGetSSHCAPublicKeyResponse>(
this, METHODID_GET_SSHCAPUBLIC_KEY)))
.addMethod(
getVerifyJWTMethod(),
asyncUnaryCall(
new MethodHandlers<
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest,
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse>(
this, METHODID_VERIFY_JWT)))
.build();
}
}
Expand Down Expand Up @@ -159,6 +207,17 @@ public void getSSHCAPublicKey(com.strongdm.api.v1.plumbing.ControlPanelPlumbing.
asyncUnaryCall(
getChannel().newCall(getGetSSHCAPublicKeyMethod(), getCallOptions()), request, responseObserver);
}

/**
* <pre>
* VerifyJWT reports whether the given JWT token (x-sdm-token) is valid.
* </pre>
*/
public void verifyJWT(com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest request,
io.grpc.stub.StreamObserver<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse> responseObserver) {
asyncUnaryCall(
getChannel().newCall(getVerifyJWTMethod(), getCallOptions()), request, responseObserver);
}
}

/**
Expand Down Expand Up @@ -191,6 +250,16 @@ public com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelGetSSHCAPub
return blockingUnaryCall(
getChannel(), getGetSSHCAPublicKeyMethod(), getCallOptions(), request);
}

/**
* <pre>
* VerifyJWT reports whether the given JWT token (x-sdm-token) is valid.
* </pre>
*/
public com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse verifyJWT(com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest request) {
return blockingUnaryCall(
getChannel(), getVerifyJWTMethod(), getCallOptions(), request);
}
}

/**
Expand Down Expand Up @@ -224,9 +293,21 @@ public com.google.common.util.concurrent.ListenableFuture<com.strongdm.api.v1.pl
return futureUnaryCall(
getChannel().newCall(getGetSSHCAPublicKeyMethod(), getCallOptions()), request);
}

/**
* <pre>
* VerifyJWT reports whether the given JWT token (x-sdm-token) is valid.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse> verifyJWT(
com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest request) {
return futureUnaryCall(
getChannel().newCall(getVerifyJWTMethod(), getCallOptions()), request);
}
}

private static final int METHODID_GET_SSHCAPUBLIC_KEY = 0;
private static final int METHODID_VERIFY_JWT = 1;

private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
Expand All @@ -249,6 +330,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserv
serviceImpl.getSSHCAPublicKey((com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelGetSSHCAPublicKeyRequest) request,
(io.grpc.stub.StreamObserver<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelGetSSHCAPublicKeyResponse>) responseObserver);
break;
case METHODID_VERIFY_JWT:
serviceImpl.verifyJWT((com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTRequest) request,
(io.grpc.stub.StreamObserver<com.strongdm.api.v1.plumbing.ControlPanelPlumbing.ControlPanelVerifyJWTResponse>) responseObserver);
break;
default:
throw new AssertionError();
}
Expand Down Expand Up @@ -311,6 +396,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new ControlPanelFileDescriptorSupplier())
.addMethod(getGetSSHCAPublicKeyMethod())
.addMethod(getVerifyJWTMethod())
.build();
}
}
Expand Down
Loading

0 comments on commit d8b8de5

Please sign in to comment.