Added XMPP modification to encrypt payload

Shabirmean 9 years ago
parent 5f8751cd95
commit d13c3f8dde

@ -71,7 +71,7 @@ public class FireAlarmXMPPCommunicator extends XMPPTransportHandler {
resource = agentManager.getAgentConfigs().getDeviceOwner();
xmppDeviceJID = username + "@" + server;
xmppAdminJID = AgentConstants.XMPP_ADMIN_ACCOUNT_UNAME + "@" + server;
xmppAdminJID = agentManager.getAgentConfigs().getServerName() + "_" + AgentConstants.DEVICE_TYPE + "@" + server;
Runnable connect = new Runnable() {
@ -187,19 +187,26 @@ public class FireAlarmXMPPCommunicator extends XMPPTransportHandler {
Runnable pushDataRunnable = new Runnable() {
@Override
public void run() {
Message xmppMessage = new Message();
try {
int currentTemperature = agentManager.getTemperature();
String payLoad = AgentConstants.TEMPERATURE_CONTROL + ":" + currentTemperature;
Message xmppMessage = new Message();
String message = AgentConstants.TEMPERATURE_CONTROL + ":" + currentTemperature;
String payLoad = AgentUtilOperations.prepareSecurePayLoad(message);
xmppMessage.setTo(xmppAdminJID);
xmppMessage.setSubject("PUBLISHER");
xmppMessage.setBody(payLoad);
xmppMessage.setType(Message.Type.chat);
sendXMPPMessage(xmppAdminJID, xmppMessage);
log.info(AgentConstants.LOG_APPENDER + "Message: '" + xmppMessage.getBody() +
"' sent to XMPP JID [" + xmppAdminJID + "] under subject [" +
xmppMessage.getSubject() + "]");
log.info(AgentConstants.LOG_APPENDER + "Message: '" + message + "' sent to XMPP JID - " +
"[" + xmppAdminJID + "] under subject [" + xmppMessage.getSubject() + "].");
} catch (AgentCoreOperationException e) {
log.warn(AgentConstants.LOG_APPENDER + "Preparing Secure payload failed for XMPP JID - " +
"[" + xmppAdminJID + "] with subject - [" + xmppMessage.getSubject() + "].");
}
}
};

@ -572,8 +572,8 @@ public class VirtualFireAlarmService {
*/
@Path("controller/bulb")
@POST
@Feature( code="VIRTUALFIREALARM_BULBCONTROL", name="Control Bulb",
description="Switch on/off Virtual Fire Alarm Bulb")
@Feature(code = "VIRTUALFIREALARM_BULBCONTROL", name = "Control Bulb", type = "operation",
description = "Switch on/off Virtual Fire Alarm Bulb")
public void switchBulb(@HeaderParam("owner") String owner,
@HeaderParam("deviceId") String deviceId,
@HeaderParam("protocol") String protocol,
@ -657,7 +657,7 @@ public class VirtualFireAlarmService {
*/
@Path("controller/readhumidity")
@GET
@Feature( code="VIRTUALFIREALARM_READHUMIDITY", name="Read Humidity",
@Feature( code="VIRTUALFIREALARM_READHUMIDITY", name="Read Humidity", type = "monitor",
description="Read Humidity Readings from Virtual Fire Alarm")
public String requestHumidity(@HeaderParam("owner") String owner,
@HeaderParam("deviceId") String deviceId,
@ -738,7 +738,7 @@ public class VirtualFireAlarmService {
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Feature( code="VIRTUALFIREALARM_REQTEMP", name="Request Tempreature",
@Feature( code="VIRTUALFIREALARM_REQTEMP", name="Request Tempreature", type = "monitor",
description="Request Tempreature reading from Virtual Fire Alarm")
public SensorRecord requestTemperature(@HeaderParam("owner") String owner,
@HeaderParam("deviceId") String deviceId,

@ -73,6 +73,7 @@ public class VirtualFireAlarmXMPPConnector extends XMPPTransportHandler {
public void createXMPPAccountForDeviceType() {
boolean accountExists = false;
XmppServerClient xmppServerClient = new XmppServerClient();
xmppServerClient.initControlQueue();
try {
accountExists = xmppServerClient.doesXMPPUserAccountExist(xmppVFireAlarmAdminUsername);

@ -62,7 +62,7 @@ public class XmppServerClient implements ControlQueueConnector {
}
@Override
public void initControlQueue() throws DeviceControllerException {
public void initControlQueue() {
xmppEndpoint = XmppConfig.getInstance().getXmppEndpoint();
xmppUsername = XmppConfig.getInstance().getXmppUsername();
xmppPassword = XmppConfig.getInstance().getXmppPassword();

Loading…
Cancel
Save