Remove @Value annotation and use inner configuration properties to set
the default value. Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -10,8 +10,9 @@ package org.eclipse.hawkbit.security;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* The common properties for security.
|
||||
@@ -22,47 +23,102 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties
|
||||
public class SecurityProperties {
|
||||
|
||||
@Value("${hawkbit.server.controller.security.rp.cnHeader:X-Ssl-Client-Cn}")
|
||||
private String rpCnHeader;
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.server.controller.security.rp")
|
||||
public static class RpProperties {
|
||||
private String cnHeader = "X-Ssl-Client-Cn";
|
||||
private String sslIssuerHashHeader = "X-Ssl-Issuer-Hash-%d";
|
||||
private List<String> trustedIPs;
|
||||
|
||||
@Value("${hawkbit.server.controller.security.rp.sslIssuerHashHeader:X-Ssl-Issuer-Hash-%d}")
|
||||
private String rpSslIssuerHashHeader;
|
||||
/**
|
||||
* @return the cnHeader
|
||||
*/
|
||||
public String getCnHeader() {
|
||||
return cnHeader;
|
||||
}
|
||||
|
||||
@Value("${hawkbit.server.controller.security.rp.trustedIPs:#{null}}")
|
||||
private List<String> rpTrustedIPs;
|
||||
/**
|
||||
* @param cnHeader
|
||||
* the cnHeader to set
|
||||
*/
|
||||
public void setCnHeader(final String cnHeader) {
|
||||
this.cnHeader = cnHeader;
|
||||
}
|
||||
|
||||
@Value("${hawkbit.server.controller.security.authentication.anonymous.enabled}")
|
||||
private Boolean anonymousEnabled;
|
||||
/**
|
||||
* @return the sslIssuerHashHeader
|
||||
*/
|
||||
public String getSslIssuerHashHeader() {
|
||||
return sslIssuerHashHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sslIssuerHashHeader
|
||||
* the sslIssuerHashHeader to set
|
||||
*/
|
||||
public void setSslIssuerHashHeader(final String sslIssuerHashHeader) {
|
||||
this.sslIssuerHashHeader = sslIssuerHashHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the trustedIPs
|
||||
*/
|
||||
public List<String> getTrustedIPs() {
|
||||
return trustedIPs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trustedIPs
|
||||
* the trustedIPs to set
|
||||
*/
|
||||
public void setTrustedIPs(final List<String> trustedIPs) {
|
||||
this.trustedIPs = trustedIPs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.server.controller.security.authentication")
|
||||
public static class AuthenticationsProperties {
|
||||
private Boolean anonymousEnabled = Boolean.FALSE;
|
||||
|
||||
/**
|
||||
* @param anonymousEnabled
|
||||
* the anonymousEnabled to set
|
||||
*/
|
||||
public void setAnonymousEnabled(final Boolean anonymousEnabled) {
|
||||
this.anonymousEnabled = anonymousEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the anonymousEnabled
|
||||
*/
|
||||
public Boolean getAnonymousEnabled() {
|
||||
return anonymousEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RpProperties rppProperties;
|
||||
|
||||
@Autowired
|
||||
private AuthenticationsProperties authenticationsProperties;
|
||||
|
||||
public String getRpCnHeader() {
|
||||
return rpCnHeader;
|
||||
return rppProperties.getCnHeader();
|
||||
}
|
||||
|
||||
public String getRpSslIssuerHashHeader() {
|
||||
return rpSslIssuerHashHeader;
|
||||
return rppProperties.getSslIssuerHashHeader();
|
||||
}
|
||||
|
||||
public List<String> getRpTrustedIPs() {
|
||||
return rpTrustedIPs;
|
||||
return rppProperties.getTrustedIPs();
|
||||
}
|
||||
|
||||
public Boolean getAnonymousEnabled() {
|
||||
return anonymousEnabled;
|
||||
return authenticationsProperties.getAnonymousEnabled();
|
||||
}
|
||||
|
||||
public void setRpCnHeader(final String rpCnHeader) {
|
||||
this.rpCnHeader = rpCnHeader;
|
||||
}
|
||||
|
||||
public void setRpSslIssuerHashHeader(final String rpSslIssuerHashHeader) {
|
||||
this.rpSslIssuerHashHeader = rpSslIssuerHashHeader;
|
||||
}
|
||||
|
||||
public void setRpTrustedIPs(final List<String> rpTrustedIPs) {
|
||||
this.rpTrustedIPs = rpTrustedIPs;
|
||||
}
|
||||
|
||||
public void setAnonymousEnabled(final Boolean anonymousEnabled) {
|
||||
this.anonymousEnabled = anonymousEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user