diff --git a/broker/src/main/java/io/moquette/server/Server.java b/broker/src/main/java/io/moquette/server/Server.java index 1bd63904..a9c8b9dd 100644 --- a/broker/src/main/java/io/moquette/server/Server.java +++ b/broker/src/main/java/io/moquette/server/Server.java @@ -81,6 +81,7 @@ public class Server { /** * Starts Moquette bringing the configuration from the file * located at m_config/moquette.conf + * @throws IOException in case of any IO error. */ public void startServer() throws IOException { IResourceLoader filesystemLoader = new FileResourceLoader(defaultConfigFile()); @@ -95,6 +96,8 @@ public class Server { /** * Starts Moquette bringing the configuration from the given file + * @param configFile text file that contains the configuration. + * @throws IOException in case of any IO Error. */ public void startServer(File configFile) throws IOException { LOG.info("Using m_config file: " + configFile.getAbsolutePath()); @@ -111,6 +114,9 @@ public class Server { *
diff --git a/broker/src/main/java/io/moquette/spi/impl/security/ResourceAuthenticator.java b/broker/src/main/java/io/moquette/spi/impl/security/ResourceAuthenticator.java index 406b8353..9761ae3f 100644 --- a/broker/src/main/java/io/moquette/spi/impl/security/ResourceAuthenticator.java +++ b/broker/src/main/java/io/moquette/spi/impl/security/ResourceAuthenticator.java @@ -33,7 +33,7 @@ import java.util.Map; /** * Load user credentials from a text resource. - * Each line of the file is formatted as ": ". The username mustn't contains : char. + * Each line of the file is formatted as "[username]:[sha256(password)]". The username mustn't contains : char. * * To encode your password from command line on Linux systems, you could use: * diff --git a/broker/src/main/java/io/moquette/spi/impl/subscriptions/SubscriptionsStore.java b/broker/src/main/java/io/moquette/spi/impl/subscriptions/SubscriptionsStore.java index 6330f9a2..b1ebe262 100644 --- a/broker/src/main/java/io/moquette/spi/impl/subscriptions/SubscriptionsStore.java +++ b/broker/src/main/java/io/moquette/spi/impl/subscriptions/SubscriptionsStore.java @@ -44,6 +44,8 @@ public class SubscriptionsStore { /** * Check if the topic filter of the subscription is well formed + * @param topicFilter the filter to validate + * @return true if it's correct. * */ public static boolean validate(String topicFilter) { try { @@ -98,6 +100,7 @@ public class SubscriptionsStore { /** * Initialize the subscription tree with the list of subscriptions. * Maintained for compatibility reasons. + * @param sessionsStore to be used as backing store from the subscription store. */ public void init(ISessionsStore sessionsStore) { LOG.debug("init invoked"); @@ -178,6 +181,7 @@ public class SubscriptionsStore { /** * Visit the topics tree to remove matching subscriptions with clientID. * It's a mutating structure operation so create a new subscription tree (partial or total). + * @param clientID the client ID to remove. */ public void removeForClient(String clientID) { TreeNode oldRoot; @@ -194,6 +198,9 @@ public class SubscriptionsStore { * Given a topic string return the clients subscriptions that matches it. * Topic string can't contain character # and + because they are reserved to * listeners subscriptions, and not topic publishing. + * + * @param topic to use fo searching matching subscriptions. + * @return the list of matching subscriptions, or empty if not matching. */ public Listmatches(String topic) { List tokens; @@ -252,6 +259,9 @@ public class SubscriptionsStore { /** * Verify if the 2 topics matching respecting the rules of MQTT Appendix A + * @param msgTopic the topic to match from the message + * @param subscriptionTopic the topic filter of the subscription + * @return true if the two topics match. */ //TODO reimplement with iterators or with queues public static boolean matchTopics(String msgTopic, String subscriptionTopic) { diff --git a/broker/src/main/java/io/moquette/spi/persistence/MapDBMessagesStore.java b/broker/src/main/java/io/moquette/spi/persistence/MapDBMessagesStore.java index f8c3d583..ebf7593a 100644 --- a/broker/src/main/java/io/moquette/spi/persistence/MapDBMessagesStore.java +++ b/broker/src/main/java/io/moquette/spi/persistence/MapDBMessagesStore.java @@ -74,18 +74,18 @@ class MapDBMessagesStore implements IMessagesStore { } @Override - public MessageGUID storePublishForFuture(StoredMessage evt) { - LOG.debug("storePublishForFuture store evt {}", evt); - if (evt.getClientID() == null) { - LOG.error("persisting a message without a clientID, bad programming error msg: {}", evt); + public MessageGUID storePublishForFuture(StoredMessage storedMessage) { + LOG.debug("storePublishForFuture store evt {}", storedMessage); + if (storedMessage.getClientID() == null) { + LOG.error("persisting a message without a clientID, bad programming error msg: {}", storedMessage); throw new IllegalArgumentException("\"persisting a message without a clientID, bad programming error"); } MessageGUID guid = new MessageGUID(UUID.randomUUID().toString()); - evt.setGuid(guid); + storedMessage.setGuid(guid); LOG.debug("storePublishForFuture guid <{}>", guid); - m_persistentMessageStore.put(guid, evt); - ConcurrentMap messageIdToGuid = m_db.getHashMap(MapDBSessionsStore.messageId2GuidsMapName(evt.getClientID())); - messageIdToGuid.put(evt.getMessageID(), guid); + m_persistentMessageStore.put(guid, storedMessage); + ConcurrentMap messageIdToGuid = m_db.getHashMap(MapDBSessionsStore.messageId2GuidsMapName(storedMessage.getClientID())); + messageIdToGuid.put(storedMessage.getMessageID(), guid); return guid; } diff --git a/broker/src/main/java/io/moquette/spi/persistence/MapDBPersistentStore.java b/broker/src/main/java/io/moquette/spi/persistence/MapDBPersistentStore.java index 164941e2..3d1cbb81 100644 --- a/broker/src/main/java/io/moquette/spi/persistence/MapDBPersistentStore.java +++ b/broker/src/main/java/io/moquette/spi/persistence/MapDBPersistentStore.java @@ -69,6 +69,7 @@ public class MapDBPersistentStore { /** * Factory method to create message store backed by MapDB + * @return the message store instance. * */ public IMessagesStore messagesStore() { return m_messageStore; diff --git a/broker/src/main/java/io/moquette/spi/security/IAuthorizator.java b/broker/src/main/java/io/moquette/spi/security/IAuthorizator.java index 5d53c0cd..1e3c6c21 100644 --- a/broker/src/main/java/io/moquette/spi/security/IAuthorizator.java +++ b/broker/src/main/java/io/moquette/spi/security/IAuthorizator.java @@ -28,6 +28,10 @@ public interface IAuthorizator { /** * Ask the implementation of the authorizator if the topic can be used in a publish. + * @param topic the topic to write to. + * @param user the user + * @param client the client + * @return true if the user from client can publish data on topic. * */ boolean canWrite(String topic, String user, String client); diff --git a/broker/src/test/java/io/moquette/spi/impl/MemoryMessagesStore.java b/broker/src/test/java/io/moquette/spi/impl/MemoryMessagesStore.java index 3cf8d5cb..74bb83f0 100644 --- a/broker/src/test/java/io/moquette/spi/impl/MemoryMessagesStore.java +++ b/broker/src/test/java/io/moquette/spi/impl/MemoryMessagesStore.java @@ -67,14 +67,14 @@ public class MemoryMessagesStore implements IMessagesStore { } @Override - public MessageGUID storePublishForFuture(StoredMessage evt) { - LOG.debug("storePublishForFuture store evt {}", evt); + public MessageGUID storePublishForFuture(StoredMessage storedMessage) { + LOG.debug("storePublishForFuture store evt {}", storedMessage); MessageGUID guid = new MessageGUID(UUID.randomUUID().toString()); - evt.setGuid(guid); - m_persistentMessageStore.put(guid, evt); + storedMessage.setGuid(guid); + m_persistentMessageStore.put(guid, storedMessage); HashMap guids = (HashMap ) defaultGet(m_messageToGuids, - evt.getClientID(), new HashMap ()); - guids.put(evt.getMessageID(), guid); + storedMessage.getClientID(), new HashMap ()); + guids.put(storedMessage.getMessageID(), guid); return guid; }