package tech.easyflow.auth.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;

/**
 * 认证传输密钥环实体。
 */
@Table(value = "tb_auth_credential_key", comment = "认证传输密钥环")
public class AuthCredentialKey implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键。
     */
    @Id(keyType = KeyType.Generator, value = "snowFlakeId", comment = "ID")
    private BigInteger id;

    /**
     * 对外使用的密钥标识。
     */
    @Column(comment = "密钥标识")
    private String keyId;

    /**
     * PEM 格式公钥。
     */
    @Column(comment = "公钥PEM")
    private String publicKeyPem;

    /**
     * 由部署主密钥加密后的 PEM 私钥。
     */
    @Column(comment = "加密后的私钥PEM")
    private String encryptedPrivateKey;

    /**
     * 公钥 DER 的 SHA-256 指纹。
     */
    @Column(comment = "公钥指纹")
    private String fingerprint;

    /**
     * 密钥状态。
     */
    @Column(comment = "状态")
    private String status;

    /**
     * 轮换序号。
     */
    @Column(comment = "轮换序号")
    private Long rotateSeq;

    /**
     * 上一密钥标识。
     */
    @Column(comment = "上一密钥标识")
    private String parentKeyId;

    /**
     * 新密钥被旧密钥授权的 canonical payload。
     */
    @Column(comment = "轮换载荷")
    private String transitionPayload;

    /**
     * 旧私钥对轮换载荷的签名。
     */
    @Column(comment = "轮换签名")
    private String transitionSignature;

    /**
     * 生效时间。
     */
    @Column(comment = "生效时间")
    private Date notBefore;

    /**
     * 过期时间。
     */
    @Column(comment = "过期时间")
    private Date expiresAt;

    /**
     * 计划轮换时间。
     */
    @Column(comment = "计划轮换时间")
    private Date rotateAt;

    /**
     * 旧密钥可继续解密的截止时间。
     */
    @Column(comment = "旧密钥保留解密截止时间")
    private Date previousUntil;

    /**
     * 创建时间。
     */
    @Column(comment = "创建时间")
    private Date created;

    /**
     * 修改时间。
     */
    @Column(comment = "修改时间")
    private Date modified;

    public BigInteger getId() {
        return id;
    }

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

    public String getKeyId() {
        return keyId;
    }

    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    public String getPublicKeyPem() {
        return publicKeyPem;
    }

    public void setPublicKeyPem(String publicKeyPem) {
        this.publicKeyPem = publicKeyPem;
    }

    public String getEncryptedPrivateKey() {
        return encryptedPrivateKey;
    }

    public void setEncryptedPrivateKey(String encryptedPrivateKey) {
        this.encryptedPrivateKey = encryptedPrivateKey;
    }

    public String getFingerprint() {
        return fingerprint;
    }

    public void setFingerprint(String fingerprint) {
        this.fingerprint = fingerprint;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Long getRotateSeq() {
        return rotateSeq;
    }

    public void setRotateSeq(Long rotateSeq) {
        this.rotateSeq = rotateSeq;
    }

    public String getParentKeyId() {
        return parentKeyId;
    }

    public void setParentKeyId(String parentKeyId) {
        this.parentKeyId = parentKeyId;
    }

    public String getTransitionPayload() {
        return transitionPayload;
    }

    public void setTransitionPayload(String transitionPayload) {
        this.transitionPayload = transitionPayload;
    }

    public String getTransitionSignature() {
        return transitionSignature;
    }

    public void setTransitionSignature(String transitionSignature) {
        this.transitionSignature = transitionSignature;
    }

    public Date getNotBefore() {
        return notBefore;
    }

    public void setNotBefore(Date notBefore) {
        this.notBefore = notBefore;
    }

    public Date getExpiresAt() {
        return expiresAt;
    }

    public void setExpiresAt(Date expiresAt) {
        this.expiresAt = expiresAt;
    }

    public Date getRotateAt() {
        return rotateAt;
    }

    public void setRotateAt(Date rotateAt) {
        this.rotateAt = rotateAt;
    }

    public Date getPreviousUntil() {
        return previousUntil;
    }

    public void setPreviousUntil(Date previousUntil) {
        this.previousUntil = previousUntil;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getModified() {
        return modified;
    }

    public void setModified(Date modified) {
        this.modified = modified;
    }
}
