ARTEMIS-4020: have the concrete classes provide logger to the shared abstract impl instead of using getClass() in parent

followup to 12cc70c5bf PR discussion
This commit is contained in:
Robbie Gemmell 2022-09-30 11:38:32 +01:00
parent d2354ae470
commit 1ad1128db2
6 changed files with 42 additions and 10 deletions

View File

@ -43,7 +43,6 @@ import org.apache.activemq.artemis.spi.core.security.jaas.SCRAMMechanismCallback
import org.apache.activemq.artemis.spi.core.security.scram.SCRAM;
import org.apache.activemq.artemis.spi.core.security.scram.UserData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* abstract class that implements the SASL-SCRAM authentication scheme, concrete implementations
@ -51,12 +50,12 @@ import org.slf4j.LoggerFactory;
*/
public abstract class SCRAMServerSASLFactory implements ServerSASLFactory {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Logger logger;
private final SCRAM scramType;
public SCRAMServerSASLFactory(SCRAM scram) {
public SCRAMServerSASLFactory(SCRAM scram, Logger logger) {
this.scramType = scram;
this.logger = logger;
}
@Override

View File

@ -16,15 +16,21 @@
*/
package org.apache.activemq.artemis.protocol.amqp.sasl.scram;
import java.lang.invoke.MethodHandles;
import org.apache.activemq.artemis.spi.core.security.scram.SCRAM;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* provides SASL SRAM-SHA256
* provides SASL SCRAM-SHA256
*/
public class SHA256SCRAMServerSASLFactory extends SCRAMServerSASLFactory {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public SHA256SCRAMServerSASLFactory() {
super(SCRAM.SHA256);
super(SCRAM.SHA256, logger);
}
@Override

View File

@ -16,15 +16,21 @@
*/
package org.apache.activemq.artemis.protocol.amqp.sasl.scram;
import java.lang.invoke.MethodHandles;
import org.apache.activemq.artemis.spi.core.security.scram.SCRAM;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* provides SASL SRAM-SHA512
* provides SASL SCRAM-SHA512
*/
public class SHA512SCRAMServerSASLFactory extends SCRAMServerSASLFactory {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public SHA512SCRAMServerSASLFactory() {
super(SCRAM.SHA512);
super(SCRAM.SHA512, logger);
}
@Override

View File

@ -30,13 +30,12 @@ import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstract login module that uses an external authenticated principal
*/
public abstract class AbstractPrincipalLoginModule implements AuditLoginModule {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Logger logger;
private Subject subject;
private final List<Principal> authenticatedPrincipals = new LinkedList<>();
@ -44,6 +43,10 @@ public abstract class AbstractPrincipalLoginModule implements AuditLoginModule {
private boolean loginSucceeded;
private Principal[] principals;
public AbstractPrincipalLoginModule(Logger logger) {
this.logger = logger;
}
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
Map<String, ?> options) {

View File

@ -16,10 +16,19 @@
*/
package org.apache.activemq.artemis.spi.core.security.jaas;
import java.lang.invoke.MethodHandles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* populate a subject with kerberos credential from the handler
*/
public class Krb5LoginModule extends AbstractPrincipalLoginModule {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public Krb5LoginModule() {
super(logger);
}
}

View File

@ -16,10 +16,19 @@
*/
package org.apache.activemq.artemis.spi.core.security.jaas;
import java.lang.invoke.MethodHandles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Handles the actual login after channel authentication has succeeded
*/
public class SCRAMLoginModule extends AbstractPrincipalLoginModule {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public SCRAMLoginModule() {
super(logger);
}
}