All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.datastax.driver.core.exceptions.AuthenticationException Maven / Gradle / Ivy

There is a newer version: 4.15.102
Show newest version
/*
 * 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.core.exceptions;

import com.datastax.driver.core.EndPoint;
import java.net.InetAddress;
import java.net.InetSocketAddress;

/** Indicates an error during the authentication phase while connecting to a node. */
public class AuthenticationException extends DriverException implements CoordinatorException {

  private static final long serialVersionUID = 0;

  private final EndPoint endPoint;

  public AuthenticationException(EndPoint endPoint, String message) {
    super(String.format("Authentication error on host %s: %s", endPoint, message));
    this.endPoint = endPoint;
  }

  // Preserve a constructor with InetSocketAddress for backward compatibility, because legacy
  // authenticators might use it
  public AuthenticationException(InetSocketAddress address, String message) {
    this(new WrappingEndPoint(address), message);
  }

  private AuthenticationException(EndPoint endPoint, String message, Throwable cause) {
    super(message, cause);
    this.endPoint = endPoint;
  }

  @Override
  public EndPoint getEndPoint() {
    return endPoint;
  }

  @Override
  @Deprecated
  public InetSocketAddress getAddress() {
    return (endPoint == null) ? null : endPoint.resolve();
  }

  @Override
  @Deprecated
  public InetAddress getHost() {
    return (endPoint == null) ? null : endPoint.resolve().getAddress();
  }

  @Override
  public DriverException copy() {
    return new AuthenticationException(endPoint, getMessage(), this);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy