[java-plugin-shibd] 02/02: Remove unneeded RequestMap parsing flow.
Scott Cantor
cantor.2 at osu.edu
Thu Jan 23 14:31:30 UTC 2025
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-plugin-shibd.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=f48cc7e25325a74244429f24a1c36ac33a540476
commit f48cc7e25325a74244429f24a1c36ac33a540476
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 23 09:31:25 2025 -0500
Remove unneeded RequestMap parsing flow.
---
.../parse-request-map/parse-request-map-beans.xml | 34 ---
.../parse-request-map/parse-request-map-flow.xml | 26 ---
.../sp/flows/ParseRequestMapFlowTest.java | 143 -------------
.../main/java/net/shibboleth/sp/SPConstants.java | 40 ----
.../schema/shibboleth-sp-requestmap-4.0.xsd | 228 ---------------------
.../sp/config/impl/ParseAgentRequestMap.java | 161 ---------------
.../shibboleth/sp/config/impl/package-info.java | 18 --
.../sp/config/impl/ParseAgentRequestMapTest.java | 150 --------------
8 files changed, 800 deletions(-)
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-beans.xml
deleted file mode 100644
index 361c4b8..0000000
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-beans.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://www.springframework.org/schema/c"
- xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
- default-init-method="initialize" default-destroy-method="destroy">
-
- <bean id="shibboleth.sp.profileId" class="java.lang.String" c:_0="http://shibboleth.net/ns/profiles/sp/parse-request-map" />
- <bean id="shibboleth.sp.loggingId" class="java.lang.String" c:_0="%{sp.service.logging.requestmap:SPAgent.ParseRequestMap}" />
-
- <bean id="ParseAgentRequestMap"
- class="net.shibboleth.sp.config.impl.ParseAgentRequestMap" scope="prototype"
- p:parserPool-ref="shibboleth.ParserPool"
- p:schemaBuilder-ref="RequestMap.SchemaBuilder" />
-
- <bean id="RequestMap.SchemaBuilder"
- class="org.opensaml.saml.common.xml.SAMLSchemaBuilder" c:ver="SAML_11" c:strict="%{idp.schemaValidation.strict:false}">
- <property name="schemaBuilder">
- <bean class="net.shibboleth.shared.xml.SchemaBuilder"
- p:schemaResources-ref="RequestMap.Schemas">
- <property name="resourceResolver">
- <bean class="net.shibboleth.shared.xml.ClasspathResolver" />
- </property>
- </bean>
- </property>
- </bean>
-
- <util:list id="RequestMap.Schemas">
- <value>#{'classpath:' + T(net.shibboleth.sp.SPConstants).SHIBSP4_REQUESTMAP_SCHEMA_LOCATION}</value>
- </util:list>
-
-</beans>
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-flow.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-flow.xml
deleted file mode 100644
index 9f7e0fa..0000000
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-flow.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<flow xmlns="http://www.springframework.org/schema/webflow"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow.xsd"
- parent="sp/abstract">
-
- <action-state id="InitializeProfileRequestContext">
- <evaluate expression="InitializeProfileRequestContext" />
- <evaluate expression="'proceed'" />
-
- <!-- Branch to parent flow for authentication. -->
- <transition on="proceed" to="AuthenticationSetup" />
- </action-state>
-
- <!-- Resume flow operation after set up by parent. -->
- <action-state id="DoOperation">
- <evaluate expression="ParseAgentRequestMap" />
- <evaluate expression="'proceed'" />
-
- <!-- Branch to parent flow to send response. -->
- <transition on="proceed" to="EncodeAgentResponse" />
- </action-state>
-
- <!-- The file really exists in this directory, but it's referenced from extending flow-directories -->
- <bean-import resource="classpath:/META-INF/net/shibboleth/idp/flows/sp/parse-request-map/parse-request-map-beans.xml" />
-
-</flow>
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/ParseRequestMapFlowTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/ParseRequestMapFlowTest.java
deleted file mode 100644
index e3e1c39..0000000
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/ParseRequestMapFlowTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.sp.flows;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import javax.annotation.Nonnull;
-
-import org.opensaml.profile.action.EventIds;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.webflow.executor.FlowExecutionResult;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import net.shibboleth.sp.SPConstants;
-import net.shibboleth.sp.ddf.DDF;
-import net.shibboleth.sp.ddf.DDFSupport;
-
-/**
- * Unit test for the SP RequestMap-parsing flow.
- */
- at SuppressWarnings("javadoc")
-public class ParseRequestMapFlowTest extends AbstractSPFlowTest {
-
- /** Flow ID. */
- @Nonnull public static final String FLOW_ID = "sp/parse-request-map";
-
- protected ParseRequestMapFlowTest() {
- super(FLOW_ID);
- }
-
- @Test
- public void testWrapNoInput() {
- setDefaultAuth();
- request.setMethod("POST");
- final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
- assertFlowExecutionResult(result, FLOW_ID);
- assertFlowExecutionOutcome(result.getOutcome());
- assertOutputMessageEvent(result, EventIds.INVALID_MESSAGE);
- }
-
- @Test
- public void testNonWellFormed() throws IOException {
- setDefaultAuth();
-
- final DDF input = new DDF().unsafe_string("<RequestMap".getBytes(Charset.forName("UTF-8")));
- setRequest("POST", input);
-
- final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
- assertFlowExecutionResult(result, FLOW_ID);
- assertFlowExecutionOutcome(result.getOutcome());
- assertOutputMessageEvent(result, EventIds.INVALID_MESSAGE);
- }
-
- @Test
- public void testInvalid() throws IOException {
- setDefaultAuth();
-
- final DDF input = new DDF().unsafe_string("<RequestMap/>".getBytes(Charset.forName("UTF-8")));
- setRequest("POST", input);
-
- final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
- assertFlowExecutionResult(result, FLOW_ID);
- assertFlowExecutionOutcome(result.getOutcome());
- assertOutputMessageEvent(result, EventIds.INVALID_MESSAGE);
- }
-
- @Test
- public void testEmpty() throws IOException {
- setDefaultAuth();
-
- final DDF input = new DDF().unsafe_string("<RequestMap xmlns='urn:mace:shibboleth:sp:requestmap:4.0'/>".getBytes(Charset.forName("UTF-8")));
- setRequest("POST", input);
-
- final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
- assertFlowExecutionResult(result, FLOW_ID);
- assertFlowExecutionOutcome(result.getOutcome());
- final DDF output = assertOutputMessageEvent(result, null);
-
- assert output != null;
- Assert.assertTrue(output.isstruct());
- Assert.assertTrue(output.getmember("RequestMap").isstruct());
- Assert.assertEquals(output.getmember("RequestMap.xmlns").string(), SPConstants.SHIBSP4_REQUESTMAP_NS);
- }
-
- @Test
- public void testFull() throws IOException {
- setDefaultAuth();
-
- final ClassPathResource resource = new ClassPathResource("/net/shibboleth/sp/config/impl/example-map.xml");
- try (final InputStream in = resource.getInputStream()) {
- assert in != null;
- final byte[] bytes = in.readAllBytes();
- final DDF input = new DDF().unsafe_string(bytes);
- setRequest("POST", input);
- }
-
- // To capture wire input needed to drive flow.
- // arc.getInput().serialize(System.err);
-
- // Sample command to run flow:
- // $ cd sp-server-impl/src/test/resources/net/shibboleth/sp/config/impl/
- // $ curl -k -X POST -H "Content-Type: text/plain" --data-binary @example-map.ddf -u sp.example.org:foo https://localhost/idp/profile/sp/parse-request-map
-
- final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
- assertFlowExecutionResult(result, FLOW_ID);
- assertFlowExecutionOutcome(result.getOutcome());
- final DDF output = assertOutputMessageEvent(result, null);
-
- assert output != null;
- Assert.assertTrue(output.isstruct());
- Assert.assertTrue(output.getmember("RequestMap").isstruct());
-
- final DDF nestedPath = output.getmember("RequestMap")
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0)
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0)
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0)
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0);
-
- Assert.assertEquals(nestedPath.name(), "Path");
- Assert.assertTrue(nestedPath.isstruct());
- Assert.assertEquals(nestedPath.getmember("applicationId").string(), "example-special");
- }
-
-}
\ No newline at end of file
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/SPConstants.java b/sp-server-api/src/main/java/net/shibboleth/sp/SPConstants.java
deleted file mode 100644
index d42ca81..0000000
--- a/sp-server-api/src/main/java/net/shibboleth/sp/SPConstants.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.sp;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-
-/** SP constants. */
-public final class SPConstants {
-
- /** Relative resource path for XML schema for SP agent RequestMap. */
- @Nonnull @NotEmpty public static final String SHIBSP4_REQUESTMAP_SCHEMA_LOCATION = "/schema/shibboleth-sp-requestmap-4.0.xsd";
-
- /** URI for XML schema namespace for SP agent RequestMap. */
- @Nonnull @NotEmpty public static final String SHIBSP4_REQUESTMAP_NS = "urn:mace:shibboleth:sp:requestmap:4.0";
-
- /** Namespace QName prefix for SP agent RequestMap. */
- @Nonnull @NotEmpty public static final String SHIBSP4_REQUESTMAP_PREFIX = "map";
-
- /** Name of root element for SP agent RequestMap. */
- @Nonnull @NotEmpty public static final String SHIBSP4_REQUESTMAP_ELEMENT_NAME = "RequestMap";
-
- /** Constructor. */
- private SPConstants() {
- }
-
-}
\ No newline at end of file
diff --git a/sp-server-api/src/main/resources/schema/shibboleth-sp-requestmap-4.0.xsd b/sp-server-api/src/main/resources/schema/shibboleth-sp-requestmap-4.0.xsd
deleted file mode 100644
index 35b3dcf..0000000
--- a/sp-server-api/src/main/resources/schema/shibboleth-sp-requestmap-4.0.xsd
+++ /dev/null
@@ -1,228 +0,0 @@
-<?xml version="1.0" encoding="US-ASCII"?>
-<schema targetNamespace="urn:mace:shibboleth:sp:requestmap:4.0"
- xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:map="urn:mace:shibboleth:sp:requestmap:4.0"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- blockDefault="substitution"
- version="4.0">
-
- <annotation>
- <documentation>
- Schema for XML-based configuration of the Shibboleth SP RequestMap and access control features.
- First appearing in Shibboleth SP 4.0 release.
- </documentation>
- </annotation>
-
- <simpleType name="string">
- <restriction base="string">
- <minLength value="1"/>
- </restriction>
- </simpleType>
-
- <simpleType name="listOfStrings">
- <list itemType="map:string"/>
- </simpleType>
-
- <simpleType name="anyURI">
- <restriction base="anyURI">
- <minLength value="1"/>
- </restriction>
- </simpleType>
-
- <simpleType name="listOfURIs">
- <list itemType="map:anyURI"/>
- </simpleType>
-
- <element name="AccessControl" type="map:UniOperatorType">
- <annotation>
- <documentation>
- A simple example access policy language extension that supersedes Apache .htaccess
- </documentation>
- </annotation>
- </element>
- <complexType name="UniOperatorType">
- <choice>
- <element name="AND" type="map:MultiOperatorType"/>
- <element name="OR" type="map:MultiOperatorType"/>
- <element name="NOT" type="map:UniOperatorType"/>
- <element name="Rule" type="map:RuleType"/>
- <element name="RuleRegex" type="map:RuleRegexType"/>
- </choice>
- </complexType>
- <complexType name="MultiOperatorType">
- <choice minOccurs="2" maxOccurs="unbounded">
- <element name="AND" type="map:MultiOperatorType"/>
- <element name="OR" type="map:MultiOperatorType"/>
- <element name="NOT" type="map:UniOperatorType"/>
- <element name="Rule" type="map:RuleType"/>
- <element name="RuleRegex" type="map:RuleRegexType"/>
- </choice>
- </complexType>
- <complexType name="RuleType">
- <simpleContent>
- <extension base="map:listOfStrings">
- <attribute name="require" type="map:string" use="required"/>
- <attribute name="list" type="boolean"/>
- </extension>
- </simpleContent>
- </complexType>
- <complexType name="RuleRegexType">
- <simpleContent>
- <extension base="map:string">
- <attribute name="require" type="map:string" use="required"/>
- <attribute name="caseSensitive" type="boolean"/>
- </extension>
- </simpleContent>
- </complexType>
-
- <attributeGroup name="ContentSettings">
- <attribute name="applicationId" type="map:string"/>
- <attribute name="authType" type="map:string"/>
- <attribute name="requireSession" type="boolean"/>
- <attribute name="requireSessionWith" type="map:string"/>
- <attribute name="requireLogoutWith" type="map:anyURI"/>
- <attribute name="exportAssertion" type="boolean"/>
- <attribute name="exportStdVars" type="boolean"/>
- <attribute name="exportCookie" type="boolean"/>
- <attribute name="exportDuplicateValues" type="boolean"/>
- <attribute name="redirectToSSL" type="unsignedInt"/>
- <attribute name="entityID" type="map:anyURI"/>
- <attribute name="entityIDSelf" type="map:anyURI"/>
- <attribute name="discoveryURL" type="map:anyURI"/>
- <attribute name="discoveryPolicy" type="map:string"/>
- <attribute name="isPassive" type="boolean"/>
- <attribute name="returnOnError" type="boolean"/>
- <attribute name="forceAuthn" type="boolean"/>
- <attribute name="authnContextClassRef" type="map:listOfURIs"/>
- <attribute name="authnContextComparison">
- <simpleType>
- <restriction base="map:string">
- <enumeration value="exact"/>
- <enumeration value="minimum"/>
- <enumeration value="maximum"/>
- <enumeration value="better"/>
- </restriction>
- </simpleType>
- </attribute>
- <attribute name="NameIDFormat" type="map:anyURI"/>
- <attribute name="SPNameQualifier" type="map:string"/>
- <attribute name="redirectErrors" type="map:anyURI"/>
- <attribute name="sessionError" type="map:anyURI"/>
- <attribute name="metadataError" type="map:anyURI"/>
- <attribute name="accessError" type="map:anyURI"/>
- <attribute name="sslError" type="map:anyURI"/>
- <attribute name="target" type="map:anyURI"/>
- <attribute name="acsIndex" type="unsignedShort"/>
- <attribute name="attributeIndex" type="map:string"/>
- <attribute name="REMOTE_ADDR" type="map:string"/>
- <attribute name="encoding" type="map:string"/>
- <attribute name="attributeValueDelimiter" type="map:string"/>
- <attribute name="unset" type="map:listOfStrings"/>
- <anyAttribute namespace="##other" processContents="lax"/>
- </attributeGroup>
-
- <element name="RequestMap">
- <annotation>
- <documentation>
- Built-in request mapping syntax, decomposes URLs into Host/Path/Path/...
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <choice minOccurs="0">
- <element ref="map:AccessControl"/>
- </choice>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element name="Host" type="map:HostType"/>
- <element name="HostRegex" type="map:HostRegexType"/>
- </choice>
- </sequence>
- <attribute name="unicodeAware" type="boolean"/>
- <attributeGroup ref="map:ContentSettings"/>
- </complexType>
- </element>
-
- <complexType name="HostType">
- <sequence>
- <choice minOccurs="0">
- <element ref="map:AccessControl"/>
- </choice>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element name="Path" type="map:PathType"/>
- <element name="PathRegex" type="map:PathRegexType"/>
- <element name="Query" type="map:QueryType"/>
- </choice>
- </sequence>
- <attribute name="scheme">
- <simpleType>
- <restriction base="map:string">
- <enumeration value="http"/>
- <enumeration value="https"/>
- <enumeration value="ftp"/>
- <enumeration value="ldap"/>
- <enumeration value="ldaps"/>
- </restriction>
- </simpleType>
- </attribute>
- <attribute name="name" type="map:string" use="required"/>
- <attribute name="port" type="unsignedInt"/>
- <attributeGroup ref="map:ContentSettings"/>
- </complexType>
-
- <complexType name="HostRegexType">
- <sequence>
- <choice minOccurs="0">
- <element ref="map:AccessControl"/>
- </choice>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element name="Path" type="map:PathType"/>
- <element name="PathRegex" type="map:PathRegexType"/>
- <element name="Query" type="map:QueryType"/>
- </choice>
- </sequence>
- <attribute name="regex" type="map:string" use="required"/>
- <attribute name="caseSensitive" type="boolean"/>
- <attributeGroup ref="map:ContentSettings"/>
- </complexType>
-
- <complexType name="PathType">
- <sequence>
- <choice minOccurs="0">
- <element ref="map:AccessControl"/>
- </choice>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element name="Path" type="map:PathType"/>
- <element name="PathRegex" type="map:PathRegexType"/>
- <element name="Query" type="map:QueryType"/>
- </choice>
- </sequence>
- <attribute name="name" type="map:string" use="required"/>
- <attributeGroup ref="map:ContentSettings"/>
- </complexType>
-
- <complexType name="PathRegexType">
- <sequence>
- <choice minOccurs="0">
- <element ref="map:AccessControl"/>
- </choice>
- <element name="Query" type="map:QueryType" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="regex" type="map:string" use="required"/>
- <attribute name="caseSensitive" type="boolean"/>
- <attributeGroup ref="map:ContentSettings"/>
- </complexType>
-
- <complexType name="QueryType">
- <sequence>
- <choice minOccurs="0">
- <element ref="map:AccessControl"/>
- </choice>
- <element name="Query" type="map:QueryType" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="name" type="map:string" use="required"/>
- <attribute name="regex" type="map:string"/>
- <attributeGroup ref="map:ContentSettings"/>
- </complexType>
-
-</schema>
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java b/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java
deleted file mode 100644
index 1ac6826..0000000
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/ParseAgentRequestMap.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.sp.config.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.annotation.Nonnull;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.validation.Validator;
-
-import org.opensaml.profile.action.ActionSupport;
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.saml.common.xml.SAMLSchemaBuilder;
-import org.slf4j.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.LoggerFactory;
-import net.shibboleth.shared.xml.ElementSupport;
-import net.shibboleth.shared.xml.ParserPool;
-import net.shibboleth.shared.xml.QNameSupport;
-import net.shibboleth.shared.xml.XMLParserException;
-import net.shibboleth.sp.SPConstants;
-import net.shibboleth.sp.ddf.DDF;
-import net.shibboleth.sp.ddf.DDFSupport;
-import net.shibboleth.sp.profile.AbstractAgentRequestAction;
-
-/**
- * Action that handles parsing the legacy 3.0 XML configuration for an agent.
- *
- * <p>The input must be an unsafe_string.</p>
- *
- * <p>The output if parsing succeeds will be the DDF conversion of the DOM tree in a
- * structure named "xml".</p>
- *
- * @event {@link EventIds#PROCEED_EVENT_ID}
- * @event {@link EventIds#INVALID_MESSAGE}
- */
-public class ParseAgentRequestMap extends AbstractAgentRequestAction {
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(ParseAgentRequestMap.class);
-
- /** Parser pool. */
- @NonnullAfterInit private ParserPool parserPool;
-
- /** SAML schema source. */
- @NonnullAfterInit private SAMLSchemaBuilder samlSchemaBuilder;
-
- /**
- * Set the {@link ParserPool} instance to use.
- *
- * @param parser parser pool
- */
- public void setParserPool(@Nonnull final ParserPool parser) {
- checkSetterPreconditions();
-
- parserPool = Constraint.isNotNull(parser, "ParserPool cannot be null");
- }
-
- /**
- * Set the {@link SAMLSchemaBuilder} to validate with.
- *
- * @param builder SAML schema builder to use
- */
- public void setSchemaBuilder(@Nonnull final SAMLSchemaBuilder builder) {
- samlSchemaBuilder = Constraint.isNotNull(builder, "SAMLSchemaBuilder cannot be null");
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (parserPool == null) {
- throw new ComponentInitializationException("ParserPool cannot be null");
- } else if (samlSchemaBuilder == null) {
- throw new ComponentInitializationException("SAMLSchemaBuilder cannot be null");
- }
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext) {
- final DDF input = ensureAgentRequestContext().getInput();
-
- if (input == null || !input.isunsafestring()) {
- log.warn("{} input was not an unsafe string", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
- return;
- }
-
- try (final InputStream data = new ByteArrayInputStream(input.unsafe_string())) {
- final Document doc = parserPool.parse(data);
- final Element root = doc.getDocumentElement();
- assert root != null;
-
- if (!ElementSupport.isElementNamed(root, SPConstants.SHIBSP4_REQUESTMAP_NS,
- SPConstants.SHIBSP4_REQUESTMAP_ELEMENT_NAME)) {
- log.warn("{} Root element was invalid: {}", getLogPrefix(),
- QNameSupport.getNodeQName(root));
- ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
- return;
- }
-
- validate(root);
- final DDF output = new DDF().structure();
- output.add(DDFSupport.fromElement(root));
- ensureAgentRequestContext().setOutput(output);
-
- } catch (final IOException | XMLParserException e) {
- log.warn("{} Unable to parse or validate supplied RequestMap", getLogPrefix(), e);
- ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
- }
- }
-
- /**
- * Apply schema validation to DOM.
- *
- * @param root root of document
- *
- * @throws IOException if an I/O error occurs
- * @throws XMLParserException if a general validation failure occurs
- */
- private void validate(@Nonnull final Element root) throws IOException, XMLParserException {
- final Validator schemaValidator;
- try {
- schemaValidator = samlSchemaBuilder.getSAMLSchema().newValidator();
- } catch (final SAXException e) {
- log.error("{} Unable to build RequestMap validation schema: {}", getLogPrefix(), e.getMessage());
- throw new XMLParserException("Unable to build RequestMap validation schema", e);
- }
-
- try {
- schemaValidator.validate(new DOMSource(root));
- } catch (final SAXException e) {
- log.error("{} RequestMap was not schema valid: {}", getLogPrefix(), e.getMessage());
- throw new XMLParserException("RequestMap was not schema valid", e);
- }
- }
-
-}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/package-info.java b/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/package-info.java
deleted file mode 100644
index 16fcca5..0000000
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/config/impl/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of SP-specific configuration.
- */
-package net.shibboleth.sp.config.impl;
\ No newline at end of file
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java
deleted file mode 100644
index 9dbe090..0000000
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/config/impl/ParseAgentRequestMapTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.sp.config.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.saml.common.xml.SAMLSchemaBuilder;
-import org.opensaml.saml.common.xml.SAMLSchemaBuilder.SAML1Version;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.webflow.execution.Event;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import net.shibboleth.idp.profile.testing.ActionTestingSupport;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.spring.resource.ResourceHelper;
-import net.shibboleth.shared.xml.ClasspathResolver;
-import net.shibboleth.shared.xml.SchemaBuilder;
-import net.shibboleth.shared.xml.impl.BasicParserPool;
-import net.shibboleth.sp.SPConstants;
-import net.shibboleth.sp.ddf.DDF;
-import net.shibboleth.sp.ddf.DDFSupport;
-import net.shibboleth.sp.profile.impl.BaseAgentRequestTest;
-
-/**
- * Unit test for {@link ParseAgentRequestMap} action.
- */
- at SuppressWarnings("javadoc")
-public class ParseAgentRequestMapTest extends BaseAgentRequestTest {
-
- private ParseAgentRequestMap action;
-
- @BeforeMethod
- public void setUp() throws ComponentInitializationException {
- super.beforeMethod();
-
- final BasicParserPool parser = new BasicParserPool();
- parser.initialize();
-
- final SchemaBuilder extBuilder = new SchemaBuilder();
- extBuilder.setResourceResolver(new ClasspathResolver());
- extBuilder.addSchema(ResourceHelper.of(new ClassPathResource(SPConstants.SHIBSP4_REQUESTMAP_SCHEMA_LOCATION)));
-
- final SAMLSchemaBuilder schemaBuilder = new SAMLSchemaBuilder(SAML1Version.SAML_11);
- schemaBuilder.setSchemaBuilder(extBuilder);
-
- action = new ParseAgentRequestMap();
- action.setParserPool(parser);
- action.setSchemaBuilder(schemaBuilder);
- action.initialize();
- }
-
- @Test
- public void testNoInput() {
- Event event = action.execute(src);
- ActionTestingSupport.assertEvent(event, EventIds.INVALID_MESSAGE);
-
- arc.setInput(new DDF().string("test"));
-
- event = action.execute(src);
- ActionTestingSupport.assertEvent(event, EventIds.INVALID_MESSAGE);
- }
-
- @Test
- public void testNonWellFormed() throws UnsupportedEncodingException {
- arc.setInput(new DDF().unsafe_string("<RequestMap".getBytes(Charset.forName("UTF-8"))));
-
- final Event event = action.execute(src);
- ActionTestingSupport.assertEvent(event, EventIds.INVALID_MESSAGE);
- }
-
- @Test
- public void testInvalid() throws UnsupportedEncodingException {
- arc.setInput(new DDF().unsafe_string("<RequestMap/>".getBytes(Charset.forName("UTF-8"))));
-
- final Event event = action.execute(src);
- ActionTestingSupport.assertEvent(event, EventIds.INVALID_MESSAGE);
- }
-
- @Test
- public void testEmpty() throws UnsupportedEncodingException {
- arc.setInput(new DDF().unsafe_string("<RequestMap xmlns='urn:mace:shibboleth:sp:requestmap:4.0'/>".getBytes(Charset.forName("UTF-8"))));
-
- final Event event = action.execute(src);
- ActionTestingSupport.assertProceedEvent(event);
-
- final DDF output = arc.getOutput();
- assert output != null;
- Assert.assertTrue(output.isstruct());
- Assert.assertTrue(output.getmember("RequestMap").isstruct());
- Assert.assertEquals(output.getmember("RequestMap.xmlns").string(), SPConstants.SHIBSP4_REQUESTMAP_NS);
- }
-
- @Test
- public void testFull() throws IOException {
-
- try (final InputStream in = getClass().getResourceAsStream("example-map.xml")) {
- assert in != null;
- final byte[] bytes = in.readAllBytes();
- arc.setInput(new DDF().unsafe_string(bytes));
- }
-
- // To capture wire input needed to drive flow.
- // arc.getInput().serialize(System.err);
-
- // Sample command to run flow:
- // $ cd sp-server-impl/src/test/resources/net/shibboleth/sp/config/impl/
- // $ curl -k -X POST -H "Content-Type: text/plain" --data-binary @example-map.ddf -u sp.example.org:foo https://localhost/idp/profile/sp/parse-request-map
-
- final Event event = action.execute(src);
- ActionTestingSupport.assertProceedEvent(event);
-
- final DDF output = arc.getOutput();
- assert output != null;
- Assert.assertTrue(output.isstruct());
- Assert.assertTrue(output.getmember("RequestMap").isstruct());
-
- final DDF nestedPath = output.getmember("RequestMap")
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0)
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0)
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0)
- .getmember(DDFSupport.CHILD_ELEMENTS_MEMBER)
- .asList().get(0);
-
- Assert.assertEquals(nestedPath.name(), "Path");
- Assert.assertTrue(nestedPath.isstruct());
- Assert.assertEquals(nestedPath.getmember("applicationId").string(), "example-special");
- }
-
-}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list