From 3ead2fee52a1e43e12610fda8175cb1a74e8b1f0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 31 Aug 2020 13:51:14 +0200 Subject: update validation in case of file:/ paths because trusted templates can be relative to config directory --- .../moa/id/config/auth/data/DummyAuthConfig.java | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'id/server/idserverlib/src/test/java/at/gv') diff --git a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/config/auth/data/DummyAuthConfig.java b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/config/auth/data/DummyAuthConfig.java index 7707f3b90..b2f425a2c 100644 --- a/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/config/auth/data/DummyAuthConfig.java +++ b/id/server/idserverlib/src/test/java/at/gv/egovernment/moa/id/config/auth/data/DummyAuthConfig.java @@ -2,7 +2,9 @@ package at.gv.egovernment.moa.id.config.auth.data; import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,6 +22,7 @@ import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters; import at.gv.egovernment.moa.id.commons.api.IStorkConfig; import at.gv.egovernment.moa.id.commons.api.data.ProtocolAllowed; import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException; +import at.gv.egovernment.moa.util.MiscUtil; import at.gv.util.config.EgovUtilPropertiesConfiguration; public class DummyAuthConfig implements AuthConfiguration { @@ -28,11 +31,12 @@ public class DummyAuthConfig implements AuthConfiguration { private Map basicConfig = new HashMap<>(); private List slRequestTemplates; - + private String configRootDir; + @Override public String getRootConfigFileDir() { - // TODO Auto-generated method stub - return null; + return configRootDir; + } @Override @@ -246,7 +250,7 @@ public class DummyAuthConfig implements AuthConfiguration { @Override public List getSLRequestTemplates() throws ConfigurationException { - return slRequestTemplates; + return new ArrayList<>(slRequestTemplates); } @@ -451,8 +455,18 @@ public class DummyAuthConfig implements AuthConfiguration { @Override public URI getConfigurationRootDirectory() { - // TODO Auto-generated method stub - return null; + try { + if (MiscUtil.isNotEmpty(configRootDir)) { + return new URI(configRootDir); + + } + } catch (URISyntaxException e) { + e.printStackTrace(); + + } + + return null; + } @Override @@ -501,5 +515,11 @@ public class DummyAuthConfig implements AuthConfiguration { slRequestTemplates = templates; } + + public void setConfigRootDir(String configRootDir) { + this.configRootDir = configRootDir; + } + + } -- cgit v1.2.3