• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IApiConnectionResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.apiman.gateway.engine.IApiConnectionResponse的典型用法代码示例。如果您正苦于以下问题:Java IApiConnectionResponse类的具体用法?Java IApiConnectionResponse怎么用?Java IApiConnectionResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IApiConnectionResponse类属于io.apiman.gateway.engine包,在下文中一共展示了IApiConnectionResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: HttpApiConnection

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param client the http client to use
 * @param sslStrategy the SSL strategy
 * @param request the request
 * @param api the API
 * @param requiredAuthType the authorization type
 * @param hasDataPolicy if policy chain contains data policies
 * @param handler the result handler
 * @throws ConnectorException when unable to connect
 */
public HttpApiConnection(OkHttpClient client, ApiRequest request, Api api,
        RequiredAuthType requiredAuthType, SSLSessionStrategy sslStrategy,
        boolean hasDataPolicy, IAsyncResultHandler<IApiConnectionResponse> handler) throws ConnectorException {
    this.client = client;
    this.request = request;
    this.api = api;
    this.requiredAuthType = requiredAuthType;
    this.sslStrategy = sslStrategy;
    this.hasDataPolicy = hasDataPolicy;
    this.responseHandler = handler;

    try {
        connect();
    } catch (Exception e) {
        // Sometimes it's possible that multiple exceptions end up coming through. Ignore secondary ones.
        if (!isError) {
            handler.handle(AsyncResultImpl.<IApiConnectionResponse> create(e));
            isError = true;
        }
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:34,代码来源:HttpApiConnection.java


示例2: end

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * @see io.apiman.gateway.engine.io.IWriteStream#end()
 */
@Override
public void end() {
    try {
        IOUtils.closeQuietly(outputStream);
        if (isError) {
            return;
        } else if (!connected) {
            throw new IOException("Not connected."); //$NON-NLS-1$
        }
        outputStream = null;
        // Process the response, convert to an ApiResponse object, and return it
        response = GatewayThreadContext.getApiResponse();
        Map<String, List<String>> headerFields = connection.getHeaderFields();
        for (String headerName : headerFields.keySet()) {
            if (headerName != null && !SUPPRESSED_RESPONSE_HEADERS.contains(headerName)) {
                response.getHeaders().add(headerName, connection.getHeaderField(headerName));
            }
        }
        response.setCode(connection.getResponseCode());
        response.setMessage(connection.getResponseMessage());
        responseHandler.handle(AsyncResultImpl.<IApiConnectionResponse> create(this));
    } catch (Exception e) {
        handleConnectionError(e);
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:29,代码来源:HttpApiConnection.java


示例3: shouldSucceedWhenAllowedSelfSigned

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - no CA inherited trust
 *   - gateway does not explicitly trust the API, but automatically validates against self-signed
 *   - API trusts gateway certificate
 */
@Test
public void shouldSucceedWhenAllowedSelfSigned() {
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/basic_mutual_auth/gateway_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYSTORE, getResourcePath("2waytest/basic_mutual_auth/gateway_ks.jks"));
    config.put(TLSOptions.TLS_KEYSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "true");

   HttpConnectorFactory factory = new HttpConnectorFactory(config);
   IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.MTLS, false);
   IApiConnection connection = connector.connect(request,
           new IAsyncResultHandler<IApiConnectionResponse>() {

    @Override
    public void handle(IAsyncResult<IApiConnectionResponse> result) {
        Assert.assertTrue(result.isSuccess());
    }
   });

   connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:30,代码来源:BasicMutualAuthTest.java


示例4: shouldFailWithInValidKeyAlias

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - Select invalid key alias (no such key).
 *   - Negotiation will fail
 * @throws CertificateException the certificate exception
 * @throws IOException the IO exception
 */
@Test
public void shouldFailWithInValidKeyAlias() throws CertificateException, IOException  {
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/basic_mutual_auth_2/gateway_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYSTORE, getResourcePath("2waytest/basic_mutual_auth_2/gateway_ks.jks"));
    config.put(TLSOptions.TLS_KEYSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "false");
    // No such key exists in the keystore
    config.put(TLSOptions.TLS_KEYALIASES, "xxx");

    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.MTLS, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue(result.isError());
                }
            });

            connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:33,代码来源:BasicMutualAuthTest.java


示例5: shouldFailWithDevModeAndNoClientKeys

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - Development mode TLS pass-through. Gateway accepts anything.
 *   - Server should still refuse on basis of requiring client auth.
 */
@Test
public void shouldFailWithDevModeAndNoClientKeys() {
    config.put(TLSOptions.TLS_DEVMODE, "true");

    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.DEFAULT, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

     @Override
     public void handle(IAsyncResult<IApiConnectionResponse> result) {
             Assert.assertTrue(result.isError());
             System.out.println(result.getError());
         }
    });

    connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:24,代码来源:BasicMutualAuthTest.java


示例6: shouldSucceedWithValidTLS

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - CA inherited trust
 *   - gateway trusts API via CA
 *   - API does not evaluate trust
 */
@Test
public void shouldSucceedWithValidTLS() {
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/mutual_trust_via_ca/common_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "false");

    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.DEFAULT, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

        @Override
        public void handle(IAsyncResult<IApiConnectionResponse> result) {
            if (result.isError())
                throw new RuntimeException(result.getError());

            Assert.assertTrue(result.isSuccess());
        }
    });

    connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:30,代码来源:StandardTLSTest.java


示例7: shouldFailWhenCANotTrusted

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - CA is only in API trust store, missing from gateway trust store
 *   - Gateway does not trust API, as it does not trust CA
 *   - API trusts gateway via CA
 */
@Test
public void shouldFailWhenCANotTrusted() {
    // Keystore does not trust the root CA API is signed with.
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/basic_mutual_auth/gateway_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "false");

    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.DEFAULT, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

     @Override
     public void handle(IAsyncResult<IApiConnectionResponse> result) {
         Assert.assertTrue(result.isError());
         System.out.println(result.getError());
         Assert.assertTrue(result.getError() instanceof ConnectorException);
     }
    });

    connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:30,代码来源:StandardTLSTest.java


示例8: shouldAllowAllWhenDevMode

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - Development mode TLS pass-through. Accepts anything.
 */
@Test
public void shouldAllowAllWhenDevMode() {
    config.put(TLSOptions.TLS_DEVMODE, "true");

    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.DEFAULT, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

     @Override
     public void handle(IAsyncResult<IApiConnectionResponse> result) {
         Assert.assertTrue(result.isSuccess());
     }
    });

    connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:22,代码来源:StandardTLSTest.java


示例9: shouldFailWithNoSettings

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - No settings whatsoever.
 *   - Will fail, as defaults are relatively safe,
 *     and API certificate will not be recognised.
 */
@Test
public void shouldFailWithNoSettings() {
    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.DEFAULT, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

     @Override
     public void handle(IAsyncResult<IApiConnectionResponse> result) {
             Assert.assertTrue(result.isError());
             System.out.println(result.getError());
         }
    });

    connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:23,代码来源:StandardTLSTest.java


示例10: shouldSucceedWithBasicAuth

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario successful connection to the back end API via basic auth.
 */
@Test
public void shouldSucceedWithBasicAuth() {
    endpointProperties.put(BasicAuthOptions.BASIC_USERNAME, "user");
    endpointProperties.put(BasicAuthOptions.BASIC_PASSWORD, "user123!");
    endpointProperties.put(BasicAuthOptions.BASIC_REQUIRE_SSL, "false");
    api.setEndpointProperties(endpointProperties);
    api.setEndpoint("http://localhost:8008/echo");

    HttpConnectorFactory factory = new HttpConnectorFactory(globalConfig);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.BASIC, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {
                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue("Expected a successful connection response.", result.isSuccess());
                    IApiConnectionResponse scr = result.getResult();
                    Assert.assertEquals("Expected a 200 response from the echo server (valid creds).", 200, scr.getHead().getCode());
                }
            });

    if (connection.isConnected()) {
        connection.end();
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:28,代码来源:BasicAuthTest.java


示例11: shouldSucceedWithBasicAuthAndSSL

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario successful connection to the back end API via basic auth.
 */
@Test
public void shouldSucceedWithBasicAuthAndSSL() {
    endpointProperties.put(BasicAuthOptions.BASIC_USERNAME, "user");
    endpointProperties.put(BasicAuthOptions.BASIC_PASSWORD, "user123!");
    endpointProperties.put(BasicAuthOptions.BASIC_REQUIRE_SSL, "true");
    api.setEndpointProperties(endpointProperties);
    api.setEndpoint("https://localhost:8009/echo");

    HttpConnectorFactory factory = new HttpConnectorFactory(globalConfig);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.BASIC, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {
                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue("Expected a successful connection response.", result.isSuccess());
                    IApiConnectionResponse scr = result.getResult();
                    Assert.assertEquals("Expected a 200 response from the echo server (valid creds).", 200, scr.getHead().getCode());
                }
            });

    if (connection.isConnected()) {
        connection.end();
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:28,代码来源:BasicAuthTest.java


示例12: shouldFailWithNoSSL

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario successful connection to the back end API via basic auth.
 */
@Test
public void shouldFailWithNoSSL() {
    endpointProperties.put(BasicAuthOptions.BASIC_USERNAME, "user");
    endpointProperties.put(BasicAuthOptions.BASIC_PASSWORD, "user123!");
    endpointProperties.put(BasicAuthOptions.BASIC_REQUIRE_SSL, "true");
    api.setEndpointProperties(endpointProperties);
    api.setEndpoint("http://localhost:8008/echo");

    HttpConnectorFactory factory = new HttpConnectorFactory(globalConfig);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.BASIC, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {
                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue("Expected an error due to not using SSL.", result.isError());
                    Assert.assertTrue("Expected a ConnectorException due to not using SSL.", result.getError() instanceof ConnectorException);
                    Assert.assertEquals("Endpoint security requested (BASIC auth) but endpoint is not secure (SSL).", result.getError().getMessage());
                }
            });

    if (connection.isConnected()) {
        connection.end();
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:28,代码来源:BasicAuthTest.java


示例13: shouldFailWithBadCredentials

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Should fail because the credentials provided are not valid/
 */
@Test
public void shouldFailWithBadCredentials() {
    endpointProperties.put(BasicAuthOptions.BASIC_USERNAME, "user");
    endpointProperties.put(BasicAuthOptions.BASIC_PASSWORD, "bad-password");
    endpointProperties.put(BasicAuthOptions.BASIC_REQUIRE_SSL, "false");
    api.setEndpointProperties(endpointProperties);
    api.setEndpoint("http://localhost:8008/echo");

    HttpConnectorFactory factory = new HttpConnectorFactory(globalConfig);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.BASIC, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {
                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue("Expected a successful connection response.", result.isSuccess());
                    IApiConnectionResponse scr = result.getResult();
                    Assert.assertEquals("Expected a 401 response from the echo server (invalid creds).", 401, scr.getHead().getCode());
                }
            });

    if (connection.isConnected()) {
        connection.end();
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:28,代码来源:BasicAuthTest.java


示例14: shouldFailWithNoCredentials

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Should fail because no credentials were provided.
 */
@Test
public void shouldFailWithNoCredentials() {
    endpointProperties.remove(BasicAuthOptions.BASIC_USERNAME);
    endpointProperties.remove(BasicAuthOptions.BASIC_PASSWORD);
    endpointProperties.put(BasicAuthOptions.BASIC_REQUIRE_SSL, "false");
    api.setEndpointProperties(endpointProperties);
    api.setEndpoint("http://localhost:8008/echo");

    HttpConnectorFactory factory = new HttpConnectorFactory(globalConfig);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.BASIC, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {
                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue("Expected a successful connection response.", result.isSuccess());
                    IApiConnectionResponse scr = result.getResult();
                    Assert.assertEquals("Expected a 401 response from the echo server (invalid creds).", 401, scr.getHead().getCode());
                }
            });

    if (connection.isConnected()) {
        connection.end();
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:28,代码来源:BasicAuthTest.java


示例15: HttpConnector

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Construct an {@link HttpConnector} instance. The {@link #resultHandler} must remain exclusive to a
 * given instance.
 *
 * @param vertx a vertx
 * @param client the vertx http client
 * @param api an API
 * @param request a request with fields filled
 * @param options the connector options
 * @param resultHandler a handler, called when reading is permitted
 */
public HttpConnector(Vertx vertx, HttpClient client, ApiRequest request, Api api, ApimanHttpConnectorOptions options,
        IAsyncResultHandler<IApiConnectionResponse> resultHandler) {
   this.client = client;
   this.api = api;
   this.apiRequest = request;

   this.resultHandler = resultHandler;
   this.exceptionHandler = new ExceptionHandler();
   this.apiEndpoint = options.getUri();
   this.options = options;

   apiHost = apiEndpoint.getHost();
   apiPort = getPort();
   apiPath = apiEndpoint.getPath().isEmpty() || apiEndpoint.getPath().equals("/") ? "" : apiEndpoint.getPath();
   destination = apiRequest.getDestination() == null ? "" : apiRequest.getDestination();

   verifyConnection();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:30,代码来源:HttpConnector.java


示例16: createConnector

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
@Override
public IApiConnector createConnector() {
    return new IApiConnector() {
        @Override
        public IApiConnection connect(ApiRequest request, IAsyncResultHandler<IApiConnectionResponse> handler) throws ConnectorException {
            return new ShortcircuitServiceConnection(handler);
        }
    };
}
 
开发者ID:outofcoffee,项目名称:apiman-plugins-session,代码行数:10,代码来源:ShortcircuitConnectorInterceptor.java


示例17: ShortcircuitServiceConnection

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
public ShortcircuitServiceConnection(IAsyncResultHandler<IApiConnectionResponse> handler) {
    responseHandler = handler;

    response = new ApiResponse();
    response.setCode(HttpURLConnection.HTTP_OK);
    response.setHeaders(new HeaderMap());
}
 
开发者ID:outofcoffee,项目名称:apiman-plugins-session,代码行数:8,代码来源:ShortcircuitConnectorInterceptor.java


示例18: ShortcircuitApiConnection

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
public ShortcircuitApiConnection(IAsyncResultHandler<IApiConnectionResponse> handler) {
    responseHandler = handler;

    response = new ApiResponse();
    response.setCode(200);
    response.setMessage("OK"); //$NON-NLS-1$
    response.setHeaders(responseHeaders);
}
 
开发者ID:apiman,项目名称:apiman-plugins,代码行数:9,代码来源:CorsConnector.java


示例19: shouldSucceedWithValidMTLS

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - no CA inherited trust
 *   - gateway trusts API certificate directly
 *   - API trusts gateway certificate directly
 */
@Test
public void shouldSucceedWithValidMTLS() {
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/basic_mutual_auth_2/gateway_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYSTORE, getResourcePath("2waytest/basic_mutual_auth_2/gateway_ks.jks"));
    config.put(TLSOptions.TLS_KEYSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "false");

   HttpConnectorFactory factory = new HttpConnectorFactory(config);
   IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.MTLS, false);
   IApiConnection connection = connector.connect(request,
           new IAsyncResultHandler<IApiConnectionResponse>() {

    @Override
    public void handle(IAsyncResult<IApiConnectionResponse> result) {
        if (result.isError())
            throw new RuntimeException(result.getError());

      Assert.assertTrue(result.isSuccess());
    }
   });

   connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:33,代码来源:BasicMutualAuthTest.java


示例20: shouldFailWhenGatewayDoesNotTrustApi

import io.apiman.gateway.engine.IApiConnectionResponse; //导入依赖的package包/类
/**
 * Scenario:
 *   - no CA inherited trust
 *   - gateway does <em>not</em> trust the API
 *   - API trusts gateway certificate
 */
@Test
public void shouldFailWhenGatewayDoesNotTrustApi() {
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/basic_mutual_auth/gateway_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYSTORE, getResourcePath("2waytest/basic_mutual_auth/gateway_ks.jks"));
    config.put(TLSOptions.TLS_KEYSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "false");

   HttpConnectorFactory factory = new HttpConnectorFactory(config);
   IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.MTLS, false);
   IApiConnection connection = connector.connect(request,
           new IAsyncResultHandler<IApiConnectionResponse>() {

    @Override
    public void handle(IAsyncResult<IApiConnectionResponse> result) {
        Assert.assertTrue(result.isError());

        System.out.println(result.getError());
        Assert.assertTrue(result.getError() instanceof ConnectorException);
        // Would like to assert on SSL error, but is sun specific info
        // TODO improve connector to handle this situation better
    }
   });

   connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:35,代码来源:BasicMutualAuthTest.java



注:本文中的io.apiman.gateway.engine.IApiConnectionResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SQLDataSetDef类代码示例发布时间:2022-05-16
下一篇:
Java DbEntity类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap