Java 类org.apache.http.localserver.ResponseBasicUnauthorized 实例源码

项目:gondola    文件:LocalTestServer.java   
public LocalTestServer(HttpRequestHandler handler) {
    try {
        setUp();
        HttpProcessor httpproc = HttpProcessorBuilder.create()
            .add(new ResponseDate())
            .add(new ResponseServer(LocalServerTestBase.ORIGIN))
            .add(new ResponseContent())
            .add(new ResponseConnControl())
            .add(new RequestBasicAuth())
            .add(new ResponseBasicUnauthorized()).build();
        this.serverBootstrap.setHttpProcessor(httpproc);
        this.serverBootstrap.registerHandler("*", handler);
        host = start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:Camel    文件:HttpCompressionTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestDecompressingInterceptor());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseCompressingInterceptor());
    responseInterceptors.add(new ResponseBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    return httpproc;
}
项目:Camel    文件:HttpAuthenticationTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestBasicAuth());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseContent());
    responseInterceptors.add(new ResponseBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    return httpproc;
}
项目:Camel    文件:HttpsAuthenticationTest.java   
@Override
protected HttpProcessor getBasicHttpProcessor() {
    List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
    requestInterceptors.add(new RequestBasicAuth());
    List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
    responseInterceptors.add(new ResponseContent());
    responseInterceptors.add(new ResponseBasicUnauthorized());
    ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);

    return httpproc;
}
项目:purecloud-iot    文件:TestClientAuthentication.java   
@Before @Override
public void setUp() throws Exception {
    super.setUp();
    final HttpProcessor httpproc = HttpProcessorBuilder.create()
        .add(new ResponseDate())
        .add(new ResponseServer(LocalServerTestBase.ORIGIN))
        .add(new ResponseContent())
        .add(new ResponseConnControl())
        .add(new RequestBasicAuth())
        .add(new ResponseBasicUnauthorized()).build();
    this.serverBootstrap.setHttpProcessor(httpproc);
}
项目:purecloud-iot    文件:TestClientAuthentication.java   
@Test
public void testBasicAuthenticationSuccessOnNonRepeatablePutExpectContinue() throws Exception {
    final HttpProcessor httpproc = HttpProcessorBuilder.create()
        .add(new ResponseDate())
        .add(new ResponseServer(LocalServerTestBase.ORIGIN))
        .add(new ResponseContent())
        .add(new ResponseConnControl())
        .add(new RequestBasicAuth())
        .add(new ResponseBasicUnauthorized()).build();
    this.serverBootstrap.setHttpProcessor(httpproc)
        .setExpectationVerifier(new AuthExpectationVerifier())
        .registerHandler("*", new AuthHandler());

    final HttpHost target = start();

    final RequestConfig config = RequestConfig.custom()
            .setExpectContinueEnabled(true)
            .build();
    final HttpPut httpput = new HttpPut("/");
    httpput.setConfig(config);
    httpput.setEntity(new InputStreamEntity(
            new ByteArrayInputStream(
                    new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ),
                    -1));
    final HttpClientContext context = HttpClientContext.create();
    final TestCredentialsProvider credsProvider = new TestCredentialsProvider(
            new UsernamePasswordCredentials("test", "test"));
    context.setCredentialsProvider(credsProvider);

    final HttpResponse response = this.httpclient.execute(target, httpput, context);
    final HttpEntity entity = response.getEntity();
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    Assert.assertNotNull(entity);
}