You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/02/05 12:45:53 UTC
[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3432: ARTEMIS-33 Generic integration with SASL Frameworks
gemmellr commented on a change in pull request #3432:
URL: https://github.com/apache/activemq-artemis/pull/3432#discussion_r570898820
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/sasl/MechanismFinder.java
##########
@@ -17,11 +17,31 @@
package org.apache.activemq.artemis.protocol.amqp.sasl;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.stream.Stream;
+
public class MechanismFinder {
- public static String[] KNOWN_MECHANISMS = new String[]{PlainSASL.NAME, AnonymousServerSASL.NAME};
+ private static final String[] DEFAULT_MECHANISMS = new String[] {PlainSASL.NAME, AnonymousServerSASL.NAME};
+
+ private static final Map<String, ServerSASLFactory> FACTORY_MAP = new HashMap<>();
+
+ static {
+ ServiceLoader<ServerSASLFactory> serviceLoader =
+ ServiceLoader.load(ServerSASLFactory.class, MechanismFinder.class.getClassLoader());
+ for (ServerSASLFactory factory : serviceLoader) {
+ FACTORY_MAP.put(factory.getMechanism(), factory);
+ }
+ }
public static String[] getKnownMechanisms() {
- return KNOWN_MECHANISMS;
+ return Stream.concat(Arrays.stream(DEFAULT_MECHANISMS), FACTORY_MAP.keySet().stream()).toArray(String[]::new);
Review comment:
The server is meant to announce them in descending order of preference, and little should ever come after ANONYMOUS, so this seems questionable. So would just dumping them at the front, though possibly less so.
It should perhaps also be guarded that its not a duplicate, avoiding dup mech announcements and perhaps also alert that a loaded mechanism wont be used should it already be known/handled.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org