Skip to content

Commit

Permalink
[Broker Auth SASL] Remove unnecessary authenticate method definition (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljmarshall authored Sep 20, 2021
1 parent e189de9 commit 32401bb
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.authentication.metrics.AuthenticationMetrics;
import org.apache.pulsar.common.api.AuthData;
import org.apache.pulsar.common.sasl.JAASCredentialsContainer;
import org.apache.pulsar.common.sasl.SaslConstants;

/**
* Authentication Provider for SASL (Simple Authentication and Security Layer).
*
* Note: This provider does not override the default implementation for
* {@link AuthenticationProvider#authenticate(AuthenticationDataSource)}. As the Javadoc for the interface's method
* indicates, this method should only be implemented when using single stage authentication. In the case of this
* provider, the authentication is multi-stage.
*/
@Slf4j
public class AuthenticationProviderSasl implements AuthenticationProvider {

Expand Down Expand Up @@ -98,22 +105,6 @@ public void initialize(ServiceConfiguration config) throws IOException {
this.signer = new SaslRoleTokenSigner(Long.toString(new Random().nextLong()).getBytes());
}

@Override
public String authenticate(AuthenticationDataSource authData) throws AuthenticationException {
try {
if (authData instanceof SaslAuthenticationDataSource) {
AuthenticationMetrics.authenticateSuccess(getClass().getSimpleName(), getAuthMethodName());
return ((SaslAuthenticationDataSource) authData).getAuthorizationID();
} else {
throw new AuthenticationException("Not support authDataSource type, expect sasl.");
}
} catch (AuthenticationException exception) {
AuthenticationMetrics.authenticateFailure(getClass().getSimpleName(), getAuthMethodName(), exception.getMessage());
throw exception;
}

}

@Override
public String getAuthMethodName() {
return SaslConstants.AUTH_METHOD_NAME;
Expand Down

0 comments on commit 32401bb

Please sign in to comment.