Search in sources :

Example 1 with Authenticator

use of org.apache.dubbo.auth.spi.Authenticator in project dubbo by alibaba.

the class ProviderAuthFilter method invoke.

@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    URL url = invoker.getUrl();
    boolean shouldAuth = url.getParameter(Constants.SERVICE_AUTH, false);
    if (shouldAuth) {
        Authenticator authenticator = ExtensionLoader.getExtensionLoader(Authenticator.class).getExtension(url.getParameter(Constants.AUTHENTICATOR, Constants.DEFAULT_AUTHENTICATOR));
        try {
            authenticator.authenticate(invocation, url);
        } catch (Exception e) {
            return AsyncRpcResult.newDefaultAsyncResult(e, invocation);
        }
    }
    return invoker.invoke(invocation);
}
Also used : URL(org.apache.dubbo.common.URL) Authenticator(org.apache.dubbo.auth.spi.Authenticator) RpcException(org.apache.dubbo.rpc.RpcException)

Example 2 with Authenticator

use of org.apache.dubbo.auth.spi.Authenticator in project dubbo by alibaba.

the class ConsumerSignFilter method invoke.

@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    URL url = invoker.getUrl();
    boolean shouldAuth = url.getParameter(Constants.SERVICE_AUTH, false);
    if (shouldAuth) {
        Authenticator authenticator = ExtensionLoader.getExtensionLoader(Authenticator.class).getExtension(url.getParameter(Constants.AUTHENTICATOR, Constants.DEFAULT_AUTHENTICATOR));
        authenticator.sign(invocation, url);
    }
    return invoker.invoke(invocation);
}
Also used : URL(org.apache.dubbo.common.URL) Authenticator(org.apache.dubbo.auth.spi.Authenticator)

Aggregations

Authenticator (org.apache.dubbo.auth.spi.Authenticator)2 URL (org.apache.dubbo.common.URL)2 RpcException (org.apache.dubbo.rpc.RpcException)1