Update JaasAuthenticationBroker.java

Allow user use encrypt password to check entry detail info via web console
This commit is contained in:
chris-joys 2021-09-13 10:05:32 +08:00 committed by GitHub
parent 96f1ca988b
commit 70f25a5052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package org.apache.activemq.security;
import java.security.Principal;
import java.security.cert.X509Certificate;
import java.util.Properties;
import java.util.Set;
import javax.security.auth.Subject;
@ -26,6 +27,7 @@ import javax.security.auth.login.LoginContext;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.command.ConnectionInfo;
import org.apache.activemq.jaas.EncryptionSupport;
import org.apache.activemq.jaas.JassCredentialCallbackHandler;
/**
@ -86,6 +88,10 @@ public class JaasAuthenticationBroker extends AbstractAuthenticationBroker {
@Override
public SecurityContext authenticate(String username, String password, X509Certificate[] certificates) throws SecurityException {
SecurityContext result = null;
Properties prop = new Properties();
prop.put(username, password);
EncryptionSupport.decrypt(prop);
password = prop.getProperty(username);
JassCredentialCallbackHandler callback = new JassCredentialCallbackHandler(username, password);
try {
LoginContext lc = new LoginContext(jassConfiguration, callback);