[java-idp-testbed COMMIT] /trunk/src/test/java/idp/AbstractFlowTest.java
noreply at shibboleth.net
noreply at shibboleth.net
Wed Apr 30 10:47:32 EDT 2014
Author: tzeller
Date: Wed Apr 30 10:47:31 2014
New Revision: 210
URL: http://svn.shibboleth.net/view/java-idp-testbed?rev=210&view=rev
Log:
Remove the use of bean profiles to configure IP address based authn in the testbed. Instead, manually assemble the IP address authn flow and map of principal names to IP ranges.
Modified:
trunk/src/test/java/idp/AbstractFlowTest.java
Modified: trunk/src/test/java/idp/AbstractFlowTest.java
URL: http://svn.shibboleth.net/view/java-idp-testbed/trunk/src/test/java/idp/AbstractFlowTest.java?rev=210&r1=209&r2=210&view=diff
==============================================================================
--- trunk/src/test/java/idp/AbstractFlowTest.java (original)
+++ trunk/src/test/java/idp/AbstractFlowTest.java Wed Apr 30 10:47:31 2014
@@ -17,6 +17,10 @@
package idp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
@@ -24,6 +28,7 @@
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.net.HttpServletRequestResponseContext;
+import net.shibboleth.utilities.java.support.net.IPRange;
import net.shibboleth.utilities.java.support.xml.ParserPool;
import org.opensaml.core.xml.XMLObject;
@@ -38,13 +43,14 @@
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.webflow.definition.FlowDefinition;
import org.springframework.webflow.execution.FlowExecutionOutcome;
import org.springframework.webflow.executor.FlowExecutionResult;
import org.springframework.webflow.executor.FlowExecutor;
+import org.springframework.webflow.executor.FlowExecutorImpl;
import org.springframework.webflow.test.MockExternalContext;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
@@ -60,7 +66,6 @@
/**
* Abstract flow test.
*/
- at ActiveProfiles("dev")
@ContextConfiguration({"/system/conf/global-system.xml", "/conf/global-user.xml", "/system/conf/mvc-beans.xml",
"/conf/webflow-config.xml"})
@WebAppConfiguration
@@ -86,6 +91,12 @@
/** The SP relay state. */
@Nonnull public final static String SP_RELAY_STATE = "myRelayState";
+
+ /** The name of the bean which maps principals to IP ranges for IP address based authn. */
+ @Nonnull public final static String IP_ADDRESS_AUTHN_MAP_BEAN_NAME = "shibboleth.authn.IPAddress.Mappings";
+
+ /** The flow ID for IP address based authn. */
+ @Nonnull public final static String IP_ADDRESS_AUTHN_FLOW_ID = "AuthenticationFlow/IPAddress";
/** In-memory directory server. */
@NonnullAfterInit protected InMemoryDirectory directoryServer;
@@ -239,4 +250,21 @@
return envelope;
}
+ /**
+ * Configure IP address based authentication by assembling the {@link #IP_ADDRESS_AUTHN_FLOW_ID} flow for the first
+ * time and overriding the map of allowed principals to IP ranges via the {@link #IP_ADDRESS_AUTHN_MAP_BEAN_NAME}
+ * bean.
+ */
+ @BeforeMethod(dependsOnMethods = {"initializeFlowExecutor"}) public void overrideIPBasedAuthn() {
+ final FlowDefinition flowDefinition =
+ ((FlowExecutorImpl) flowExecutor).getDefinitionLocator().getFlowDefinition(IP_ADDRESS_AUTHN_FLOW_ID);
+
+ final Map map = flowDefinition.getApplicationContext().getBean(IP_ADDRESS_AUTHN_MAP_BEAN_NAME, Map.class);
+
+ final List<IPRange> ipRanges = new ArrayList<IPRange>(2);
+ ipRanges.add(IPRange.parseCIDRBlock("127.0.0.1/24"));
+ ipRanges.add(IPRange.parseCIDRBlock("::1/128"));
+ map.put("jdoe", ipRanges);
+ }
+
}
More information about the commits
mailing list