Repository: SAP/cloud-security-xsuaa-integration
Pull request #445 (2021-01-04 15:37:36)

[java-security] HOTFIX for version 2.8.1


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01ec7e29..eaf4ec98 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
 # Change Log 
 
 All notable changes to this project will be documented in this file.
+
+## 2.8.2
+- [java-security] HOTFIX for ``2.8.1`` version.
+ 
 ## 2.8.1
 - [spring-xsuaa]   
   - *Beta release* of ias2xsuaa token exchange. Further information can be found [here](/spring-xsuaa#token-exchange).
diff --git a/api/README.md b/api/README.md
index 0eef79e5..53f073a7 100644
--- a/api/README.md
+++ b/api/README.md
@@ -5,6 +5,6 @@
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>api</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 ```
diff --git a/api/pom.xml b/api/pom.xml
index 118fd200..6d3e08e1 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -8,7 +8,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<packaging>jar</packaging>
diff --git a/java-api/README.md b/java-api/README.md
index e8584a61..283f7c88 100644
--- a/java-api/README.md
+++ b/java-api/README.md
@@ -5,6 +5,6 @@
 <dependency>
     <groupId>com.sap.cloud.security</groupId>
     <artifactId>java-api</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 ```
diff --git a/java-api/pom.xml b/java-api/pom.xml
index 2d70340a..5aa68903 100644
--- a/java-api/pom.xml
+++ b/java-api/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<groupId>com.sap.cloud.security</groupId>
diff --git a/java-security-it/pom.xml b/java-security-it/pom.xml
index 60f7a089..5c27d41b 100644
--- a/java-security-it/pom.xml
+++ b/java-security-it/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <artifactId>parent</artifactId>
         <groupId>com.sap.cloud.security.xsuaa</groupId>
-        <version>2.8.1</version>
+        <version>2.8.2</version>
     </parent>
 
     <artifactId>java-security-it</artifactId>
diff --git a/java-security/Migration_SpringSecurityProjects.md b/java-security/Migration_SpringSecurityProjects.md
index 76579acf..92e801e9 100644
--- a/java-security/Migration_SpringSecurityProjects.md
+++ b/java-security/Migration_SpringSecurityProjects.md
@@ -37,19 +37,19 @@ First make sure you have the following dependencies defined in your pom.xml:
 <dependency>
   <groupId>com.sap.cloud.security.xsuaa</groupId>
   <artifactId>api</artifactId>
-  <version>2.8.1</version>
+  <version>2.8.2</version>
 </dependency>
 <dependency>
   <groupId>com.sap.cloud.security</groupId>
   <artifactId>java-security</artifactId>
-  <version>2.8.1</version>
+  <version>2.8.2</version>
 </dependency>
 
 <!-- new java-security dependencies for unit tests -->
 <dependency>
   <groupId>com.sap.cloud.security</groupId>
   <artifactId>java-security-test</artifactId>
-  <version>2.8.1</version>
+  <version>2.8.2</version>
   <scope>test</scope>
 </dependency>
 ```
diff --git a/java-security/README.md b/java-security/README.md
index 660a88f7..97f453b5 100644
--- a/java-security/README.md
+++ b/java-security/README.md
@@ -46,7 +46,7 @@ In case of XSUAA does the JWT provide a valid `jku` token header parameter that
 <dependency>
     <groupId>com.sap.cloud.security</groupId>
     <artifactId>java-security</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 <dependency>
     <groupId>org.apache.httpcomponents</groupId>
diff --git a/java-security/pom.xml b/java-security/pom.xml
index 67649fdb..53457567 100644
--- a/java-security/pom.xml
+++ b/java-security/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<groupId>com.sap.cloud.security</groupId>
diff --git a/java-security/src/main/java/com/sap/cloud/security/servlet/TokenFactory.java b/java-security/src/main/java/com/sap/cloud/security/servlet/TokenFactory.java
index 25c65dcc..4042730d 100644
--- a/java-security/src/main/java/com/sap/cloud/security/servlet/TokenFactory.java
+++ b/java-security/src/main/java/com/sap/cloud/security/servlet/TokenFactory.java
@@ -1,11 +1,13 @@
 package com.sap.cloud.security.servlet;
 
-import com.sap.cloud.security.token.SapIdToken;
-import com.sap.cloud.security.token.Token;
-import com.sap.cloud.security.token.XsuaaToken;
+import com.sap.cloud.security.token.*;
+import com.sap.cloud.security.xsuaa.Assertions;
 import com.sap.cloud.security.xsuaa.jwt.Base64JwtDecoder;
 import com.sap.cloud.security.xsuaa.jwt.DecodedJwt;
 
+import javax.annotation.Nonnull;
+import java.util.regex.Pattern;
+
 import static com.sap.cloud.security.token.TokenClaims.XSUAA.EXTERNAL_ATTRIBUTE;
 import static com.sap.cloud.security.token.TokenClaims.XSUAA.EXTERNAL_ATTRIBUTE_ENHANCER;
 
@@ -24,15 +26,31 @@ class TokenFactory {
 	 * Determines whether the JWT token is issued by XSUAA identity service, and
 	 * creates a Token for it.
 	 *
-	 * @param encodedToken
-	 *            the encoded token
+	 * @param jwtToken
+	 *            the encoded JWT token (access_token or id_token), e.g. from the
+	 *            Authorization Header.
 	 * @return the new token instance
 	 */
-	public static Token create(String encodedToken) {
-		DecodedJwt decodedJwt = Base64JwtDecoder.getInstance().decode(encodedToken);
+	public static Token create(String jwtToken) {
+		return create(jwtToken, null);
+	}
+
+	/**
+	 * Determines whether the JWT token is issued by XSUAA identity service, and
+	 * creates a Token for it.
+	 *
+	 * @param jwtToken
+	 *            the encoded JWT token (access_token or id_token), e.g. from the
+	 *            Authorization Header.
+	 * @param localScopeConverter
+	 *            the scope converter, e.g. {@link XsuaaScopeConverter}
+	 * @return the new token instance
+	 */
+	public static Token create(String jwtToken, ScopeConverter localScopeConverter) {
+		DecodedJwt decodedJwt = Base64JwtDecoder.getInstance().decode(removeBearer(jwtToken));
 
 		if (isXsuaaToken(decodedJwt)) {
-			return new XsuaaToken(decodedJwt);
+			return new XsuaaToken(decodedJwt).withScopeConverter(localScopeConverter);
 		}
 		return new SapIdToken(decodedJwt);
 	}
@@ -51,4 +69,10 @@ class TokenFactory {
 				&& jwtPayload.contains(EXTERNAL_ATTRIBUTE_ENHANCER)
 				&& jwtPayload.contains("xsuaa");
 	}
+
+	private static String removeBearer(@Nonnull String jwtToken) {
+		Assertions.assertHasText(jwtToken, "jwtToken must not be null / empty");
+		Pattern bearerPattern = Pattern.compile("[B|b]earer ");
+		return bearerPattern.matcher(jwtToken).replaceFirst("");
+	}
 }
diff --git a/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java b/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java
index 64ec98eb..fd963f84 100644
--- a/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java
+++ b/java-security/src/main/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticator.java
@@ -69,7 +69,7 @@ public class XsuaaTokenAuthenticator extends AbstractTokenAuthenticator {
 			String authorizationHeader = httpRequest.getHeader(HttpHeaders.AUTHORIZATION);
 			if (headerIsAvailable(authorizationHeader)) {
 				try {
-					Token token = TokenFactory.create(authorizationHeader);
+					Token token = TokenFactory.create(authorizationHeader, getScopeConverter());
 					if (isIasXsuaaXchangeEnabled() && token.getService() == Service.IAS) {
 						token = new XsuaaToken(Objects.requireNonNull(
 								exchangeBroker.doIasToXsuaaXchange(httpClient, token, serviceConfiguration),
diff --git a/pom.xml b/pom.xml
index 1e7433f3..ebf188cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
 
 	<groupId>com.sap.cloud.security.xsuaa</groupId>
 	<artifactId>parent</artifactId>
-	<version>2.8.1</version>
+	<version>2.8.2</version>
 	<packaging>pom</packaging>
 
 	<name>parent</name>
diff --git a/samples/java-security-usage-ias/pom.xml b/samples/java-security-usage-ias/pom.xml
index db0a81e9..4f8f32db 100755
--- a/samples/java-security-usage-ias/pom.xml
+++ b/samples/java-security-usage-ias/pom.xml
@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sap.cloud.security.xssec.samples</groupId>
     <artifactId>java-security-usage-ias</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
     <packaging>war</packaging>
 
     <!--profiles>
@@ -24,7 +24,7 @@
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
-        <sap.cloud.security.version>2.8.1</sap.cloud.security.version>
+        <sap.cloud.security.version>2.8.2</sap.cloud.security.version>
         <slf4j.api.version>1.7.30</slf4j.api.version>
         <apache.httpclient.version>4.5.9</apache.httpclient.version>
         <javax.servlet.api.version>3.1.0</javax.servlet.api.version>
diff --git a/samples/java-security-usage/pom.xml b/samples/java-security-usage/pom.xml
index 2f5f05c9..9ee60478 100755
--- a/samples/java-security-usage/pom.xml
+++ b/samples/java-security-usage/pom.xml
@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sap.cloud.security.xssec.samples</groupId>
     <artifactId>java-security-usage</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
     <packaging>war</packaging>
 
     <!--profiles>
@@ -24,7 +24,7 @@
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
-        <sap.cloud.security.version>2.8.1</sap.cloud.security.version>
+        <sap.cloud.security.version>2.8.2</sap.cloud.security.version>
         <slf4j.api.version>1.7.30</slf4j.api.version>
         <apache.httpclient.version>4.5.9</apache.httpclient.version>
         <javax.servlet.api.version>3.1.0</javax.servlet.api.version>
diff --git a/samples/java-tokenclient-usage/pom.xml b/samples/java-tokenclient-usage/pom.xml
index 9f926699..78c91d3a 100755
--- a/samples/java-tokenclient-usage/pom.xml
+++ b/samples/java-tokenclient-usage/pom.xml
@@ -3,13 +3,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.sap.cloud.security.xssec.samples</groupId>
     <artifactId>java-tokenclient-usage</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
     <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.8.1</sap.cloud.security.version>
+        <sap.cloud.security.version>2.8.2</sap.cloud.security.version>
         <apache.httpclient.version>4.5.9</apache.httpclient.version>
         <javax.servlet.api.version>3.1.0</javax.servlet.api.version>
     </properties>
diff --git a/samples/sap-java-buildpack-api-usage/pom.xml b/samples/sap-java-buildpack-api-usage/pom.xml
index 68da0629..3ef039e6 100755
--- a/samples/sap-java-buildpack-api-usage/pom.xml
+++ b/samples/sap-java-buildpack-api-usage/pom.xml
@@ -3,13 +3,13 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.sap.cloud.security.xssec.samples</groupId>
 	<artifactId>sap-java-buildpack-api-usage</artifactId>
-	<version>2.8.1</version>
+	<version>2.8.2</version>
 	<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.8.1</sap.cloud.security.version>
+		<sap.cloud.security.version>2.8.2</sap.cloud.security.version>
 		<javax.servlet.api.version>3.1.0</javax.servlet.api.version>
 	</properties>
 
diff --git a/samples/spring-security-basic-auth/pom.xml b/samples/spring-security-basic-auth/pom.xml
index 22c1606b..d12e682a 100644
--- a/samples/spring-security-basic-auth/pom.xml
+++ b/samples/spring-security-basic-auth/pom.xml
@@ -11,14 +11,14 @@
 	</parent>
 
 	<artifactId>spring-security-basic-auth</artifactId>
-	<version>2.8.1</version>
+	<version>2.8.2</version>
 	<name>spring-security-basic-auth</name>
 
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 		<java.version>1.8</java.version>
-		<sap.cloud.security.version>2.8.1</sap.cloud.security.version>
+		<sap.cloud.security.version>2.8.2</sap.cloud.security.version>
 	</properties>
 
 	<dependencies>
diff --git a/samples/spring-security-xsuaa-usage/pom.xml b/samples/spring-security-xsuaa-usage/pom.xml
index 4605bdec..fe0b7eca 100644
--- a/samples/spring-security-xsuaa-usage/pom.xml
+++ b/samples/spring-security-xsuaa-usage/pom.xml
@@ -14,7 +14,7 @@
 
 	<groupId>com.sap.cloud.security.samples</groupId>
 	<artifactId>spring-security-xsuaa-usage</artifactId>
-	<version>2.8.1</version>
+	<version>2.8.2</version>
 	<name>spring-security-xsuaa-usage</name>
 
 	<properties>
@@ -27,7 +27,7 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 		<java.version>1.8</java.version>
-		<sap.cloud.security.version>2.8.1</sap.cloud.security.version>
+		<sap.cloud.security.version>2.8.2</sap.cloud.security.version>
 	</properties>
 
     <dependencies>
diff --git a/samples/spring-webflux-security-xsuaa-usage/pom.xml b/samples/spring-webflux-security-xsuaa-usage/pom.xml
index c551b6a1..87d6d530 100644
--- a/samples/spring-webflux-security-xsuaa-usage/pom.xml
+++ b/samples/spring-webflux-security-xsuaa-usage/pom.xml
@@ -12,12 +12,12 @@
 
     <groupId>com.sap.cloud.security.samples</groupId>
     <artifactId>spring-webflux-security-xsuaa-usage</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
     <name>spring-webflux-security-xsuaa-usage</name>
 
     <properties>
         <java.version>1.8</java.version>
-        <sap.cloud.security.version>2.8.1</sap.cloud.security.version>
+        <sap.cloud.security.version>2.8.2</sap.cloud.security.version>
     </properties>
 
     <dependencies>
diff --git a/spring-xsuaa-it/pom.xml b/spring-xsuaa-it/pom.xml
index cdb59409..b52ac371 100644
--- a/spring-xsuaa-it/pom.xml
+++ b/spring-xsuaa-it/pom.xml
@@ -6,7 +6,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<artifactId>spring-xsuaa-it</artifactId>
diff --git a/spring-xsuaa-mock/README.md b/spring-xsuaa-mock/README.md
index 05eaedb2..f127c33c 100644
--- a/spring-xsuaa-mock/README.md
+++ b/spring-xsuaa-mock/README.md
@@ -21,7 +21,7 @@ The default implementation offers already valid *token_keys* for JWT tokens, tha
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>spring-xsuaa-mock</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 <dependency> <!-- new with version 1.5.0 - provided with org.springframework.boot:spring-boot-starter:jar -->
     <groupId>org.springframework.boot</groupId>
diff --git a/spring-xsuaa-mock/pom.xml b/spring-xsuaa-mock/pom.xml
index e1345092..441fd0bf 100644
--- a/spring-xsuaa-mock/pom.xml
+++ b/spring-xsuaa-mock/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<artifactId>spring-xsuaa-mock</artifactId>
diff --git a/spring-xsuaa-starter/pom.xml b/spring-xsuaa-starter/pom.xml
index 17ccc634..215de906 100644
--- a/spring-xsuaa-starter/pom.xml
+++ b/spring-xsuaa-starter/pom.xml
@@ -14,7 +14,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<artifactId>xsuaa-spring-boot-starter</artifactId>
diff --git a/spring-xsuaa/README.md b/spring-xsuaa/README.md
index c5ce2f21..646dac93 100644
--- a/spring-xsuaa/README.md
+++ b/spring-xsuaa/README.md
@@ -25,7 +25,7 @@ These (spring) dependencies needs to be provided:
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>spring-xsuaa</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 <dependency> <!-- new with version 1.5.0 -->
     <groupId>org.apache.logging.log4j</groupId>
@@ -40,7 +40,7 @@ These (spring) dependencies needs to be provided:
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>xsuaa-spring-boot-starter</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 ```
 
diff --git a/spring-xsuaa/pom.xml b/spring-xsuaa/pom.xml
index edfe845a..0bbef897 100644
--- a/spring-xsuaa/pom.xml
+++ b/spring-xsuaa/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<artifactId>spring-xsuaa</artifactId>
diff --git a/spring-xsuaa/src/main/java/com/sap/cloud/security/xsuaa/token/XsuaaToken.java b/spring-xsuaa/src/main/java/com/sap/cloud/security/xsuaa/token/XsuaaToken.java
index 3a9c704f..3c96b018 100644
--- a/spring-xsuaa/src/main/java/com/sap/cloud/security/xsuaa/token/XsuaaToken.java
+++ b/spring-xsuaa/src/main/java/com/sap/cloud/security/xsuaa/token/XsuaaToken.java
@@ -274,7 +274,7 @@ public class XsuaaToken extends Jwt implements Token {
 		}
 
 		// convert JSONArray to String[]
-		JSONArray attributeJsonArray = new JSONArray((ArrayList)claimMap.get(attributeName));
+		JSONArray attributeJsonArray = new JSONArray((ArrayList) claimMap.get(attributeName));
 		if (attributeJsonArray != null) {
 			attributeValues = new String[attributeJsonArray.length()];
 			for (int i = 0; i < attributeJsonArray.length(); i++) {
diff --git a/token-client/README.md b/token-client/README.md
index 3e8752e9..fa1bdf65 100644
--- a/token-client/README.md
+++ b/token-client/README.md
@@ -23,7 +23,7 @@ The Resource owner password credentials (i.e., username and password) can be use
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>token-client</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 <dependency>
   <groupId>org.apache.httpcomponents</groupId>
@@ -64,7 +64,7 @@ By default, the `DefaultOAuth2TokenService` caches tokens internally. The Cache
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>token-client</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 ```
 
@@ -95,7 +95,7 @@ In context of a Spring Boot application you may like to leverage auto-configurat
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>xsuaa-spring-boot-starter</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
 </dependency>
 ```
 
diff --git a/token-client/pom.xml b/token-client/pom.xml
index 71697760..4165be92 100644
--- a/token-client/pom.xml
+++ b/token-client/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<artifactId>token-client</artifactId>


Test patch:
diff --git a/java-security-test/README.md b/java-security-test/README.md
index 2a0f9891..19a841d0 100644
--- a/java-security-test/README.md
+++ b/java-security-test/README.md
@@ -22,7 +22,7 @@ It includes for example a `JwtGenerator` that generates JSON Web Tokens (JWT) th
 <dependency>
     <groupId>com.sap.cloud.security</groupId>
     <artifactId>java-security-test</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
     <scope>test</scope>
 </dependency>
 ```
diff --git a/java-security-test/pom.xml b/java-security-test/pom.xml
index 7d4b86df..f994f205 100644
--- a/java-security-test/pom.xml
+++ b/java-security-test/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<groupId>com.sap.cloud.security</groupId>
diff --git a/java-security-test/src/main/java/com/sap/cloud/security/test/JwtGenerator.java b/java-security-test/src/main/java/com/sap/cloud/security/test/JwtGenerator.java
index 99f9a6f1..8567b4b6 100644
--- a/java-security-test/src/main/java/com/sap/cloud/security/test/JwtGenerator.java
+++ b/java-security-test/src/main/java/com/sap/cloud/security/test/JwtGenerator.java
@@ -148,7 +148,7 @@ public class JwtGenerator {
 			withClaimValue(TokenClaims.XSUAA.CLIENT_ID, azp); // Client Id left for backward compatibility
 			jsonPayload.put(TokenClaims.AUDIENCE, Arrays.asList(azp));
 			jsonPayload.put(TokenClaims.XSUAA.ZONE_ID, DEFAULT_ZONE_ID);
-			jsonPayload.put(TokenClaims.XSUAA.EXTERNAL_ATTRIBUTE, createJsonObject("{\"enhancer\" : \"xsuaa\"} "));
+			jsonPayload.put(TokenClaims.XSUAA.EXTERNAL_ATTRIBUTE, createJsonObject("{\"enhancer\" : \"XSUAA\"} "));
 		}
 	}
 
diff --git a/java-security-test/src/test/java/com/sap/cloud/security/test/JwtGeneratorTest.java b/java-security-test/src/test/java/com/sap/cloud/security/test/JwtGeneratorTest.java
index 0c1d835f..8cc748df 100644
--- a/java-security-test/src/test/java/com/sap/cloud/security/test/JwtGeneratorTest.java
+++ b/java-security-test/src/test/java/com/sap/cloud/security/test/JwtGeneratorTest.java
@@ -71,7 +71,7 @@ public class JwtGeneratorTest {
 		assertThat(token.getZoneId()).isEqualTo(DEFAULT_ZONE_ID);
 		assertThat(token.getClaimAsString(TokenClaims.XSUAA.ZONE_ID)).isEqualTo(DEFAULT_ZONE_ID);
 		assertThat(token.getExpiration()).isEqualTo(JwtGenerator.NO_EXPIRE_DATE);
-		assertThat(((AbstractToken)token).isXsuaaToken()).isTrue();
+		assertThat(((AbstractToken) token).isXsuaaToken()).isTrue();
 	}
 
 	@Test
diff --git a/java-security/src/test/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticatorTest.java b/java-security/src/test/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticatorTest.java
index c2cb1218..bc1ead73 100644
--- a/java-security/src/test/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticatorTest.java
+++ b/java-security/src/test/java/com/sap/cloud/security/servlet/XsuaaTokenAuthenticatorTest.java
@@ -114,6 +114,8 @@ public class XsuaaTokenAuthenticatorTest {
 		assertThat(response.getUnauthenticatedReason()).isEmpty();
 		assertThat(response.isAuthenticated()).isTrue();
 		assertThat(response.getToken()).isSameAs(SecurityContext.getToken());
+		assertThat(response.getToken().getService()).isEqualTo(Service.XSUAA);
+		assertThat(((XsuaaToken) response.getToken()).hasLocalScope("test")).isFalse();
 	}
 
 	@Test
diff --git a/samples/spring-security-xsuaa-usage/src/main/java/sample/spring/xsuaa/TestController.java b/samples/spring-security-xsuaa-usage/src/main/java/sample/spring/xsuaa/TestController.java
index ea497bfe..f54a47ac 100644
--- a/samples/spring-security-xsuaa-usage/src/main/java/sample/spring/xsuaa/TestController.java
+++ b/samples/spring-security-xsuaa-usage/src/main/java/sample/spring/xsuaa/TestController.java
@@ -146,13 +146,14 @@ public class TestController {
      * <p>
      *
      *
-     * @param jwt - the Jwt as a result of authentication.
+     * @param token - the Jwt as a result of authentication.
      * @throws TokenFlowException in case of any errors.
      */
     @GetMapping("/v3/requestUserToken")
-    public String requestUserToken(@AuthenticationPrincipal Jwt jwt) throws TokenFlowException {
+    public String requestUserToken(@AuthenticationPrincipal Token token) throws TokenFlowException {
         OAuth2TokenResponse userTokenResponse = tokenFlows.userTokenFlow()
-                .token(jwt.getTokenValue())
+                .token(token.getAppToken())
+                .subdomain(token.getSubdomain())
                 .execute();
 
         logger.info("Got the exchanged token for 3rd party service: {}", userTokenResponse);
diff --git a/spring-xsuaa-test/README.md b/spring-xsuaa-test/README.md
index 9d3e0b7b..f42f5cc4 100644
--- a/spring-xsuaa-test/README.md
+++ b/spring-xsuaa-test/README.md
@@ -31,7 +31,7 @@ This includes for example a `JwtGenerator` that generates JSON Web Tokens (JWT)
 <dependency>
     <groupId>com.sap.cloud.security.xsuaa</groupId>
     <artifactId>spring-xsuaa-test</artifactId>
-    <version>2.8.1</version>
+    <version>2.8.2</version>
     <scope>test</scope>
 </dependency>
 
diff --git a/spring-xsuaa-test/pom.xml b/spring-xsuaa-test/pom.xml
index 6b8685b4..87d63909 100644
--- a/spring-xsuaa-test/pom.xml
+++ b/spring-xsuaa-test/pom.xml
@@ -7,7 +7,7 @@
 	<parent>
 		<groupId>com.sap.cloud.security.xsuaa</groupId>
 		<artifactId>parent</artifactId>
-		<version>2.8.1</version>
+		<version>2.8.2</version>
 	</parent>
 
 	<artifactId>spring-xsuaa-test</artifactId>