Skip to content

Commit

Permalink
[MTM-59215]: New port is open for device access token API
Browse files Browse the repository at this point in the history
  • Loading branch information
pans-c8y committed Jun 7, 2024
1 parent 0eca56f commit 1b27505
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions x509-rest-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ In X509RestClient.java provide:
* **TRUSTSTORE_FORMAT** - trust store format (eg. 'jks')
* **CLIENT_ID** - client Id which matches the certificate subject common name
* **PLATFORM_URL** - URL for mTLS connection
* **PLATFORM_MTLS_PORT** - Port for established mTLS connection using certificates
* **X_SSL_CERT_CHAIN** - constant for header key `x-ssl-cert-chain`
* **DEVICE_ACCESS_TOKEN_PATH** - API endpoint for making mTLS protocol
* **LOCAL_DEVICE_CHAIN** - value of header key `x-ssl-cert-chain` which contains full device chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class X509RestClient {
private static final String TRUSTSTORE_PASSWORD = "";
private static final String TRUSTSTORE_FORMAT = "";
private static final String PLATFORM_URL = "";
private static final String PLATFORM_MTLS_PORT = "2443";
private static final String X_SSL_CERT_CHAIN = "x-ssl-cert-chain";
private static final String DEVICE_ACCESS_TOKEN_PATH = "/devicecontrol/deviceAccessToken";
private static final String LOCAL_DEVICE_CHAIN = "";
Expand Down Expand Up @@ -57,7 +58,7 @@ private static SSLContext getSSLContext(TrustManagerFactory trustManagerFactory,

private static HttpRequest buildRequest() {
try {
return HttpRequest.newBuilder().uri(new URI(PLATFORM_URL + DEVICE_ACCESS_TOKEN_PATH))
return HttpRequest.newBuilder().uri(new URI(PLATFORM_URL + ":" + PLATFORM_MTLS_PORT + DEVICE_ACCESS_TOKEN_PATH))
.POST(HttpRequest.BodyPublishers.noBody()).header("Accept", "application/json")
.header(X_SSL_CERT_CHAIN, LOCAL_DEVICE_CHAIN).build();
} catch (URISyntaxException uRISyntaxException) {
Expand Down

0 comments on commit 1b27505

Please sign in to comment.