private static void prepareKmsKeys() throws IOException { String projectId = remoteStorageHelper.getOptions().getProjectId(); GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); ManagedChannel kmsChannel = ManagedChannelBuilder.forTarget("cloudkms.googleapis.com:443").build(); KeyManagementServiceBlockingStub kmsStub = KeyManagementServiceGrpc.newBlockingStub(kmsChannel) .withCallCredentials(MoreCallCredentials.from(credentials)); IAMPolicyGrpc.IAMPolicyBlockingStub iamStub = IAMPolicyGrpc.newBlockingStub(kmsChannel) .withCallCredentials(MoreCallCredentials.from(credentials)); ensureKmsKeyRingExistsForTests(kmsStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME); ensureKmsKeyRingIamPermissionsForTests( iamStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME); kmsKeyOneResourcePath = ensureKmsKeyExistsForTests( kmsStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME, KMS_KEY_ONE_NAME); kmsKeyTwoResourcePath = ensureKmsKeyExistsForTests( kmsStub, projectId, KMS_KEY_RING_LOCATION, KMS_KEY_RING_NAME, KMS_KEY_TWO_NAME); }
@Override public GrpcCallContext withCredentials(Credentials newCredentials) { Preconditions.checkNotNull(newCredentials); CallCredentials callCredentials = MoreCallCredentials.from(newCredentials); return withCallOptions(callOptions.withCallCredentials(callCredentials)); }
@Override public GrpcCallContext withCredentials(Credentials newCredentials) { Preconditions.checkNotNull(newCredentials); CallCredentials callCredentials = MoreCallCredentials.from(newCredentials); return withCallOptions(callOptions.withCallCredentials(callCredentials)); }
@Bean @ConditionalOnMissingBean StorageComponent storage( @Value("${zipkin.storage.strict-trace-id:true}") boolean strictTraceId, @Qualifier("projectId") String projectId, ManagedChannel managedChannel, Credentials credentials) { return StackdriverStorage.newBuilder(managedChannel) .projectId(projectId) .strictTraceId(strictTraceId) .callOptions(DEFAULT.withCallCredentials(MoreCallCredentials.from(credentials))) .build(); }
/** * Get CallCredentials from OAuthCredentials * * @param oAuthCredentials the credentials from the AuthenticationHelper * @return the CallCredentials for the GRPC requests */ private CallCredentials getCallCredentials(OAuthCredentials oAuthCredentials) { AccessToken accessToken = new AccessToken( oAuthCredentials.getAccessToken(), new Date(oAuthCredentials.getExpirationTime()) ); OAuth2Credentials oAuth2Credentials = new OAuth2Credentials(accessToken); // Create an instance of {@link io.grpc.CallCredentials} return MoreCallCredentials.from(oAuth2Credentials); }
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)); }
if (credentials != null) { PravegaCredentialsWrapper wrapper = new PravegaCredentialsWrapper(credentials); client = client.withCallCredentials(MoreCallCredentials.from(wrapper));
CallOptions callOptions = CallOptions.DEFAULT .withCallCredentials( MoreCallCredentials.from( this.finalCredentialsProvider.getCredentials())) .withExecutor(executorProvider.getExecutor());