diff --git a/modules/core/src/com/haulmont/cuba/core/app/ServerConfig.java b/modules/core/src/com/haulmont/cuba/core/app/ServerConfig.java index 79f01882bb..6fcdd00a97 100644 --- a/modules/core/src/com/haulmont/cuba/core/app/ServerConfig.java +++ b/modules/core/src/com/haulmont/cuba/core/app/ServerConfig.java @@ -48,6 +48,7 @@ public interface ServerConfig extends Config { String getTrustedClientPassword(); @Property("cuba.trustedClientPermittedIpList") + @Source(type = SourceType.DATABASE) String getTrustedClientPermittedIpList(); @Property("cuba.security.resetPasswordTemplateBody") diff --git a/modules/core/src/com/haulmont/cuba/security/sys/TrustedLoginHandler.java b/modules/core/src/com/haulmont/cuba/security/sys/TrustedLoginHandler.java index 51a7fbefea..622c0d61e7 100644 --- a/modules/core/src/com/haulmont/cuba/security/sys/TrustedLoginHandler.java +++ b/modules/core/src/com/haulmont/cuba/security/sys/TrustedLoginHandler.java @@ -19,7 +19,6 @@ package com.haulmont.cuba.security.sys; import com.haulmont.cuba.core.app.ServerConfig; import org.apache.commons.lang.StringUtils; - import org.springframework.stereotype.Component; import javax.inject.Inject; @@ -32,23 +31,17 @@ public class TrustedLoginHandler { @Inject protected ServerConfig serverConfig; - protected Pattern permittedIpMaskPattern; - - @Inject - public void setServerConfig(ServerConfig serverConfig) { - String permittedIpList = serverConfig.getTrustedClientPermittedIpList(); - permittedIpList = convertToRegex(permittedIpList); - if (StringUtils.isEmpty(permittedIpList)) { - permittedIpList = "127\\.0\\.0\\.1"; - } - permittedIpMaskPattern = Pattern.compile(permittedIpList); - } - /** * @param address ip-address * @return true if address in trusted list */ public boolean checkAddress(String address) { + String permittedIpList = serverConfig.getTrustedClientPermittedIpList(); + permittedIpList = convertToRegex(permittedIpList); + if (StringUtils.isEmpty(permittedIpList)) { + permittedIpList = "127\\.0\\.0\\.1"; + } + Pattern permittedIpMaskPattern = Pattern.compile(permittedIpList); return permittedIpMaskPattern.matcher(address).matches(); }