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

com.datahub.authentication.Authentication Maven / Gradle / Ivy

Go to download

DataHub Auth API for developers to write custom Authentication & Authorization plugins for DataHub

There is a newer version: 0.13.3-3rc3
Show newest version
package com.datahub.authentication;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nonnull;

/** Class representing an authenticated actor accessing DataHub. */
public class Authentication {

  private final Actor authenticatedActor;
  private final String credentials;
  private final Map claims;

  public Authentication(
      @Nonnull final Actor authenticatedActor, @Nonnull final String credentials) {
    this(authenticatedActor, credentials, Collections.emptyMap());
  }

  public Authentication(
      @Nonnull final Actor authenticatedActor,
      @Nonnull final String credentials,
      @Nonnull final Map claims) {
    this.authenticatedActor = Objects.requireNonNull(authenticatedActor);
    this.credentials = Objects.requireNonNull(credentials);
    this.claims = Objects.requireNonNull(claims);
  }

  /**
   * @return Returns the authenticated actor
   */
  public Actor getActor() {
    return this.authenticatedActor;
  }

  /**
   * @return Returns the credentials associated with the current request (e.g. the value of the
   *     "Authorization" header)
   */
  public String getCredentials() {
    return this.credentials;
  }

  /**
   * @return Returns an arbitrary set of claims resolved by the Authenticator
   */
  public Map getClaims() {
    return this.claims;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy