io.github.nichetoolkit.rest.configure.RestShaProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-toolkit-utils Show documentation
Show all versions of rest-toolkit-utils Show documentation
Rest toolkit utils project for Spring Boot
package io.github.nichetoolkit.rest.configure;
import io.github.nichetoolkit.rest.util.GeneralUtils;
import io.github.nichetoolkit.rest.worker.RadixWorker;
import io.github.nichetoolkit.rest.worker.sha.ShaAlgorithm;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* RestShaProperties
* @author Cyan (snow22314 @ outlook.com)
* @version v1.0.0
*/
@Component
@ConfigurationProperties(prefix = "nichetoolkit.rest.sha")
public class RestShaProperties {
private boolean enabled;
private String secret;
private ShaAlgorithm algorithm = ShaAlgorithm.SHA256;
public RestShaProperties() {
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getSecret() {
if (GeneralUtils.isEmpty(this.secret)) {
return secret = RadixWorker.encrypts(System.currentTimeMillis());
}
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public ShaAlgorithm getAlgorithm() {
return algorithm;
}
public void setAlgorithm(ShaAlgorithm algorithm) {
this.algorithm = algorithm;
}
}