<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>io.quarkiverse.cxf</groupId>
        <artifactId>quarkus-cxf-integration-tests</artifactId>
        <version>3.8.7</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>quarkus-cxf-integration-test-santuario-xmlsec</artifactId>

    <name>Quarkus CXF - Integration Test - Santuario XML Security</name>


    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.cxf</groupId>
            <artifactId>quarkus-cxf-santuario-xmlsec</artifactId>
        </dependency>

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>keytool-maven-plugin</artifactId>
                <configuration>
                    <validity>3650</validity>
                    <keyalg>RSA</keyalg>
                    <skip>${keytool.skip}</skip>
                </configuration>
                <executions>
                    <!-- CA -->
                    <execution>
                        <id>generate-cxfca-keypair</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>clean</goal>
                            <goal>generateKeyPair</goal>
                        </goals>
                        <configuration>
                            <alias>cxfca</alias>
                            <dname>CN=cxfca, OU=eng, O=apache.org</dname>
                            <exts>
                                <ext>bc:c=ca:true,pathlen:2147483647</ext>
                                <ext>IssuerAlternativeName=DNS:NOT-FOR-PRODUCTION-USE</ext>
                            </exts>
                            <keypass>cxfca-password</keypass>
                            <storepass>cxfca-password</storepass>
                            <keystore>${project.build.outputDirectory}/cxfca.jks</keystore>
                        </configuration>
                    </execution>
                    <execution>
                        <id>export-cxfca-certificate</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exportCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>cxfca</alias>
                            <keystore>${project.build.outputDirectory}/cxfca.jks</keystore>
                            <rfc>true</rfc>
                            <storepass>cxfca-password</storepass>
                            <file>${project.build.outputDirectory}/cxfca.pem</file>
                        </configuration>
                    </execution>
                    <!-- Myclient -->
                    <execution>
                        <id>generate-myclient-keypair</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>clean</goal>
                            <goal>generateKeyPair</goal>
                        </goals>
                        <configuration>
                            <alias>myclient</alias>
                            <dname>CN=myclient, OU=eng, O=apache.org</dname>
                            <exts>
                                <ext>bc:c=ca:true,pathlen:2147483647</ext>
                                <ext>IssuerAlternativeName=DNS:NOT-FOR-PRODUCTION-USE</ext>
                            </exts>
                            <keypass>myclient-keystore-password</keypass>
                            <storepass>myclient-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myclient-keystore.jks</keystore>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-myclient-certificate-request</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generateCertificateRequest</goal>
                        </goals>
                        <configuration>
                            <alias>myclient</alias>
                            <storepass>myclient-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myclient-keystore.jks</keystore>
                            <file>${project.build.outputDirectory}/myclient.csr</file>
                        </configuration>
                    </execution>
                    <execution>
                        <id>sign-myclient-certificate</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generateCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>cxfca</alias>
                            <storepass>cxfca-password</storepass>
                            <keystore>${project.build.outputDirectory}/cxfca.jks</keystore>
                            <rfc>true</rfc>
                            <infile>${project.build.outputDirectory}/myclient.csr</infile>
                            <outfile>${project.build.outputDirectory}/myclient.pem</outfile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>import-cxfca-certificate-to-myclientkey-keystore</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>importCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>cxfca</alias>
                            <trustcacerts>true</trustcacerts>
                            <noprompt>true</noprompt>
                            <storepass>myclient-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myclient-keystore.jks</keystore>
                            <file>${project.build.outputDirectory}/cxfca.pem</file>
                        </configuration>
                    </execution>
                    <execution>
                        <id>import-signed-myclientkey-certificate-to-myclient-keystore</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>importCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>myclient</alias>
                            <trustcacerts>true</trustcacerts>
                            <noprompt>true</noprompt>
                            <storepass>myclient-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myclient-keystore.jks</keystore>
                            <file>${project.build.outputDirectory}/myclient.pem</file>
                        </configuration>
                    </execution>
                    <!-- Myservice -->
                    <execution>
                        <id>generate-myservice-keypair</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>clean</goal>
                            <goal>generateKeyPair</goal>
                        </goals>
                        <configuration>
                            <alias>myservice</alias>
                            <dname>CN=myservice, OU=eng, O=apache.org</dname>
                            <exts>
                                <ext>bc:c=ca:true,pathlen:2147483647</ext>
                                <ext>IssuerAlternativeName=DNS:NOT-FOR-PRODUCTION-USE</ext>
                            </exts>
                            <keypass>myservice-keystore-password</keypass>
                            <storepass>myservice-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myservice-keystore.jks</keystore>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-myservice-certificate-request</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generateCertificateRequest</goal>
                        </goals>
                        <configuration>
                            <alias>myservice</alias>
                            <storepass>myservice-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myservice-keystore.jks</keystore>
                            <file>${project.build.outputDirectory}/myservice.csr</file>
                        </configuration>
                    </execution>
                    <execution>
                        <id>sign-myservice-certificate</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generateCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>cxfca</alias>
                            <storepass>cxfca-password</storepass>
                            <keystore>${project.build.outputDirectory}/cxfca.jks</keystore>
                            <rfc>true</rfc>
                            <infile>${project.build.outputDirectory}/myservice.csr</infile>
                            <outfile>${project.build.outputDirectory}/myservice.pem</outfile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>import-cxfca-certificate-to-myservice-keystore</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>importCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>cxfca</alias>
                            <trustcacerts>true</trustcacerts>
                            <noprompt>true</noprompt>
                            <storepass>myservice-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myservice-keystore.jks</keystore>
                            <file>${project.build.outputDirectory}/cxfca.pem</file>
                        </configuration>
                    </execution>
                    <execution>
                        <id>import-signed-myservice-certificate-to-myservice-keystore</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>importCertificate</goal>
                        </goals>
                        <configuration>
                            <alias>myservice</alias>
                            <trustcacerts>true</trustcacerts>
                            <noprompt>true</noprompt>
                            <storepass>myservice-keystore-password</storepass>
                            <keystore>${project.build.outputDirectory}/myservice-keystore.jks</keystore>
                            <file>${project.build.outputDirectory}/myservice.pem</file>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>${native.surefire.skip}</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                                <configuration>
                                    <systemPropertyVariables>
                                        <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                                        <maven.home>${maven.home}</maven.home>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <quarkus.package.type>native</quarkus.package.type>
            </properties>
        </profile>
        <profile>
            <id>virtualDependencies</id>
            <activation>
                <property>
                    <name>!noVirtualDependencies</name>
                </property>
            </activation>
            <dependencies>
                <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
                <dependency>
                    <groupId>io.quarkiverse.cxf</groupId>
                    <artifactId>quarkus-cxf-santuario-xmlsec-deployment</artifactId>
                    <version>${project.version}</version>
                    <type>pom</type>
                    <scope>test</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>*</groupId>
                            <artifactId>*</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>