[ 
https://issues.apache.org/jira/browse/ARTEMIS-33?focusedWorklogId=548763&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-548763
 ]

ASF GitHub Bot logged work on ARTEMIS-33:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Feb/21 16:57
            Start Date: 05/Feb/21 16:57
    Worklog Time Spent: 10m 
      Work Description: laeubi commented on a change in pull request #3432:
URL: https://github.com/apache/activemq-artemis/pull/3432#discussion_r571110875



##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/sasl/MechanismFinder.java
##########
@@ -17,11 +17,41 @@
 
 package org.apache.activemq.artemis.protocol.amqp.sasl;
 
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+
 public class MechanismFinder {
 
-   public static String[] KNOWN_MECHANISMS = new String[]{PlainSASL.NAME, 
AnonymousServerSASL.NAME};
+   private static final Map<String, ServerSASLFactory> FACTORY_MAP = new 
HashMap<>();
+   private static final Comparator<? super ServerSASLFactory> 
PRECEDENCE_COMPARATOR =
+      (f1, f2) -> Integer.compare(f1.getPrecedence(), f2.getPrecedence());
+
+   static {
+      ServiceLoader<ServerSASLFactory> serviceLoader =
+               ServiceLoader.load(ServerSASLFactory.class, 
MechanismFinder.class.getClassLoader());
+      for (ServerSASLFactory factory : serviceLoader) {
+         FACTORY_MAP.merge(factory.getMechanism(), factory, (f1, f2) -> {
+            if (f2.getPrecedence() > f1.getPrecedence()) {
+               return f2;
+            } else {
+               return f1;
+            }
+         });
+      }
+   }
+
+   public static String[] getDefaultMechanisms() {
+      return FACTORY_MAP.values()
+            .stream()
+            .filter(ServerSASLFactory::isDefaultPermitted)
+            .sorted(PRECEDENCE_COMPARATOR.reversed())
+            .map(ServerSASLFactory::getMechanism)
+            .toArray(String[]::new);

Review comment:
       The value is just read once on connector creation if I see right, 
nerveless I'll extract this so it is only computed once.




----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 548763)
    Time Spent: 2.5h  (was: 2h 20m)

> Generic integration with SASL Frameworks
> ----------------------------------------
>
>                 Key: ARTEMIS-33
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-33
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>    Affects Versions: 1.0.0
>            Reporter: Clebert Suconic
>            Priority: Critical
>             Fix For: unscheduled
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> Right now we are bound to User/Password or anonymous on SASL.
> We should use some framework that would allow SASL integration with a bigger 
> number of possibilities.
> We should investigate options from the JDK for this... or if there is any 
> other framework available.
> I believe this only affects AMQP, but as part of this issue we should 
> investigate if there is any interest extending SASL into any other protocol.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to