com.infusers.core.secrets.dto.OtherSecrets Maven / Gradle / Ivy
package com.infusers.core.secrets.dto;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Component
@ConfigurationProperties(prefix = "infusers.jwt")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OtherSecrets implements ISecrets {
// private OtherSecrets() {
//
// }
// private static OtherSecrets secrets;
public static final int MIN_EXPIRY_HOURS = 2;
public static final int MAX_EXPIRY_HOURS = 12;
private String jwttokensecret;
private String jwtTokenExpiryHours;
// private double jwtTokenExpiryHoursNumber = 1;
//
public double getJwtTokenExpiryHoursNumber() {
return Integer.parseInt(jwtTokenExpiryHours);
}
//
// public void setJwtTokenExpiryHoursNumber(double jwtTokenExpiryHours) {
// this.jwtTokenExpiryHoursNumber = jwtTokenExpiryHours;
// }
public String getJwtTokenExpiryHours() {
return jwtTokenExpiryHours;
}
public void setJwtTokenExpiryHours(String jwtTokenExpiryHours) {
this.jwtTokenExpiryHours = jwtTokenExpiryHours;
}
public String getJwttokensecret() {
return jwttokensecret;
}
public void setJwttokensecret(String jwttokensecret) {
this.jwttokensecret = jwttokensecret;
}
public boolean isValid() {
return isValidField(jwttokensecret) && isValidField(jwtTokenExpiryHours) &&
isValidJWTTokenExpiryHours(jwtTokenExpiryHours);
}
private boolean isValidField(String field) {
return field != null && !field.isEmpty();
}
private boolean isValidJWTTokenExpiryHours(String expiryHours) {
try {
int intValue = Integer.parseInt(expiryHours);
return intValue >= MIN_EXPIRY_HOURS && intValue <= MAX_EXPIRY_HOURS;
} catch (NumberFormatException e) {
return false; // Not a valid integer
}
}
// public static final OtherSecrets getInstance() {
// if(secrets ==null) {
// secrets = new OtherSecrets();
// }
// return secrets;
// }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy