You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2021/04/09 15:23:58 UTC
[activemq-artemis] branch master updated: ARTEMIS-3106 - apply mvn
verify template to the example
This is an automated email from the ASF dual-hosted git repository.
gtully pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new a195790 ARTEMIS-3106 - apply mvn verify template to the example
a195790 is described below
commit a195790005bad5f9d97d275fc436d5dc8bca12a4
Author: gtully <ga...@gmail.com>
AuthorDate: Fri Apr 9 16:23:23 2021 +0100
ARTEMIS-3106 - apply mvn verify template to the example
---
examples/protocols/amqp/sasl-scram/pom.xml | 83 ++++++++++++++++++++--
examples/protocols/amqp/sasl-scram/readme.md | 21 ++++++
.../protocols/amqp/sasl-scram/sasl-client/pom.xml | 49 -------------
.../amqp/sasl-scram/sasl-client/readme.md | 3 -
.../protocols/amqp/sasl-scram/sasl-server/pom.xml | 54 --------------
.../amqp/sasl-scram/sasl-server/readme.md | 3 -
.../activemq/artemis/jms/example/TestServer.java | 35 ---------
.../activemq/artemis/jms/example/QPIDClient.java | 1 -
.../activemq/server0}/artemis-roles.properties | 0
.../activemq/server0}/artemis-users.properties | 1 -
.../main/resources/activemq/server0}/broker.xml | 6 +-
.../main/resources/activemq/server0/login.config} | 10 ++-
12 files changed, 112 insertions(+), 154 deletions(-)
diff --git a/examples/protocols/amqp/sasl-scram/pom.xml b/examples/protocols/amqp/sasl-scram/pom.xml
index a7b34e8..eab001c 100644
--- a/examples/protocols/amqp/sasl-scram/pom.xml
+++ b/examples/protocols/amqp/sasl-scram/pom.xml
@@ -33,11 +33,84 @@ under the License.
</properties>
<artifactId>sasl-scram</artifactId>
- <packaging>pom</packaging>
+ <packaging>jar</packaging>
<name>ActiveMQ Artemis SASL-SCRAM Example</name>
- <modules>
- <module>sasl-client</module>
- <module>sasl-server</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-jms-client</artifactId>
+ <version>${qpid.jms.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <ignore>${noServer}</ignore>
+ <instance>${basedir}/target/server0</instance>
+ <configuration>${basedir}/target/classes/activemq/server0</configuration>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <ignore>${noServer}</ignore>
+ <testURI>tcp://localhost:61616</testURI>
+ <testUser>hello</testUser>
+ <testPassword>ogre1234</testPassword>
+ <args>
+ <param>run</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>runClient</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.example.QPIDClient</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <ignore>${noServer}</ignore>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.amqp</groupId>
+ <artifactId>sasl-scram</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/examples/protocols/amqp/sasl-scram/readme.md b/examples/protocols/amqp/sasl-scram/readme.md
new file mode 100644
index 0000000..d9570da
--- /dev/null
+++ b/examples/protocols/amqp/sasl-scram/readme.md
@@ -0,0 +1,21 @@
+# Artemis SASL-SCRAM Server and Client Example
+
+Demonstrates the usage of SASL-SCRAM authentication with ActiveMQ Artemis
+
+To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify**
+if you want to start and create the broker manually.
+
+Of note is the AMQP acceptor configuration restricting the offered mechanisms to SCRAM-SHA-256, and the reference
+to the login config scope ``amqp-sasl-scram`` that holds the relevant SCRAM login module.
+
+````
+ <acceptor name="amqp">tcp://localhost:5672?protocols=AMQP;saslMechanisms=SCRAM-SHA-256;saslLoginConfigScope=amqp-sasl-scram
+````
+
+Also note, the password supplied to the QPID JMS AMQP client is not stored in the users.properties on the broker. It does not
+leave the client!.
+The secure encoded form of the password has been generated/registered using:
+
+````
+ java org.apache.activemq.artemis.spi.core.security.jaas.SCRAMPropertiesLoginModule <username> <password> [<iterations>]
+````
\ No newline at end of file
diff --git a/examples/protocols/amqp/sasl-scram/sasl-client/pom.xml b/examples/protocols/amqp/sasl-scram/sasl-client/pom.xml
deleted file mode 100644
index c05fde8..0000000
--- a/examples/protocols/amqp/sasl-scram/sasl-client/pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version='1.0'?>
-<!--
-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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.amqp</groupId>
- <artifactId>sasl-scram</artifactId>
- <version>2.18.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>sasl-scram-client</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis SASL-SCRAM-Client Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../../..</activemq.basedir>
- <artemis-version>${project.version}</artemis-version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.qpid</groupId>
- <artifactId>qpid-jms-client</artifactId>
- <version>${qpid.jms.version}</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/examples/protocols/amqp/sasl-scram/sasl-client/readme.md b/examples/protocols/amqp/sasl-scram/sasl-client/readme.md
deleted file mode 100644
index 50fe5d7..0000000
--- a/examples/protocols/amqp/sasl-scram/sasl-client/readme.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Artemis SASL-SCRAM Server and Client Example
-
-demonstrate the usage of SASL-SCRAM authentication with ActiveMQ Artemis
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/pom.xml b/examples/protocols/amqp/sasl-scram/sasl-server/pom.xml
deleted file mode 100644
index e1683ab..0000000
--- a/examples/protocols/amqp/sasl-scram/sasl-server/pom.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version='1.0'?>
-<!--
-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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.amqp</groupId>
- <artifactId>sasl-scram</artifactId>
- <version>2.18.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>sasl-scram-server</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis SASL-SCRAM-Server Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../../..</activemq.basedir>
- <artemis-version>${project.version}</artemis-version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-server</artifactId>
- <version>${artemis-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-amqp-protocol</artifactId>
- <version>${artemis-version}</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/readme.md b/examples/protocols/amqp/sasl-scram/sasl-server/readme.md
deleted file mode 100644
index 1cc11ed..0000000
--- a/examples/protocols/amqp/sasl-scram/sasl-server/readme.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Artemis SASL-SCRAM Server and Client Example
-
-demonstrate the usage of SASL-SCRAM authentication with ActiveMQ Artemis
\ No newline at end of file
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/java/org/apache/activemq/artemis/jms/example/TestServer.java b/examples/protocols/amqp/sasl-scram/sasl-server/src/main/java/org/apache/activemq/artemis/jms/example/TestServer.java
deleted file mode 100644
index 4bb92d3..0000000
--- a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/java/org/apache/activemq/artemis/jms/example/TestServer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * <p>
- * All rights reserved. Licensed 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.jms.example;
-
-import java.io.File;
-
-import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
-
-public class TestServer {
- public static void main(String[] args) throws Exception {
- File configFolder = new File(args.length > 0 ? args[0] : "src/main/resources/").getAbsoluteFile();
- System.setProperty("java.security.auth.login.config", new File(configFolder, "login.conf").getAbsolutePath());
- EmbeddedActiveMQ embedded = new EmbeddedActiveMQ();
- embedded.setSecurityManager(new ActiveMQJAASSecurityManager("artemis"));
- embedded.setConfigResourcePath(new File(configFolder, "broker.xml").getAbsoluteFile().toURI().toASCIIString());
- embedded.start();
- while (true) {
- // intentional empty
- }
-
- }
-}
diff --git a/examples/protocols/amqp/sasl-scram/sasl-client/src/main/java/org/apache/activemq/artemis/jms/example/QPIDClient.java b/examples/protocols/amqp/sasl-scram/src/main/java/org/apache/activemq/artemis/jms/example/QPIDClient.java
similarity index 97%
rename from examples/protocols/amqp/sasl-scram/sasl-client/src/main/java/org/apache/activemq/artemis/jms/example/QPIDClient.java
rename to examples/protocols/amqp/sasl-scram/src/main/java/org/apache/activemq/artemis/jms/example/QPIDClient.java
index 5e4dd2e..d090693 100644
--- a/examples/protocols/amqp/sasl-scram/sasl-client/src/main/java/org/apache/activemq/artemis/jms/example/QPIDClient.java
+++ b/examples/protocols/amqp/sasl-scram/src/main/java/org/apache/activemq/artemis/jms/example/QPIDClient.java
@@ -27,7 +27,6 @@ import org.apache.qpid.jms.JmsConnectionFactory;
public class QPIDClient {
public static void main(String[] args) throws JMSException {
- sendReceive("SCRAM-SHA-1", "hello", "ogre1234");
sendReceive("SCRAM-SHA-256", "test", "test");
}
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/artemis-roles.properties b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/artemis-roles.properties
similarity index 100%
rename from examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/artemis-roles.properties
rename to examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/artemis-roles.properties
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/artemis-users.properties b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/artemis-users.properties
similarity index 92%
rename from examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/artemis-users.properties
rename to examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/artemis-users.properties
index 4846235..3462f06 100644
--- a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/artemis-users.properties
+++ b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/artemis-users.properties
@@ -19,6 +19,5 @@
# Example for an encoded username/password, encoded forms can be generated with java org.apache.activemq.artemis.spi.core.security.jaas.SCRAMPropertiesLoginModule <username> <password> [<iterations>]
test|SHA512 = ENC(7TilOEFipzE4KNkDUTlfnuMkYE1yveyXmK6iBx8/fnE=:4096:yPl/n8eZQEyVmkhuYvrgZCchEpO+a9QiGLXwJfqBWOIfTxMX5TkoHp5eYGABc68cUvoynqCnoqRLDPac+H1urg==:eX5X39hbChbXz00TCkMpmsHqsJTiMGCwamty6yjUS0M+HoE/SLtd2MYY1Shyn+5mu30qFsbXz0WlRA+dZ3Lv3A==)
test|SHA256 = ENC(yNekJSAvbunYIIHKni32oXgg7uCSUZSzvgNq3pLL3so=:4096:45p4iB+tgMB2b2FM6MmuzyTF63QOfQroQLwNXxhCZ48=:PXUabvM/90DWQsl/p9Cp7wYlavCTPJZnzdU9PFUuiXc=)
-test|SHA1 = ENC(ehArM+Qzko2eua0hMq0o+NQ9BaTTf4q8xY0tzfy2Zvw=:4096:LvpLr4ezL4ICxeiXAkXEVH9EhO0=:gLELi8NpLVorxXbPIIbVZF/oqh8=)
# Example for a plain username/password, don't use this on public servers!
hello = ogre1234
\ No newline at end of file
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/broker.xml b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/broker.xml
similarity index 90%
rename from examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/broker.xml
rename to examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/broker.xml
index a0252ac..d3c3295 100644
--- a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/broker.xml
+++ b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/broker.xml
@@ -28,8 +28,12 @@ under the License.
<security-enabled>true</security-enabled>
<acceptors>
- <acceptor name="amqp">tcp://localhost:5672?protocols=AMQP;saslMechanisms=SCRAM-SHA-256,SCRAM-SHA-1;saslLoginConfigScope=amqp-sasl-scram
+ <acceptor name="amqp">tcp://localhost:5672?protocols=AMQP;saslMechanisms=SCRAM-SHA-256;saslLoginConfigScope=amqp-sasl-scram
</acceptor>
+
+ <acceptor name="core-for-async-start-check">tcp://localhost:61616?protocols=CORE
+ </acceptor>
+
</acceptors>
<security-settings>
<security-setting match="#">
diff --git a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/login.conf b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/login.config
similarity index 80%
rename from examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/login.conf
rename to examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/login.config
index 7fad76f..7333277 100644
--- a/examples/protocols/amqp/sasl-scram/sasl-server/src/main/resources/login.conf
+++ b/examples/protocols/amqp/sasl-scram/src/main/resources/activemq/server0/login.config
@@ -23,7 +23,13 @@ amqp-sasl-scram {
};
-artemis {
- org.apache.activemq.artemis.spi.core.security.jaas.SCRAMLoginModule required
+activemq {
+ org.apache.activemq.artemis.spi.core.security.jaas.SCRAMLoginModule sufficient
;
+
+ org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule sufficient
+ org.apache.activemq.jaas.properties.user="artemis-users.properties"
+ org.apache.activemq.jaas.properties.role="artemis-roles.properties"
+ ;
+
};
\ No newline at end of file