Using the Captured Connection Information in the Customization Code
This section describes the usage of the endpoint information captured using the captureExternalConnection utility in the integrations example customization code.
The connection information, captured using the captureExternalConnections utility, is accessed in the integrations example customization code using the CustomIntegrationHelper class.
The following code snippet shows how the connection information is obtained using the CustomIntegrationHelper class:
public String getPartNumber() throws Exception {
URI apiUrl = customIntegrationHelper.getNamedEndpointURI("get_material_number");
Map<String, String> map = customIntegrationHelper.getSecretsMap();
String bearerToken = map.get("bearer_token");
SSLContext sslContext = customIntegrationHelper.getInitializedSSLContext();
String uniqueNo = performGetRequest(apiUrl, sslContext, bearerToken);
if (log.isDebugEnabled()) {
log.debug("API URL for fetching part number: " + apiUrl);
log.debug("Unique number returned from API Client :" + uniqueNo);
}
return uniqueNo;
}
Examine the JSON that is used for capturing information and the customization code from customization/integrations/main/src/com/acme/ext/APIClient.java to understand how the CustomIntegrationHelper is used to access the connection information. In the table below, notice that the base-URL, bearer token, and the SSL context, generated using client and server certificate chains, are retrieved in the customization code using an object instance of CustomIntegrationHelper.
Connection information submitted via captureExternalConnections utility
Customization code submitted via CCD utility
"material_api": {
"baseurl": "replace with your base-url",
"url_fragments": {
"get_material_number": "/api/material",
"get_material_data_stream": "/api/materialData/stream"
},
"secrets": {
"client_cert": "replace with path to clientcertchain",
"bearer_token": "Bearer replace with your bearer token"
},
"server_cert": "replace with path to clientcertchain"
}
CustomIntegrationHelper customIntegrationHelper
= new CustomIntegrationHelper("material_api");

public String getPartNumber() throws Exception {
URL apiUr1 = customIntegrationHelper.getNamedEndpointURL("get_material_number");
Map<String, String> map = customIntegrationHelper.getSecretsMap();
String bearerToken = map.get("bearer_token");
SSLContext sslContext = customIntegrationHelper.getInitializedSSLContext();
.
.
.
}
* 
The bearer_token is not a reserved keyword, and there is no specific handling for bearer token authentication in the sample implementation. It could essentially be any other string that the customization code can identify and utilize while constructing a request for the relevant external endpoint.
這是否有幫助?