Search in sources :

Example 1 with RequestDefaultHeaders

use of org.apache.http.client.protocol.RequestDefaultHeaders in project robovm by robovm.

the class DefaultHttpClient method createHttpProcessor.

@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}
Also used : RequestAddCookies(org.apache.http.client.protocol.RequestAddCookies) RequestContent(org.apache.http.protocol.RequestContent) RequestTargetHost(org.apache.http.protocol.RequestTargetHost) RequestConnControl(org.apache.http.protocol.RequestConnControl) RequestProxyAuthentication(org.apache.http.client.protocol.RequestProxyAuthentication) RequestExpectContinue(org.apache.http.protocol.RequestExpectContinue) RequestUserAgent(org.apache.http.protocol.RequestUserAgent) RequestDefaultHeaders(org.apache.http.client.protocol.RequestDefaultHeaders) RequestTargetAuthentication(org.apache.http.client.protocol.RequestTargetAuthentication) ResponseProcessCookies(org.apache.http.client.protocol.ResponseProcessCookies) BasicHttpProcessor(org.apache.http.protocol.BasicHttpProcessor)

Example 2 with RequestDefaultHeaders

use of org.apache.http.client.protocol.RequestDefaultHeaders in project hive by apache.

the class TestThriftHttpCLIServiceFeatures method verifyForwardedHeaders.

private void verifyForwardedHeaders(ArrayList<String> headerIPs, String cmd) throws Exception {
    TTransport transport;
    DefaultHttpClient hClient = new DefaultHttpClient();
    String httpUrl = getHttpUrl();
    // add an interceptor that adds the X-Forwarded-For header with given ips
    if (!headerIPs.isEmpty()) {
        Header xForwardHeader = new BasicHeader("X-Forwarded-For", Joiner.on(",").join(headerIPs));
        RequestDefaultHeaders headerInterceptor = new RequestDefaultHeaders(Arrays.asList(xForwardHeader));
        hClient.addRequestInterceptor(headerInterceptor);
    }
    // interceptor for adding username, pwd
    HttpBasicAuthInterceptor authInt = new HttpBasicAuthInterceptor(ThriftCLIServiceTest.USERNAME, ThriftCLIServiceTest.PASSWORD, null, null, false, null, null);
    hClient.addRequestInterceptor(authInt);
    transport = new THttpClient(httpUrl, hClient);
    TCLIService.Client httpClient = getClient(transport);
    // Create a new open session request object
    TOpenSessionReq openReq = new TOpenSessionReq();
    TOpenSessionResp openResp = httpClient.OpenSession(openReq);
    // execute a query
    TExecuteStatementReq execReq = new TExecuteStatementReq(openResp.getSessionHandle(), "show tables");
    httpClient.ExecuteStatement(execReq);
    // capture arguments to authorizer impl call and verify ip addresses passed
    ArgumentCaptor<HiveAuthzContext> contextCapturer = ArgumentCaptor.forClass(HiveAuthzContext.class);
    verify(mockedAuthorizer).checkPrivileges(any(HiveOperationType.class), Matchers.anyListOf(HivePrivilegeObject.class), Matchers.anyListOf(HivePrivilegeObject.class), contextCapturer.capture());
    HiveAuthzContext context = contextCapturer.getValue();
    System.err.println("Forwarded IP Addresses " + context.getForwardedAddresses());
    List<String> auditIPAddresses = new ArrayList<String>(context.getForwardedAddresses());
    Collections.sort(auditIPAddresses);
    Collections.sort(headerIPs);
    Assert.assertEquals("Checking forwarded IP Address", headerIPs, auditIPAddresses);
}
Also used : RequestDefaultHeaders(org.apache.http.client.protocol.RequestDefaultHeaders) HiveAuthzContext(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext) ArrayList(java.util.ArrayList) THttpClient(org.apache.thrift.transport.THttpClient) TExecuteStatementReq(org.apache.hive.service.rpc.thrift.TExecuteStatementReq) HiveOperationType(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType) HivePrivilegeObject(org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) TCLIService(org.apache.hive.service.rpc.thrift.TCLIService) Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) TTransport(org.apache.thrift.transport.TTransport) TOpenSessionReq(org.apache.hive.service.rpc.thrift.TOpenSessionReq) TOpenSessionResp(org.apache.hive.service.rpc.thrift.TOpenSessionResp) BasicHeader(org.apache.http.message.BasicHeader) HttpBasicAuthInterceptor(org.apache.hive.jdbc.HttpBasicAuthInterceptor)

Example 3 with RequestDefaultHeaders

use of org.apache.http.client.protocol.RequestDefaultHeaders in project XobotOS by xamarin.

the class DefaultHttpClient method createHttpProcessor.

@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}
Also used : RequestAddCookies(org.apache.http.client.protocol.RequestAddCookies) RequestContent(org.apache.http.protocol.RequestContent) RequestTargetHost(org.apache.http.protocol.RequestTargetHost) RequestConnControl(org.apache.http.protocol.RequestConnControl) RequestProxyAuthentication(org.apache.http.client.protocol.RequestProxyAuthentication) RequestExpectContinue(org.apache.http.protocol.RequestExpectContinue) RequestUserAgent(org.apache.http.protocol.RequestUserAgent) RequestDefaultHeaders(org.apache.http.client.protocol.RequestDefaultHeaders) RequestTargetAuthentication(org.apache.http.client.protocol.RequestTargetAuthentication) ResponseProcessCookies(org.apache.http.client.protocol.ResponseProcessCookies) BasicHttpProcessor(org.apache.http.protocol.BasicHttpProcessor)

Example 4 with RequestDefaultHeaders

use of org.apache.http.client.protocol.RequestDefaultHeaders in project platform_external_apache-http by android.

the class DefaultHttpClient method createHttpProcessor.

@Override
protected BasicHttpProcessor createHttpProcessor() {
    BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new RequestDefaultHeaders());
    // Required protocol interceptors
    httpproc.addInterceptor(new RequestContent());
    httpproc.addInterceptor(new RequestTargetHost());
    // Recommended protocol interceptors
    httpproc.addInterceptor(new RequestConnControl());
    httpproc.addInterceptor(new RequestUserAgent());
    httpproc.addInterceptor(new RequestExpectContinue());
    // HTTP state management interceptors
    httpproc.addInterceptor(new RequestAddCookies());
    httpproc.addInterceptor(new ResponseProcessCookies());
    // HTTP authentication interceptors
    httpproc.addInterceptor(new RequestTargetAuthentication());
    httpproc.addInterceptor(new RequestProxyAuthentication());
    return httpproc;
}
Also used : RequestAddCookies(org.apache.http.client.protocol.RequestAddCookies) RequestContent(org.apache.http.protocol.RequestContent) RequestTargetHost(org.apache.http.protocol.RequestTargetHost) RequestConnControl(org.apache.http.protocol.RequestConnControl) RequestProxyAuthentication(org.apache.http.client.protocol.RequestProxyAuthentication) RequestExpectContinue(org.apache.http.protocol.RequestExpectContinue) RequestUserAgent(org.apache.http.protocol.RequestUserAgent) RequestDefaultHeaders(org.apache.http.client.protocol.RequestDefaultHeaders) RequestTargetAuthentication(org.apache.http.client.protocol.RequestTargetAuthentication) ResponseProcessCookies(org.apache.http.client.protocol.ResponseProcessCookies) BasicHttpProcessor(org.apache.http.protocol.BasicHttpProcessor)

Aggregations

RequestDefaultHeaders (org.apache.http.client.protocol.RequestDefaultHeaders)4 RequestAddCookies (org.apache.http.client.protocol.RequestAddCookies)3 RequestProxyAuthentication (org.apache.http.client.protocol.RequestProxyAuthentication)3 RequestTargetAuthentication (org.apache.http.client.protocol.RequestTargetAuthentication)3 ResponseProcessCookies (org.apache.http.client.protocol.ResponseProcessCookies)3 BasicHttpProcessor (org.apache.http.protocol.BasicHttpProcessor)3 RequestConnControl (org.apache.http.protocol.RequestConnControl)3 RequestContent (org.apache.http.protocol.RequestContent)3 RequestExpectContinue (org.apache.http.protocol.RequestExpectContinue)3 RequestTargetHost (org.apache.http.protocol.RequestTargetHost)3 RequestUserAgent (org.apache.http.protocol.RequestUserAgent)3 ArrayList (java.util.ArrayList)1 HiveAuthzContext (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext)1 HiveOperationType (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType)1 HivePrivilegeObject (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject)1 HttpBasicAuthInterceptor (org.apache.hive.jdbc.HttpBasicAuthInterceptor)1 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)1 TExecuteStatementReq (org.apache.hive.service.rpc.thrift.TExecuteStatementReq)1 TOpenSessionReq (org.apache.hive.service.rpc.thrift.TOpenSessionReq)1 TOpenSessionResp (org.apache.hive.service.rpc.thrift.TOpenSessionResp)1