diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java index e6742ebc8..d3c426977 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java @@ -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 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 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 getTrustedIPs() { + return trustedIPs; + } + + /** + * @param trustedIPs + * the trustedIPs to set + */ + public void setTrustedIPs(final List 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 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 rpTrustedIPs) { - this.rpTrustedIPs = rpTrustedIPs; - } - - public void setAnonymousEnabled(final Boolean anonymousEnabled) { - this.anonymousEnabled = anonymousEnabled; - } }