package cn.qinys.platform.base.security.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 *
 * @author tanlie
 * Date: 2023/12/22 16:46
 */
@Component
@ConfigurationProperties(prefix = "jwt")
@Data
public class JwtProperties implements Serializable {
    public static final String DEFAULT_SIGN = "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9u";

    private String sign;

    private List<String> ignoreUrls = new ArrayList<>();

    private List<String> blackUrls = new ArrayList<>();

    private Long expiredSeconds;

    public Long getExpiredSeconds() {
        return (expiredSeconds == null || expiredSeconds <= 0) ? 7200L : expiredSeconds;
    }

    public String getSign() {
        return StringUtils.hasLength(sign) ? sign : DEFAULT_SIGN;
    }
}
