From 1347be2cea28e3a3c547d47628d7284bb1b54930 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 24 Oct 2018 20:10:31 +0530 Subject: [PATCH] Fixed incorrect port issue when default ssl port is used --- .../oauth/OAuthTokenValidaterStubFactory.java | 8 ++++++-- .../oauth/OAuthTokenValidatorStubFactory.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java index 5beb5c487a..92510d6143 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java @@ -116,8 +116,12 @@ public class OAuthTokenValidaterStubFactory extends BasePoolableObjectFactory { if (hostURL.getProtocol().equals("https")) { // set up ssl factory since axis2 https transport is used. EasySSLProtocolSocketFactory sslProtocolSocketFactory = createProtocolSocketFactory(); - Protocol authhttps = new Protocol(hostURL.getProtocol() - , (ProtocolSocketFactory) sslProtocolSocketFactory, hostURL.getPort()); + int port = hostURL.getPort(); + if (port == -1) { + port = 443; + } + Protocol authhttps = new Protocol(hostURL.getProtocol(), + (ProtocolSocketFactory) sslProtocolSocketFactory, port); Protocol.registerProtocol(hostURL.getProtocol(), authhttps); options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, authhttps); } diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java index 93a49160b2..399b08c011 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java @@ -116,8 +116,12 @@ public class OAuthTokenValidatorStubFactory extends BasePoolableObjectFactory { if (hostURL.getProtocol().equals("https")) { // set up ssl factory since axis2 https notification is used. EasySSLProtocolSocketFactory sslProtocolSocketFactory = createProtocolSocketFactory(); - Protocol authhttps = new Protocol(hostURL.getProtocol() - , (ProtocolSocketFactory) sslProtocolSocketFactory, hostURL.getPort()); + int port = hostURL.getPort(); + if (port == -1) { + port = 443; + } + Protocol authhttps = new Protocol(hostURL.getProtocol(), + (ProtocolSocketFactory) sslProtocolSocketFactory, port); Protocol.registerProtocol(hostURL.getProtocol(), authhttps); options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, authhttps); }