public static MqttException createMqttException(int reasonCode) { if ((reasonCode == MqttException.REASON_CODE_FAILED_AUTHENTICATION) || (reasonCode == MqttException.REASON_CODE_NOT_AUTHORIZED)) { return new MqttSecurityException(reasonCode); } return new MqttException(reasonCode); }
public void publishMessage(String topic, String content, Integer qos, Boolean retain) { MqttMessage message = new MqttMessage(StringEscapeUtils.unescapeJava(content).getBytes()); message.setQos(Optional.ofNullable(qos).orElse(1)); message.setRetained(Optional.ofNullable(retain).orElse(false)); try { if(!myClient.isConnected()) { try { myClient.connect(); } catch (MqttSecurityException e1) { log.error("Could not retry connect to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e1.getMessage()); return; } catch (MqttException e1) { log.error("Could not retry connect to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e1.getMessage()); return; } } myClient.publish(topic, message); } catch (MqttException e) { log.error("Could not publish to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e.getMessage()); } }
public static MqttException createMqttException(Throwable cause) { if (cause.getClass().getName().equals("java.security.GeneralSecurityException")) { return new MqttSecurityException(cause); } return new MqttException(cause); }
@Override protected Boolean doInBackground(MqttConnectOptions... params) { options = params[0]; try { MQTT_CLIENT.connect(options); } catch (MqttSecurityException e) { if (Aware.DEBUG) Log.e(TAG, "SecurityException: " + e.getMessage()); return false; } catch (MqttException e) { if (Aware.DEBUG) Log.e(TAG, "MqttException: " + e.getMessage()); return false; } return true; }
throw new MqttSecurityException(e);
/** * Subscribe to a topic * * @param topicName */ public static boolean subscribe(String topicName) { if (MQTT_CLIENT != null && MQTT_CLIENT.isConnected()) { try { MQTT_CLIENT.subscribe(topicName, Integer.parseInt(MQTT_QoS)); } catch (MqttSecurityException e) { if (Aware.DEBUG) Log.e(TAG, e.getMessage()); return false; } catch (MqttException e) { if (Aware.DEBUG) Log.e(TAG, e.getMessage()); return false; } } return true; }
keyMgr=keyMgrFact.getKeyManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); } catch (UnrecoverableKeyException e) { throw new MqttSecurityException(e); trustMgr=trustMgrFact.getTrustManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); throw new MqttSecurityException(e); } catch (NoSuchProviderException e) { throw new MqttSecurityException(e); } catch (KeyManagementException e) { throw new MqttSecurityException(e);
this.mqttClient.connect(connectOptions).waitForCompletion(); } catch (MqttSecurityException e) { changeState(EndpointState.ERROR, e , e.getMessage()); return false; } catch (MqttException e) {
public static MqttException createMqttException(int reasonCode) { if ((reasonCode == MqttException.REASON_CODE_FAILED_AUTHENTICATION) || (reasonCode == MqttException.REASON_CODE_NOT_AUTHORIZED)) { return new MqttSecurityException(reasonCode); } return new MqttException(reasonCode); }
public static MqttException createMqttException(Throwable cause) { if (cause.getClass().getName().equals("java.security.GeneralSecurityException")) { return new MqttSecurityException(cause); } return new MqttException(cause); }
public static MqttException createMqttException(int reasonCode) { if ((reasonCode == MqttException.REASON_CODE_FAILED_AUTHENTICATION) || (reasonCode == MqttException.REASON_CODE_NOT_AUTHORIZED)) { return new MqttSecurityException(reasonCode); } return new MqttException(reasonCode); }
public static MqttException createMqttException(Throwable cause) { if (cause.getClass().getName().equals("java.security.GeneralSecurityException")) { return new MqttSecurityException(cause); } return new MqttException(cause); }
public static MqttException createMqttException(int reasonCode) { if ((reasonCode == MqttException.REASON_CODE_FAILED_AUTHENTICATION) || (reasonCode == MqttException.REASON_CODE_NOT_AUTHORIZED)) { return new MqttSecurityException(reasonCode); } return new MqttException(reasonCode); }
public static MqttException createMqttException(Throwable cause) { if (cause.getClass().getName().equals("java.security.GeneralSecurityException")) { return new MqttSecurityException(cause); } return new MqttException(cause); }
throw new MqttSecurityException(e);
keyMgr=keyMgrFact.getKeyManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); } catch (UnrecoverableKeyException e) { throw new MqttSecurityException(e); trustMgr=trustMgrFact.getTrustManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); throw new MqttSecurityException(e); } catch (NoSuchProviderException e) { throw new MqttSecurityException(e); } catch (KeyManagementException e) { throw new MqttSecurityException(e);
keyMgr=keyMgrFact.getKeyManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); } catch (UnrecoverableKeyException e) { throw new MqttSecurityException(e); trustMgr=trustMgrFact.getTrustManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); throw new MqttSecurityException(e); } catch (NoSuchProviderException e) { throw new MqttSecurityException(e); } catch (KeyManagementException e) { throw new MqttSecurityException(e);
keyMgr=keyMgrFact.getKeyManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); } catch (UnrecoverableKeyException e) { throw new MqttSecurityException(e); trustMgr=trustMgrFact.getTrustManagers(); } catch (KeyStoreException e) { throw new MqttSecurityException(e); } catch (CertificateException e) { throw new MqttSecurityException(e); } catch (FileNotFoundException e) { throw new MqttSecurityException(e); } catch (IOException e) { throw new MqttSecurityException(e); throw new MqttSecurityException(e); } catch (NoSuchProviderException e) { throw new MqttSecurityException(e); } catch (KeyManagementException e) { throw new MqttSecurityException(e);