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

com.docusign.maestro.client.auth.HttpBasicAuth Maven / Gradle / Ivy

Go to download

The Docusign NuGet package makes integrating Docusign into your apps and websites a super fast and painless process. The library is open sourced on GitHub, look for the docusign-maestro-csharp-client repository.

There is a newer version: 2.0.0
Show newest version
package com.docusign.maestro.client.auth;

import com.docusign.maestro.client.Pair;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Map;

/** HttpBasicAuth class. */
public class HttpBasicAuth implements Authentication {
  private String username;
  private String password;

  /**
   * getUsername method.
   *
   * @return String
   */
  public String getUsername() {
    return username;
  }

  /**
   * setUsername method.
   *
   * @param username Sets username
   */
  public void setUsername(String username) {
    this.username = username;
  }

  /**
   * getPassword method.
   *
   * @return String
   */
  public String getPassword() {
    return password;
  }

  /**
   * setPassword method.
   *
   * @param password Sets password
   */
  public void setPassword(String password) {
    this.password = password;
  }

  /**
   * applyToParams method.
   *
   * @param queryParams The query params
   * @param headerParams The header params
   */
  @Override
  public void applyToParams(List queryParams, Map headerParams) {
    if (username == null && password == null) {
      return;
    }
    String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
    headerParams.put(
        "Authorization",
        "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8)));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy