<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">

<!-- Configuration file for UrlRewriteFilter http://www.tuckey.org/urlrewrite/ -->
<urlrewrite>

	<rule>
		<note>
			The rule means that requests to /test/status/ will be redirected to
			/rewrite-status
			the url will be rewritten.
		</note>
		<from>/test/status/</from>
		<to type="redirect">%{context-path}/rewrite-status</to>
	</rule>

	<!-- Legacy Rules -->
	<rule match-type="regex">
		<from>^/StartAuthentication$</from>
		<to type="forward">/dispatcher?mod=id_saml1&amp;action=GetArtifact</to>
	</rule>
	<rule match-type="regex">
		<from>^/StartAuthentication\?(.*)$</from>
		<to type="forward">/dispatcher?mod=id_saml1&amp;action=GetArtifact&amp;$1</to>
	</rule>

	<rule match-type="regex">
		<from>^/auth/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$</from>
		<to type="forward">/dispatcher?mod=$1&amp;action=$2</to>
	</rule>
	<rule match-type="regex">
		<from>^/auth/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)\?(.*)$</from>
		<to type="forward">/dispatcher?mod=$1&amp;action=$2&amp;$3</to>
	</rule>


	<rule match-type="regex">
		<from>^/pvp2/metadata$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=Metadata&amp;%{query-string}</to>
	</rule>
	<rule match-type="regex">
		<from>^/pvp2/redirect$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=Redirect&amp;endpointtype=idp&amp;%{query-string}</to>
	</rule>
	<rule match-type="regex">
		<from>^/pvp2/post$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=Post&amp;endpointtype=idp&amp;%{query-string}</to>
	</rule>
	<rule match-type="regex">
		<from>^/pvp2/Soap$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=Soap&amp;endpointtype=idp</to>
	</rule>
	<rule match-type="regex">
		<from>^/pvp2/attributequery$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=AttributeQuery&amp;endpointtype=idp</to>
	</rule>
	<rule match-type="regex">
		<from>^/pvp2/sp/redirect$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=Redirect&amp;endpointtype=sp&amp;%{query-string}</to>
	</rule>
	<rule match-type="regex">
		<from>^/pvp2/sp/post$</from>
		<to type="forward">/dispatcher?mod=id_pvp2x&amp;action=Post&amp;endpointtype=sp&amp;%{query-string}</to>
	</rule>


    <rule match-type="regex">
        <from>^/stork2/StartAuthentication$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=AuthenticationRequest&amp;%{query-string}</to>
    </rule>
    <rule match-type="regex">
        <from>^/stork2/ResumeAuthentication$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=AttributeCollector&amp;%{query-string}</to>
    </rule>
    <rule match-type="regex">
        <from>^/stork2/CompleteAuthentication$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=ConsentEvaluator&amp;%{query-string}</to>
    </rule>
    <rule match-type="regex">
        <from>^/stork2/SendPEPSAuthnRequest$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=AuthenticationRequest&amp;%{query-string}</to>
    </rule>
    <rule match-type="regex">
        <from>^/stork2/ServiceProvider$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=AuthenticationRequest&amp;%{query-string}</to>
    </rule>
    <rule match-type="regex">
        <from>^/stork2/SendPEPSAuthnRequestWithoutSignedDoc$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=AuthenticationRequest1&amp;%{query-string}</to>
    </rule>
    <rule match-type="regex">
        <from>^/stork2/RetrieveMandate$</from>
        <to type="forward">/dispatcher?mod=id_stork2&amp;action=MandateRetrievalRequest&amp;%{query-string}</to>
    </rule>


    <rule match-type="regex">
		<from>^/oauth2/auth\\?(.*)$</from>
		<to type="forward">/dispatcher?mod=id_oauth20&amp;action=AUTH&amp;%{query-string}</to>
	</rule>
	<rule match-type="regex">
		<from>^/oauth2/token\\?(.*)$</from>
		<to type="forward">/dispatcher?mod=id_oauth20&amp;action=TOKEN&amp;%{query-string}</to>
	</rule>
	

	<outbound-rule>
		<note>
			The outbound-rule specifies that when response.encodeURL is called (if
			you are using JSTL c:url)
			the url /rewrite-status will be rewritten to /test/status/.

			The above rule and this outbound-rule means that end users should never
			see the
			url /rewrite-status only /test/status/ both in thier location bar and in
			hyperlinks
			in your pages.
		</note>
		<from>/rewrite-status</from>
		<to>/test/status/</to>
	</outbound-rule>

</urlrewrite>