com.datastax.driver.dse.auth.BaseDseAuthenticator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
/*
* Copyright DataStax, Inc.
*
* This software can be used solely with DataStax Enterprise. Please consult the license at
* http://www.datastax.com/terms/datastax-dse-driver-license-terms
*/
package com.datastax.driver.dse.auth;
import com.datastax.driver.core.Authenticator;
/**
* Base class for {@link Authenticator} implementations that want to make use of the authentication
* scheme negotiation in the DseAuthenticator
*/
abstract class BaseDseAuthenticator implements Authenticator {
private static final String DSE_AUTHENTICATOR =
"com.datastax.bdp.cassandra.auth.DseAuthenticator";
private final String authenticator;
protected BaseDseAuthenticator(String authenticator) {
this.authenticator = authenticator;
}
/**
* Return a byte array containing the required SASL mechanism. This should be one of:
*
*
* - "PLAIN".getBytes(Charsets.UTF_8);
*
- "GSSAPI".getBytes(Charsets.UTF_8);
*
*
* @return a byte array containing the SASL mechanism
*/
public abstract byte[] getMechanism();
/**
* Return a byte array containing the expected successful server challenge. This should be one of:
*
*
* - "PLAIN-START".getBytes(Charsets.UTF_8);
*
- "GSSAPI-START".getBytes(Charsets.UTF_8);
*
*
* @return a byte array containing the server challenge
*/
public abstract byte[] getInitialServerChallenge();
public byte[] initialResponse() {
if (isDseAuthenticator()) return getMechanism();
else return evaluateChallenge(getInitialServerChallenge());
}
public void onAuthenticationSuccess(byte[] token) {}
private boolean isDseAuthenticator() {
return authenticator.equals(DSE_AUTHENTICATOR);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy