editorconfig: max line length set

max line length warnings removed
missing Copyright added
useless publics removed
unmaintainable Javadoc tags: @author removed
helper class warnings removed
field default value initialization removed
Multiple warnings removed
pref: checkstyle warnings removed
Checkstyle will fail the build process if it detects violations
switch default cases error logger added
This commit is contained in:
Andreas Mager
2017-04-13 22:16:57 +02:00
parent 6dc762f47f
commit 9221a87812
122 changed files with 999 additions and 454 deletions
@@ -37,8 +37,6 @@ import static io.moquette.logging.LoggingUtils.getInterceptorIds;
/**
* An interceptor that execute the interception tasks asynchronously.
*
* @author Wagner Macedo
*/
final class BrokerInterceptor implements Interceptor {
@@ -63,14 +61,14 @@ final class BrokerInterceptor implements Interceptor {
*
* @param handlers
*/
public BrokerInterceptor(List<InterceptHandler> handlers) {
BrokerInterceptor(List<InterceptHandler> handlers) {
this(1, handlers);
}
/**
* Configures a broker interceptor using the pool size specified in the IConfig argument.
*/
public BrokerInterceptor(IConfig props, List<InterceptHandler> handlers) {
BrokerInterceptor(IConfig props, List<InterceptHandler> handlers) {
this(Integer.parseInt(props.getProperty(BrokerConstants.BROKER_INTERCEPTOR_THREAD_POOL_SIZE, "1")), handlers);
}
@@ -201,7 +199,7 @@ final class BrokerInterceptor implements Interceptor {
@Override
public void addInterceptHandler(InterceptHandler interceptHandler) {
Class<?>[] interceptedMessageTypes = getInterceptedMessageTypes(interceptHandler);
LOG.info( "Adding MQTT message interceptor. InterceptorId={}, handledMessageTypes={}",
LOG.info("Adding MQTT message interceptor. InterceptorId={}, handledMessageTypes={}",
interceptHandler.getID(), interceptedMessageTypes);
for (Class<?> interceptMessageType : interceptedMessageTypes) {
this.handlers.get(interceptMessageType).add(interceptHandler);
@@ -17,15 +17,13 @@
package io.moquette.spi.impl;
import io.netty.buffer.ByteBuf;
import java.nio.ByteBuffer;
/**
*
* @author andrea
*/
class DebugUtils {
final class DebugUtils {
static String payload2Str(ByteBuf content) {
return new String(content.copy ().array());
return new String(content.copy().array());
}
private DebugUtils() {
}
}
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -22,7 +37,7 @@ class MessagesPublisher {
private final IMessagesStore m_messagesStore;
private final PersistentQueueMessageSender messageSender;
public MessagesPublisher(ConnectionDescriptorStore connectionDescriptors, ISessionsStore sessionsStore,
MessagesPublisher(ConnectionDescriptorStore connectionDescriptors, ISessionsStore sessionsStore,
IMessagesStore messagesStore, PersistentQueueMessageSender messageSender) {
this.connectionDescriptors = connectionDescriptors;
this.m_sessionsStore = sessionsStore;
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -15,7 +30,7 @@ class PersistentQueueMessageSender {
private static final Logger LOG = LoggerFactory.getLogger(PersistentQueueMessageSender.class);
private final ConnectionDescriptorStore connectionDescriptorStore;
public PersistentQueueMessageSender(ConnectionDescriptorStore connectionDescriptorStore) {
PersistentQueueMessageSender(ConnectionDescriptorStore connectionDescriptorStore) {
this.connectionDescriptorStore = connectionDescriptorStore;
}
@@ -24,7 +39,7 @@ class PersistentQueueMessageSender {
final int messageId = pubMessage.variableHeader().messageId();
final String topicName = pubMessage.variableHeader().topicName();
if (LOG.isDebugEnabled()) {
LOG.debug("Sending PUBLISH message. MessageId={}, CId={}, topic={}, qos={}, payload={}", messageId,
LOG.debug("Sending PUBLISH message. MessageId={}, CId={}, topic={}, qos={}, payload={}", messageId,
clientId, topicName, DebugUtils.payload2Str(pubMessage.payload()));
} else {
LOG.info("Sending PUBLISH message. MessageId={}, CId={}, topic={}", messageId, clientId, topicName);
@@ -34,8 +49,8 @@ class PersistentQueueMessageSender {
MqttQoS qos = pubMessage.fixedHeader().qosLevel();
if (!messageDelivered && qos != AT_MOST_ONCE && !clientsession.isCleanSession()) {
LOG.warn("PUBLISH message could not be delivered. It will be stored. MessageId={}, CId={}, topic={}, qos={}, " +
"cleanSession={}", messageId, clientId, topicName, qos, false);
LOG.warn("PUBLISH message could not be delivered. It will be stored. MessageId={}, CId={}, topic={}, "
+ "qos={}, cleanSession={}", messageId, clientId, topicName, qos, false);
clientsession.enqueue(asStoredMessage(pubMessage));
} else {
LOG.warn("PUBLISH message could not be delivered. It will be discarded. MessageId={}, CId={}, topic={}, " +
@@ -56,8 +56,6 @@ import static io.moquette.server.ConnectionDescriptor.ConnectionState.*;
* execution.
*
* Used by the front facing class ProtocolProcessorBootstrapper.
*
* @author andrea
*/
public class ProtocolProcessor {
@@ -68,7 +66,7 @@ public class ProtocolProcessor {
private final boolean retained;
private final MqttQoS qos;
public WillMessage(String topic, ByteBuffer payload, boolean retained, MqttQoS qos) {
WillMessage(String topic, ByteBuffer payload, boolean retained, MqttQoS qos) {
this.topic = topic;
this.payload = payload;
this.retained = retained;
@@ -474,7 +472,8 @@ public class ProtocolProcessor {
targetSession.inFlightAcknowledged(messageID);
String topic = inflightMsg.getTopic();
m_interceptor.notifyMessageAcknowledged(new InterceptAcknowledgedMessage(inflightMsg, topic, username, messageID));
m_interceptor
.notifyMessageAcknowledged(new InterceptAcknowledgedMessage(inflightMsg, topic, username, messageID));
}
public static IMessagesStore.StoredMessage asStoredMessage(MqttPublishMessage msg) {
@@ -511,6 +510,7 @@ public class ProtocolProcessor {
this.qos2PublishHandler.receivedPublishQos2(channel, msg);
break;
default:
LOG.error("Unkonwn QoS-Type:{}", qos);
break;
}
}
@@ -618,7 +618,8 @@ public class ProtocolProcessor {
StoredMessage inflightMsg = targetSession.secondPhaseAcknowledged(messageID);
String username = NettyUtils.userName(channel);
String topic = inflightMsg.getTopic();
m_interceptor.notifyMessageAcknowledged(new InterceptAcknowledgedMessage(inflightMsg, topic, username, messageID));
m_interceptor
.notifyMessageAcknowledged(new InterceptAcknowledgedMessage(inflightMsg, topic, username, messageID));
}
public void processDisconnect(Channel channel) throws InterruptedException {
@@ -921,7 +922,7 @@ public class ProtocolProcessor {
} else {
// recreate a publish from stored publish in queue
boolean retained = m_messagesStore.getMessageByGuid(msg.getGuid()) != null;
MqttPublishMessage pubMsg = createPublishForQos( msg.getTopic(), msg.getQos(), msg.getMessage(),
MqttPublishMessage pubMsg = createPublishForQos(msg.getTopic(), msg.getQos(), msg.getMessage(),
retained, 0);
channel.write(pubMsg);
}
@@ -936,11 +937,11 @@ public class ProtocolProcessor {
public void removeInterceptHandler(InterceptHandler interceptHandler) {
this.m_interceptor.removeInterceptHandler(interceptHandler);
}
public IMessagesStore getMessagesStore() {
return m_messagesStore;
}
public ISessionsStore getSessionsStore() {
return m_sessionsStore;
}
@@ -44,8 +44,6 @@ import java.util.List;
/**
* It's main responsibility is bootstrap the ProtocolProcessor.
*
* @author andrea
*/
public class ProtocolProcessorBootstrapper {
@@ -56,7 +54,7 @@ public class ProtocolProcessorBootstrapper {
private ISessionsStore m_sessionsStore;
private Runnable storeShutdown = null;
private Runnable storeShutdown;
private BrokerInterceptor m_interceptor;
@@ -155,7 +153,7 @@ public class ProtocolProcessorBootstrapper {
LOG.info("Parsing ACL file. Path = {}", aclFilePath);
authorizator = ACLFileParser.parse(resourceLoader.loadResource(aclFilePath));
} catch (ParseException pex) {
LOG.error("Unable to parse ACL file. path="+ aclFilePath, pex);
LOG.error("Unable to parse ACL file. path=" + aclFilePath, pex);
}
} else {
authorizator = new PermitAllAuthorizator();
@@ -167,8 +165,10 @@ public class ProtocolProcessorBootstrapper {
connectionDescriptors = new ConnectionDescriptorStore(m_sessionsStore);
LOG.info("Initializing MQTT protocol processor...");
boolean allowAnonymous = Boolean.parseBoolean(props.getProperty(BrokerConstants.ALLOW_ANONYMOUS_PROPERTY_NAME, "true"));
boolean allowZeroByteClientId = Boolean.parseBoolean(props.getProperty(BrokerConstants.ALLOW_ZERO_BYTE_CLIENT_ID_PROPERTY_NAME, "false"));
boolean allowAnonymous = Boolean
.parseBoolean(props.getProperty(BrokerConstants.ALLOW_ANONYMOUS_PROPERTY_NAME, "true"));
boolean allowZeroByteClientId = Boolean
.parseBoolean(props.getProperty(BrokerConstants.ALLOW_ZERO_BYTE_CLIENT_ID_PROPERTY_NAME, "false"));
m_processor.init(connectionDescriptors, subscriptions, messagesStore, m_sessionsStore, authenticator,
allowAnonymous, allowZeroByteClientId, authorizator, m_interceptor,
props.getProperty(BrokerConstants.PORT_PROPERTY_NAME));
@@ -185,11 +185,19 @@ public class ProtocolProcessorBootstrapper {
// check if method getInstance exists
Method method = clazz.getMethod("getInstance", new Class[]{});
try {
LOG.info("Invoking getInstance() method. ClassName = {}, interfaceName = {}.", className, intrface.getName());
LOG.info(
"Invoking getInstance() method. ClassName = {}, interfaceName = {}.",
className,
intrface.getName());
instance = (T) method.invoke(null, new Object[]{});
} catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException ex) {
LOG.error("Unable to invoke getInstance() method. ClassName = {}, interfaceName = {}, cause = {}, errorMessage = {}.",
className, intrface.getName(), ex.getCause(), ex.getMessage());
LOG.error(
"Unable to invoke getInstance() method. ClassName = {}, interfaceName = {}, cause = {}, "
+ "errorMessage = {}.",
className,
intrface.getName(),
ex.getCause(),
ex.getMessage());
return null;
}
} catch (NoSuchMethodException nsmex) {
@@ -204,17 +212,31 @@ public class ProtocolProcessorBootstrapper {
.getConstructor(constructorArgClass)
.newInstance(props);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
LOG.warn("Unable to invoke constructor with {} argument. ClassName = {}, interfaceName = {}, cause = {}, errorMessage = {}.",
constructorArgClass.getName(), className, intrface.getName(), ex.getCause(), ex.getMessage());
LOG.warn(
"Unable to invoke constructor with {} argument. ClassName = {}, interfaceName = {}, cause = {}"
+ ", errorMessage = {}.",
constructorArgClass.getName(),
className,
intrface.getName(),
ex.getCause(),
ex.getMessage());
return null;
} catch (NoSuchMethodException | InvocationTargetException e) {
try {
LOG.info("Invoking default constructor. ClassName = {}, interfaceName = {}.", className, intrface.getName());
LOG.info(
"Invoking default constructor. ClassName = {}, interfaceName = {}.",
className,
intrface.getName());
// fallback to default constructor
instance = this.getClass().getClassLoader().loadClass(className).asSubclass(intrface).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
LOG.error("Unable to invoke default constructor. ClassName = {}, interfaceName = {}, cause = {}, errorMessage = {}.",
className, intrface.getName(), ex.getCause(), ex.getMessage());
LOG.error(
"Unable to invoke default constructor. ClassName = {}, interfaceName = {}, cause = {}, "
+ "errorMessage = {}.",
className,
intrface.getName(),
ex.getCause(),
ex.getMessage());
return null;
}
}
@@ -222,8 +244,13 @@ public class ProtocolProcessorBootstrapper {
LOG.error("The class does not exist. ClassName = {}, interfaceName = {}.", className, intrface.getName());
return null;
} catch (SecurityException ex) {
LOG.error("Unable to load class due to a security violation. ClassName = {}, interfaceName = {}, cause = {}, errorMessage = {}.",
className, intrface.getName(), ex.getCause(), ex.getMessage());
LOG.error(
"Unable to load class due to a security violation. ClassName = {}, interfaceName = {}, cause = {}, "
+ "errorMessage = {}.",
className,
intrface.getName(),
ex.getCause(),
ex.getMessage());
return null;
}
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -23,8 +38,8 @@ class Qos0PublishHandler extends QosPublishHandler {
private final BrokerInterceptor m_interceptor;
private final MessagesPublisher publisher;
public Qos0PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
IMessagesStore messagesStore, BrokerInterceptor interceptor, MessagesPublisher messagesPublisher) {
Qos0PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions, IMessagesStore messagesStore,
BrokerInterceptor interceptor, MessagesPublisher messagesPublisher) {
super(authorizator);
this.subscriptions = subscriptions;
this.m_messagesStore = messagesStore;
@@ -1,10 +1,24 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
import io.moquette.server.ConnectionDescriptorStore;
import io.moquette.server.netty.NettyUtils;
import io.moquette.spi.IMessagesStore;
import io.moquette.spi.MessageGUID;
import io.moquette.spi.impl.subscriptions.Subscription;
import io.moquette.spi.impl.subscriptions.SubscriptionsStore;
import io.moquette.spi.impl.subscriptions.Topic;
@@ -31,9 +45,9 @@ class Qos1PublishHandler extends QosPublishHandler {
private final ConnectionDescriptorStore connectionDescriptors;
private final MessagesPublisher publisher;
public Qos1PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
IMessagesStore messagesStore, BrokerInterceptor interceptor,
ConnectionDescriptorStore connectionDescriptors, String brokerPort, MessagesPublisher messagesPublisher) {
Qos1PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions, IMessagesStore messagesStore,
BrokerInterceptor interceptor, ConnectionDescriptorStore connectionDescriptors, String brokerPort,
MessagesPublisher messagesPublisher) {
super(authorizator);
this.subscriptions = subscriptions;
this.m_messagesStore = messagesStore;
@@ -97,7 +111,7 @@ class Qos1PublishHandler extends QosPublishHandler {
LOG.debug("clientIDs are {}", connectionDescriptors);
if (!connectionDescriptors.isConnected(clientId)) {
throw new RuntimeException(String.format("Can't find a ConnectionDescriptor for client %s in cache %s",
clientId,connectionDescriptors));
clientId, connectionDescriptors));
}
connectionDescriptors.sendMessage(pubAckMessage, messageID, clientId);
} catch (Throwable t) {
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -34,7 +49,7 @@ class Qos2PublishHandler extends QosPublishHandler {
private final ISessionsStore m_sessionsStore;
private final MessagesPublisher publisher;
public Qos2PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
Qos2PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
IMessagesStore messagesStore, BrokerInterceptor interceptor,
ConnectionDescriptorStore connectionDescriptors, ISessionsStore sessionsStore, String brokerPort,
MessagesPublisher messagesPublisher) {
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl;
@@ -9,7 +24,7 @@ import java.util.Map;
/**
* Utility static methods, like Map get with default value, or elvis operator.
*/
public class Utils {
public final class Utils {
public static <T, K> T defaultGet(Map<K, T> map, K key, T defaultValue) {
T value = map.get(key);
@@ -30,4 +45,7 @@ public class Utils {
payload.readerIndex(mark);
return payloadContent;
}
private Utils() {
}
}
@@ -24,10 +24,8 @@ import java.text.ParseException;
/**
* Parses the acl configuration file. If a line starts with # it's comment. Blank lines are skipped.
* The format is "topic [read|write|readwrite] {topic name}"
*
* @author andrea
*/
public class ACLFileParser {
public final class ACLFileParser {
private static final Logger LOG = LoggerFactory.getLogger(ACLFileParser.class);
@@ -110,4 +108,7 @@ public class ACLFileParser {
}
return collector;
}
private ACLFileParser() {
}
}
@@ -1,11 +1,23 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl.security;
import io.moquette.spi.security.IAuthenticator;
/**
* Created by andrea on 8/23/14.
*/
public class AcceptAllAuthenticator implements IAuthenticator {
public boolean checkValid(String clientId, String username, byte[] password) {
@@ -21,8 +21,6 @@ import io.moquette.spi.impl.subscriptions.Topic;
/**
* Carries the read/write authorization to topics for the users.
*
* @author andrea
*/
public class Authorization {
@@ -18,8 +18,6 @@ package io.moquette.spi.impl.security;
import io.moquette.spi.impl.subscriptions.Topic;
import io.moquette.spi.security.IAuthorizator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.util.*;
@@ -28,18 +26,14 @@ import java.util.*;
* mode to check it topics matches the ACLs.
*
* Not thread safe.
*
* @author andrea
*/
class AuthorizationsCollector implements IAuthorizator {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizationsCollector.class);
private List<Authorization> m_globalAuthorizations = new ArrayList<>();
private List<Authorization> m_patternAuthorizations = new ArrayList<>();
private Map<String, List<Authorization>> m_userAuthorizations = new HashMap<>();
private boolean m_parsingUsersSpecificSection = false;
private boolean m_parsingPatternSpecificSection = false;
private boolean m_parsingUsersSpecificSection;
private boolean m_parsingPatternSpecificSection;
private String m_currentUser = "";
static final AuthorizationsCollector emptyImmutableCollector() {
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl.security;
@@ -13,10 +28,7 @@ import java.sql.*;
/**
* Load user credentials from a SQL database. sql driver must be provided at runtime
*
* @author mackristof
*/
public class DBAuthenticator implements IAuthenticator {
private static final Logger LOG = LoggerFactory.getLogger(DBAuthenticator.class);
@@ -19,9 +19,6 @@ package io.moquette.spi.impl.security;
import io.moquette.spi.impl.subscriptions.Topic;
import io.moquette.spi.security.IAuthorizator;
/**
* @author andrea
*/
public class DenyAllAuthorizator implements IAuthorizator {
@Override
@@ -31,7 +31,6 @@ import io.moquette.server.config.FileResourceLoader;
* NB -n is important because echo append a newline by default at the of string. -n avoid this
* behaviour.
*
* @author andrea
* @deprecated user {@link ResourceAuthenticator} instead
*/
public class FileAuthenticator extends ResourceAuthenticator {
@@ -19,9 +19,6 @@ package io.moquette.spi.impl.security;
import io.moquette.spi.impl.subscriptions.Topic;
import io.moquette.spi.security.IAuthorizator;
/**
* @author andrea
*/
public class PermitAllAuthorizator implements IAuthorizator {
@Override
@@ -42,19 +42,16 @@ import java.util.Map;
*
* NB -n is important because echo append a newline by default at the of string. -n avoid this
* behaviour.
*
* @author andrea
*/
public class ResourceAuthenticator implements IAuthenticator {
protected static final Logger LOG = LoggerFactory.getLogger(ResourceAuthenticator.class);
private Map<String, String> m_identities = new HashMap<>();
private MessageDigest m_digest;
public ResourceAuthenticator(IResourceLoader resourceLoader, String resourceName) {
try {
this.m_digest = MessageDigest.getInstance("SHA-256");
MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException nsaex) {
LOG.error("Can't find SHA-256 for password encoding", nsaex);
throw new RuntimeException(nsaex);
@@ -22,9 +22,6 @@ import java.io.Serializable;
/**
* Maintain the information about which Topic a certain ClientID is subscribed and at which QoS
*
*
* @author andrea
*/
public final class Subscription implements Serializable {
@@ -26,8 +26,6 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* Represents a tree of topics subscriptions.
*
* @author andrea
*/
public class SubscriptionsStore {
@@ -125,7 +123,7 @@ public class SubscriptionsStore {
couple.createdNode.addSubscription(newSubscription); //createdNode could be null?
couple.root.recalculateSubscriptionsSize();
//spin lock repeating till we can, swap root, if can't swap just re-do the operation
} while(!subscriptions.compareAndSet(oldRoot, couple.root));
} while (!subscriptions.compareAndSet(oldRoot, couple.root));
LOG.debug("A subscription has been added. Root = {}, oldRoot = {}.", couple.root, oldRoot);
}
@@ -168,7 +166,7 @@ public class SubscriptionsStore {
couple.createdNode.remove(new ClientTopicCouple(clientID, topic));
couple.root.recalculateSubscriptionsSize();
//spin lock repeating till we can, swap root, if can't swap just re-do the operation
} while(!subscriptions.compareAndSet(oldRoot, couple.root));
} while (!subscriptions.compareAndSet(oldRoot, couple.root));
}
/**
@@ -26,7 +26,7 @@ class TreeNode {
List<TreeNode> m_children = new ArrayList<>();
Set<ClientTopicCouple> m_subscriptions = new HashSet<>();
private int subtreeSubscriptions = 0;
private int subtreeSubscriptions;
TreeNode() {
}