You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "gtully (via GitHub)" <gi...@apache.org> on 2023/04/28 12:03:56 UTC

[GitHub] [activemq-artemis] gtully commented on a diff in pull request #4458: [ARTEMIS-4263] - authenticator to adapt to artemis jaas login modules…

gtully commented on code in PR #4458:
URL: https://github.com/apache/activemq-artemis/pull/4458#discussion_r1180323951


##########
artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/AuthenticatorAdapter.java:
##########
@@ -0,0 +1,128 @@
+/**
+ * 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
+ * <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.spi.core.security.jaas;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+
+import java.security.Principal;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.StringTokenizer;
+
+import com.sun.net.httpserver.Authenticator;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpPrincipal;
+import com.sun.net.httpserver.HttpsExchange;
+
+// delegate to our JAAS login modules by adapting our handlers to httpExchange
+// allow the jolokia jvm agent to integrate with our auth
+public class AuthenticatorAdapter extends Authenticator {
+
+   static final String REALM_PROPERTY_NAME = "jolokiaJvmAgent.realm";
+   static final String REQUEST_SUBJECT_ATTRIBUTE_PROPERTY_NAME = "jolokiaJvmAgent.requestSubjectAttribute";
+   static String DEFAULT_SUBJECT_ATTRIBUTE = "org.jolokia.jaasSubject";
+   static final String DEFAULT_REALM = "jolokia_jvm_agent";

Review Comment:
   good catch, those can be more generic, httpServerAuthenticator. without defaults.
   more eyes are great!



-- 
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.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org