Changing default host to 0.0.0.0 by default and allowing it to be configured during create

This is changing the default host to 0.0.0.0 per feedback from the community (activemq dev-list)
however if clustered is used some input or other properties will get input during the create process
I've also done some other changes based on some small issues I have encountered
This commit is contained in:
Clebert Suconic 2015-05-14 12:02:43 -04:00
parent 4b157934e3
commit 3e07a03ce5
22 changed files with 441 additions and 184 deletions

View File

@ -0,0 +1,102 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.cli.commands;
import java.util.Scanner;
public abstract class ActionAbstract implements Action
{
protected ActionContext context;
private Scanner scanner;
private boolean noInput = false;
protected void disableInputs()
{
noInput = true;
}
protected String input(String propertyName, String prompt, String silentDefault)
{
if (noInput)
{
return silentDefault;
}
String inputStr;
boolean valid = false;
System.out.println();
do
{
context.out.println(propertyName + ": is mandatory with this configuration:");
context.out.println(prompt);
inputStr = scanner.nextLine();
if (inputStr.trim().equals(""))
{
System.out.println("Invalid Entry!");
}
else
{
valid = true;
}
}
while (!valid);
return inputStr.trim();
}
protected String inputPassword(String propertyName, String prompt, String silentDefault)
{
if (noInput)
{
return silentDefault;
}
String inputStr;
boolean valid = false;
System.out.println();
do
{
context.out.println(propertyName + ": is mandatory with this configuration:");
context.out.println(prompt);
inputStr = new String(System.console().readPassword());
if (inputStr.trim().equals(""))
{
System.out.println("Invalid Entry!");
}
else
{
valid = true;
}
}
while (!valid);
return inputStr.trim();
}
public Object execute(ActionContext context) throws Exception
{
this.context = context;
scanner = new Scanner(context.in);
return null;
}
}

View File

@ -36,7 +36,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
/**
* Abstract class where we can replace the configuration in various places *
*/
public abstract class Configurable
public abstract class Configurable extends ActionAbstract
{
@Arguments(description = "Broker Configuration URI, default 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'")
String configuration;

View File

@ -30,13 +30,13 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl;
import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE;
import static java.nio.file.attribute.PosixFilePermission.GROUP_READ;
@ -51,7 +51,7 @@ import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
* CLI action that creates a broker instance directory.
*/
@Command(name = "create", description = "creates a new broker instance")
public class Create implements Action
public class Create extends ActionAbstract
{
private static final Integer DEFAULT_PORT = 61616;
@ -75,11 +75,16 @@ public class Create implements Action
public static final String ETC_BROKER_XML = "etc/broker.xml";
public static final String ETC_ARTEMIS_ROLES_PROPERTIES = "etc/artemis-roles.properties";
public static final String ETC_ARTEMIS_USERS_PROPERTIES = "etc/artemis-users.properties";
public static final String ETC_REPLICATED_SETTINGS_TXT = "etc/replicated-settings.txt";
public static final String ETC_SHARED_STORE_SETTINGS_TXT = "etc/shared-store-settings.txt";
public static final String ETC_CLUSTER_SECURITY_SETTINGS_TXT = "etc/cluster-security-settings.txt";
public static final String ETC_CLUSTER_SETTINGS_TXT = "etc/cluster-settings.txt";
public static final String ETC_CONNECTOR_SETTINGS_TXT = "etc/connector-settings.txt";
@Arguments(description = "The instance directory to hold the broker's configuration and data", required = true)
File directory;
@Option(name = "--host", description = "The host name of the broker")
@Option(name = "--host", description = "The host name of the broker (Default: 0.0.0.0 or input if clustered)")
String host;
@Option(name = "--port-offset", description = "Off sets the default ports")
@ -91,6 +96,9 @@ public class Create implements Action
@Option(name = "--home", description = "Directory where ActiveMQ Artemis is installed")
File home;
@Option(name = "--data", description = "Directory where ActiveMQ Data is used. Path are relative to artemis.instance/bin")
String data = "../data";
@Option(name = "--clustered", description = "Enable clustering")
boolean clustered = false;
@ -100,10 +108,10 @@ public class Create implements Action
@Option(name = "--shared-store", description = "Enable broker shared store")
boolean sharedStore = false;
@Option(name = "--cluster-user", description = "The cluster user to use for clustering")
@Option(name = "--cluster-user", description = "The cluster user to use for clustering. (Default: input)")
String clusterUser = null;
@Option(name = "--cluster-password", description = "The cluster password to use for clustering")
@Option(name = "--cluster-password", description = "The cluster password to use for clustering. (Default: input)")
String clusterPassword = null;
@Option(name = "--encoding", description = "The encoding that text files should use")
@ -112,9 +120,20 @@ public class Create implements Action
@Option(name = "--java-options", description = "Extra java options to be passed to the profile")
String javaOptions = "";
ActionContext context;
@Option(name = "--allow-anonymous", description = "Enables anonymous configuration on security (Default: input)")
Boolean allowAnonymous = null;
private Scanner scanner;
@Option(name = "--user", description = "The username (Default: input)")
String user;
@Option(name = "--password", description = "The user's password (Default: input)")
String password;
@Option(name = "--role", description = "The name for the role created (Default: amq)")
String role;
@Option(name = "--silent-input", description = "It will disable all the inputs, and it would make a best guess for any required input")
boolean silentInput;
boolean IS_WINDOWS;
@ -152,6 +171,20 @@ public class Create implements Action
public String getHost()
{
if (host == null)
{
host = "0.0.0.0";
}
return host;
}
public String getHostForClustered()
{
if (getHost().equals("0.0.0.0"))
{
host = input("--host", "Host " + host + " is not valid for clustering, please provide a valid IP or hostname", "localhost");
}
return host;
}
@ -224,9 +257,113 @@ public class Create implements Action
this.encoding = encoding;
}
public String getData()
{
return data;
}
public void setData(String data)
{
this.data = data;
}
public String getClusterUser()
{
if (clusterUser == null)
{
clusterUser = input("--cluster-user", "Please provide the username:", "cluster-admin");
}
return clusterUser;
}
public void setClusterUser(String clusterUser)
{
this.clusterUser = clusterUser;
}
public String getClusterPassword()
{
if (clusterPassword == null)
{
clusterPassword = inputPassword("--cluster-password", "Please enter the password:", "password-admin");
}
return clusterPassword;
}
public void setClusterPassword(String clusterPassword)
{
this.clusterPassword = clusterPassword;
}
public boolean isAllowAnonymous()
{
if (allowAnonymous == null)
{
String value = input("--allow-anonymous", "Allow anonymous access? (Y/N):", "Y");
allowAnonymous = Boolean.valueOf(value.toLowerCase().equals("y"));
}
return allowAnonymous.booleanValue();
}
public void setAllowAnonymous(boolean allowGuest)
{
this.allowAnonymous = Boolean.valueOf(allowGuest);
}
public String getPassword()
{
if (password == null)
{
this.password = inputPassword("--password", "Please provide the default password:", "admin");
}
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getUser()
{
if (user == null)
{
user = input("--user", "Please provide the default username:", "admin");
}
return user;
}
public void setUser(String user)
{
this.user = user;
}
public String getRole()
{
if (role == null)
{
role = "amq";
}
return role;
}
public void setRole(String role)
{
this.role = role;
}
@Override
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
if (silentInput)
{
this.disableInputs();
}
try
{
return run(context);
@ -248,77 +385,77 @@ public class Create implements Action
public Object run(ActionContext context) throws Exception
{
this.context = context;
scanner = new Scanner(System.in);
IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win");
IS_CYGWIN = IS_WINDOWS && "cygwin".equals(System.getenv("OSTYPE"));
context.out.println(String.format("Creating ActiveMQ Artemis instance at: %s", directory.getCanonicalPath()));
if (host == null)
{
host = "localhost";
}
HashMap<String, String> filters = new HashMap<String, String>();
String replicatedSettings = "";
if (replicated)
{
clustered = true;
replicatedSettings = readTextFile("etc/replicated-settings.txt");
filters.put("${replicated.settings}", readTextFile(ETC_REPLICATED_SETTINGS_TXT));
}
else
{
filters.put("${replicated.settings}", "");
}
filters.put("${replicated.settings}", replicatedSettings);
String sharedStoreSettings = "";
if (sharedStore)
{
clustered = true;
sharedStoreSettings = readTextFile("etc/shared-store-settings.txt");
filters.put("${shared-store.settings}", readTextFile(ETC_SHARED_STORE_SETTINGS_TXT));
}
filters.put("${shared-store.settings}", sharedStoreSettings);
String clusterSettings = "";
String clusterSecuritySettings = "";
String clusterUserSettings = "";
String clusterPasswordSettings = "";
if (clustered)
else
{
clusterSettings = readTextFile("etc/cluster-settings.txt");
if (clusterUser == null)
{
clusterUser = input("Please provide a user name for clustering (leave empty for default)");
}
if (clusterUser != null && clusterUser.length() > 0)
{
clusterUserSettings = clusterUser;
clusterSecuritySettings = readTextFile("etc/cluster-security-settings.txt");
}
if (clusterPassword == null)
{
clusterPassword = input("Please provide a password for clustering (leave empty for default)");
}
if (clusterPassword != null && clusterPassword.length() > 0)
{
clusterPasswordSettings = clusterPassword;
}
filters.put("${shared-store.settings}", "");
}
filters.put("${cluster-security.settings}", clusterSecuritySettings);
filters.put("${cluster.settings}", clusterSettings);
filters.put("${cluster-user}", clusterUserSettings);
filters.put("${cluster-password}", clusterPasswordSettings);
if (IS_WINDOWS || !AsynchronousFileImpl.isLoaded())
{
filters.put("${journal.settings}", "NIO");
}
else
{
filters.put("${journal.settings}", "AIO");
}
filters.put("${user}", System.getProperty("user.name", ""));
filters.put("${host}", host);
filters.put("${default.port}", String.valueOf(DEFAULT_PORT + portOffset));
filters.put("${amqp.port}", String.valueOf(AMQP_PORT + portOffset));
filters.put("${stomp.port}", String.valueOf(STOMP_PORT + portOffset));
filters.put("${hq.port}", String.valueOf(HQ_PORT + portOffset));
filters.put("${http.port}", String.valueOf(HTTP_PORT + portOffset));
filters.put("${data.dir}", data);
filters.put("${user}", getUser());
filters.put("${password}", getPassword());
filters.put("${role}", getRole());
if (clustered)
{
filters.put("${host}", getHostForClustered());
String connectorSettings = readTextFile(ETC_CONNECTOR_SETTINGS_TXT);
connectorSettings = applyFilters(connectorSettings, filters);
filters.put("${connector-config.settings}", connectorSettings);
filters.put("${cluster-security.settings}", readTextFile(ETC_CLUSTER_SECURITY_SETTINGS_TXT));
filters.put("${cluster.settings}", readTextFile(ETC_CLUSTER_SETTINGS_TXT));
filters.put("${cluster-user}", getClusterUser());
filters.put("${cluster-password}", getClusterPassword());
}
else
{
filters.put("${host}", getHost());
filters.put("${connector-config.settings}", "");
filters.put("${cluster-security.settings}", "");
filters.put("${cluster.settings}", "");
filters.put("${cluster-user}", "");
filters.put("${cluster-password}", "");
}
if (home != null)
{
@ -361,10 +498,20 @@ public class Create implements Action
}
write(ETC_LOGGING_PROPERTIES, null, false);
if (isAllowAnonymous())
{
filters.put("${bootstrap.guest}", "default-user=\"" + getUser() + "\"");
}
else
{
filters.put("${bootstrap.guest}", "");
}
write(ETC_BOOTSTRAP_XML, filters, false);
write(ETC_BROKER_XML, filters, false);
write(ETC_ARTEMIS_ROLES_PROPERTIES, null, false);
write(ETC_ARTEMIS_USERS_PROPERTIES, null, false);
write(ETC_ARTEMIS_ROLES_PROPERTIES, filters, false);
write(ETC_ARTEMIS_USERS_PROPERTIES, filters, false);
context.out.println("");
context.out.println("You can now start the broker by executing: ");
@ -415,12 +562,6 @@ public class Create implements Action
return null;
}
private String input(String prompt)
{
context.out.println(prompt);
return scanner.nextLine();
}
private void makeExec(String path) throws IOException
{
try
@ -447,8 +588,6 @@ public class Create implements Action
{
if (unixPaths && IS_CYGWIN)
{
// import scala.sys.process._
// Seq("cygpath", value.getCanonicalPath).!!.trim
return value.getCanonicalPath();
}
else
@ -469,15 +608,7 @@ public class Create implements Action
throw new RuntimeException(String.format("The file '%s' already exists. Use --force to overwrite.", target));
}
String content = readTextFile(source);
if (filters != null)
{
for (Map.Entry<String, String> entry : filters.entrySet())
{
content = replace(content, entry.getKey(), entry.getValue());
}
}
String content = applyFilters(readTextFile(source), filters);
// and then writing out in the new target encoding.. Let's also replace \n with the values
// that is correct for the current platform.
@ -491,6 +622,19 @@ public class Create implements Action
}
}
private String applyFilters(String content, HashMap<String, String> filters) throws IOException
{
if (filters != null)
{
for (Map.Entry<String, String> entry : filters.entrySet())
{
content = replace(content, entry.getKey(), entry.getValue());
}
}
return content;
}
private String readTextFile(String source) throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
@ -517,56 +661,11 @@ public class Create implements Action
}
}
private boolean canLoad(String name)
{
try
{
this.getClass().getClassLoader().loadClass(name);
return true;
}
catch (Throwable e)
{
return false;
}
}
private String replace(String content, String key, String value)
{
return content.replaceAll(Pattern.quote(key), Matcher.quoteReplacement(value));
}
private int system(File wd, String... command) throws IOException, InterruptedException
{
Process process = Runtime.getRuntime().exec(command, null, wd);
process.getOutputStream().close();
drain(command[0], process.getInputStream(), context.out);
drain(command[0], process.getErrorStream(), context.err);
process.waitFor();
return process.exitValue();
}
private void drain(String threadName, final InputStream is, final OutputStream os)
{
new Thread(threadName)
{
{
setDaemon(true);
}
@Override
public void run()
{
try
{
copy(is, os);
}
catch (Throwable e)
{
}
}
}.start();
}
private void copy(InputStream is, OutputStream os) throws IOException
{
byte[] buffer = new byte[1024 * 4];

View File

@ -22,12 +22,14 @@ import io.airlift.airline.Command;
import org.apache.activemq.artemis.dto.BrokerDTO;
@Command(name = "kill", description = "Kills a broker instance started with --allow-kill")
public class Kill extends Configurable implements Action
public class Kill extends Configurable
{
@Override
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
BrokerDTO broker = getBrokerDTO();
File file = broker.server.getConfigurationFile().getParentFile();

View File

@ -36,7 +36,7 @@ import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
@Command(name = "run", description = "runs the broker instance")
public class Run extends Configurable implements Action
public class Run extends Configurable
{
@Option(name = "--allow-kill", description = "This will allow the server to kill itself. Useful for tests (failover tests for instance)")
boolean allowKill;
@ -48,6 +48,7 @@ public class Run extends Configurable implements Action
@Override
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
Artemis.printBanner();

View File

@ -22,12 +22,12 @@ import io.airlift.airline.Command;
import org.apache.activemq.artemis.dto.BrokerDTO;
@Command(name = "stop", description = "stops the broker instance")
public class Stop extends Configurable implements Action
public class Stop extends Configurable
{
@Override
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
BrokerDTO broker = getBrokerDTO();
File file = broker.server.getConfigurationFile().getParentFile();

View File

@ -59,6 +59,7 @@ public class DecodeJournal extends Configurable implements Action
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
try
{
if (directory == null)

View File

@ -53,6 +53,7 @@ public class EncodeJournal extends Configurable implements Action
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
try
{
if (directory == null)

View File

@ -62,6 +62,7 @@ public class PrintData extends DataAbstract implements Action
@Override
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
try
{
printData(getBinding(), getJournal(), getPaging());

View File

@ -126,6 +126,8 @@ public final class XmlDataExporter extends DataAbstract implements Action
@Override
public Object execute(ActionContext context) throws Exception
{
super.execute(context);
try
{
process(System.out, getBinding(), getJournal(), getPaging(), getLargeMessages());

View File

@ -14,4 +14,4 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
guest=guest
${user}=${role}

View File

@ -14,4 +14,4 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
guest=guest
${user}=${password}

View File

@ -21,11 +21,11 @@
<basic-security
users="file:${artemis.instance}/etc/artemis-users.properties"
roles="file:${artemis.instance}/etc/artemis-roles.properties"
default-user="guest"
/>
${bootstrap.guest}/>
<server configuration="file:${artemis.instance}/etc/broker.xml"/>
<!-- The web server is only bound to loalhost by default -->
<web bind="http://localhost:${http.port}" path="web">
<app url="jolokia" war="jolokia-war-1.2.3.war"/>
</web>

View File

@ -21,48 +21,50 @@ under the License.
<configuration xmlns="urn:activemq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<jms xmlns="urn:activemq:jms">
<queue name="DLQ"/>
<queue name="ExpiryQueue"/>
</jms>
<core xmlns="urn:activemq:core">
<paging-directory>${data.dir:../data}/paging</paging-directory>
<bindings-directory>${data.dir:../data}/bindings</bindings-directory>
<!-- this could be AIO or NIO
-->
<journal-type>${journal.settings}</journal-type>
<journal-directory>${data.dir:../data}/journal</journal-directory>
<paging-directory>${data.dir}/paging</paging-directory>
<bindings-directory>${data.dir}/bindings</bindings-directory>
<journal-directory>${data.dir}/journal</journal-directory>
<large-messages-directory>${data.dir}/large-messages</large-messages-directory>
<journal-min-files>10</journal-min-files>
<large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>
<connectors>
<!-- Default Connector. Returned to clients during broadcast and distributed around cluster. See broadcast and discovery-groups -->
<connector name="artemis">tcp://${activemq.remoting.default.host:${host}}:${activemq.remoting.default.port:${default.port}}</connector>
</connectors>
${connector-config.settings}
<acceptors>
<!-- Default ActiveMQ Artemis Acceptor. Multi-protocol adapter. Currently supports Core, OpenWire, Stomp and AMQP. -->
<acceptor name="artemis">tcp://${activemq.remoting.default.host:${host}}:${activemq.remoting.default.port:${default.port}}</acceptor>
<acceptor name="artemis">tcp://${host}:${default.port}</acceptor>
<!-- AMQP Acceptor. Listens on default AMQP port for AMQP traffic.-->
<acceptor name="amqp">tcp://${activemq.remoting.amqp.host:${host}}:${activemq.remoting.amqp.port:${amqp.port}}?protocols=AMQP</acceptor>
<acceptor name="amqp">tcp://${host}:${amqp.port}?protocols=AMQP</acceptor>
<!-- STOMP Acceptor. -->
<acceptor name="stomp">tcp://${activemq.remoting.stomp.host:${host}}:${activemq.remoting.stomp.port:${stomp.port}}?protocols=STOMP</acceptor>
<acceptor name="stomp">tcp://${host}:${stomp.port}?protocols=STOMP</acceptor>
<!-- HornetQ Compatibility Acceptor. Enables ActiveMQ Artemis Core and STOMP for legacy HornetQ clients. -->
<acceptor name="hornetq">tcp://${activemq.remoting.hornetq.host:${host}}:${activemq.remoting.hornetq.port:${hq.port}}?protocols=HORNETQ,STOMP</acceptor>
<acceptor name="hornetq">tcp://${host}:${hq.port}?protocols=HORNETQ,STOMP</acceptor>
</acceptors>
${cluster-security.settings}${cluster.settings}${replicated.settings}${shared-store.settings}
${cluster-security.settings}${cluster.settings}${replicated.settings}${shared-store.settings}
<security-settings>
<security-setting match="#">
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="send" roles="guest"/>
<permission type="createNonDurableQueue" roles="${role}"/>
<permission type="deleteNonDurableQueue" roles="${role}"/>
<permission type="createDurableQueue" roles="${role}"/>
<permission type="deleteDurableQueue" roles="${role}"/>
<permission type="consume" roles="${role}"/>
<permission type="send" roles="${role}"/>
</security-setting>
</security-settings>

View File

@ -1,3 +1,4 @@
<cluster-user>${cluster-user}</cluster-user>
<cluster-password>${cluster-password}</cluster-password>
<cluster-password>${cluster-password}</cluster-password>

View File

@ -0,0 +1,6 @@
<connectors>
<!-- Connector used to be announced through cluster connections and notifications -->
<connector name="artemis">tcp://${host}:${default.port}</connector>
</connectors>

View File

@ -42,6 +42,12 @@ public class StreamClassPathTest
openStream(Create.ETC_BROKER_XML);
openStream(Create.ETC_ARTEMIS_ROLES_PROPERTIES);
openStream(Create.ETC_ARTEMIS_USERS_PROPERTIES);
openStream(Create.ETC_REPLICATED_SETTINGS_TXT);
openStream(Create.ETC_REPLICATED_SETTINGS_TXT);
openStream(Create.ETC_SHARED_STORE_SETTINGS_TXT);
openStream(Create.ETC_CLUSTER_SECURITY_SETTINGS_TXT);
openStream(Create.ETC_CLUSTER_SETTINGS_TXT);
openStream(Create.ETC_CONNECTOR_SETTINGS_TXT);
}

View File

@ -23,6 +23,9 @@ under the License.
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Apache ActiveMQ Artemis README</title>
<link rel="stylesheet" type="text/css" href="./examples/jms/common/common.css" />
<link rel="stylesheet" type="text/css" href="./examples/jms/common/prettify.css" />
<script type="text/javascript" src="./examples/jms/common/prettify.js"></script>
</head>
<body>
@ -38,6 +41,42 @@ To create a broker, navigate to the distribution 'bin/' directory and run: </br>
$ ./artemis create $directory </br></br>Where $directory is the folder that you'd like the broker to be created.
The create process will input for any required property not specified. Example:
<PRE>
--user: is mandatory at the current context:
Please provide the default username:
admin
--password: is mandatory at the current context:
Please provide the default password:
--allow-anonymous: is mandatory at the current context:
Allow anonymous access? (Y/N):
Y
</PRE>
For a full list of availble options for the create process you may use:
$ ./artemis help create
<PRE>
NAME
artemis create - creates a new broker instance
SYNOPSIS
artemis create [--allow-anonymous]
[--cluster-password <clusterPassword>] [--cluster-user <clusterUser>]
[--clustered] [--data <data>] [--encoding <encoding>] [--force]
[--home <home>] [--host <host>] [--java-options <javaOptions>]
[--password <password>] [--port-offset <portOffset>] [--replicated]
[--role <role>] [--shared-store] [--silent-input] [--user <user>] [--]
<directory>
...
</PRE>
<h2>Starting the Broker</h2>
Once the broker has been created, use the artemis (or artemis.cmd on windows) script of the under the bin directory of the newly created broker to manage the life cycle of the broker.

View File

@ -16,13 +16,14 @@
*/
package org.apache.activemq.artemis.core.config.impl;
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
import org.apache.activemq.artemis.utils.SensitiveDataCodec;
import java.net.URL;
import java.util.Properties;
import java.util.Set;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
import org.apache.activemq.artemis.utils.SensitiveDataCodec;
public class FileSecurityConfiguration extends SecurityConfiguration
{
private final String usersUrl;
@ -111,10 +112,17 @@ public class FileSecurityConfiguration extends SecurityConfiguration
for (String username : keys)
{
String roles = roleProps.getProperty(username);
String[] split = roles.split(",");
for (String role : split)
if (roles == null)
{
addRole(username, role.trim());
ActiveMQServerLogger.LOGGER.cannotFindRoleForUser(username);
}
else
{
String[] split = roles.split(",");
for (String role : split)
{
addRole(username, role.trim());
}
}
}

View File

@ -1104,6 +1104,13 @@ public interface ActiveMQServerLogger extends BasicLogger
format = Message.Format.MESSAGE_FORMAT)
void disallowedProtocol(String protocol);
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222191,
value = "Could not find any configured role for user {0}.",
format = Message.Format.MESSAGE_FORMAT)
void cannotFindRoleForUser(String user);
@LogMessage(level = Logger.Level.ERROR)
@Message(id = 224000, value = "Failure in initialisation", format = Message.Format.MESSAGE_FORMAT)
void initializationError(@Cause Throwable e);

View File

@ -17,7 +17,6 @@
package org.apache.activemq.artemis.core.server.impl;
import javax.management.MBeanServer;
import java.io.File;
import java.io.FilenameFilter;
import java.io.PrintWriter;
@ -88,12 +87,12 @@ import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.security.SecurityStore;
import org.apache.activemq.artemis.core.security.impl.SecurityStoreImpl;
import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Bindable;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Bindable;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
import org.apache.activemq.artemis.core.server.MemoryManager;
@ -116,18 +115,18 @@ import org.apache.activemq.artemis.core.server.management.impl.ManagementService
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository;
import org.apache.activemq.artemis.core.transaction.ResourceManager;
import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
import org.apache.activemq.artemis.core.transaction.ResourceManager;
import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl;
import org.apache.activemq.artemis.core.version.Version;
import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
import org.apache.activemq.artemis.utils.ClassloadingUtil;
import org.apache.activemq.artemis.utils.ConcurrentHashSet;
import org.apache.activemq.artemis.utils.ExecutorFactory;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
import org.apache.activemq.artemis.utils.OrderedExecutorFactory;
import org.apache.activemq.artemis.utils.ReusableLatch;
import org.apache.activemq.artemis.utils.SecurityFormatter;
@ -1736,7 +1735,9 @@ public class ActiveMQServerImpl implements ActiveMQServer
storageManager = createStorageManager();
if (ActiveMQDefaultConfiguration.getDefaultClusterUser().equals(configuration.getClusterUser()) && ActiveMQDefaultConfiguration.getDefaultClusterPassword().equals(configuration.getClusterPassword()))
if (configuration.getClusterConfigurations().size() > 0 &&
ActiveMQDefaultConfiguration.getDefaultClusterUser().equals(configuration.getClusterUser()) && ActiveMQDefaultConfiguration.getDefaultClusterPassword().equals(configuration.getClusterPassword()))
{
ActiveMQServerLogger.LOGGER.clusterSecurityRisk();
}

View File

@ -1,22 +0,0 @@
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
for i in `find . -name "*.xml"`; do
newFile=`echo $i | sed 's/xml/md/'`
echo creating $newFile
pandoc -f docbook -t markdown $i -o $newFile
done