Search in sources :

Example 6 with AuthHandler

use of io.pravega.auth.AuthHandler in project pravega by pravega.

the class AuthContext method current.

/**
 * Initiates a new instance using the current {@link io.grpc.Context}.
 *
 * @return an instance containing {@link Principal} and {@link AuthHandler} from the current {@link io.grpc.Context}
 */
public static AuthContext current() {
    // Obtains the Principal object stored in the current gRPC Context. The 'get()' method gets the value from the
    // Context associated with the current gRPC scope, so the value changes for each gRPC request/scope.
    Principal principal = AuthInterceptor.PRINCIPAL_OBJECT_KEY.get();
    // Obtains the AuthInterceptor object stored in the current gRPC Context. The 'get()' method gets the value
    // from the Context associated with the current gRPC scope, so the value changes for each gRPC request/scope.
    AuthInterceptor serverAuthInterceptor = AuthInterceptor.AUTH_INTERCEPTOR_OBJECT_KEY.get();
    AuthHandler authHandler = null;
    if (serverAuthInterceptor != null) {
        authHandler = serverAuthInterceptor.getHandler();
    }
    return new AuthContext(principal, authHandler);
}
Also used : AuthHandler(io.pravega.auth.AuthHandler) Principal(java.security.Principal)

Aggregations

AuthHandler (io.pravega.auth.AuthHandler)6 AuthenticationException (io.pravega.common.auth.AuthenticationException)2 Principal (java.security.Principal)2 AuthException (io.pravega.auth.AuthException)1 AuthenticationException (io.pravega.auth.AuthenticationException)1