当前位置: 首页>>代码示例>>Java>>正文


Java Http2Client类代码示例

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


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

示例1: ClientCredentialsRequest

import com.networknt.client.Http2Client; //导入依赖的package包/类
public ClientCredentialsRequest() {
    setGrantType(CLIENT_CREDENTIALS);
    Map<String, Object> clientConfig = Config.getInstance().getJsonMapConfig(Http2Client.CONFIG_NAME);
    // client_secret is in secret.yml instead of client.yml
    if(clientConfig != null) {
        Map<String, Object> oauthConfig = (Map<String, Object>)clientConfig.get(OAUTH);
        if(oauthConfig != null) {
            Map<String, Object> tokenConfig = (Map<String, Object>)oauthConfig.get(TOKEN);
            if(tokenConfig != null) {
                setServerUrl((String)tokenConfig.get(SERVER_URL));
                Map<String, Object> ccConfig = (Map<String, Object>) tokenConfig.get(CLIENT_CREDENTIALS);
                if(ccConfig != null) {
                    setClientId((String)ccConfig.get(CLIENT_ID));
                    setClientSecret((String)secret.get(SecretConstants.CLIENT_CREDENTIALS_CLIENT_SECRET));
                    setUri((String)ccConfig.get(URI));
                    setScope((List<String>)ccConfig.get(SCOPE));
                }
            }
        }
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:22,代码来源:ClientCredentialsRequest.java

示例2: AuthorizationCodeRequest

import com.networknt.client.Http2Client; //导入依赖的package包/类
/**
 * load default values from client.json for authorization code grant, overwrite by setters
 * in case you want to change it at runtime.
 */
public AuthorizationCodeRequest() {
    setGrantType(AUTHORIZATION_CODE);
    Map<String, Object> clientConfig = Config.getInstance().getJsonMapConfig(Http2Client.CONFIG_NAME);
    // client_secret is in secret.yml instead of client.yml
    if(clientConfig != null) {
        Map<String, Object> oauthConfig = (Map<String, Object>)clientConfig.get(OAUTH);
        if(oauthConfig != null) {
            Map<String, Object> tokenConfig = (Map<String, Object>)oauthConfig.get(TOKEN);
            if(tokenConfig != null) {
                setServerUrl((String)tokenConfig.get(SERVER_URL));
                Map<String, Object> acConfig = (Map<String, Object>) tokenConfig.get(AUTHORIZATION_CODE);
                if(acConfig != null) {
                    setClientId((String)acConfig.get(CLIENT_ID));
                    setClientSecret((String)secret.get(SecretConstants.AUTHORIZATION_CODE_CLIENT_SECRET));
                    setUri((String)acConfig.get(URI));
                    setScope((List<String>)acConfig.get(SCOPE));
                    setRedirectUri((String)acConfig.get(REDIRECT_URI));
                }
            }
        }
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:27,代码来源:AuthorizationCodeRequest.java

示例3: KeyRequest

import com.networknt.client.Http2Client; //导入依赖的package包/类
public KeyRequest(String kid) {
    Map<String, Object> clientConfig = Config.getInstance().getJsonMapConfig(Http2Client.CONFIG_NAME);
    // client_secret is in secret.yml instead of client.yml
    if(clientConfig != null) {
        Map<String, Object> oauthConfig = (Map<String, Object>)clientConfig.get(OAUTH);
        if(oauthConfig != null) {
            Map<String, Object> keyConfig = (Map<String, Object>)oauthConfig.get(KEY);
            if(keyConfig != null) {
                setServerUrl((String)keyConfig.get(SERVER_URL));
                setUri(keyConfig.get(URI) + "/" + kid);
                setClientId((String)keyConfig.get(CLIENT_ID));
                setClientSecret((String)secret.get(SecretConstants.KEY_CLIENT_SECRET));
            }
        }
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:17,代码来源:KeyRequest.java

示例4: getPrivateKey

import com.networknt.client.Http2Client; //导入依赖的package包/类
private static PrivateKey getPrivateKey(String filename, String password, String key) {
    PrivateKey privateKey = null;

    try {
        KeyStore keystore = KeyStore.getInstance("JKS");
        keystore.load(Http2Client.class.getResourceAsStream(filename),
                password.toCharArray());

        privateKey = (PrivateKey) keystore.getKey(key,
                password.toCharArray());
    } catch (Exception e) {
        logger.error("Exception:", e);
    }

    if (privateKey == null) {
        logger.error("Failed to retrieve private key from keystore");
    }

    return privateKey;
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:21,代码来源:OauthHelperTest.java

示例5: getEncodedString

import com.networknt.client.Http2Client; //导入依赖的package包/类
private static String getEncodedString(TokenRequest request) throws UnsupportedEncodingException {
    Map<String, String> params = new HashMap<>();
    params.put(GRANT_TYPE, request.getGrantType());
    if(TokenRequest.AUTHORIZATION_CODE.equals(request.getGrantType())) {
        params.put(CODE, ((AuthorizationCodeRequest)request).getAuthCode());
        params.put(REDIRECT_URI, ((AuthorizationCodeRequest)request).getRedirectUri());
    }
    if(request.getScope() != null) {
        params.put(SCOPE, StringUtils.join(request.getScope(), " "));
    }
    return Http2Client.getFormDataString(params);
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:13,代码来源:OauthHelper.java

示例6: DataGetHandler

import com.networknt.client.Http2Client; //导入依赖的package包/类
public DataGetHandler() {
    try {
        apidHost = cluster.serviceToUrl("https", "com.networknt.apid-1.0.0", tag, null);
        connection = client.connect(new URI(apidHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
    } catch (Exception e) {
        logger.error("Exeption:", e);
    }
}
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:9,代码来源:DataGetHandler.java

示例7: DataGetHandler

import com.networknt.client.Http2Client; //导入依赖的package包/类
public DataGetHandler() {
    try {
        connection = client.connect(new URI(apidHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
    } catch (Exception e) {
        logger.error("Exeption:", e);
    }
}
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:8,代码来源:DataGetHandler.java

示例8: DataGetHandler

import com.networknt.client.Http2Client; //导入依赖的package包/类
public DataGetHandler() {
    try {
        apibHost = cluster.serviceToUrl("https", "com.networknt.apib-1.0.0", tag, null);
        apicHost = cluster.serviceToUrl("https", "com.networknt.apic-1.0.0", tag, null);
        connectionB = client.connect(new URI(apibHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
        connectionC = client.connect(new URI(apicHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
    } catch (Exception e) {
        logger.error("Exeption:", e);
    }
}
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:11,代码来源:DataGetHandler.java

示例9: DataGetHandler

import com.networknt.client.Http2Client; //导入依赖的package包/类
public DataGetHandler() {
    try {
        connectionB = client.connect(new URI(apibHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
        connectionC = client.connect(new URI(apicHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
    } catch (Exception e) {
        logger.error("Exeption:", e);
    }
}
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:9,代码来源:DataGetHandler.java

示例10: DataGetHandler

import com.networknt.client.Http2Client; //导入依赖的package包/类
public DataGetHandler() {
    try {
        connection = client.connect(new URI(apicHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
    } catch (Exception e) {
        logger.error("Exeption:", e);
    }
}
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:8,代码来源:DataGetHandler.java

示例11: DataGetHandler

import com.networknt.client.Http2Client; //导入依赖的package包/类
public DataGetHandler() {
    try {
        connection = client.connect(new URI(apibHost), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, OptionMap.create(UndertowOptions.ENABLE_HTTP2, true)).get();
    } catch (Exception e) {
        logger.error("Exeption:", e);
    }
}
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:8,代码来源:DataGetHandler.java

示例12: testCustomersToaccountsIdPostHandlerTest

import com.networknt.client.Http2Client; //导入依赖的package包/类
@Test
    public void testCustomersToaccountsIdPostHandlerTest() throws ClientException, ApiException {
        final Http2Client client = Http2Client.getInstance();
        final CountDownLatch latch = new CountDownLatch(1);
        final ClientConnection connection;
     /*   try {
            connection = client.connect(new URI(url), Http2Client.WORKER, Http2Client.SSL, Http2Client.POOL, enableHttp2 ? OptionMap.create(UndertowOptions.ENABLE_HTTP2, true): OptionMap.EMPTY).get();
        } catch (Exception e) {
            throw new ClientException(e);
        }
        final AtomicReference<ClientResponse> reference = new AtomicReference<>();
        ToAccountInfo toAccountInfo = new ToAccountInfo("122222", "title", "google", "trest case");
        String json = JSonMapper.toJson(toAccountInfo);
        try {
            ClientRequest request = new ClientRequest().setPath("/v1/customers/toaccounts/1").setMethod(Methods.POST);

            request.getRequestHeaders().put(Headers.CONTENT_TYPE, "application/json");
            request.getRequestHeaders().put(Headers.TRANSFER_ENCODING, "chunked");
            connection.sendRequest(request, client.createClientCallback(reference, latch, json));

            latch.await();
        } catch (Exception e) {
            logger.error("Exception: ", e);
            throw new ClientException(e);
        } finally {
            IoUtils.safeClose(connection);
        }
        int statusCode = reference.get().getResponseCode();
        String body = reference.get().getAttachment(Http2Client.RESPONSE_BODY);
        System.out.println("response:" + body);
        Assert.assertEquals(200, statusCode);
        Assert.assertNotNull(body);
*/

    }
 
开发者ID:networknt,项目名称:light-example-4j,代码行数:36,代码来源:CustomersToaccountsIdPostHandlerTest.java

示例13: EventuateRESTClient

import com.networknt.client.Http2Client; //导入依赖的package包/类
public EventuateRESTClient(String authToken, URI url, String correlationId, String traceabilityId) {
    client = Http2Client.getInstance();
    this.authToken = authToken;
    this.url = url;
    this.correlationId = correlationId;
    this.traceabilityId = traceabilityId;
   // HttpGet httpGet = new HttpGet(url);
  //  client.populateHeader(httpGet, authToken, correlationId,traceabilityId );
}
 
开发者ID:networknt,项目名称:light-eventuate-4j,代码行数:10,代码来源:EventuateRESTClient.java


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