Search in sources :

Example 1 with ControllerServiceStub

use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub in project pravega by pravega.

the class ControllerImpl method getClientWithCredentials.

private ControllerServiceStub getClientWithCredentials(ControllerImplConfig config) {
    ControllerServiceStub client = ControllerServiceGrpc.newStub(this.channel);
    try {
        Credentials credentials = config.getClientConfig().getCredentials();
        if (credentials != null) {
            PravegaCredentialsWrapper wrapper = new PravegaCredentialsWrapper(credentials);
            client = client.withCallCredentials(MoreCallCredentials.from(wrapper));
        }
    } catch (Exception e) {
        log.error("Error while setting credentials to controller client", e);
        closeChannel();
        throw e;
    }
    return client;
}
Also used : ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) MoreCallCredentials(io.grpc.auth.MoreCallCredentials) Credentials(io.pravega.shared.security.auth.Credentials) NoSuchScopeException(io.pravega.client.stream.NoSuchScopeException) SSLException(javax.net.ssl.SSLException) PingFailedException(io.pravega.client.stream.PingFailedException) StatusRuntimeException(io.grpc.StatusRuntimeException) TxnFailedException(io.pravega.client.stream.TxnFailedException) ReaderGroupNotFoundException(io.pravega.client.stream.ReaderGroupNotFoundException) CompletionException(java.util.concurrent.CompletionException) InvalidStreamException(io.pravega.client.stream.InvalidStreamException)

Example 2 with ControllerServiceStub

use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub in project pravega by pravega.

the class ControllerGrpcAuthFocusedTest method listStreamsReturnsAllWhenUserHasWildCardAccessUsingAsyncStub.

@Test(timeout = 20000)
public void listStreamsReturnsAllWhenUserHasWildCardAccessUsingAsyncStub() {
    // Arrange
    String scopeName = "scope1";
    createScopeAndStreams(scopeName, Arrays.asList("stream1", "stream2"), prepareFromFixedScaleTypePolicy(2));
    Controller.StreamsInScopeRequest request = Controller.StreamsInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope(scopeName).build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
    ControllerServiceStub stub = prepareNonBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
    ResultObserver<Controller.StreamsInScopeResponse> responseObserver = new ResultObserver<>();
    stub.listStreamsInScope(request, responseObserver);
    List<Controller.StreamInfo> streamsInResponse = responseObserver.get().getStreamsList();
    assertFalse(Strings.isNullOrEmpty(responseObserver.get().getContinuationToken().getToken()));
    assertEquals(2, streamsInResponse.size());
}
Also used : ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) AuthFileUtils.credentialsAndAclAsString(io.pravega.auth.AuthFileUtils.credentialsAndAclAsString) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) Test(org.junit.Test)

Example 3 with ControllerServiceStub

use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub in project pravega by pravega.

the class ControllerGrpcAuthFocusedTest method prepareNonBlockingCallStub.

private ControllerServiceStub prepareNonBlockingCallStub(String username, String password) {
    Exceptions.checkNotNullOrEmpty(username, "username");
    Exceptions.checkNotNullOrEmpty(password, "password");
    ControllerServiceGrpc.ControllerServiceStub stub = ControllerServiceGrpc.newStub(inProcessChannel);
    // Set call credentials
    Credentials credentials = new DefaultCredentials(password, username);
    if (credentials != null) {
        PravegaCredentialsWrapper wrapper = new PravegaCredentialsWrapper(credentials);
        stub = stub.withCallCredentials(MoreCallCredentials.from(wrapper));
    }
    return stub;
}
Also used : DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) PravegaCredentialsWrapper(io.pravega.client.control.impl.PravegaCredentialsWrapper) ControllerServiceGrpc(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc) MoreCallCredentials(io.grpc.auth.MoreCallCredentials) DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) Credentials(io.pravega.shared.security.auth.Credentials)

Aggregations

ControllerServiceStub (io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub)3 MoreCallCredentials (io.grpc.auth.MoreCallCredentials)2 Credentials (io.pravega.shared.security.auth.Credentials)2 StatusRuntimeException (io.grpc.StatusRuntimeException)1 AuthFileUtils.credentialsAndAclAsString (io.pravega.auth.AuthFileUtils.credentialsAndAclAsString)1 PravegaCredentialsWrapper (io.pravega.client.control.impl.PravegaCredentialsWrapper)1 InvalidStreamException (io.pravega.client.stream.InvalidStreamException)1 NoSuchScopeException (io.pravega.client.stream.NoSuchScopeException)1 PingFailedException (io.pravega.client.stream.PingFailedException)1 ReaderGroupNotFoundException (io.pravega.client.stream.ReaderGroupNotFoundException)1 TxnFailedException (io.pravega.client.stream.TxnFailedException)1 Controller (io.pravega.controller.stream.api.grpc.v1.Controller)1 StreamInfo (io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo)1 ControllerServiceGrpc (io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc)1 DefaultCredentials (io.pravega.shared.security.auth.DefaultCredentials)1 CompletionException (java.util.concurrent.CompletionException)1 SSLException (javax.net.ssl.SSLException)1 Test (org.junit.Test)1