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

com.clouway.oauth2.authorization.Authorization Maven / Gradle / Ivy

package com.clouway.oauth2.authorization;

import java.util.Date;
import java.util.Objects;
import java.util.Set;

/**
 * @author Ivan Stefanov 
 */
public class Authorization {
  public final String responseType;
  public final String clientId;
  public final String code;
  public final Set scopes;
  public final Set redirectUrls;
  public final String identityId;

  private Date usageDate = null;

  public Authorization(String responseType, String clientId, String identityId, String code, Set scopes, Set redirectUrls) {
    this.responseType = responseType;
    this.clientId = clientId;
    this.code = code;
    this.scopes = scopes;
    this.redirectUrls = redirectUrls;
    this.identityId = identityId;
  }

  public void usedOn(Date date) {
    usageDate = date;
  }

  public boolean wasAlreadyUsed() {
    return usageDate != null;
  }

  public boolean isNotUsed() {
    return usageDate == null;
  }

  public Date getUsedOnDate() {
    return usageDate;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    Authorization that = (Authorization) o;
    return Objects.equals(responseType, that.responseType) &&
            Objects.equals(clientId, that.clientId) &&
            Objects.equals(code, that.code) &&
            Objects.equals(scopes, that.scopes) &&
            Objects.equals(redirectUrls, that.redirectUrls) &&
            Objects.equals(identityId, that.identityId) &&
            Objects.equals(usageDate, that.usageDate);
  }

  @Override
  public int hashCode() {
    return Objects.hash(responseType, clientId, code, redirectUrls, identityId, usageDate);
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy