Repository: SAP/cloud-security-xsuaa-integration
Pull request #313 (2020-06-24 11:53:57)

Improve maven plugin management
This PR moves the configuration of the maven plugins pmd and jacoco into the main pom.xml.

It updates:

- **jacoco-maven-plugin** from `0.8.2` to `0.8.5`
- **maven-pmd-plugin** from `3.10.0` to `3.13.0`
- **dependency-check-maven** from `5.2.2` to `5.3.2`

Also `maven.compiler.source` and `maven.compiler.target` are now set to `1.8` in **sap-java-buildpack-api-usage** and **java-tokenclient-usage** because they would not compile with JDK 11 without this setting.

Now the project compiles fine with JDK 11!


Patch:
diff --git a/java-api/pom.xml b/java-api/pom.xml
index 6ff0c5a4..d13c1413 100644
--- a/java-api/pom.xml
+++ b/java-api/pom.xml
@@ -85,46 +85,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>
diff --git a/java-security/pom.xml b/java-security/pom.xml
index 578fabda..5611afb7 100644
--- a/java-security/pom.xml
+++ b/java-security/pom.xml
@@ -119,46 +119,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>
diff --git a/java-security/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java b/java-security/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java
index a3a920c4..45d0f1b5 100644
--- a/java-security/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java
+++ b/java-security/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java
@@ -6,6 +6,7 @@ import javax.annotation.Nonnull;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 import static com.sap.cloud.security.config.cf.CFConstants.*;
 
@@ -98,44 +99,72 @@ public class OAuth2ServiceConfigurationBuilder {
 	 * @return the oauth2 service configuration.
 	 */
 	public OAuth2ServiceConfiguration build() {
-		return new OAuth2ServiceConfiguration() {
-
-			@Override
-			public String getClientId() {
-				return properties.get(CLIENT_ID);
-			}
-
-			@Override
-			public String getClientSecret() {
-				return properties.get(CLIENT_SECRET);
-			}
-
-			@Override
-			public URI getUrl() {
-				return URI.create(properties.get(URL));
-			}
-
-			@Override
-			public String getProperty(String name) {
-				return properties.get(name);
-			}
-
-			@Override
-			public boolean hasProperty(String name) {
-				return properties.containsKey(name);
-			}
-
-			@Override
-			public Service getService() {
-				return service;
-			}
-
-			@Override
-			public boolean isLegacyMode() {
-				return runInLegacyMode;
-			}
-		};
-
+		return new OAuth2ServiceConfigurationImpl(properties, service, runInLegacyMode);
 	}
 
+	private class OAuth2ServiceConfigurationImpl implements OAuth2ServiceConfiguration {
+
+		private final Map<String, String> properties;
+		private final boolean runInLegacyMode;
+		private final Service service;
+
+		private OAuth2ServiceConfigurationImpl(@Nonnull Map<String, String> properties,
+				@Nonnull Service service, boolean runInLegacyMode) {
+			this.properties = properties;
+			this.service = service;
+			this.runInLegacyMode = runInLegacyMode;
+		}
+
+		@Override
+		public String getClientId() {
+			return properties.get(CLIENT_ID);
+		}
+
+		@Override
+		public String getClientSecret() {
+			return properties.get(CLIENT_SECRET);
+		}
+
+		@Override
+		public URI getUrl() {
+			return URI.create(properties.get(URL));
+		}
+
+		@Override
+		public String getProperty(String name) {
+			return properties.get(name);
+		}
+
+		@Override
+		public boolean hasProperty(String name) {
+			return properties.containsKey(name);
+		}
+
+		@Override
+		public Service getService() {
+			return service;
+		}
+
+		@Override
+		public boolean isLegacyMode() {
+			return runInLegacyMode;
+		}
+
+		@Override
+		public boolean equals(Object o) {
+			if (this == o)
+				return true;
+			if (o == null || getClass() != o.getClass())
+				return false;
+			OAuth2ServiceConfigurationImpl that = (OAuth2ServiceConfigurationImpl) o;
+			return runInLegacyMode == that.runInLegacyMode &&
+					properties.equals(that.properties) &&
+					service == that.service;
+		}
+
+		@Override
+		public int hashCode() {
+			return Objects.hash(properties, runInLegacyMode, service);
+		}
+	}
 }
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 13f57861..cd4106c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -299,10 +299,54 @@
 			<build>
 				<pluginManagement>
 					<plugins>
+						<plugin>
+							<groupId>org.apache.maven.plugins</groupId>
+							<artifactId>maven-pmd-plugin</artifactId>
+							<version>3.13.0</version>
+							<executions>
+								<execution>
+									<phase>verify</phase>
+									<goals>
+										<goal>pmd</goal>
+										<goal>cpd</goal>
+									</goals>
+								</execution>
+							</executions>
+						</plugin>
+						<plugin>
+							<groupId>org.jacoco</groupId>
+							<artifactId>jacoco-maven-plugin</artifactId>
+							<version>0.8.5</version>
+							<executions>
+								<execution>
+									<id>default-prepare-agent</id>
+									<goals>
+										<goal>prepare-agent</goal>
+									</goals>
+								</execution>
+								<execution>
+									<id>default-report</id>
+									<phase>prepare-package</phase>
+									<goals>
+										<goal>report</goal>
+									</goals>
+								</execution>
+								<execution>
+									<id>default-check</id>
+									<goals>
+										<goal>check</goal>
+									</goals>
+									<configuration>
+										<rules>
+										</rules>
+									</configuration>
+								</execution>
+							</executions>
+						</plugin>
 						<plugin>
 							<groupId>org.owasp</groupId> <!--scans for vulnerabilities-->
 							<artifactId>dependency-check-maven</artifactId>
-							<version>5.2.2</version>
+							<version>5.3.2</version>
 							<executions>
 								<execution>
 									<goals>
@@ -343,7 +387,6 @@
 								</execution>
 							</executions>
 						</plugin>
-
 						<plugin>
 							<groupId>net.revelc.code</groupId>
 							<artifactId>impsort-maven-plugin</artifactId>
diff --git a/samples/java-tokenclient-usage/pom.xml b/samples/java-tokenclient-usage/pom.xml
index 5958690d..7aded2aa 100755
--- a/samples/java-tokenclient-usage/pom.xml
+++ b/samples/java-tokenclient-usage/pom.xml
@@ -7,6 +7,8 @@
     <packaging>war</packaging>
 
     <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
         <sap.cloud.security.version>2.7.2</sap.cloud.security.version>
         <apache.httpclient.version>4.5.8</apache.httpclient.version>
         <javax.servlet.api.version>3.0.1</javax.servlet.api.version>
diff --git a/samples/sap-java-buildpack-api-usage/pom.xml b/samples/sap-java-buildpack-api-usage/pom.xml
index 0d74e24c..1d75300d 100755
--- a/samples/sap-java-buildpack-api-usage/pom.xml
+++ b/samples/sap-java-buildpack-api-usage/pom.xml
@@ -7,6 +7,8 @@
 	<packaging>war</packaging>
 
 	<properties>
+		<maven.compiler.source>1.8</maven.compiler.source>
+		<maven.compiler.target>1.8</maven.compiler.target>
 		<sap.cloud.security.version>2.7.2</sap.cloud.security.version>
 		<javax.servlet.api.version>3.0.1</javax.servlet.api.version>
 	</properties>
diff --git a/samples/spring-security-basic-auth/pom.xml b/samples/spring-security-basic-auth/pom.xml
index a33aed39..6d725a74 100644
--- a/samples/spring-security-basic-auth/pom.xml
+++ b/samples/spring-security-basic-auth/pom.xml
@@ -52,7 +52,7 @@
 			<plugin>
 				<groupId>org.owasp</groupId> <!--scans for vulnerabilities-->
 				<artifactId>dependency-check-maven</artifactId>
-				<version>5.2.2</version>
+				<version>5.3.2</version>
 				<executions>
 					<execution>
 						<goals>
diff --git a/samples/spring-security-xsuaa-usage/pom.xml b/samples/spring-security-xsuaa-usage/pom.xml
index 87fbe9a2..b9da61fc 100644
--- a/samples/spring-security-xsuaa-usage/pom.xml
+++ b/samples/spring-security-xsuaa-usage/pom.xml
@@ -65,7 +65,7 @@
 			<plugin>
 				<groupId>org.owasp</groupId> <!--scans for vulnerabilities-->
 				<artifactId>dependency-check-maven</artifactId>
-				<version>5.2.2</version>
+				<version>5.3.2</version>
 				<executions>
 					<execution>
 						<goals>
diff --git a/samples/spring-webflux-security-xsuaa-usage/pom.xml b/samples/spring-webflux-security-xsuaa-usage/pom.xml
index 85dc1086..096b4aab 100644
--- a/samples/spring-webflux-security-xsuaa-usage/pom.xml
+++ b/samples/spring-webflux-security-xsuaa-usage/pom.xml
@@ -85,7 +85,7 @@
             <plugin>
                 <groupId>org.owasp</groupId> <!--scans for vulnerabilities-->
                 <artifactId>dependency-check-maven</artifactId>
-                <version>5.2.2</version>
+                <version>5.3.2</version>
                 <executions>
                     <execution>
                         <goals>
diff --git a/spring-xsuaa-mock/pom.xml b/spring-xsuaa-mock/pom.xml
index a3d437b9..8650e6dc 100644
--- a/spring-xsuaa-mock/pom.xml
+++ b/spring-xsuaa-mock/pom.xml
@@ -96,46 +96,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>
diff --git a/spring-xsuaa/pom.xml b/spring-xsuaa/pom.xml
index efd50346..f6af75d2 100644
--- a/spring-xsuaa/pom.xml
+++ b/spring-xsuaa/pom.xml
@@ -145,46 +145,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>
diff --git a/token-client/pom.xml b/token-client/pom.xml
index 1306ef67..18ece673 100644
--- a/token-client/pom.xml
+++ b/token-client/pom.xml
@@ -121,46 +121,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>


Test patch:
diff --git a/java-security-test/pom.xml b/java-security-test/pom.xml
index 4dc73667..21f5b4f4 100644
--- a/java-security-test/pom.xml
+++ b/java-security-test/pom.xml
@@ -127,46 +127,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 		</plugins>
 	</build>
diff --git a/java-security/src/test/java/com/sap/cloud/security/token/validation/validators/JwtValidatorBuilderTest.java b/java-security/src/test/java/com/sap/cloud/security/token/validation/validators/JwtValidatorBuilderTest.java
index d63bd67e..75a99cda 100644
--- a/java-security/src/test/java/com/sap/cloud/security/token/validation/validators/JwtValidatorBuilderTest.java
+++ b/java-security/src/test/java/com/sap/cloud/security/token/validation/validators/JwtValidatorBuilderTest.java
@@ -36,7 +36,9 @@ public class JwtValidatorBuilderTest {
 		OAuth2ServiceConfiguration configuration = xsuaaConfigBuilder.build();
 		JwtValidatorBuilder builder_1 = JwtValidatorBuilder.getInstance(configuration);
 		JwtValidatorBuilder builder_2 = JwtValidatorBuilder.getInstance(configuration);
+		JwtValidatorBuilder builder_3 = JwtValidatorBuilder.getInstance(xsuaaConfigBuilder.build());
 		assertThat(builder_1).isSameAs(builder_2);
+		assertThat(builder_1).isSameAs(builder_3);
 	}
 
 	@Test
diff --git a/spring-xsuaa-test/pom.xml b/spring-xsuaa-test/pom.xml
index 7d76dc1e..aa099756 100644
--- a/spring-xsuaa-test/pom.xml
+++ b/spring-xsuaa-test/pom.xml
@@ -75,46 +75,10 @@
 			<plugin>
 				<groupId>org.jacoco</groupId>
 				<artifactId>jacoco-maven-plugin</artifactId>
-				<version>0.8.2</version>
-				<executions>
-					<execution>
-						<id>default-prepare-agent</id>
-						<goals>
-							<goal>prepare-agent</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-report</id>
-						<phase>prepare-package</phase>
-						<goals>
-							<goal>report</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>default-check</id>
-						<goals>
-							<goal>check</goal>
-						</goals>
-						<configuration>
-							<rules>
-							</rules>
-						</configuration>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.10.0</version>
-				<executions>
-					<execution>
-						<phase>verify</phase>
-						<goals>
-							<goal>pmd</goal>
-							<goal>cpd</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>