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

Java ReqContext类代码示例

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

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



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

示例1: populateContext

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * Populates a given context with a new Subject derived from the credentials in a servlet request.
 * 
 * @param context the context to be populated
 * @param req the servlet request
 * @return the context
 */
@Override
public ReqContext populateContext(ReqContext context, HttpServletRequest req) {
    String userName = getUserName(req);

    String doAsUser = req.getHeader("doAsUser");
    if (doAsUser == null) {
        doAsUser = req.getParameter("doAsUser");
    }

    if (doAsUser != null) {
        context.setRealPrincipal(new SingleUserPrincipal(userName));
        userName = doAsUser;
    }

    Set<Principal> principals = new HashSet<Principal>();
    if (userName != null) {
        Principal p = new SingleUserPrincipal(userName);
        principals.add(p);
    }
    Subject s = new Subject(true, principals, new HashSet(), new HashSet());
    context.setSubject(s);

    return context;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:32,代码来源:DefaultHttpCredentialsPlugin.java


示例2: handleAuthorizeCallback

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    LOG.info("Successfully authenticated client: authenticationID=" + authenticationID + " authorizationID= " + ac.getAuthorizationID());

    // if authorizationId is not set, set it to authenticationId.
    if (ac.getAuthorizationID() == null) {
        ac.setAuthorizedID(authenticationID);
    }

    // When authNid and authZid are not equal , authNId is attempting to impersonate authZid, We
    // add the authNid as the real user in reqContext's subject which will be used during authorization.
    if (!ac.getAuthenticationID().equals(ac.getAuthorizationID())) {
        ReqContext.context().setRealPrincipal(new SaslTransportPlugin.User(ac.getAuthenticationID()));
    }

    ac.setAuthorized(true);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:18,代码来源:ServerCallbackHandler.java


示例3: handleAuthorizeCallback

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
private void handleAuthorizeCallback(AuthorizeCallback ac) {
    String authenticationID = ac.getAuthenticationID();
    LOG.info("Successfully authenticated client: authenticationID = " + authenticationID + " authorizationID = " + ac.getAuthorizationID());

    // if authorizationId is not set, set it to authenticationId.
    if (ac.getAuthorizationID() == null) {
        ac.setAuthorizedID(authenticationID);
    }

    // When authNid and authZid are not equal , authNId is attempting to impersonate authZid, We
    // add the authNid as the real user in reqContext's subject which will be used during authorization.
    if (!authenticationID.equals(ac.getAuthorizationID())) {
        LOG.info("Impersonation attempt  authenticationID = " + ac.getAuthenticationID() + " authorizationID = " + ac.getAuthorizationID());
        ReqContext.context().setRealPrincipal(new SaslTransportPlugin.User(ac.getAuthenticationID()));
    }

    ac.setAuthorized(true);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:19,代码来源:ServerCallbackHandler.java


示例4: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param context
 *            request context includes info about
 * @param operation
 *            operation name
 * @param topology_storm
 *            configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
@Override
public boolean permit(ReqContext context, String operation,
		Map topology_conf) {
	LOG.info("[req "
			+ context.requestID()
			+ "] Access "
			+ " from: "
			+ (context.remoteAddress() == null ? "null" : context
					.remoteAddress().toString()) + " principal:"
			+ (context.principal() == null ? "null" : context.principal())
			+ " op:" + operation + " topoology:"
			+ topology_conf.get(Config.TOPOLOGY_NAME));
	return true;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:26,代码来源:NoopAuthorizer.java


示例5: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param contrext
 *            request context
 * @param operation
 *            operation name
 * @param topology_storm
 *            configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
@Override
public boolean permit(ReqContext context, String operation,
		Map topology_conf) {
	LOG.info("[req "
			+ context.requestID()
			+ "] Access "
			+ " from: "
			+ (context.remoteAddress() == null ? "null" : context
					.remoteAddress().toString()) + " principal:"
			+ (context.principal() == null ? "null" : context.principal())
			+ " op:" + operation + " topoology:"
			+ topology_conf.get(Config.TOPOLOGY_NAME));
	return false;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:26,代码来源:DenyAuthorizer.java


示例6: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param context
 *            request context includes info about
 * @param operation
 *            operation name
 * @param topology_storm
 *            configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation,
		Map topology_conf) {
	LOG.info("[req "
			+ context.requestID()
			+ "] Access "
			+ " from: "
			+ (context.remoteAddress() == null ? "null" : context
					.remoteAddress().toString()) + " principal:"
			+ (context.principal() == null ? "null" : context.principal())
			+ " op:" + operation + " topoology:"
			+ topology_conf.get(Config.TOPOLOGY_NAME));
	return true;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:25,代码来源:NoopAuthorizer.java


示例7: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param contrext
 *            request context
 * @param operation
 *            operation name
 * @param topology_storm
 *            configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation,
		Map topology_conf) {
	LOG.info("[req "
			+ context.requestID()
			+ "] Access "
			+ " from: "
			+ (context.remoteAddress() == null ? "null" : context
					.remoteAddress().toString()) + " principal:"
			+ (context.principal() == null ? "null" : context.principal())
			+ " op:" + operation + " topoology:"
			+ topology_conf.get(Config.TOPOLOGY_NAME));
	return false;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:25,代码来源:DenyAuthorizer.java


示例8: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * Authorizes request from to the DRPC server.
 * 
 * @param context the client request context
 * @param operation the operation requested by the DRPC server
 * @param params a Map with any key-value entries of use to the authorization implementation
 */
@Override
public boolean permit(ReqContext context, String operation, Map params) {
    if ("execute".equals(operation)) {
        return permitClientRequest(context, operation, params);
    } else if ("failRequest".equals(operation) || "fetchRequest".equals(operation) || "result".equals(operation)) {
        return permitInvocationRequest(context, operation, params);
    }
    // Deny unsupported operations.
    LOG.warn("Denying unsupported operation \"" + operation + "\" from " + context.remoteAddress());
    return false;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:19,代码来源:DRPCAuthorizerBase.java


示例9: getUserFromContext

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
private String getUserFromContext(ReqContext context) {
    if (context != null) {
        Principal princ = context.principal();
        if (princ != null) {
            return princ.getName();
        }
    }
    return null;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:10,代码来源:DRPCSimpleACLAuthorizer.java


示例10: permitClientOrInvocationRequest

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
protected boolean permitClientOrInvocationRequest(ReqContext context, Map params, String fieldName) {
    Map<String, AclFunctionEntry> acl = readAclFromConfig();
    String function = (String) params.get(FUNCTION_KEY);
    if (function != null && !function.isEmpty()) {
        AclFunctionEntry entry = acl.get(function);
        if (entry == null && _permitWhenMissingFunctionEntry) {
            return true;
        }
        if (entry != null) {
            Object value;
            try {
                Field field = AclFunctionEntry.class.getDeclaredField(fieldName);
                value = field.get(entry);
            } catch (Exception ex) {
                LOG.warn("Caught Exception while accessing ACL", ex);
                return false;
            }
            String principal = getUserFromContext(context);
            String user = getLocalUserFromContext(context);
            if (value == null) {
                LOG.warn("Configuration for function '" + function + "' is " + "invalid: it should have both an invocation user "
                        + "and a list of client users defined.");
            } else if (value instanceof Set && (((Set<String>) value).contains(principal) || ((Set<String>) value).contains(user))) {
                return true;
            } else if (value instanceof String && (value.equals(principal) || value.equals(user))) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:32,代码来源:DRPCSimpleACLAuthorizer.java


示例11: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * @param context request context includes info about 
 * @param operation operation name
 * @param topology_storm configuration of targeted topology 
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation, Map topology_conf) {
    LOG.info("[req "+ context.requestID()+ "] Access "
            + " from: " + (context.remoteAddress() == null? "null" : context.remoteAddress().toString())
            + " principal:"+(context.principal() == null? "null" : context.principal()) 
            +" op:"+ operation
            + " topoology:"+ topology_conf.get(Config.TOPOLOGY_NAME));
    return true;
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:16,代码来源:NoopAuthorizer.java


示例12: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * @param contrext request context 
 * @param operation operation name
 * @param topology_storm configuration of targeted topology 
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation, Map topology_conf) {
    LOG.info("[req "+ context.requestID()+ "] Access "
            + " from: " + (context.remoteAddress() == null? "null" : context.remoteAddress().toString())
            + " principal:"+ (context.principal() == null? "null" : context.principal())
            +" op:"+operation
            + " topoology:"+topology_conf.get(Config.TOPOLOGY_NAME));
    return false;
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:16,代码来源:DenyAuthorizer.java


示例13: getLocalUserFromContext

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
private String getLocalUserFromContext(ReqContext context) {
    if (context != null) {
        return _ptol.toLocal(context.principal());
    }
    return null;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:7,代码来源:DRPCSimpleACLAuthorizer.java


示例14: permitClientRequest

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
@Override
protected boolean permitClientRequest(ReqContext context, String operation, Map params) {
    return permitClientOrInvocationRequest(context, params, "clientUsers");
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:5,代码来源:DRPCSimpleACLAuthorizer.java


示例15: permitInvocationRequest

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
@Override
protected boolean permitInvocationRequest(ReqContext context, String operation, Map params) {
    return permitClientOrInvocationRequest(context, params, "invocationUser");
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:5,代码来源:DRPCSimpleACLAuthorizer.java


示例16: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param context request context includes info about
 * @param operation operation name
 * @param topology_storm configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
@Override
public boolean permit(ReqContext context, String operation, Map topology_conf) {
    LOG.info("[req " + context.requestID() + "] Access " + " from: " + (context.remoteAddress() == null ? "null" : context.remoteAddress().toString())
            + (context.principal() == null ? "" : (" principal:" + context.principal())) + " op:" + operation
            + (topology_conf == null ? "" : (" topoology:" + topology_conf.get(Config.TOPOLOGY_NAME))));
    return context.principal() != null ? users.contains(context.principal().getName()) : false;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:16,代码来源:SimpleWhitelistAuthorizer.java


示例17: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param context request context includes info about
 * @param operation operation name
 * @param topology_storm configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation, Map topology_conf) {
    LOG.info("[req " + context.requestID() + "] Access " + " from: " + (context.remoteAddress() == null ? "null" : context.remoteAddress().toString())
            + (context.principal() == null ? "" : (" principal:" + context.principal())) + " op:" + operation
            + (topology_conf == null ? "" : (" topoology:" + topology_conf.get(Config.TOPOLOGY_NAME))));
    return true;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:15,代码来源:NoopAuthorizer.java


示例18: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 * 
 * @param contrext request context
 * @param operation operation name
 * @param topology_storm configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation, Map topology_conf) {
    LOG.info("[req " + context.requestID() + "] Access " + " from: " + (context.remoteAddress() == null ? "null" : context.remoteAddress().toString())
            + (context.principal() == null ? "" : (" principal:" + context.principal())) + " op:" + operation
            + (topology_conf == null ? "" : (" topoology:" + topology_conf.get(Config.TOPOLOGY_NAME))));
    return false;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:15,代码来源:DenyAuthorizer.java


示例19: permit

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * permit() method is invoked for each incoming Thrift request
 *
 * @param context       request context
 * @param operation     operation name
 * @param topology_conf configuration of targeted topology
 * @return true if the request is authorized, false if reject
 */
public boolean permit(ReqContext context, String operation, Map topology_conf) {
    LOG.info("[req " + context.requestID() + "] Access " + " from: " +
            (context.remoteAddress() == null ? "null" : context.remoteAddress().toString())
            + (context.principal() == null ? "" : (" principal:" + context.principal())) + " op:" + operation
            + (topology_conf == null ? "" : (" topoology:" + topology_conf.get(Config.TOPOLOGY_NAME))));
    return false;
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:16,代码来源:DenyAuthorizer.java


示例20: populateContext

import backtype.storm.security.auth.ReqContext; //导入依赖的package包/类
/**
 * Populates a given context with credentials information from an HTTP request.
 * 
 * @param req the servlet request
 * @return the context
 */
ReqContext populateContext(ReqContext context, HttpServletRequest req);
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:8,代码来源:IHttpCredentialsPlugin.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java TileEntityDropper类代码示例发布时间:2022-05-22
下一篇:
Java ShadowEnvironment类代码示例发布时间: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