本文整理汇总了Java中org.elasticsearch.http.netty.NettyHttpRequest.request方法的典型用法代码示例。如果您正苦于以下问题:Java NettyHttpRequest.request方法的具体用法?Java NettyHttpRequest.request怎么用?Java NettyHttpRequest.request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.http.netty.NettyHttpRequest
的用法示例。
在下文中一共展示了NettyHttpRequest.request方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateRequestIndex
import org.elasticsearch.http.netty.NettyHttpRequest; //导入方法依赖的package包/类
private RestRequest updateRequestIndex(RestRequest request, String oldIndex, String newIndex) {
String uri = request.uri();
String replaced = uri.replace(oldIndex, newIndex);
NettyHttpRequest nettyRequest = (NettyHttpRequest) request;
HttpRequest httpRequest = nettyRequest.request();
httpRequest.setUri(replaced);
RestRequest updatedRequest = new NettyHttpRequest(httpRequest, nettyRequest.getChannel());
updatedRequest.copyContextAndHeadersFrom(request);
return updatedRequest;
}
示例2: modifyRequest
import org.elasticsearch.http.netty.NettyHttpRequest; //导入方法依赖的package包/类
/**
* Modify the request of needed
* @param request the original request
* @param context the Openshift context
* @return a modified request
*/
public RestRequest modifyRequest(RestRequest request, OpenshiftRequestContext context) {
if(!getUser(request).equals(context.getUser()) && request instanceof NettyHttpRequest) {
NettyHttpRequest netty = (NettyHttpRequest)request;
HttpRequest httpRequest = netty.request();
httpRequest.headers().set(proxyUserHeader, context.getUser());
return new NettyHttpRequest(httpRequest, netty.getChannel());
}
return request;
}
示例3: authenticate
import org.elasticsearch.http.netty.NettyHttpRequest; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
@Override
public User authenticate(final RestRequest request, final RestChannel channel, final AuthenticationBackend backend,
final Authorizator authorizator) throws AuthException {
String dn = null;
sun.security.x509.X500Name x500Principal = null;
try {
final NettyHttpRequest nettyRequest = (NettyHttpRequest) request;
final DefaultHttpsRequest httpsRequest = (DefaultHttpsRequest) nettyRequest.request();
x500Principal = (sun.security.x509.X500Name) httpsRequest.getPrincipal();
dn = String.valueOf(x500Principal);// request.header(MutualSSLHandler.SEARCHGUARD_MUTUAL_SSL_AUTH);
} catch (final Exception e) {
log.error("Invalid request or invalid principal. Pls. check settings, this authenticater works only with https/ssl", e);
}
if (dn == null || dn.isEmpty() || dn.equals("null")) {
throw new AuthException("No x500 principal found in request");
}
final String userAttribute = settings.get(ConfigConstants.ARMOR_AUTHENTICATION_HTTPS_CLIENTCERT_ATTRIBUTENAME, "cn")
.toLowerCase();
final int index = dn.toLowerCase().indexOf(userAttribute + "=");
String userName = dn;
if (index > -1) {
final int start = index + userAttribute.length() + 1;
userName = dn.substring(start, dn.indexOf(",", start));
}
final User authenticatedUser = backend.authenticate(new AuthCredentials(userName, x500Principal));
authorizator.fillRoles(authenticatedUser, new AuthCredentials(authenticatedUser.getName(), x500Principal));
log.debug("User '{}' is authenticated", authenticatedUser);
return authenticatedUser;
}
示例4: updateMGetRequest
import org.elasticsearch.http.netty.NettyHttpRequest; //导入方法依赖的package包/类
private RestRequest updateMGetRequest(RestRequest request, String oldIndex, String newIndex) {
BytesReference content = request.content();
String stringContent = content.toUtf8();
String replaced = stringContent.replaceAll("_index\":\"" + oldIndex + "\"", "_index\":\"" + newIndex + "\"");
NettyHttpRequest nettyRequest = (NettyHttpRequest) request;
HttpRequest httpRequest = nettyRequest.request();
BytesReference replacedContent = new BytesArray(replaced);
BigEndianHeapChannelBuffer buffer = new BigEndianHeapChannelBuffer(replacedContent.array());
httpRequest.setContent(buffer);
RestRequest updatedRequest = new NettyHttpRequest(httpRequest, nettyRequest.getChannel());
updatedRequest.copyContextAndHeadersFrom(request);
return updatedRequest;
}