diff --git a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmMQTTConnector.java b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmMQTTConnector.java index 74c850b0ea..acc3622653 100644 --- a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmMQTTConnector.java +++ b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmMQTTConnector.java @@ -29,7 +29,7 @@ import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException; import org.wso2.carbon.device.mgt.iot.transport.mqtt.MQTTTransportHandler; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.exception.VirtualFireAlarmException; -import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.util.VerificationManager; +import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.util.SecurityManager; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.util.VirtualFireAlarmServiceUtils; import java.io.File; @@ -99,7 +99,7 @@ public class VirtualFireAlarmMQTTConnector extends MQTTTransportHandler { try { PublicKey clientPublicKey = VirtualFireAlarmServiceUtils.getDevicePublicKey(deviceId); - PrivateKey serverPrivateKey = VerificationManager.getServerPrivateKey(); + PrivateKey serverPrivateKey = SecurityManager.getServerPrivateKey(); actualMessage = VirtualFireAlarmServiceUtils.extractMessageFromPayload(mqttMessage.toString(), serverPrivateKey, clientPublicKey); if (log.isDebugEnabled()) { @@ -151,7 +151,7 @@ public class VirtualFireAlarmMQTTConnector extends MQTTTransportHandler { try { PublicKey devicePublicKey = VirtualFireAlarmServiceUtils.getDevicePublicKey(deviceId); - PrivateKey serverPrivateKey = VerificationManager.getServerPrivateKey(); + PrivateKey serverPrivateKey = SecurityManager.getServerPrivateKey(); String actualMessage = resource + ":" + state; String encryptedMsg = VirtualFireAlarmServiceUtils.prepareSecurePayLoad(actualMessage, diff --git a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmXMPPConnector.java b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmXMPPConnector.java index c378fae079..531e115ec3 100644 --- a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmXMPPConnector.java +++ b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/transport/VirtualFireAlarmXMPPConnector.java @@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.transport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.paho.client.mqttv3.MqttMessage; import org.jivesoftware.smack.packet.Message; import org.wso2.carbon.device.mgt.iot.config.server.DeviceManagementConfigurationManager; import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppAccount; @@ -32,11 +31,10 @@ import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException; import org.wso2.carbon.device.mgt.iot.transport.xmpp.XMPPTransportHandler; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.exception.VirtualFireAlarmException; -import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.util.VerificationManager; +import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.util.SecurityManager; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.util.VirtualFireAlarmServiceUtils; import java.io.File; -import java.nio.charset.StandardCharsets; import java.security.PrivateKey; import java.security.PublicKey; import java.util.Calendar; @@ -161,7 +159,7 @@ public class VirtualFireAlarmXMPPConnector extends XMPPTransportHandler { try { PublicKey clientPublicKey = VirtualFireAlarmServiceUtils.getDevicePublicKey(deviceId); - PrivateKey serverPrivateKey = VerificationManager.getServerPrivateKey(); + PrivateKey serverPrivateKey = SecurityManager.getServerPrivateKey(); String actualMessage = VirtualFireAlarmServiceUtils.extractMessageFromPayload(message, serverPrivateKey, clientPublicKey); if (log.isDebugEnabled()) { @@ -223,7 +221,7 @@ public class VirtualFireAlarmXMPPConnector extends XMPPTransportHandler { try { PublicKey devicePublicKey = VirtualFireAlarmServiceUtils.getDevicePublicKey(deviceId); - PrivateKey serverPrivateKey = VerificationManager.getServerPrivateKey(); + PrivateKey serverPrivateKey = SecurityManager.getServerPrivateKey(); String actualMessage = resource + ":" + state; String encryptedMsg = VirtualFireAlarmServiceUtils.prepareSecurePayLoad(actualMessage, diff --git a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VerificationManager.java b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/SecurityManager.java similarity index 98% rename from components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VerificationManager.java rename to components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/SecurityManager.java index 07bd72ffb1..c97c5503fe 100644 --- a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VerificationManager.java +++ b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/SecurityManager.java @@ -47,14 +47,14 @@ import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; -public class VerificationManager { - private static final Log log = LogFactory.getLog(VerificationManager.class); +public class SecurityManager { + private static final Log log = LogFactory.getLog(SecurityManager.class); private static PrivateKey serverPrivateKey; private static final String SIGNATURE_ALG = "SHA1withRSA"; private static final String CIPHER_PADDING = "RSA/ECB/PKCS1Padding"; - private VerificationManager() { + private SecurityManager() { } diff --git a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VirtualFireAlarmServiceUtils.java b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VirtualFireAlarmServiceUtils.java index b2e60c1484..916661a20c 100644 --- a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VirtualFireAlarmServiceUtils.java +++ b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/util/VirtualFireAlarmServiceUtils.java @@ -246,8 +246,8 @@ public class VirtualFireAlarmServiceUtils { public static String prepareSecurePayLoad(String message, Key encryptionKey, PrivateKey signatureKey) throws VirtualFireAlarmException { - String encryptedMsg = VerificationManager.encryptMessage(message, encryptionKey); - String signedPayload = VerificationManager.signMessage(encryptedMsg, signatureKey); + String encryptedMsg = SecurityManager.encryptMessage(message, encryptionKey); + String signedPayload = SecurityManager.signMessage(encryptedMsg, signatureKey); JSONObject jsonPayload = new JSONObject(); jsonPayload.put(JSON_MESSAGE_KEY, encryptedMsg); @@ -266,9 +266,9 @@ public class VirtualFireAlarmServiceUtils { Object signedPayload = jsonPayload.get(JSON_SIGNATURE_KEY); if (encryptedMessage != null && signedPayload != null) { - if (VerificationManager.verifySignature( + if (SecurityManager.verifySignature( encryptedMessage.toString(), signedPayload.toString(), verifySignatureKey)) { - actualMessage = VerificationManager.decryptMessage(encryptedMessage.toString(), decryptionKey); + actualMessage = SecurityManager.decryptMessage(encryptedMessage.toString(), decryptionKey); } else { String errorMsg = "The message was not signed by a valid client. Could not verify signature on payload"; throw new VirtualFireAlarmException(errorMsg); diff --git a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml index 7f231b47b7..7a3021647e 100644 --- a/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt-iot-virtualfirealarm/org.wso2.carbon.device.mgt.iot.virtualfirealarm.controller.service.impl/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -28,7 +28,7 @@ - + @@ -38,8 +38,8 @@ - +