<?xml version="1.0"?>
<!--
  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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.cxf.fediz</groupId>
        <artifactId>fediz</artifactId>
        <version>1.2.2</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <artifactId>fediz-idp</artifactId>
    <name>Apache Fediz IDP</name>
    <packaging>war</packaging>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf.fediz</groupId>
            <artifactId>fediz-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>spring-webflow</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.security.version}</version>
        </dependency>
        <dependency>
            <groupId>ognl</groupId>
            <artifactId>ognl</artifactId>
            <version>${ognl.version}</version>
            <scope>runtime</scope>
            <exclusions>
                <exclusion>
                    <groupId>javassist</groupId>
                    <artifactId>javassist</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>${javassist.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-security</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-security-sso-saml</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-policy</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-addr</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons.lang.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-service-description</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-jaxrs</artifactId>
            <version>1.9.13</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-xc</artifactId>
            <version>1.9.13</version>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>${hsqldb.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.1_3</version>
        </dependency>
        <!-- 
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-all</artifactId>
            <version>${openjpa.version}</version>
        </dependency>
        -->
        <dependency>
            <groupId>commons-dbcp</groupId> 
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-jdbc</artifactId>
            <version>${openjpa.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-persistence-jdbc</artifactId>
            <version>${openjpa.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-client</artifactId>
            <version>${cxf.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>${javax.validation.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.bval</groupId>
            <artifactId>bval-jsr303</artifactId>
            <version>${bval.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>${commons.validator.version}</version>
        </dependency>
        
    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/realm.properties</include>
                    <include>**/persistence.properties</include>
                    <include>**/web.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/realm.properties</exclude>
                    <exclude>**/persistence.properties</exclude>
                    <exclude>**/web.xml</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.openjpa</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <version>${openjpa.version}</version>
                <inherited>true</inherited>
                <configuration>
                    <persistenceXmlFile>${project.basedir}/src/main/resources/META-INF/spring-persistence.xml</persistenceXmlFile>
                    <includes>org/apache/cxf/fediz/service/idp/service/jpa/**/*.class</includes>
                </configuration>
                <executions>
                    <execution>
                        <id>enhancer</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>xerces</groupId>
                        <artifactId>xercesImpl</artifactId>
                        <version>2.11.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <!--for mvn tomcat:deploy/:undeploy/:redeploy -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <server>myTomcat</server>
                    <url>http://localhost:9080/manager/text</url>
                    <path>/${project.build.finalName}</path>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                            <includes>
                                <include>**/applicationContext.xml</include>
                                <include>**/web.xml</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>false</filtering>
                            <excludes>
                                <exclude>**/applicationContext.xml</exclude>
                                <exclude>**/web.xml</exclude>
                            </excludes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>reserve-network-port</id>
                        <goals>
                            <goal>reserve-network-port</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <portNames>
                                <portName>idp.https.port</portName>
                                <portName>idp.http.port</portName>
                                <portName>idp.stop.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>set-tomcat-properties</id>
                        <goals>
                            <goal>set-system-properties</goal>
                        </goals>
                        <configuration>
                            <properties>
                                <property>
                                    <name>catalina.base</name>
                                    <value>target</value>
                                </property>
                            </properties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <stopPort>${idp.stop.port}</stopPort>
                    <stopKey>STOP</stopKey>
                    <connectors>
                        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                            <port>${idp.http.port}</port>
                            <maxIdleTime>30000</maxIdleTime>
                        </connector>
                        <connector implementation="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
                            <port>${idp.https.port}</port>
                            <maxIdleTime>30000</maxIdleTime>
                            <keystore>${basedir}/../../examples/samplekeys/idp-ssl-key.jks</keystore>
                            <keyPassword>tompass</keyPassword>
                            <password>tompass</password>
                        </connector>
                    </connectors>
                    <contextHandlers>
                        <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                            <war>${basedir}/target/fediz-idp-sts.war</war>
                            <contextPath>/fediz-idp-sts</contextPath>
                            <throwUnavailableOnStartupException>false</throwUnavailableOnStartupException>
                        </contextHandler>
                        <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                            <war>${basedir}/target/fediz-idp.war</war>
                            <contextPath>/fediz-idp</contextPath>
                        </contextHandler>
                    </contextHandlers>
                </configuration>
                <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run-war</goal>
                        </goals>
                        <configuration>
                            <scanIntervalSeconds>0</scanIntervalSeconds>
                            <daemon>true</daemon>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <version>${hsqldb.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <systemPropertyVariables>
                                <idp.https.port>${idp.https.port}</idp.https.port>
                                <realm>${realm}</realm>
                                <catalina.base>target</catalina.base>
                            </systemPropertyVariables>
                            <includes>
                                <include>**/integrationtests/**</include>
                            </includes>
                            <argLine>-XX:MaxPermSize=512M</argLine>
                        </configuration>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <inherited>true</inherited>
                <configuration>
                    <excludes>
                        <exclude>**/integrationtests/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
        <!-- Name of the generated WAR file -->
        <finalName>fediz-idp</finalName>
    </build>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <jpa.url>jdbc:hsqldb:target/db/realma/myDB;shutdown=true</jpa.url>
                <realm>realm-a</realm>
            </properties>
            <build>
                <filters>
                    <filter>src/main/filters/realm-a/env.properties</filter>
                </filters>
            </build>
        </profile>
        <profile>
            <id>realm-a</id>
            <properties>
                <jpa.url>jdbc:hsqldb:target/db/realma/myDB;shutdown=true</jpa.url>
                <idp.https.port>9443</idp.https.port>
                <idp.http.port>9080</idp.http.port>
                <realm>realm-a</realm>
            </properties>
            <build>
                <filters>
                    <filter>src/main/filters/realm-a/env.properties</filter>
                </filters>
                <plugins>
                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <configuration>
                            <contextHandlers>
                                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                                    <war>${basedir}/target/fediz-idp.war</war>
                                    <contextPath>/fediz-idp</contextPath>
                                </contextHandler>
                            </contextHandlers>
                         </configuration>
                     </plugin>
                 </plugins>
            </build>
        </profile>
        <profile>
            <id>realm-b</id>
            <properties>
                <jpa.url>jdbc:hsqldb:target/db/realmb/myDB;shutdown=true</jpa.url>
                <idp.https.port>12346</idp.https.port>
                <idp.http.port>12345</idp.http.port>
                <realm>realm-b</realm>
            </properties>
            <build>
                <filters>
                    <filter>src/main/filters/realm-b/env.properties</filter>
                </filters>
                <plugins>
                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <configuration>
                            <contextHandlers>
                                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                                    <war>${basedir}/target/fediz-idp-remote.war</war>
                                    <contextPath>/fediz-idp-remote</contextPath>
                                </contextHandler>
                            </contextHandlers>
                         </configuration>
                     </plugin>
                 </plugins>
                <finalName>fediz-idp-remote</finalName>
            </build>
        </profile>
        <profile>
            <id>standalone</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
            <build>
                <defaultGoal>jetty:run-war</defaultGoal>
            </build>
        </profile>

        <profile>
            <id>sts</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-sts</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.apache.cxf.fediz</groupId>
                                            <artifactId>fediz-idp-sts</artifactId>
                                            <version>${project.version}</version>
                                            <type>war</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
                                    <overWriteSnapshots>true</overWriteSnapshots>
                                    <overWriteIfNewer>true</overWriteIfNewer>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <configuration>
                            <contextHandlers combine.children="append">
                                <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                                    <war>${basedir}/target/fediz-idp-sts.war</war>
                                    <contextPath>/fediz-idp-sts</contextPath>
                                </contextHandler>
                            </contextHandlers>
                         </configuration>
                     </plugin>
                 </plugins>
            </build>
        </profile>
    </profiles>
</project>
