/*-
 * ~~~~~~licensing~~~~~~
 * basic-auth-api
 * ==========
 * Copyright (C) 2020 - 2025 EmDev LLC
 * ==========
 * You may not use this file except in accordance with the License Terms of the Copyright
 * Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
 * rights to the Software and any copies are the property of the Copyright Holder. Unless
 * it is explicitly allowed the Copyright Holder, the User is prohibited from using the
 * Software for commercial purposes to provide services to third parties.
 * 
 * The Copyright Holder hereby declares that the Software is provided on an "AS IS".
 * Under no circumstances does the Copyright Holder guarantee or promise that the
 * Software provided by him will be suitable or not suitable for the specific purposes
 * of the User, that the Software will meet all commercial and personal subjective
 * expectations of the User, that the Software will work properly, without technical
 * errors, quickly and uninterruptedly.
 * 
 * Under no circumstances shall the Copyright Holder or its Affiliates is not liable
 * to the User for any direct or indirect losses of the User, his expenses or actual
 * damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
 * or damage to data, property, etc.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.esb.system.auth.basic.jpa.api.entity;

import com.sun.istack.NotNull;
import ru.entaxy.esb.system.auth.basic.jpa.api.entity.field.EncryptionAlgorithm;
import ru.entaxy.esb.system.auth.basic.jpa.api.entity.field.EncryptionAlgorithmAttributeConverter;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

@Entity
@Table(name = "basic_auth_account")
public class BasicAuthAccount {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @NotNull
    @Column(name = "login")
    private String login;
    @NotNull
    @Column(name = "password_hash")
    private String passwordHash;
    @Column(name = "encryption_algorithm")
    @Convert(converter = EncryptionAlgorithmAttributeConverter.class)
    private EncryptionAlgorithm encryptionAlgorithm;
    @Column(name = "system_uuid")
    private String systemUUID;
    @NotNull
    @Column(name = "authorization_header_hash")
    private String authorizationHeaderHash;
    @Column(name = "description")
    private String description;
    @NotNull
    @Column(name = "create_date")
    private Date createDate;
    @Column(name = "edit_date")
    private Date editDate;
    @NotNull
    @Column(name = "created_by")
    private String createdBy;
    @Column(name = "edited_by")
    private String editedBy;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPasswordHash() {
        return passwordHash;
    }

    public void setPasswordHash(String passwordHash) {
        this.passwordHash = passwordHash;
    }

    public EncryptionAlgorithm getEncryptionAlgorithm() {
        return encryptionAlgorithm;
    }

    public void setEncryptionAlgorithm(EncryptionAlgorithm encryptionAlgorithm) {
        this.encryptionAlgorithm = encryptionAlgorithm;
    }

    public String getSystemUUID() {
        return systemUUID;
    }

    public void setSystemUUID(String systemUUID) {
        this.systemUUID = systemUUID;
    }

    public String getAuthorizationHeaderHash() {
        return authorizationHeaderHash;
    }

    public void setAuthorizationHeaderHash(String authorizationHeaderHash) {
        this.authorizationHeaderHash = authorizationHeaderHash;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getEditDate() {
        return editDate;
    }

    public void setEditDate(Date editDate) {
        this.editDate = editDate;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public String getEditedBy() {
        return editedBy;
    }

    public void setEditedBy(String editedBy) {
        this.editedBy = editedBy;
    }

    @Override
    public int hashCode() {
        return Objects.hash(authorizationHeaderHash, createDate, createdBy, description, editDate, editedBy,
                encryptionAlgorithm, login, passwordHash, systemUUID);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        BasicAuthAccount other = (BasicAuthAccount) obj;
        return Objects.equals(authorizationHeaderHash, other.authorizationHeaderHash)
                && Objects.equals(createDate, other.createDate) && Objects.equals(createdBy, other.createdBy)
                && Objects.equals(description, other.description) && Objects.equals(editDate, other.editDate)
                && Objects.equals(editedBy, other.editedBy)
                && Objects.equals(encryptionAlgorithm, other.encryptionAlgorithm) && Objects.equals(login, other.login)
                && Objects.equals(passwordHash, other.passwordHash)
                && Objects.equals(systemUUID, other.systemUUID);
    }

    @Override
    public String toString() {
        return "BasicAuthAccount [login=" + login + ", passwordHash=" + passwordHash + ", encryptionAlgorithm="
                + encryptionAlgorithm + ", systemUUID=" + systemUUID + ", authorizationHeaderHash=" + authorizationHeaderHash
                + ", description=" + description + ", createDate=" + createDate + ", editDate=" + editDate
                + ", createdBy=" + createdBy + ", editedBy=" + editedBy + "]";
    }

}
