package tech.easyflow.auth.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

/**
 * 登录凭证加密密钥轮换配置。
 */
@Configuration
@ConfigurationProperties(prefix = "easyflow.auth.credential-key")
public class CredentialKeyProperties {

    /**
     * 密钥完整生命周期。
     */
    private Duration lifetime = Duration.ofDays(30);

    /**
     * 到期前提前轮换窗口。
     */
    private Duration rotateBefore = Duration.ofDays(1);

    /**
     * 自动轮换检查间隔。
     */
    private Duration checkInterval = Duration.ofHours(1);

    /**
     * 前端安全材料有效期。
     */
    private Duration materialTtl = Duration.ofMinutes(5);

    /**
     * 登录 nonce 有效期。
     */
    private Duration nonceTtl = Duration.ofMinutes(5);

    /**
     * 旧密钥短期保留解密窗口。
     */
    private Duration previousRetain = Duration.ofMinutes(15);

    public Duration getLifetime() {
        return lifetime;
    }

    public void setLifetime(Duration lifetime) {
        this.lifetime = lifetime;
    }

    public Duration getRotateBefore() {
        return rotateBefore;
    }

    public void setRotateBefore(Duration rotateBefore) {
        this.rotateBefore = rotateBefore;
    }

    public Duration getCheckInterval() {
        return checkInterval;
    }

    public void setCheckInterval(Duration checkInterval) {
        this.checkInterval = checkInterval;
    }

    public Duration getMaterialTtl() {
        return materialTtl;
    }

    public void setMaterialTtl(Duration materialTtl) {
        this.materialTtl = materialTtl;
    }

    public Duration getNonceTtl() {
        return nonceTtl;
    }

    public void setNonceTtl(Duration nonceTtl) {
        this.nonceTtl = nonceTtl;
    }

    public Duration getPreviousRetain() {
        return previousRetain;
    }

    public void setPreviousRetain(Duration previousRetain) {
        this.previousRetain = previousRetain;
    }
}
