From 2be0fd84feee081c944da00e21f77c3d75d4c90c Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Sat, 23 Aug 2014 12:34:31 +0200 Subject: [PATCH] Fixed bug once the moquette.conf provided doesn't provide a valid path to pasword.conf --- ChangeLog.txt | 4 ++++ .../messaging/spi/impl/AcceptAllAuthenticator.java | 12 ++++++++++++ .../moquette/messaging/spi/impl/SimpleMessaging.java | 9 +++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AcceptAllAuthenticator.java diff --git a/ChangeLog.txt b/ChangeLog.txt index f74e0292..0c0807e6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +Version 0.7: + Fix issue #38, added aligned to MQTT 3.1.1 + Refactored big event switch to @Annotation dispatcher + Version 0.6: Fix issue #42, bad password file path composition Fix issue #43, missed topic case (finance/+ does has to match finance) diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AcceptAllAuthenticator.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AcceptAllAuthenticator.java new file mode 100644 index 00000000..545856a7 --- /dev/null +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AcceptAllAuthenticator.java @@ -0,0 +1,12 @@ +package org.dna.mqtt.moquette.messaging.spi.impl; + +import org.dna.mqtt.moquette.server.IAuthenticator; + +/** + * Created by andrea on 8/23/14. + */ +class AcceptAllAuthenticator implements IAuthenticator { + public boolean checkValid(String username, String password) { + return true; + } +} diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java index 7cca4008..bbd4567a 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/SimpleMessaging.java @@ -163,9 +163,14 @@ public class SimpleMessaging implements IMessaging, EventHandler { List storedSubscriptions = m_sessionsStore.listAllSubscriptions(); subscriptions.init(storedSubscriptions); - String passwdPath = props.getProperty("password_file"); + String passwdPath = props.getProperty("password_file", ""); String configPath = System.getProperty("moquette.path", null); - IAuthenticator authenticator = new FileAuthenticator(configPath, passwdPath); + IAuthenticator authenticator; + if (passwdPath.isEmpty()) { + authenticator = new AcceptAllAuthenticator(); + } else { + authenticator = new FileAuthenticator(configPath, passwdPath); + } m_processor.init(subscriptions, m_storageService, m_sessionsStore, authenticator); }