当前位置: 首页>>代码示例>>Java>>正文


Java ThreadContext.getTransient方法代码示例

本文整理汇总了Java中org.elasticsearch.common.util.concurrent.ThreadContext.getTransient方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadContext.getTransient方法的具体用法?Java ThreadContext.getTransient怎么用?Java ThreadContext.getTransient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.util.concurrent.ThreadContext的用法示例。


在下文中一共展示了ThreadContext.getTransient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractCredentials

import org.elasticsearch.common.util.concurrent.ThreadContext; //导入方法依赖的package包/类
@Override
public AuthCredentials extractCredentials(final RestRequest request, ThreadContext context) {
	
    if(context.getTransient(ConfigConstants.SG_XFF_DONE) !=  Boolean.TRUE) {
        throw new ElasticsearchSecurityException("xff not done");
    }
    
    final String userHeader = settings.get("user_header");
    final String rolesHeader = settings.get("roles_header");

    if(log.isDebugEnabled()) {
        log.debug("headers {}", request.getHeaders());
        log.debug("userHeader {}, value {}", userHeader, userHeader == null?null:request.header(userHeader));
        log.debug("rolesHeader {}, value {}", rolesHeader, rolesHeader == null?null:request.header(rolesHeader));
    }

    if (!Strings.isNullOrEmpty(userHeader) && !Strings.isNullOrEmpty((String) request.header(userHeader))) {

        String[] backendRoles = null;

        if (!Strings.isNullOrEmpty(rolesHeader) && !Strings.isNullOrEmpty((String) request.header(rolesHeader))) {
            backendRoles = ((String) request.header(rolesHeader)).split(",");
        }
        return new AuthCredentials((String) request.header(userHeader), backendRoles).markComplete();
    } else {
        if(log.isTraceEnabled()) {
            log.trace("No '{}' header, send 401", userHeader);
        }
        return null;
    }
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:32,代码来源:HTTPProxyAuthenticator.java

示例2: extractCredentials

import org.elasticsearch.common.util.concurrent.ThreadContext; //导入方法依赖的package包/类
@Override
public AuthCredentials extractCredentials(final RestRequest request, final ThreadContext threadContext) {

    final String principal = threadContext.getTransient(ConfigConstants.SG_SSL_PRINCIPAL);

    if (!Strings.isNullOrEmpty(principal)) {
        
        final String usernameAttribute = settings.get("username_attribute");
        final String rolesAttribute = settings.get("roles_attribute");
        
        try {
            final LdapName rfc2253dn = new LdapName(principal);
            String username = principal.trim();
            String[] backendRoles = null;
            
            if(usernameAttribute != null && usernameAttribute.length() > 0) {
                final List<String> usernames = getDnAttribute(rfc2253dn, usernameAttribute);
                if(usernames.isEmpty() == false) {
                    username = usernames.get(0);
                }
            }
            
            if(rolesAttribute != null && rolesAttribute.length() > 0) {
                final List<String> roles = getDnAttribute(rfc2253dn, rolesAttribute);
                if(roles.isEmpty() == false) {
                    backendRoles = roles.toArray(new String[0]);
                }
            }
            
            return new AuthCredentials(username, backendRoles).markComplete();
        } catch (InvalidNameException e) {
            log.error("Client cert had no properly formed DN (was: {})", principal);
            return null;
        }

    } else {
        log.trace("No CLIENT CERT, send 401");
        return null;
    }
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:41,代码来源:HTTPClientCertAuthenticator.java

示例3: isInterClusterRequest

import org.elasticsearch.common.util.concurrent.ThreadContext; //导入方法依赖的package包/类
public static boolean isInterClusterRequest(final ThreadContext context) {
    return context.getTransient(ConfigConstants.SG_SSL_TRANSPORT_INTERCLUSTER_REQUEST) == Boolean.TRUE;
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:4,代码来源:HeaderHelper.java

示例4: isDirectRequest

import org.elasticsearch.common.util.concurrent.ThreadContext; //导入方法依赖的package包/类
public static boolean isDirectRequest(final ThreadContext context) {
    
    return  "direct".equals(context.getTransient(ConfigConstants.SG_CHANNEL_TYPE))
              || context.getTransient(ConfigConstants.SG_CHANNEL_TYPE) == null;
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:6,代码来源:HeaderHelper.java

示例5: isTrustedClusterRequest

import org.elasticsearch.common.util.concurrent.ThreadContext; //导入方法依赖的package包/类
public static boolean isTrustedClusterRequest(final ThreadContext context) {
    return context.getTransient(ConfigConstants.SG_SSL_TRANSPORT_TRUSTED_CLUSTER_REQUEST) == Boolean.TRUE;
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:4,代码来源:HeaderHelper.java


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