本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}