<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>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.2.2</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <groupId>io.netfoundry</groupId>
  <artifactId>clientsync</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>clientsync</name>
  <description>Integrates with various IAM/LDAP providers to (de)provision endpoint clients.
  </description>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring-cloud.version>2023.0.0</spring-cloud.version>
    <spring-cloud-aws.version>2.2.6.RELEASE</spring-cloud-aws.version>
    <aws-sdk.version>2.21.12</aws-sdk.version>
    <maven.compiler.release>21</maven.compiler.release>
    <java.version>21</java.version>

    <!-- Sonar, Lint, Java Code Coverage settings. These apply to build time only. -->
    <skip.dump>true</skip.dump>
    <jacoco.version>0.8.11</jacoco.version>
    <sonar.projectName>clientsync</sonar.projectName>
    <sonar.organization>netfoundry</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.coverage.exclusions>
      **/*Source.java,
      **/configuration/*,
      **/Mock*.java,
      src/**/httpentity/*,
      **/event/*,
      **/controller/CommonExceptionHandler.java
    </sonar.coverage.exclusions>

    <!-- API doc properties -->
    
    <spring-auto-restdocs.version>2.0.8</spring-auto-restdocs.version>
    <springdoc-openapi.version>2.1.0</springdoc-openapi.version>
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>

  </properties>

  <!-- needed for the MS Graph Azure API -->
  <profiles>
    <profile>
      <id>allow-snapshots</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>snapshots-repo</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <dependencies>

    <!-- NetFoundry -->

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>common-util-framework</artifactId>
      <version>3.0.1</version>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>messaging-framework</artifactId>
      <version>0.8.0</version>
    </dependency>
    

    <!-- Failsafe (used by common-util) -->
    <dependency>
      <groupId>net.jodah</groupId>
      <artifactId>failsafe</artifactId>
      <version>2.4.4</version>
    </dependency>

    <!-- Spring Boot -->

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-bootstrap</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.hateoas</groupId>
      <artifactId>spring-hateoas</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.retry</groupId>
      <artifactId>spring-retry</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.directory.api</groupId>
      <artifactId>api-all</artifactId>
      <version>2.0.1</version>
    </dependency>

    <!-- Ziti and ldap libraries -->
    <dependency>
      <groupId>org.openziti</groupId>
      <artifactId>ziti-ldap-client</artifactId>
      <version>1.1.0</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.openziti</groupId>
      <artifactId>ziti</artifactId>
      <version>0.21.0</version>
    </dependency>

    <dependency>
      <groupId>org.openziti</groupId>
      <artifactId>ziti-netty</artifactId>
      <version>0.21.0</version>
    </dependency>

    <dependency>
      <groupId>org.ldaptive</groupId>
      <artifactId>ldaptive</artifactId>
      <version>2.0.1</version>
    </dependency>

    <!-- Ziti transitive dependency overrides graphql dependencies-->
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>1.4.32</version>
    </dependency>

    <dependency>
      <groupId>com.squareup.okhttp3</groupId>
      <artifactId>okhttp</artifactId>
      <version>3.14.9</version>
    </dependency>

    <dependency>
      <groupId>com.squareup.retrofit2</groupId>
      <artifactId>retrofit</artifactId>
      <version>2.9.0</version>
    </dependency>

    <!-- Crypto loading overrides -->
    <dependency>
      <groupId>com.goterl</groupId>
      <artifactId>lazysodium-java</artifactId>
      <version>5.0.1</version>
    </dependency>

    <!-- AWS dependencies -->

    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-secretsmanager</artifactId>
    </dependency>

    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-sns</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-aws</artifactId>
      <version>${spring-cloud-aws.version}</version>
    </dependency>

   <!-- Metrics/Tracing Dependencies -->
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-core</artifactId>
    </dependency>
    
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-registry-elastic</artifactId>
    </dependency>
    
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-tracing-bridge-brave</artifactId>
    </dependency>
    <!-- Database dependencies -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-core</artifactId>
      <version>8.5.13</version>
    </dependency>
     <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-mysql</artifactId>
      <version>8.5.13</version>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.4.199</version><!-- $NO-MVN-MAN-VER$ Overriding default
        versions of H2, which is 1.4.196 at the moment, to pick up support for ON
        UPDATE CURRENT_TIMESTAMP support which we use in MySQL for createdAt and
        updatedAt. -->
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.5.5</version>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>mchange-commons-java</artifactId>
      <version>0.2.19</version>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
      <version>8.0.31</version>
    </dependency>
    <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>javax.persistence-api</artifactId>
      <version>2.2</version>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

     <dependency>
      <groupId>org.redisson</groupId>
      <artifactId>redisson-spring-boot-starter</artifactId>
      <version>3.19.0</version>
    </dependency>

    <dependency> <!-- Caching -->
      <groupId>com.github.ben-manes.caffeine</groupId>
      <artifactId>caffeine</artifactId>
    </dependency>

    <!-- Lombok -->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <optional>true</optional>
    </dependency>

    <!-- Testing and Test related dependencies -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-test-autoconfigure</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>capital.scalable</groupId>
      <artifactId>spring-auto-restdocs-core</artifactId>
      <version>2.0.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.restdocs</groupId>
      <artifactId>spring-restdocs-mockmvc</artifactId>
       <version>3.0.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.skyscreamer</groupId>
      <artifactId>jsonassert</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>com.vaadin.external.google</groupId>
          <artifactId>android-json</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.3.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>capital.scalable</groupId>
      <artifactId>spring-auto-restdocs-core</artifactId>
      <version>2.0.4</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>it.ozimov</groupId>
      <artifactId>embedded-redis</artifactId>
      <version>0.7.3</version>
      <scope>test</scope>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>net.logstash.logback</groupId>
      <artifactId>logstash-logback-encoder</artifactId>
      <version>7.4</version>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>

    <!-- Auth -->
    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>authorization</artifactId>
      <version>2.5.0</version>
      <classifier>client</classifier>
    </dependency>
    <dependency>
      <groupId>com.auth0</groupId>
      <artifactId>java-jwt</artifactId>
      <version>4.4.0</version>
    </dependency>
    <dependency>
      <groupId>com.auth0</groupId>
      <artifactId>jwks-rsa</artifactId>
      <version>0.22.1</version>
    </dependency>

    <!-- Azure AD -->
    <dependency>
      <groupId>com.microsoft.graph</groupId>
      <artifactId>microsoft-graph</artifactId>
      <version>5.7.0</version>
    </dependency>
    <dependency>
      <groupId>com.microsoft.graph</groupId>
      <artifactId>microsoft-graph-core</artifactId>
      <version>2.0.10</version>
    </dependency>
    <dependency>
      <groupId>com.microsoft.graph</groupId>
      <artifactId>microsoft-graph-auth</artifactId>
      <version>0.3.0</version>
    </dependency>
    <dependency>
      <groupId>com.azure</groupId>
      <artifactId>azure-identity</artifactId>
      <version>1.4.1</version>
    </dependency>
    <!--
        <dependency>
          <groupId>com.microsoft.rest</groupId>
          <artifactId>client-runtime</artifactId>
          <version>1.6.6</version>
        </dependency>
    -->

    <!-- OnPrem AD via Domain Directory Controller -->
    <dependency>
      <artifactId>ddc-core</artifactId>
      <groupId>com.imperva.ddc</groupId>
      <version>7.3.3.0.0.0</version>
    </dependency>
    <dependency>
      <artifactId>ddc-service</artifactId>
      <groupId>com.imperva.ddc</groupId>
      <version>7.3.3.0.0.0</version>
    </dependency>

    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.agent</artifactId>
      <version>${jacoco.version}</version>
      <classifier>runtime</classifier>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <dependencyManagement>
    <dependencies>

	  <dependency>
		<groupId>software.amazon.awssdk</groupId>
		<artifactId>bom</artifactId>
		<version>${aws-sdk.version}</version>
		<type>pom</type>
		<scope>import</scope>
	  </dependency>

      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>${spring-cloud.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-bom</artifactId>
        <version>1.12.63</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <forceJavacCompilerUse>true</forceJavacCompilerUse>
          <source>21</source>
          <target>21</target>
          <compilerVersion>21</compilerVersion>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <requiresUnpack>
            <dependency>
              <groupId>com.goterl</groupId>
              <artifactId>lazysodium-java</artifactId>
              <version>5.0.1</version>
            </dependency>
          </requiresUnpack>
        </configuration>
        <executions>
          <execution>
            <id>repackage</id>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
          <execution>
            <id>build-info</id>
            <goals>
              <goal>build-info</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- spring-boot-flyway-plugin -->
      <plugin>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <configuration>
          <url>jdbc:h2:file:./target/data;MODE=mysql</url>
          <user>sa</user>
          <schemas>
            <schema>clientsync</schema>
          </schemas>
          <locations>
            <location>filesystem:./src/main/resources/database/migration</location>
          </locations>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.199</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- will provide git information in the healthcheck localEndpoint -->
      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
      </plugin>

      <!-- Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports. -->
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.java</include>
          </includes>
          <systemPropertyVariables>
            <org.springframework.restdocs.outputDir>
              ${project.build.directory}/generated-snippets
            </org.springframework.restdocs.outputDir>
            <org.springframework.restdocs.javadocJsonDir>
              ${project.build.directory}/generated-javadoc-json
            </org.springframework.restdocs.javadocJsonDir>
          </systemPropertyVariables>
        </configuration>
       
      </plugin>


     <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
             <configuration>
                <source>21</source>
                <target>21</target>
            </configuration>
            <version>3.6.3</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>generate-javadoc-json</id>
                <phase>compile</phase>
                <goals>
                  <goal>javadoc-no-fork</goal>
                  <goal>test-javadoc-no-fork</goal>
                </goals>
                <configuration>
                  <doclet>capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet</doclet>
                  <docletArtifact>
                    <groupId>capital.scalable</groupId>
                    <artifactId>spring-auto-restdocs-json-doclet-jdk9</artifactId>
                    <version>2.0.5</version>
                  </docletArtifact>
                  <destDir>generated-javadoc-json</destDir>
                  <reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
                  <useStandardDocletOptions>false</useStandardDocletOptions>
                  <show>package</show>
                </configuration>
              </execution>
            </executions>
          </plugin>

      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>generate-docs</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>process-asciidoc</goal>
            </goals>
            <configuration>
              <backend>html</backend>
              <doctype>book</doctype>
              <sourceDocumentName>index.adoc</sourceDocumentName>
              <attributes>
                <snippets>${snippetsDirectory}</snippets>
              </attributes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-generated-api-docs-to-static-docs</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/static/docs</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.build.directory}/generated-docs</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-redocs-to-static-docs</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/static/docs</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.build.directory}/generated-snippets</directory>
                  <includes>
                    <include>**/*.redoc</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

			<!-- checks dependencies for vulnerabilities -->
			<plugin>
				<groupId>org.owasp</groupId>
				<artifactId>dependency-check-maven</artifactId>
				<version>9.0.9</version>
				<configuration>
					<!-- Fail Build On CVSS core more then 8.0 which is HIGH-->
					<!-- <failBuildOnCVSS>8</failBuildOnCVSS> -->
					<!-- Generate all report formats -->
					<format>ALL</format>
					<!-- Don't use Nexus Analyzer -->
					<centralAnalyzerEnabled>false</centralAnalyzerEnabled>
					<ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
					<!-- Am I the latest version? -->
					<versionCheckEnabled>true</versionCheckEnabled>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>xml-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>transform</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<transformationSets>
						<transformationSet>
							<dir>${project.build.directory}</dir>
							<includes>
								<include>dependency-check-report.xml</include>
							</includes>
							<stylesheet>
								src/main/resources/dependencycheck_to_pmd.xsl</stylesheet>
							<outputDir>target</outputDir>
							<fileMappers>
								<fileMapper
									implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
									<targetName>dependency-check-report-pmd.xml</targetName>
								</fileMapper>
							</fileMappers>
						</transformationSet>
					</transformationSets>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>net.sf.saxon</groupId>
						<artifactId>saxon</artifactId>
						<version>8.7</version>
					</dependency>
					<dependency>
						<groupId>org.owasp</groupId>
						<artifactId>dependency-check-core</artifactId>
						<version>9.0.9</version>
					</dependency>
				</dependencies>
			</plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.11</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
          <execution>
            <id>post-unit-test</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
							<!-- Sets the path to the file which contains the execution
                data. -->
              <dataFile>target/jacoco.exec</dataFile>
							<!-- Sets the output directory for the code coverage report. -->
              <outputDirectory>target/jacoco-ut</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>3.10.0.2594</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
