From 1b27505c706e31773a20277576f8dea5cdb7da15 Mon Sep 17 00:00:00 2001 From: pans Date: Fri, 7 Jun 2024 14:58:12 +0530 Subject: [PATCH] [MTM-59215]: New port is open for device access token API --- x509-rest-client/README.md | 1 + .../src/main/java/com/c8y/x509/X509RestClient.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/x509-rest-client/README.md b/x509-rest-client/README.md index 611b848774..6205e14b78 100644 --- a/x509-rest-client/README.md +++ b/x509-rest-client/README.md @@ -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 diff --git a/x509-rest-client/src/main/java/com/c8y/x509/X509RestClient.java b/x509-rest-client/src/main/java/com/c8y/x509/X509RestClient.java index ced19b5121..be2b81f254 100644 --- a/x509-rest-client/src/main/java/com/c8y/x509/X509RestClient.java +++ b/x509-rest-client/src/main/java/com/c8y/x509/X509RestClient.java @@ -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 = ""; @@ -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) {