<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements. See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership. The ASF licenses this file
 to you 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.
-->
<project name="wssec11" default="download">
    <property name="build.dir" location="target"/>
    <property name="wsdl.host" value="131.107.72.15"/>
    <property name="target.host" value="${wsdl.host}"/>
   
    <target name="download.internal" if="needsToDownload">
        <mkdir dir="${build.dir}/generated/src/main/resources/certs"/>
        <mkdir dir="${build.dir}/wsdl"/>
        <get src="http://131.107.72.15/ilab/Certs/Certs.zip" dest="${build.dir}/Certs.zip"/>
        <get src="http://${wsdl.host}/Security_Federation_FederatedService_Indigo/Symmetric.svc?wsdl" dest="${build.dir}/wsdl/WsTrustSym.wsdl"/>
        <get src="http://${wsdl.host}/Security_Federation_FederatedService_Indigo/Symmetric.svc?wsdl=wsdl0" dest="${build.dir}/wsdl/WsTrustSym_policy.wsdl"/>

        <get src="http://${wsdl.host}/Security_Federation_FederatedService_Indigo/Asymmetric.svc?wsdl" dest="${build.dir}/wsdl/WsTrustAsym.wsdl"/>
        <get src="http://${wsdl.host}/Security_Federation_FederatedService_Indigo/Asymmetric.svc?wsdl=wsdl0" dest="${build.dir}/wsdl/WsTrustAsym_policy.wsdl"/>

        <get src="http://${wsdl.host}/Security_Federation_SecurityTokenService_Indigo/Asymmetric.svc?wsdl" dest="${build.dir}/wsdl/STSAsym.wsdl"/>
        <get src="http://${wsdl.host}/Security_Federation_SecurityTokenService_Indigo/Symmetric.svc?wsdl" dest="${build.dir}/wsdl/STSSym.wsdl"/>


        <antcall target="transform"/>
        <unzip src="${build.dir}/Certs.zip" dest="${build.dir}/generated/src/main/resources/certs"/>
    </target>

    <target name="transform">
        <mkdir dir="${build.dir}/wsdl2"/>
        <xslt basedir="${build.dir}/wsdl" destdir="${build.dir}/wsdl2"
            style="src/style/makelocal.xsl" extension=".xml">
            <mapper type="identity"/>
            <param name="wsdl.host" expression="${wsdl.host}"/>
            <param name="target.host" expression="${target.host}"/>
        </xslt>
    </target>


    <target name="download">
        <mkdir dir="${build.dir}"/>
        <condition property="needsToDownload">
          <not>
            <available file="${build.dir}/Certs.zip"/>
          </not>
        </condition>
        <antcall target="download.internal"/>
    </target>
</project>
