Fixed the configuration of acl_file path
This commit is contained in:
@@ -206,9 +206,11 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
String aclFilePath = props.getProperty(ACL_FILE_PROPERTY_NAME, "");
|
String aclFilePath = props.getProperty(ACL_FILE_PROPERTY_NAME, "");
|
||||||
IAuthorizator authorizator;
|
IAuthorizator authorizator;
|
||||||
if (aclFilePath != null && !aclFilePath.isEmpty()) {
|
if (aclFilePath != null && !aclFilePath.isEmpty()) {
|
||||||
authorizator = new ACLAuthorizator(aclFilePath);
|
authorizator = new ACLAuthorizator(configPath, aclFilePath);
|
||||||
|
LOG.info("Using acl file defined at path {}", aclFilePath);
|
||||||
} else {
|
} else {
|
||||||
authorizator = new PermitAllAuthorizator();
|
authorizator = new PermitAllAuthorizator();
|
||||||
|
LOG.info("Starting without ACL definition");
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean allowAnonymous = Boolean.parseBoolean(props.getProperty(ALLOW_ANONYMOUS_PROPERTY_NAME, "true"));
|
boolean allowAnonymous = Boolean.parseBoolean(props.getProperty(ALLOW_ANONYMOUS_PROPERTY_NAME, "true"));
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ public class ACLAuthorizator implements IAuthorizator {
|
|||||||
|
|
||||||
List<Authorization> m_authorisations = Collections.emptyList();
|
List<Authorization> m_authorisations = Collections.emptyList();
|
||||||
|
|
||||||
public ACLAuthorizator(String aclFilePath) {
|
public ACLAuthorizator(String parent, String filePath) {
|
||||||
File aclFile = new File(aclFilePath);
|
File aclFile = new File(parent, filePath);
|
||||||
try {
|
try {
|
||||||
m_authorisations = ACLFileParser.parse(aclFile);
|
m_authorisations = ACLFileParser.parse(aclFile);
|
||||||
} catch (ParseException pex) {
|
} catch (ParseException pex) {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
topic write /sensors/anemometer
|
||||||
@@ -13,6 +13,7 @@ host 0.0.0.0
|
|||||||
|
|
||||||
#Password file
|
#Password file
|
||||||
password_file config/password_file.conf
|
password_file config/password_file.conf
|
||||||
|
acl_file config/acl.conf
|
||||||
|
|
||||||
#false to accept only client connetions with credentials
|
#false to accept only client connetions with credentials
|
||||||
#true to accept client connection without credentails, validating only the one that provides
|
#true to accept client connection without credentails, validating only the one that provides
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import org.fusesource.mqtt.client.Topic
|
|||||||
|
|
||||||
|
|
||||||
String host = args[0]
|
String host = args[0]
|
||||||
|
String topic = "/topic"
|
||||||
|
if (args.length > 1) {
|
||||||
|
topic = args[1]
|
||||||
|
}
|
||||||
//start a publisher
|
//start a publisher
|
||||||
MQTT mqtt2 = new MQTT()
|
MQTT mqtt2 = new MQTT()
|
||||||
mqtt2.setHost(host, 1883)
|
mqtt2.setHost(host, 1883)
|
||||||
@@ -15,7 +19,7 @@ BlockingConnection publisher = mqtt2.blockingConnection()
|
|||||||
publisher.connect()
|
publisher.connect()
|
||||||
println "publisher connected"
|
println "publisher connected"
|
||||||
|
|
||||||
publisher.publish("/topic", 'Hello world again!!'.bytes, QoS.AT_MOST_ONCE, false)
|
publisher.publish(topic, 'Hello world again!!'.bytes, QoS.AT_MOST_ONCE, false)
|
||||||
println "publisher published"
|
println "publisher published"
|
||||||
|
|
||||||
println "shutdown publisher"
|
println "shutdown publisher"
|
||||||
|
|||||||
Reference in New Issue
Block a user