Authentication.java

  1. /*
  2.  * @copyright defined in LICENSE.txt
  3.  */

  4. package hera.api.model;

  5. import hera.annotation.ApiAudience;
  6. import hera.annotation.ApiStability;
  7. import hera.util.HexUtils;
  8. import hera.util.Sha256Utils;
  9. import lombok.EqualsAndHashCode;
  10. import lombok.Getter;
  11. import lombok.NonNull;
  12. import lombok.RequiredArgsConstructor;

  13. @ApiAudience.Public
  14. @ApiStability.Unstable
  15. @EqualsAndHashCode
  16. @RequiredArgsConstructor
  17. public class Authentication {

  18.   public static Authentication of(final Identity identity, final String password) {
  19.     return new Authentication(identity, password);
  20.   }

  21.   @Getter
  22.   @NonNull
  23.   protected final Identity identity;

  24.   @Getter
  25.   @NonNull
  26.   protected final String password;

  27.   @Override
  28.   public String toString() {
  29.     return String.format("Authentication(identity=%s, password=%s)", identity.getValue(),
  30.         HexUtils.encode(Sha256Utils.digest(password.getBytes())));
  31.   }

  32. }