• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ActionFilterChain类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.action.support.ActionFilterChain的典型用法代码示例。如果您正苦于以下问题:Java ActionFilterChain类的具体用法?Java ActionFilterChain怎么用?Java ActionFilterChain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ActionFilterChain类属于org.elasticsearch.action.support包,在下文中一共展示了ActionFilterChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public <Request extends ActionRequest, Response extends ActionResponse> void apply(Task task, String action,
        Request request, ActionListener<Response> listener, ActionFilterChain<Request, Response> chain) {
    if (false == action.equals(SearchAction.NAME)) {
        chain.proceed(task, action, request, listener);
        return;
    }
    if (context.getHeader(EXAMPLE_HEADER) != null) {
        throw new IllegalArgumentException("Hurray! Sent the header!");
    }
    String auth = context.getHeader(AUTHORIZATION_HEADER);
    if (auth == null) {
        ElasticsearchSecurityException e = new ElasticsearchSecurityException("Authentication required",
                RestStatus.UNAUTHORIZED);
        e.addHeader("WWW-Authenticate", "Basic realm=auth-realm");
        throw e;
    }
    if (false == REQUIRED_AUTH.equals(auth)) {
        throw new ElasticsearchSecurityException("Bad Authorization", RestStatus.FORBIDDEN);
    }
    chain.proceed(task, action, request, listener);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:ReindexFromRemoteWithAuthTests.java


示例2: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public <Request extends ActionRequest, Response extends ActionResponse> void apply(final Task task, final String action,
        final Request request, final ActionListener<Response> listener, final ActionFilterChain<Request, Response> chain) {
    if (logger.isDebugEnabled()) {
        logger.debug("node: " + nodeName() + ", action: " + action + ", request: " + request);
    }
    final Supplier<Response> executor = getExecutor(task, action, request);
    if (executor != null) {
        indexingProxyService.write(request, ActionListener.wrap(res -> {
            listener.onResponse(executor.get());
        }, listener::onFailure));
    } else if (indexingProxyService.isRenewAction(action)) {
        indexingProxyService.renew(ActionListener.wrap(res -> {
            chain.proceed(task, action, request, listener);
        }, listener::onFailure));
    } else {
        chain.proceed(task, action, request, listener);
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:20,代码来源:ProxyActionFilter.java


示例3: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void apply(final Task task, final String action,
        @SuppressWarnings("rawtypes") final ActionRequest request,
        @SuppressWarnings("rawtypes") final ActionListener listener,
        final ActionFilterChain chain) {
    if (!DeleteSnapshotAction.NAME.equals(action)) {
        chain.proceed(task, action, request, listener);
    } else {
        final DeleteSnapshotRequest deleteSnapshotRequest = (DeleteSnapshotRequest) request;
        dictionarySnapshotService.deleteDictionarySnapshot(
                deleteSnapshotRequest.repository(),
                deleteSnapshotRequest.snapshot(),
                new ActionListener<Void>() {

                    @Override
                    public void onResponse(Void response) {
                        chain.proceed(task, action, request, listener);
                    }

                    @Override
                    public void onFailure(Throwable e) {
                        listener.onFailure(e);
                    }
                });
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:27,代码来源:DeleteSnapshotActionFilter.java


示例4: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void apply(final String action, final ActionResponse response,
        @SuppressWarnings("rawtypes") final ActionListener listener,
        final ActionFilterChain chain) {
    if (!CreateSnapshotAction.NAME.equals(action) || !clusterService.state().nodes().localNodeMaster()) {
        chain.proceed(action, response, listener);
    } else {
        final CreateSnapshotResponse createSnapshotResponse = (CreateSnapshotResponse) response;
        final SnapshotInfo snapshotInfo = createSnapshotResponse
                .getSnapshotInfo();
        dictionarySnapshotService.createDictionarySnapshot(
                ((ActionListenerWrapper<?>) listener).getSnapshotId(),
                snapshotInfo, new ActionListener<Void>() {

                    @Override
                    public void onResponse(final Void resp) {
                        chain.proceed(action, response, listener);
                    }

                    @Override
                    public void onFailure(final Throwable e) {
                        listener.onFailure(e);
                    }
                });
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:27,代码来源:CreateSnapshotActionFilter.java


示例5: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
public void apply(Task task, String action, ActionRequest request,
                  ActionListener listener, ActionFilterChain chain) {
    try {
        // authentication
        ActionSourceType sourceType = ActionSourceType.getActionSourceType(action);
        LoginUserContext userInfoContext = request.getHeader(LoginUserContext.USER_INFO_KEY);
        // authentication and authorization only happened on the proxy node(the node user connected to)
        // for sql, the authorized value will be set to true
        // for rest,
        if (sourceType == ActionSourceType.OTHERS
                && userInfoContext != null
                && !userInfoContext.authorized()
                && userInfoContext.getUserProperty() != null) {
            AuthResult authResult = authService.authenticate(request, action);
            if (authResult.getStatus() != RestStatus.OK) {
                throw new NoPermissionException(authResult.getStatus().getStatus(), authResult.getMessage());
            }
            userInfoContext.setAuthorized(true);
        }
        // filter other tenants in clusterState if necessary
        AuthService.setStateFilter(request, action);
        chain.proceed(task, action, request, listener);
    } catch (Throwable t) {
        logger.error("errors while check auth", t);
        throw t;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:28,代码来源:AuthActionFilter.java


示例6: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public <Request extends ActionRequest, Response extends ActionResponse> void apply(Task task, String action, Request request,
		ActionListener<Response> listener, ActionFilterChain<Request, Response> chain) {
	// TODO Auto-generated method stub
	log(1, "apply... " + action);

	boolean usingAuth = auther.isUsing();
	boolean usinglog = actionLogger.isUsing();

	if (usingAuth || usinglog) {
		boolean isJavaClient = isJavaClient(task, request);
		boolean isSystemAction = checkSystemAction(task, action);
		boolean isAuthed = false;
		if (!isSystemAction) {
			SpActionFilterUtil.checkRemoteAddress(request, listener);

			isAuthed = usingAuth ? auther.auth(task, action, request, listener, isJavaClient) : true;
			log(1, "remoteAddress:" + request.remoteAddress());

			if(usinglog) {
				actionLogger.log(task, action, request, isAuthed, isJavaClient);
			}
		}

		if (!isAuthed && !isSystemAction) {
			// listener.onResponse();
			// listener.onResponse(new BytesRestResponse(RestStatus.OK, helpString));
			if (!isJavaClient) {
				listener.onFailure(new Exception("the auth is must please do the auth, this message is from sp tools"));
			}

		} else {
			chain.proceed(task, action, request, listener);
		}
	} else {
		chain.proceed(task, action, request, listener);
	}

}
 
开发者ID:psfu,项目名称:es-sp-tools,代码行数:40,代码来源:SpActionFilter.java


示例7: applySecure

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void applySecure(Task task, final String action, final ActionRequest request, final ActionListener listener, final ActionFilterChain chain) {

    if (filterMap.size() == 0) {
        chain.proceed(task, action, request, listener);
        return;
    }

    for (final Iterator<Entry<String, Tuple<List<String>, List<String>>>> it = filterMap.entrySet().iterator(); it.hasNext();) {

        final Entry<String, Tuple<List<String>, List<String>>> entry = it.next();

        final String filterName = entry.getKey();
        final List<String> allowedActions = entry.getValue().v1();
        final List<String> forbiddenActions = entry.getValue().v2();

        request.putInContext("armor." + filterType + "." + filterName + ".allowed_actions", allowedActions);
        request.putInContext("armor." + filterType + "." + filterName + ".forbidden_actions", forbiddenActions);

        if (request.hasInContext("armor_filter") && filterType != null) {
            if (!((List<String>) request.getFromContext("armor_filter")).contains(filterType + ":" + filterName)) {
                ((List<String>) request.getFromContext("armor_filter")).add(filterType + ":" + filterName);
            }
        } else if (filterType != null) {
            final List<String> _filters = new ArrayList<String>();
            _filters.add(filterType + ":" + filterName);
            request.putInContext("armor_filter", _filters);
        }
    }

    chain.proceed(task, action, request, listener);
}
 
开发者ID:petalmd,项目名称:armor,代码行数:33,代码来源:RequestActionFilter.java


示例8: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public <Request extends ActionRequest, Response extends ActionResponse> void apply(final Task task, final String action, final Request request,
        final ActionListener<Response> listener, final ActionFilterChain<Request, Response> chain) {
    if (!SearchAction.INSTANCE.name().equals(action)) {
        chain.proceed(task, action, request, listener);
        return;
    }

    final SearchRequest searchRequest = (SearchRequest) request;
    final ActionListener<Response> wrappedListener = DynamicRanker.getInstance().wrapActionListener(action, searchRequest, listener);
    chain.proceed(task, action, request, wrappedListener == null ? listener : wrappedListener);
}
 
开发者ID:codelibs,项目名称:elasticsearch-dynarank,代码行数:13,代码来源:SearchActionFilter.java


示例9: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void apply(final Task task, final String action,
        @SuppressWarnings("rawtypes") final ActionRequest request,
        @SuppressWarnings("rawtypes") final ActionListener listener,
        final ActionFilterChain chain) {
    if (!RestoreSnapshotAction.NAME.equals(action) || !clusterService.state().nodes().localNodeMaster()) {
        chain.proceed(task, action, request, listener);
    } else {
        final RestoreSnapshotRequest restoreSnapshotRequest = (RestoreSnapshotRequest) request;
        dictionaryRestoreService.restoreDictionarySnapshot(
                restoreSnapshotRequest.repository(), restoreSnapshotRequest.snapshot(),
                restoreSnapshotRequest.indices(), new ActionListener<Void>() {

                    @Override
                    public void onResponse(final Void response) {
                        chain.proceed(task, action, request, listener);
                    }

                    @Override
                    public void onFailure(final Throwable e) {
                        if (logger.isDebugEnabled()) {
                            logger.debug(
                                    "Failed to restore dictionaries for {} snapshot in {} repository.",
                                    e, restoreSnapshotRequest.repository(),
                                    restoreSnapshotRequest.snapshot());
                        }
                        listener.onFailure(e);
                    }
                });
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:32,代码来源:RestoreSnapshotActionFilter.java


示例10: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void apply(final String action,
        @SuppressWarnings("rawtypes") final ActionRequest request,
        @SuppressWarnings("rawtypes") final ActionListener listener,
        final ActionFilterChain chain) {
    if (!SearchAction.INSTANCE.name().equals(action)) {
        chain.proceed(action, request, listener);
        return;
    }

    final SearchRequest searchRequest = (SearchRequest) request;
    final Boolean invoked = searchRequest.getHeader(SEARCH_REQUEST_INVOKED);
    if (invoked != null && invoked.booleanValue()) {
        if (queryResultCache.canCache(searchRequest)) {
            @SuppressWarnings({ "rawtypes", "unchecked" })
            final ActionListener cacheListener = queryResultCache
                    .execute(searchRequest, listener, chain);
            if (cacheListener != null) {
                chain.proceed(action, request, cacheListener);
            }
        } else {
            chain.proceed(action, request, listener);
        }
    } else {
        searchRequest.putHeader(SEARCH_REQUEST_INVOKED, Boolean.TRUE);
        chain.proceed(action, request, listener);
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-qrcache,代码行数:29,代码来源:QueryResultCacheFilter.java


示例11: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void apply(Task task, String action, ActionRequest request, ActionListener listener,
        ActionFilterChain chain) {
    chain.proceed(task, action, request, listener);
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:6,代码来源:KibanaUserReindexAction.java


示例12: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public  void apply(String action, ActionResponse response, ActionListener listener, ActionFilterChain chain) {
    chain.proceed(action, response, listener);
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:6,代码来源:FieldStatsResponseFilter.java


示例13: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public final void apply(Task task, final String action, final ActionRequest request, final ActionListener listener, final ActionFilterChain chain) {
    log.debug("REQUEST on node {}: {} ({}) from {}", clusterService.localNode().getName(), action, request.getClass(),
            request.remoteAddress() == null ? "INTRANODE" : request.remoteAddress().toString());
    log.debug("Context {}", request.getContext());
    log.debug("Headers {}", request.getHeaders());

    if (settings.getAsBoolean(ConfigConstants.ARMOR_ALLOW_KIBANA_ACTIONS, true) && (action.startsWith("cluster:monitor/") || action.contains("indices:data/read/field_stats"))) {
        chain.proceed(task, action, request, listener);
        return;
    }

    final User restUser = request.getFromContext("armor_authenticated_user", null);

    final boolean restAuthenticated = restUser != null;

    if (restAuthenticated) {
        log.debug("TYPE: rest authenticated request, apply filters");
        applySecure(task, action, request, listener, chain);
        return;
    }

    final boolean intraNodeRequest = request.remoteAddress() == null;

    if (intraNodeRequest) {
        log.debug("TYPE: intra node request, skip filters");
        chain.proceed(task, action, request, listener);
        return;
    }

    final Object authHeader = request.getHeader("armor_authenticated_transport_request");
    boolean interNodeAuthenticated = false;

    if (authHeader != null && authHeader instanceof String) {
        final Object decrypted = SecurityUtil.decryptAnDeserializeObject((String) authHeader, ArmorService.getSecretKey());

        if (decrypted != null && (decrypted instanceof String) && decrypted.equals("authorized")) {
            interNodeAuthenticated = true;
        }

    }

    if (interNodeAuthenticated) {
        log.debug("TYPE: inter node cluster request, skip filters");
        chain.proceed(task, action, request, listener);
        return;
    }

    final Object transportCreds = request.getHeader("armor_transport_creds");
    User authenticatedTransportUser = null;
    boolean transportAuthenticated = false;
    if (transportCreds != null && transportCreds instanceof String
            && settings.getAsBoolean(ConfigConstants.ARMOR_TRANSPORT_AUTH_ENABLED, false)) {

        try {

            final String decodedBasicHeader = new String(DatatypeConverter.parseBase64Binary((String) transportCreds),
                    StandardCharsets.US_ASCII);

            final String username = decodedBasicHeader.split(":")[0];
            final char[] password = decodedBasicHeader.split(":")[1].toCharArray();

            authenticatedTransportUser = backend.authenticate(new AuthCredentials(username, password));
            authorizator.fillRoles(authenticatedTransportUser, new AuthCredentials(authenticatedTransportUser.getName(), null));
            request.putInContext("armor_authenticated_user", authenticatedTransportUser);
        } catch (final Exception e) {
            throw new RuntimeException("Transport authentication failed due to " + e, e);
        }

    }

    transportAuthenticated = authenticatedTransportUser != null;

    if (transportAuthenticated) {
        log.debug("TYPE: transport authenticated request, apply filters");
        applySecure(task, action, request, listener, chain);
        return;
    }

    throw new RuntimeException("Unauthenticated request (SEARCHGUARD_UNAUTH_REQ) for action " + action);
}
 
开发者ID:petalmd,项目名称:armor,代码行数:82,代码来源:AbstractActionFilter.java


示例14: applySecure

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
public abstract void applySecure(Task task, final String action, final ActionRequest request, final ActionListener listener,
final ActionFilterChain chain);
 
开发者ID:petalmd,项目名称:armor,代码行数:3,代码来源:AbstractActionFilter.java


示例15: apply

import org.elasticsearch.action.support.ActionFilterChain; //导入依赖的package包/类
@Override
public void apply(final String action, final ActionResponse response, final ActionListener listener, final ActionFilterChain chain) {
    chain.proceed(action, response, listener);
}
 
开发者ID:petalmd,项目名称:armor,代码行数:5,代码来源:ArmorActionFilter.java



注:本文中的org.elasticsearch.action.support.ActionFilterChain类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Counter64类代码示例发布时间:2022-05-22
下一篇:
Java FormEntryModel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap