You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2025/06/03 13:11:17 UTC

(sling-org-apache-sling-auth-oauth-client) branch issue/SLING-12817 updated (7dcf2c9 -> 16ed48a)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to branch issue/SLING-12817
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git


 discard 7dcf2c9  SLING-12817 - Update to parent pom 62
 discard 0e07968  SLING-12817 - Update to parent pom 62
 discard 4a34855  SLING-12817 - Update to parent pom 62
    omit cb23a92  SLING-12714 - Oidc Authentication Handler
     add 7271bf8  SLING-12714 - Oidc Authentication Handler (#18)
     new 74b81e7  SLING-12817 - Update to parent pom 62
     new 366668a  SLING-12817 - Update to parent pom 62
     new 16ed48a  SLING-12817 - Update to parent pom 62

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (7dcf2c9)
            \
             N -- N -- N   refs/heads/issue/SLING-12817 (16ed48a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


(sling-org-apache-sling-auth-oauth-client) 01/03: SLING-12817 - Update to parent pom 62

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch issue/SLING-12817
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git

commit 74b81e7f784271b9dfca3ec0598034e95d88e43b
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Jun 3 15:08:51 2025 +0200

    SLING-12817 - Update to parent pom 62
    
    Update the parent pom version and remove version overrides.
---
 pom.xml | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index ecc9031..516f32f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
-        <version>49</version>
+        <version>62</version>
         <relativePath/>
     </parent>
 
@@ -324,13 +324,11 @@
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
-            <version>5.9.2</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-params</artifactId>
-            <version>5.9.2</version>
             <scope>test</scope>
         </dependency>
         <dependency>


(sling-org-apache-sling-auth-oauth-client) 03/03: SLING-12817 - Update to parent pom 62

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch issue/SLING-12817
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git

commit 16ed48a42b66c56f041fa298e3cac4449d80f8eb
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Jun 3 15:10:26 2025 +0200

    SLING-12817 - Update to parent pom 62
    
    Ignore formatting applied in 0e07968bb060acd5dca35812ef40d14f85f58db2 for git blame.
---
 .git-blame-ignore-revs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000..38fee4d
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1 @@
+0e07968bb060acd5dca35812ef40d14f85f58db2


(sling-org-apache-sling-auth-oauth-client) 02/03: SLING-12817 - Update to parent pom 62

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch issue/SLING-12817
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git

commit 366668af55249d0f5d3a3c5a3cd7617f34cf4af8
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Jun 3 15:09:51 2025 +0200

    SLING-12817 - Update to parent pom 62
    
    Reformat using mvn spotless:apply
---
 pom.xml                                            | 442 ++++++++--------
 .../sling/auth/oauth_client/ClientConnection.java  |  38 +-
 .../sling/auth/oauth_client/OAuthTokenAccess.java  |  63 ++-
 .../auth/oauth_client/OAuthTokenResponse.java      |  56 +-
 .../sling/auth/oauth_client/impl/Converter.java    |  89 ++--
 .../oauth_client/impl/CryptoOAuthStateManager.java |  51 +-
 .../impl/JcrUserHomeOAuthTokenStore.java           |  93 ++--
 .../oauth_client/impl/OAuthCallbackException.java  |  28 +-
 .../oauth_client/impl/OAuthCallbackServlet.java    | 161 +++---
 .../oauth_client/impl/OAuthConnectionImpl.java     |  47 +-
 .../auth/oauth_client/impl/OAuthCookieValue.java   |  64 ++-
 .../impl/OAuthEntryPointException.java             |  28 +-
 .../oauth_client/impl/OAuthEntryPointServlet.java  |  79 +--
 .../auth/oauth_client/impl/OAuthException.java     |  27 +-
 .../auth/oauth_client/impl/OAuthFlowException.java |  34 +-
 .../auth/oauth_client/impl/OAuthStateManager.java  |  35 +-
 .../sling/auth/oauth_client/impl/OAuthToken.java   |  32 +-
 .../oauth_client/impl/OAuthTokenRefresher.java     |  36 +-
 .../oauth_client/impl/OAuthTokenRefresherImpl.java |  99 ++--
 .../auth/oauth_client/impl/OAuthTokenStore.java    |  51 +-
 .../sling/auth/oauth_client/impl/OAuthTokens.java  |  28 +-
 .../sling/auth/oauth_client/impl/OAuthUris.java    |  45 +-
 .../impl/OidcAuthenticationException.java          |  27 +-
 .../impl/OidcAuthenticationHandler.java            | 263 +++++-----
 .../auth/oauth_client/impl/OidcConnectionImpl.java |  62 ++-
 .../oauth_client/impl/OidcIdentityProvider.java    |  81 +--
 .../impl/OidcProviderMetadataRegistry.java         |  37 +-
 .../sling/auth/oauth_client/impl/OidcTokens.java   |  31 +-
 .../auth/oauth_client/impl/RedirectHelper.java     |  72 +--
 .../auth/oauth_client/impl/RedirectTarget.java     |  33 +-
 .../oauth_client/impl/RedisOAuthTokenStore.java    |  98 ++--
 .../auth/oauth_client/impl/ResolvedConnection.java |  43 +-
 .../oauth_client/impl/ResolvedOAuthConnection.java |  59 ++-
 .../oauth_client/impl/ResolvedOidcConnection.java  |  74 ++-
 .../oauth_client/impl/SlingLoginCookieManager.java |  87 ++--
 .../impl/SlingUserInfoProcessorImpl.java           |  68 +--
 .../auth/oauth_client/impl/TokenAccessImpl.java    |  82 +--
 .../sling/auth/oauth_client/impl/TokenState.java   |  30 +-
 .../sling/auth/oauth_client/impl/TokenStore.java   |  79 +--
 .../auth/oauth_client/spi/LoginCookieManager.java  |  49 +-
 .../auth/oauth_client/spi/OidcAuthCredentials.java |  72 ++-
 .../auth/oauth_client/spi/UserInfoProcessor.java   |  20 +-
 .../support/OAuthEnabledSlingServlet.java          | 214 ++++----
 .../auth/oauth_client/AuthorizationCodeFlowIT.java | 454 +++++++++-------
 .../auth/oauth_client/InMemoryOAuthTokenStore.java |  66 +--
 .../sling/auth/oauth_client/OAuthUrisTest.java     |  51 +-
 .../auth/oauth_client/TokenAccessImplTest.java     | 170 +++---
 .../auth/oauth_client/impl/ConverterTest.java      | 104 ++--
 .../impl/CryptoOAuthCookieValueManagerTest.java    |  68 ++-
 .../impl/InMemoryOAuthTokenStoreTest.java          |  27 +-
 .../impl/JcrUserHomeOAuthTokenStoreTest.java       |  65 ++-
 .../auth/oauth_client/impl/MockOidcConnection.java |  90 +++-
 .../sling/auth/oauth_client/impl/MockRequest.java  |  31 +-
 .../sling/auth/oauth_client/impl/MockResponse.java |  34 +-
 .../impl/OAuthCallbackServletTest.java             | 206 ++++----
 .../impl/OAuthEntryPointServletTest.java           | 109 ++--
 .../auth/oauth_client/impl/OAuthTokenTest.java     |  30 +-
 .../impl/OidcAuthenticationHandlerTest.java        | 569 ++++++++++++---------
 .../impl/OidcIdentityProviderTest.java             |  57 ++-
 .../auth/oauth_client/impl/RedirectHelperTest.java |  28 +-
 .../impl/RedisOAuthTokenStoreTest.java             |  40 +-
 .../impl/SlingLoginCookieManagerTest.java          |  61 +--
 .../auth/oauth_client/impl/StubCryptoService.java  |  33 +-
 .../oauth_client/impl/StubCryptoServiceTest.java   |  33 +-
 .../oauth_client/impl/StubOAuthStateManager.java   |  30 +-
 .../auth/oauth_client/impl/TokenStoreTest.java     |  39 +-
 .../oauth_client/impl/TokenStoreTestSupport.java   | 175 ++++---
 .../itbundle/DecryptOAuthTokenServlet.java         |  79 +--
 .../auth/oauth_client/itbundle/SupportBundle.java  |  58 +--
 .../support/OAuthEnabledSlingServletTest.java      | 193 ++++---
 70 files changed, 3311 insertions(+), 2796 deletions(-)

diff --git a/pom.xml b/pom.xml
index 516f32f..0347a29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,235 +23,29 @@
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
         <version>62</version>
-        <relativePath/>
+        <relativePath />
     </parent>
 
-	<artifactId>org.apache.sling.auth.oauth-client</artifactId>
-	<version>0.1.1-SNAPSHOT</version>
+    <artifactId>org.apache.sling.auth.oauth-client</artifactId>
+    <version>0.1.1-SNAPSHOT</version>
 
-	<name>Apache Sling OAuth Client</name>
-	<description>Apache Sling OAuth 2.0 client with OIDC support</description>
-
-    <properties>
-        <sling.java.version>11</sling.java.version>
-        <project.build.outputTimestamp>1747146729</project.build.outputTimestamp>
-        <bnd.baseline.skip>true</bnd.baseline.skip>
-        <it.startTimeoutSeconds>60</it.startTimeoutSeconds>
-	</properties>
+    <name>Apache Sling OAuth Client</name>
+    <description>Apache Sling OAuth 2.0 client with OIDC support</description>
 
     <scm>
         <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git</connection>
         <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git</developerConnection>
+        <tag>org.apache.sling.auth.oauth-client-0.1.0</tag>
         <url>https://github.com/apache/sling-org-apache-sling-auth-oauth-client.git</url>
-      <tag>org.apache.sling.auth.oauth-client-0.1.0</tag>
-  </scm>
+    </scm>
 
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>biz.aQute.bnd</groupId>
-				<artifactId>bnd-maven-plugin</artifactId>
-			</plugin>
-            <plugin>
-               <artifactId>maven-failsafe-plugin</artifactId>
-               <executions>
-                   <execution>
-                       <goals>
-                           <goal>integration-test</goal>
-                           <goal>verify</goal>
-                       </goals>
-                   </execution>
-               </executions>
-               <configuration>
-                   <systemPropertyVariables>
-                       <sling.http.port>${http.port}</sling.http.port>
-                   </systemPropertyVariables>
-               </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.sling</groupId>
-                <artifactId>slingfeature-maven-plugin</artifactId>
-                <version>1.9.2</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <skipAddFeatureDependencies>true</skipAddFeatureDependencies>
-                    <framework>
-                        <groupId>org.apache.felix</groupId>
-                        <artifactId>org.apache.felix.framework</artifactId>
-                        <version>7.0.5</version>
-                    </framework>
-
-                    <!--
-                        Prepares a feature model aggregate that takes the following features from
-                        the Sling Starter:
-                        - nosample_base - the base Sling Starter
-                        - oak_persistence_sns - SegmentNodeStore persistence for Oak
-                        - composum - The Composum Nodes administration tool
-                        Notably missing are the slingshot and starter samples
-                     -->
-                    <aggregates>
-                        <aggregate>
-                            <classifier>app</classifier>
-                            <filesInclude>main.json</filesInclude>
-                            <attach>false</attach>
-                            <includeArtifact>
-                                <groupId>org.apache.sling</groupId>
-                                <artifactId>org.apache.sling.starter</artifactId>
-                                <classifier>nosample_base</classifier>
-                                <version>13</version>
-                                <type>slingosgifeature</type>
-                            </includeArtifact>
-                            <includeArtifact>
-                                <groupId>org.apache.sling</groupId>
-                                <artifactId>org.apache.sling.starter</artifactId>
-                                <classifier>oak_persistence_sns</classifier>
-                                <version>13</version>
-                                <type>slingosgifeature</type>
-                            </includeArtifact>
-                            <includeArtifact>
-                                <groupId>org.apache.sling</groupId>
-                                <artifactId>org.apache.sling.starter</artifactId>
-                                <classifier>starter</classifier>
-                                <version>13</version>
-                                <type>slingosgifeature</type>
-                            </includeArtifact>
-                            <includeArtifact>
-                                <groupId>org.apache.sling</groupId>
-                                <artifactId>org.apache.sling.starter</artifactId>
-                                <classifier>composum</classifier>
-                                <version>13</version>
-                                <type>slingosgifeature</type>
-                            </includeArtifact>
-                        </aggregate>
-                    </aggregates>
-                    <repositories>
-                        <repository>
-                            <includeClassifier>app</includeClassifier>
-                        </repository>
-                    </repositories>
-                    <scans>
-                        <scan>
-                            <includeClassifier>app</includeClassifier>
-                        </scan>
-                    </scans>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>prepare-features</id>
-                        <phase>prepare-package</phase>
-                        <goals>
-                            <goal>aggregate-features</goal>
-                            <goal>analyse-features</goal>
-                            <goal>attach-features</goal>
-                        </goals>
-                    </execution>
-                    <execution>
-                        <id>create-app-repository</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>repository</goal>
-                        </goals>
-                    </execution>
-               </executions>
-            </plugin>
-            <!-- reserve network ports for the integration tests -->
-            <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>pre-integration-test</phase>
-                        <configuration>
-                            <portNames>
-                                <portName>http.port</portName>
-                            </portNames>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>prepare-feature-launcher</id>
-                        <goals>
-                            <goal>unpack</goal>
-                        </goals>
-                        <phase>package</phase>
-                        <configuration>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>org.apache.sling</groupId>
-                                    <artifactId>org.apache.sling.feature.launcher</artifactId>
-                                    <version>1.2.4</version>
-                                    <type>tar.gz</type>
-                                    <!-- remove the version number from the unpacked folder -->
-                                    <fileMappers>
-                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
-                                            <pattern>\Qorg.apache.sling.feature.launcher-1.2.4\E</pattern>
-                                            <replacement>org.apache.sling.feature.launcher</replacement>
-                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
-                                    </fileMappers>
-                                </artifactItem>
-                            </artifactItems>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.sling</groupId>
-                <artifactId>feature-launcher-maven-plugin</artifactId>
-                <version>0.1.8</version>
-                <configuration>
-                    <launches>
-                        <launch>
-                            <id>sling-starter-oak-tar</id>
-                            <skip>${skipITs}</skip>
-                            <featureFile>${project.slingfeature.outputDirectory}/feature-app.json</featureFile>
-                            <repositoryUrls>
-                                <repositoryUrl>file://${project.build.directory}/artifacts</repositoryUrl>
-                            </repositoryUrls>
-                            <launcherArguments>
-                                <!-- <vm-options>
-                                    <value>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:3007</value>
-                                </vm-options> -->
-                                <frameworkProperties>
-                                    <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port>
-                                </frameworkProperties>
-                            </launcherArguments>
-                            <environmentVariables>
-                                <IT_ENCRYPTION_PASSWORD>random</IT_ENCRYPTION_PASSWORD>
-                            </environmentVariables>
-                            <startTimeoutSeconds>${it.startTimeoutSeconds}</startTimeoutSeconds>
-                        </launch>
-                    </launches>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>start</goal>
-                            <goal>stop</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.rat</groupId>
-                <artifactId>apache-rat-plugin</artifactId>
-                <version>0.14</version>
-                <configuration>
-                    <excludes>
-                        <exclude>keycloak-data/**</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-		</plugins>
-	</build>
-	<dependencies>
+    <properties>
+        <sling.java.version>11</sling.java.version>
+        <project.build.outputTimestamp>1747146729</project.build.outputTimestamp>
+        <bnd.baseline.skip>true</bnd.baseline.skip>
+        <it.startTimeoutSeconds>60</it.startTimeoutSeconds>
+    </properties>
+    <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.service.component.annotations</artifactId>
@@ -319,7 +113,7 @@
             <version>5.0.0</version>
             <scope>provided</scope>
         </dependency>
-        
+
         <!-- test dependencies -->
         <dependency>
             <groupId>org.junit.jupiter</groupId>
@@ -458,4 +252,210 @@
             <scope>compile</scope>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <configuration>
+                    <systemPropertyVariables>
+                        <sling.http.port>${http.port}</sling.http.port>
+                    </systemPropertyVariables>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>slingfeature-maven-plugin</artifactId>
+                <version>1.9.2</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <skipAddFeatureDependencies>true</skipAddFeatureDependencies>
+                    <framework>
+                        <groupId>org.apache.felix</groupId>
+                        <artifactId>org.apache.felix.framework</artifactId>
+                        <version>7.0.5</version>
+                    </framework>
+
+                    <!--
+                        Prepares a feature model aggregate that takes the following features from
+                        the Sling Starter:
+                        - nosample_base - the base Sling Starter
+                        - oak_persistence_sns - SegmentNodeStore persistence for Oak
+                        - composum - The Composum Nodes administration tool
+                        Notably missing are the slingshot and starter samples
+                     -->
+                    <aggregates>
+                        <aggregate>
+                            <classifier>app</classifier>
+                            <filesInclude>main.json</filesInclude>
+                            <attach>false</attach>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>nosample_base</classifier>
+                                <version>13</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>oak_persistence_sns</classifier>
+                                <version>13</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>starter</classifier>
+                                <version>13</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                            <includeArtifact>
+                                <groupId>org.apache.sling</groupId>
+                                <artifactId>org.apache.sling.starter</artifactId>
+                                <classifier>composum</classifier>
+                                <version>13</version>
+                                <type>slingosgifeature</type>
+                            </includeArtifact>
+                        </aggregate>
+                    </aggregates>
+                    <repositories>
+                        <repository>
+                            <includeClassifier>app</includeClassifier>
+                        </repository>
+                    </repositories>
+                    <scans>
+                        <scan>
+                            <includeClassifier>app</includeClassifier>
+                        </scan>
+                    </scans>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>prepare-features</id>
+                        <goals>
+                            <goal>aggregate-features</goal>
+                            <goal>analyse-features</goal>
+                            <goal>attach-features</goal>
+                        </goals>
+                        <phase>prepare-package</phase>
+                    </execution>
+                    <execution>
+                        <id>create-app-repository</id>
+                        <goals>
+                            <goal>repository</goal>
+                        </goals>
+                        <phase>package</phase>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- reserve network ports for the integration tests -->
+            <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>pre-integration-test</phase>
+                        <configuration>
+                            <portNames>
+                                <portName>http.port</portName>
+                            </portNames>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>prepare-feature-launcher</id>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.sling</groupId>
+                                    <artifactId>org.apache.sling.feature.launcher</artifactId>
+                                    <version>1.2.4</version>
+                                    <type>tar.gz</type>
+                                    <!-- remove the version number from the unpacked folder -->
+                                    <fileMappers>
+                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
+                                            <pattern>\Qorg.apache.sling.feature.launcher-1.2.4\E</pattern>
+                                            <replacement>org.apache.sling.feature.launcher</replacement>
+                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
+                                    </fileMappers>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>feature-launcher-maven-plugin</artifactId>
+                <version>0.1.8</version>
+                <configuration>
+                    <launches>
+                        <launch>
+                            <id>sling-starter-oak-tar</id>
+                            <skip>${skipITs}</skip>
+                            <featureFile>${project.slingfeature.outputDirectory}/feature-app.json</featureFile>
+                            <repositoryUrls>
+                                <repositoryUrl>file://${project.build.directory}/artifacts</repositoryUrl>
+                            </repositoryUrls>
+                            <launcherArguments>
+                                <!-- <vm-options>
+                                    <value>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:3007</value>
+                                </vm-options> -->
+                                <frameworkProperties>
+                                    <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port>
+                                </frameworkProperties>
+                            </launcherArguments>
+                            <environmentVariables>
+                                <IT_ENCRYPTION_PASSWORD>random</IT_ENCRYPTION_PASSWORD>
+                            </environmentVariables>
+                            <startTimeoutSeconds>${it.startTimeoutSeconds}</startTimeoutSeconds>
+                        </launch>
+                    </launches>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <version>0.14</version>
+                <configuration>
+                    <excludes>
+                        <exclude>keycloak-data/**</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/ClientConnection.java b/src/main/java/org/apache/sling/auth/oauth_client/ClientConnection.java
index 0851db8..9c10069 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/ClientConnection.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/ClientConnection.java
@@ -1,31 +1,34 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
 import org.jetbrains.annotations.NotNull;
+
 /**
  * Identifies an OAuth or OIDC connection
- * 
+ *
  * <p>Used in the public API to identify the client connection for which to retrieve or clear tokens.</p>
- * 
+ *
  * <p>Connections are published as OSGi services and should be retrieved using the <code>name</code> property.</p>
- * 
+ *
  * <pre>{@code private @Reference(target = "(name=my-connection-name)")} ClientConnection connection;}</pre>
- * 
+ *
  * @see OAuthTokenAccess
  */
 public interface ClientConnection {
@@ -33,5 +36,6 @@ public interface ClientConnection {
     /**
      * @return the name of the connection
      */
-    @NotNull String name();
+    @NotNull
+    String name();
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenAccess.java b/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenAccess.java
index 727e544..bd102a6 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenAccess.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenAccess.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
@@ -23,10 +25,10 @@ import org.jetbrains.annotations.NotNull;
 
 /**
  * Entry point for accessing and clearing OAuth access tokens
- * 
- * <p>The tokens are stored distinctly for each client connection and user. The client connection is identified by 
+ *
+ * <p>The tokens are stored distinctly for each client connection and user. The client connection is identified by
  * {@link ClientConnection#name() name} and the user is identified by the {@link ResourceResolver#getUserID() user id}. </p>
- * 
+ *
  * <p>The storage strategy may vary and is controlled by the currently active implementation of the {@link OAuthTokenStore}.</p>
  */
 @NotNull
@@ -34,39 +36,44 @@ public interface OAuthTokenAccess {
 
     /**
      * Retrieves an existing access, valid, access token from storage.
-     * 
+     *
      * <p>Refreshes expired access tokens if a refresh token is available but does not attempt to retrieve new access tokens.</p>
-     * 
+     *
      * @param connection the client connection to retrieve token for
      * @param request the request used to determine the current user for which to retrieve the token and to build the redirect URL
      * @param redirectPath the path to redirect to after completing the OAuth flow
      * @return the token response
      */
-    @NotNull OAuthTokenResponse getAccessToken(@NotNull ClientConnection connection, @NotNull SlingHttpServletRequest request, 
-                                               @NotNull String redirectPath);
+    @NotNull
+    OAuthTokenResponse getAccessToken(
+            @NotNull ClientConnection connection,
+            @NotNull SlingHttpServletRequest request,
+            @NotNull String redirectPath);
 
     /**
      * Clears the access token for the given connection and user, as identified by the request.
-     * 
+     *
      * <p>Returns a response that does not have a valid token and contains a URI to redirect the user to.</p>
-     * 
+     *
      * @param connection the client connection to clear the token for
      * @param request the request used to determine the current user for which to retrieve the token and to build the redirect URL
-     * @param redirectPath the path to redirect to after completing the OAuth flow 
+     * @param redirectPath the path to redirect to after completing the OAuth flow
      * @return the token response
      */
-    @NotNull OAuthTokenResponse clearAccessToken(@NotNull ClientConnection connection, @NotNull SlingHttpServletRequest request, 
-                                                 @NotNull String redirectPath);
+    @NotNull
+    OAuthTokenResponse clearAccessToken(
+            @NotNull ClientConnection connection,
+            @NotNull SlingHttpServletRequest request,
+            @NotNull String redirectPath);
 
     /**
      * Clears the access token for the given connection and user, as identified by the resource resolver
-     * 
+     *
      * <p>For scenarios where a redirect URI should be generated after clearing the access token {@link #clearAccessToken(ClientConnection, SlingHttpServletRequest, String)}
      * should be used instead.</p>
-     * 
+     *
      * @param connection the client connection to clear the token for
      * @param resolver used to determine the current user for which to retrieve the token
      */
     void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver);
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenResponse.java b/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenResponse.java
index b8c664a..f2ccbe5 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenResponse.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/OAuthTokenResponse.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
@@ -25,25 +27,28 @@ import org.jetbrains.annotations.NotNull;
 
 /**
  * Encapsulates the response to a token request.
- * 
+ *
  * <p>This class has two top-level states:</p>
  * <ol>
  *   <li>has a valid access token: {@link #hasValidToken()} returns {@code true}, and {@link #getTokenValue()} returns the token value.</li>
  *   <li>does not have a valid access token: {@link #hasValidToken()} returns {@code false}, and {@link #getRedirectUri()} returns the URI to redirect the user to.</li>
  * </ol>
- * 
+ *
  * <p>Methods generally throw {@link IllegalStateException} if they are called in an unexpected state and do not return null values.</p>
  */
 @NotNull
 public class OAuthTokenResponse {
-    
+
     private final Optional<String> token;
     private final ClientConnection connection;
     private final SlingHttpServletRequest request;
     private final String redirectPath;
-    
-    public OAuthTokenResponse(@NotNull Optional<String> token, @NotNull ClientConnection connection, 
-                              @NotNull SlingHttpServletRequest request, @NotNull String redirectPath) {
+
+    public OAuthTokenResponse(
+            @NotNull Optional<String> token,
+            @NotNull ClientConnection connection,
+            @NotNull SlingHttpServletRequest request,
+            @NotNull String redirectPath) {
         this.token = token;
         this.connection = connection;
         this.request = request;
@@ -52,27 +57,26 @@ public class OAuthTokenResponse {
 
     /**
      * Returns true if a valid access token is present and false otherwise
-     * 
+     *
      * @return true if a valid access token is present
      */
     public boolean hasValidToken() {
         return token.isPresent();
     }
-    
-    
+
     /**
      * Returns a valid access token value and throws an {@link IllegalStateException} otherwise
-     * 
+     *
      * @return a valid access token value
      * @throws IllegalStateException if no access token is present
      */
     public @NotNull String getTokenValue() {
         return token.orElseThrow(() -> new IllegalStateException("No access token present."));
     }
-    
+
     /**
      * Returns the URI to redirect the user to in order to start the OAuth flow
-     * 
+     *
      * @return the URI to redirect the user to
      * @throws IllegalStateException if an access token is present
      */
@@ -80,7 +84,7 @@ public class OAuthTokenResponse {
         if (token.isPresent()) {
             throw new IllegalStateException("Access token is present, will not generate a new redirect URI.");
         }
-        
+
         return OAuthUris.getOAuthEntryPointUri(connection, request, redirectPath);
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/Converter.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/Converter.java
index fc12eff..800052b 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/Converter.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/Converter.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -26,43 +28,60 @@ public class Converter {
 
     public static @NotNull OIDCTokens toNimbusOidcTokens(@NotNull OidcTokens tokens) {
         OIDCTokens nimbusTokens;
-        RefreshToken nimbusRefreshToken = tokens.refreshToken() != null ? new RefreshToken(tokens.refreshToken()) : null;
+        RefreshToken nimbusRefreshToken =
+                tokens.refreshToken() != null ? new RefreshToken(tokens.refreshToken()) : null;
         BearerAccessToken nimbusAccessToken = new BearerAccessToken(tokens.accessToken(), tokens.expiresAt(), null);
-        if ( tokens.idToken() != null ) {
-            nimbusTokens = new OIDCTokens(tokens.idToken(), nimbusAccessToken, nimbusRefreshToken); 
+        if (tokens.idToken() != null) {
+            nimbusTokens = new OIDCTokens(tokens.idToken(), nimbusAccessToken, nimbusRefreshToken);
         } else {
             nimbusTokens = new OIDCTokens(nimbusAccessToken, nimbusRefreshToken);
         }
-        
+
         return nimbusTokens;
     }
-    
+
     public static @NotNull OidcTokens toApiOidcTokens(@NotNull OIDCTokens nimbusTokens) {
-        String accessToken = nimbusTokens.getAccessToken() != null ? nimbusTokens.getAccessToken().getValue() : null;
-        long expiresAt = nimbusTokens.getAccessToken() != null ? nimbusTokens.getAccessToken().getLifetime() : 0;
-        String refreshToken = nimbusTokens.getRefreshToken() != null ? nimbusTokens.getRefreshToken().getValue() : null;
+        String accessToken = nimbusTokens.getAccessToken() != null
+                ? nimbusTokens.getAccessToken().getValue()
+                : null;
+        long expiresAt = nimbusTokens.getAccessToken() != null
+                ? nimbusTokens.getAccessToken().getLifetime()
+                : 0;
+        String refreshToken = nimbusTokens.getRefreshToken() != null
+                ? nimbusTokens.getRefreshToken().getValue()
+                : null;
         String idToken = nimbusTokens.getIDTokenString();
-        
+
         return new OidcTokens(accessToken, expiresAt, refreshToken, idToken);
     }
-    
+
     public static @NotNull OAuthTokens toSlingOAuthTokens(@NotNull OIDCTokens nimbusTokens) {
-        String accessToken = nimbusTokens.getAccessToken() != null ? nimbusTokens.getAccessToken().getValue() : null;
-        long expiresAt = nimbusTokens.getAccessToken() != null ? nimbusTokens.getAccessToken().getLifetime() : 0;
-        String refreshToken = nimbusTokens.getRefreshToken() != null ? nimbusTokens.getRefreshToken().getValue() : null;
-        
-        return new OAuthTokens(accessToken, expiresAt, refreshToken);    
+        String accessToken = nimbusTokens.getAccessToken() != null
+                ? nimbusTokens.getAccessToken().getValue()
+                : null;
+        long expiresAt = nimbusTokens.getAccessToken() != null
+                ? nimbusTokens.getAccessToken().getLifetime()
+                : 0;
+        String refreshToken = nimbusTokens.getRefreshToken() != null
+                ? nimbusTokens.getRefreshToken().getValue()
+                : null;
+
+        return new OAuthTokens(accessToken, expiresAt, refreshToken);
     }
-    
+
     public static @NotNull OAuthTokens toSlingOAuthTokens(@NotNull Tokens oAuthTokens) {
-        String accessToken = oAuthTokens.getAccessToken() != null ? oAuthTokens.getAccessToken().getValue() : null;
-        long expiresAt = oAuthTokens.getAccessToken() != null ? oAuthTokens.getAccessToken().getLifetime() : 0;
-        String refreshToken = oAuthTokens.getRefreshToken() != null ? oAuthTokens.getRefreshToken().getValue() : null;
+        String accessToken = oAuthTokens.getAccessToken() != null
+                ? oAuthTokens.getAccessToken().getValue()
+                : null;
+        long expiresAt = oAuthTokens.getAccessToken() != null
+                ? oAuthTokens.getAccessToken().getLifetime()
+                : 0;
+        String refreshToken = oAuthTokens.getRefreshToken() != null
+                ? oAuthTokens.getRefreshToken().getValue()
+                : null;
 
         return new OAuthTokens(accessToken, expiresAt, refreshToken);
     }
-    
-    private Converter() {
-        
-    }
+
+    private Converter() {}
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthStateManager.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthStateManager.java
index ef4aae1..1077502 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthStateManager.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthStateManager.java
@@ -1,23 +1,26 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 import java.util.Optional;
 
+import com.nimbusds.oauth2.sdk.id.State;
 import org.apache.sling.commons.crypto.CryptoService;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -27,14 +30,9 @@ import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.nimbusds.oauth2.sdk.id.State;
-
 @Component(
         service = OAuthStateManager.class,
-        property = {
-                "service.ranking:Integer=10"
-        }
-)
+        property = {"service.ranking:Integer=10"})
 public class CryptoOAuthStateManager implements OAuthStateManager {
 
     private static final Logger logger = LoggerFactory.getLogger(CryptoOAuthStateManager.class);
@@ -44,7 +42,7 @@ public class CryptoOAuthStateManager implements OAuthStateManager {
     public CryptoOAuthStateManager(@Reference CryptoService cryptoService) {
         this.cryptoService = cryptoService;
     }
-    
+
     @Override
     public @NotNull State toNimbusState(@NotNull OAuthCookieValue state) {
 
@@ -60,19 +58,16 @@ public class CryptoOAuthStateManager implements OAuthStateManager {
     @Override
     public @NotNull Optional<OAuthCookieValue> toOAuthState(@Nullable State state) {
 
-        if ( state == null )
-            return Optional.empty();
-        
+        if (state == null) return Optional.empty();
+
         try {
             String encrypted = state.getValue();
-            
+
             String rawState = cryptoService.decrypt(encrypted);
-            
+
             String[] parts = rawState.split("\\|");
-            if (parts.length == 2)
-                return Optional.of(new OAuthCookieValue(parts[0], parts[1], null));
-            else if (parts.length == 3)
-                return Optional.of(new OAuthCookieValue(parts[0], parts[1], parts[2]));
+            if (parts.length == 2) return Optional.of(new OAuthCookieValue(parts[0], parts[1], null));
+            else if (parts.length == 3) return Optional.of(new OAuthCookieValue(parts[0], parts[1], parts[2]));
 
             logger.warn("Decoded state token does not contain the expected number of parts");
             return Optional.empty();
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStore.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStore.java
index 9ffb07d..d51df3f 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStore.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStore.java
@@ -1,38 +1,38 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.osgi.service.component.annotations.ConfigurationPolicy.REQUIRE;
-
-import java.time.ZonedDateTime;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 
+import java.time.ZonedDateTime;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.auth.oauth_client.ClientConnection;
-import org.jetbrains.annotations.NotNull;
 import org.apache.sling.commons.crypto.CryptoService;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
@@ -40,24 +40,27 @@ import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.osgi.service.component.annotations.ConfigurationPolicy.REQUIRE;
+
 // a config class is intentionally not defined, but a config is required to select an implementation
 @Component(configurationPolicy = REQUIRE)
 public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
-    
+
     private static final String PROPERTY_NAME_EXPIRES_AT = "expires_at";
     private static final String PROPERTY_NAME_REFRESH_TOKEN = "refresh_token";
 
     private static final Logger logger = LoggerFactory.getLogger(JcrUserHomeOAuthTokenStore.class);
-    
+
     private final CryptoService cryptoService;
-    
+
     @Activate
     public JcrUserHomeOAuthTokenStore(@Reference CryptoService cryptoService) {
         this.cryptoService = cryptoService;
     }
 
     @Override
-    public @NotNull OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) {
+    public @NotNull OAuthToken getAccessToken(
+            @NotNull ClientConnection connection, @NotNull ResourceResolver resolver) {
         try {
             User user = adaptToUser(resolver);
             Value[] expiresAt = user.getProperty(propertyPath(connection, PROPERTY_NAME_EXPIRES_AT));
@@ -77,22 +80,25 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
         }
     }
 
-    private @NotNull OAuthToken getToken(@NotNull ClientConnection connection, @NotNull User user, @NotNull String propertyName) throws RepositoryException {
+    private @NotNull OAuthToken getToken(
+            @NotNull ClientConnection connection, @NotNull User user, @NotNull String propertyName)
+            throws RepositoryException {
 
         Value[] tokenValue = user.getProperty(propertyPath(connection, propertyName));
-        if ( tokenValue == null )
-            return new OAuthToken(TokenState.MISSING, null);
+        if (tokenValue == null) return new OAuthToken(TokenState.MISSING, null);
 
-        if ( tokenValue.length != 1)
-            throw new OAuthException(String.format("Unexpected value count %d for token property %s" , tokenValue.length, propertyName));
+        if (tokenValue.length != 1)
+            throw new OAuthException(
+                    String.format("Unexpected value count %d for token property %s", tokenValue.length, propertyName));
 
         String encryptedValue = tokenValue[0].getString();
-        
+
         return new OAuthToken(TokenState.VALID, cryptoService.decrypt(encryptedValue));
     }
-    
+
     @Override
-    public @NotNull OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) {
+    public @NotNull OAuthToken getRefreshToken(
+            @NotNull ClientConnection connection, @NotNull ResourceResolver resolver) {
         try {
             User user = adaptToUser(resolver);
             return getToken(connection, user, PROPERTY_NAME_REFRESH_TOKEN);
@@ -100,9 +106,10 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
             throw new OAuthException(e);
         }
     }
-    
+
     @Override
-    public void persistTokens(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens) {
+    public void persistTokens(
+            @NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens) {
         try {
             User user = adaptToUser(resolver);
             Session session = adaptToSession(resolver);
@@ -110,7 +117,7 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
 
             setTokenProperty(user, vf, propertyPath(connection, PROPERTY_NAME_ACCESS_TOKEN), tokens.accessToken());
             setTokenProperty(user, vf, propertyPath(connection, PROPERTY_NAME_REFRESH_TOKEN), tokens.refreshToken());
-            
+
             ZonedDateTime expiry = null;
             long expiresAt = tokens.expiresAt();
             if (expiresAt > 0) {
@@ -128,9 +135,10 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
             throw new OAuthException(e);
         }
     }
-    
+
     @Override
-    public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
+    public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
         try {
             User currentUser = adaptToUser(resolver);
 
@@ -143,8 +151,13 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
             throw new OAuthException(e);
         }
     }
-    
-    private void setTokenProperty(@NotNull User user, @NotNull ValueFactory valueFactory, @NotNull String propertyPath, @Nullable String value) throws RepositoryException {
+
+    private void setTokenProperty(
+            @NotNull User user,
+            @NotNull ValueFactory valueFactory,
+            @NotNull String propertyPath,
+            @Nullable String value)
+            throws RepositoryException {
         if (value != null) {
             user.setProperty(propertyPath, createTokenValue(valueFactory, value));
         } else {
@@ -153,7 +166,7 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
             user.removeProperty(propertyPath);
         }
     }
-    
+
     private @NotNull Value createTokenValue(@NotNull ValueFactory valueFactory, @NotNull String propertyValue) {
         String encryptedValue = cryptoService.encrypt(propertyValue);
         return valueFactory.createValue(encryptedValue);
@@ -166,7 +179,7 @@ public class JcrUserHomeOAuthTokenStore implements OAuthTokenStore {
     private static @NotNull String nodePath(@NotNull ClientConnection connection) {
         return "oauth-tokens/" + connection.name();
     }
-    
+
     private static @NotNull User adaptToUser(@NotNull ResourceResolver resolver) {
         User user = resolver.adaptTo(User.class);
         if (user == null) {
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackException.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackException.java
index 5159c8e..66c0af8 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackException.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackException.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -20,7 +22,7 @@ package org.apache.sling.auth.oauth_client.impl;
  * Signals that an exceptional condition has occurred while processing an OAuth callback
  */
 public class OAuthCallbackException extends OAuthFlowException {
-    
+
     private static final long serialVersionUID = 1L;
 
     public OAuthCallbackException(String userFacingMessage, Throwable cause) {
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServlet.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServlet.java
index 801dfc8..6a83037 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServlet.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServlet.java
@@ -1,22 +1,28 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.osgi.service.component.annotations.ReferencePolicyOption.GREEDY;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 import java.net.URI;
@@ -29,26 +35,6 @@ import java.util.Optional;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.servlets.SlingAllMethodsServlet;
-import org.apache.sling.auth.core.AuthConstants;
-import org.apache.sling.auth.oauth_client.ClientConnection;
-import org.apache.sling.commons.crypto.CryptoService;
-import org.apache.sling.servlets.annotations.SlingServletPaths;
-import org.jetbrains.annotations.NotNull;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import com.nimbusds.oauth2.sdk.AuthorizationCode;
 import com.nimbusds.oauth2.sdk.AuthorizationCodeGrant;
 import com.nimbusds.oauth2.sdk.AuthorizationErrorResponse;
@@ -63,10 +49,25 @@ import com.nimbusds.oauth2.sdk.auth.Secret;
 import com.nimbusds.oauth2.sdk.http.HTTPRequest;
 import com.nimbusds.oauth2.sdk.http.HTTPResponse;
 import com.nimbusds.oauth2.sdk.id.ClientID;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.auth.core.AuthConstants;
+import org.apache.sling.auth.oauth_client.ClientConnection;
+import org.apache.sling.commons.crypto.CryptoService;
+import org.apache.sling.servlets.annotations.SlingServletPaths;
+import org.jetbrains.annotations.NotNull;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-@Component(service = { Servlet.class },
-    property = { AuthConstants.AUTH_REQUIREMENTS +"=" + OAuthCallbackServlet.PATH }
-)
+import static org.osgi.service.component.annotations.ReferencePolicyOption.GREEDY;
+
+@Component(
+        service = {Servlet.class},
+        property = {AuthConstants.AUTH_REQUIREMENTS + "=" + OAuthCallbackServlet.PATH})
 @SlingServletPaths(OAuthCallbackServlet.PATH)
 public class OAuthCallbackServlet extends SlingAllMethodsServlet {
 
@@ -75,7 +76,7 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
     private static final long serialVersionUID = 1L;
 
     private static final Logger logger = LoggerFactory.getLogger(OAuthCallbackServlet.class);
-    
+
     private final Map<String, ClientConnection> connections;
     private final OAuthTokenStore tokenStore;
     private final OAuthStateManager stateManager;
@@ -85,49 +86,48 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
         String portFragment = "";
         boolean isNonDefaultHttpPort = request.getScheme().equals("http") && request.getServerPort() != 80;
         boolean isNonDefaultHttpsPort = request.getScheme().equals("https") && request.getServerPort() != 443;
-        if ( isNonDefaultHttpPort || isNonDefaultHttpsPort )
-            portFragment = ":" + request.getServerPort();
+        if (isNonDefaultHttpPort || isNonDefaultHttpsPort) portFragment = ":" + request.getServerPort();
 
         return request.getScheme() + "://" + request.getServerName() + portFragment + PATH;
     }
-    
+
     private static String toErrorMessage(@NotNull String context, @NotNull ErrorResponse error) {
-        
+
         ErrorObject errorObject = error.getErrorObject();
         StringBuilder message = new StringBuilder();
-        
-        message.append(context)
-            .append(": ")
-            .append(errorObject.getCode());
-        
+
+        message.append(context).append(": ").append(errorObject.getCode());
+
         message.append(". Status code: ").append(errorObject.getHTTPStatusCode());
-        
+
         String description = errorObject.getDescription();
-        if ( description != null )
-           message.append(". ").append(description);
-       
+        if (description != null) message.append(". ").append(description);
+
         return message.toString();
     }
 
     @Activate
-    public OAuthCallbackServlet(@Reference(policyOption = GREEDY) List<ClientConnection> connections, 
+    public OAuthCallbackServlet(
+            @Reference(policyOption = GREEDY) List<ClientConnection> connections,
             @Reference OAuthTokenStore tokenStore,
             @Reference OAuthStateManager stateManager,
             @Reference CryptoService cryptoService) {
-        this.connections = connections.stream()
-                .collect(Collectors.toMap( ClientConnection::name, Function.identity()));
+        this.connections = connections.stream().collect(Collectors.toMap(ClientConnection::name, Function.identity()));
         this.tokenStore = tokenStore;
         this.stateManager = stateManager;
         this.cryptoService = cryptoService;
     }
 
     @Override
-    protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws ServletException {
+    protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
+            throws ServletException {
 
         // Retrieve the cookie with persisted data for oauth
         Cookie stateCookie = request.getCookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
         if (stateCookie == null) {
-            logger.debug("Failed state check: No request cookie named '{}' found", OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
+            logger.debug(
+                    "Failed state check: No request cookie named '{}' found",
+                    OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
             response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
             return;
         }
@@ -148,7 +148,9 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
 
             if (!authResponse.indicatesSuccess()) {
                 AuthorizationErrorResponse errorResponse = authResponse.toErrorResponse();
-                throw new OAuthCallbackException("Authentication failed", new RuntimeException(toErrorMessage("Error in authentication response", errorResponse)));
+                throw new OAuthCallbackException(
+                        "Authentication failed",
+                        new RuntimeException(toErrorMessage("Error in authentication response", errorResponse)));
             }
         } catch (ParseException | URISyntaxException e) {
             logger.debug("Failed to parse authorization response", e);
@@ -165,7 +167,8 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
 
             // Compare state from the client (read from the cookie) and the server (read from the request)
             if (!stateFromAuthServer.equals(stateFromClient)) {
-                throw new IllegalStateException("Failed state check: request keys from client and server are not the same");
+                throw new IllegalStateException(
+                        "Failed state check: request keys from client and server are not the same");
             }
 
             // Retrieve the connection name from the cookie and resolve the connection
@@ -175,12 +178,13 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
             }
             ClientConnection connection = connections.get(desiredConnectionName);
             if (connection == null) {
-                throw new IllegalArgumentException(String.format("Requested unknown connection '%s'", desiredConnectionName));
+                throw new IllegalArgumentException(
+                        String.format("Requested unknown connection '%s'", desiredConnectionName));
             }
             ResolvedConnection conn = ResolvedOAuthConnection.resolve(connection);
 
             ClientID clientId = new ClientID(conn.clientId());
-            
+
             String clientSecretString = conn.clientSecret();
             if (clientSecretString == null) {
                 throw new IllegalArgumentException("No client secret found in connection");
@@ -189,31 +193,37 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
             ClientSecretBasic clientCredentials = new ClientSecretBasic(clientId, clientSecret);
 
             // Retrieve the authorization Code from request
-            String authCode = authResponse.toSuccessResponse().getAuthorizationCode().getValue();
+            String authCode =
+                    authResponse.toSuccessResponse().getAuthorizationCode().getValue();
             AuthorizationCode code = new AuthorizationCode(authCode);
 
             // Prepare the request to retrieve access token from the authorization server
             URI tokenEndpoint = new URI(conn.tokenEndpoint());
             TokenRequest tokenRequest = new TokenRequest.Builder(
-                tokenEndpoint,
-                clientCredentials,
-                new AuthorizationCodeGrant(code, new URI(getCallbackUri(request)))
-            ).build();
-            
+                            tokenEndpoint,
+                            clientCredentials,
+                            new AuthorizationCodeGrant(code, new URI(getCallbackUri(request))))
+                    .build();
+
             HTTPRequest httpRequest = tokenRequest.toHTTPRequest();
             // GitHub requires an explicitly set Accept header, otherwise the response is url encoded
             // https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github
-            // see also https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/107/support-application-x-www-form-urlencoded
+            // see also
+            // https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/107/support-application-x-www-form-urlencoded
             httpRequest.setAccept("application/json");
             HTTPResponse httpResponse = httpRequest.send();
-            
+
             TokenResponse tokenResponse = TokenResponse.parse(httpResponse);
-            
+
             if (!tokenResponse.indicatesSuccess()) {
-                throw new OAuthCallbackException("Token exchange error", new RuntimeException(toErrorMessage("Error in token response", tokenResponse.toErrorResponse())));
+                throw new OAuthCallbackException(
+                        "Token exchange error",
+                        new RuntimeException(
+                                toErrorMessage("Error in token response", tokenResponse.toErrorResponse())));
             }
-            OAuthTokens tokens = Converter.toSlingOAuthTokens(tokenResponse.toSuccessResponse().getTokens());
-            
+            OAuthTokens tokens = Converter.toSlingOAuthTokens(
+                    tokenResponse.toSuccessResponse().getTokens());
+
             tokenStore.persistTokens(connection, request.getResourceResolver(), tokens);
 
             handleRedirect(oAuthCookieValue, response);
@@ -224,13 +234,13 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
             throw new OAuthCallbackException("Internal error", e);
         } catch (ParseException e) {
             throw new OAuthCallbackException("Invalid invocation", e);
-        } catch ( OAuthCallbackException e) {
+        } catch (OAuthCallbackException e) {
             throw e;
         } catch (Exception e) {
             throw new OAuthCallbackException("Unknown error", e);
         }
     }
-    
+
     private static @NotNull String getRequestURL(@NotNull SlingHttpServletRequest request) {
         StringBuffer requestURL = request.getRequestURL();
         if (request.getQueryString() != null) {
@@ -238,8 +248,9 @@ public class OAuthCallbackServlet extends SlingAllMethodsServlet {
         }
         return requestURL.toString();
     }
-    
-    private static void handleRedirect(@NotNull OAuthCookieValue clientState, @NotNull HttpServletResponse response) throws IOException {
+
+    private static void handleRedirect(@NotNull OAuthCookieValue clientState, @NotNull HttpServletResponse response)
+            throws IOException {
         Optional<String> redirect = Optional.ofNullable(clientState.redirect());
         if (redirect.isEmpty()) {
             response.setStatus(HttpServletResponse.SC_NO_CONTENT);
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthConnectionImpl.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthConnectionImpl.java
index b196416..1987666 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthConnectionImpl.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthConnectionImpl.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -34,14 +36,22 @@ public class OAuthConnectionImpl implements ClientConnection {
     @ObjectClassDefinition(name = "OAuth connection details")
     public @interface Config {
         String name();
+
         String authorizationEndpoint();
+
         String tokenEndpoint();
+
         String clientId();
-        @AttributeDefinition(type = AttributeType.PASSWORD) String clientSecret();
+
+        @AttributeDefinition(type = AttributeType.PASSWORD)
+        String clientSecret();
+
         String[] scopes();
+
         String[] additionalAuthorizationParameters();
-        
-        String webconsole_configurationFactory_nameHint() default "Name: {name}, auth endpoint: {authorizationEndpoint}, clientId: {clientId}";
+
+        String webconsole_configurationFactory_nameHint() default
+                "Name: {name}, auth endpoint: {authorizationEndpoint}, clientId: {clientId}";
     }
 
     private final Config cfg;
@@ -50,19 +60,20 @@ public class OAuthConnectionImpl implements ClientConnection {
     public OAuthConnectionImpl(@NotNull Config cfg) {
         this.cfg = cfg;
     }
-    
+
     @Override
     public @NotNull String name() {
         return cfg.name();
     }
+
     public @NotNull String authorizationEndpoint() {
         return cfg.authorizationEndpoint();
     }
-    
+
     public @NotNull String tokenEndpoint() {
         return cfg.tokenEndpoint();
     }
-    
+
     public @NotNull String clientId() {
         return cfg.clientId();
     }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCookieValue.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCookieValue.java
index 42a293a..3f67f44 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCookieValue.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthCookieValue.java
@@ -1,37 +1,39 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import com.nimbusds.oauth2.sdk.id.State;
 import com.nimbusds.oauth2.sdk.pkce.CodeVerifier;
 import com.nimbusds.openid.connect.sdk.Nonce;
 import org.apache.sling.commons.crypto.CryptoService;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-
-import com.nimbusds.oauth2.sdk.id.State;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class OAuthCookieValue {
 
     private final @NotNull String perRequestKey;
     private final @NotNull String connectionName;
 
-    // This is NOT the callback URL, but the URL to which the user should be redirected after the OAuth flow is completed.
+    // This is NOT the callback URL, but the URL to which the user should be redirected after the OAuth flow is
+    // completed.
     private final @Nullable String redirect;
     private @Nullable Nonce nonce;
     private @Nullable CodeVerifier codeVerifier;
@@ -43,15 +45,18 @@ public class OAuthCookieValue {
     public static final int NONCE_INDEX = 3;
     public static final int CODE_VERIFIER_INDEX = 4;
 
-
     public OAuthCookieValue(@NotNull String perRequestKey, @NotNull String connectionName, @Nullable String redirect) {
         this.perRequestKey = perRequestKey;
         this.connectionName = connectionName;
         this.redirect = redirect;
     }
 
-    public OAuthCookieValue(@NotNull String perRequestKey, @NotNull String connectionName, @Nullable String redirect,
-                            @NotNull Nonce nonce, @Nullable CodeVerifier codeVerifier) {
+    public OAuthCookieValue(
+            @NotNull String perRequestKey,
+            @NotNull String connectionName,
+            @Nullable String redirect,
+            @NotNull Nonce nonce,
+            @Nullable CodeVerifier codeVerifier) {
         this.perRequestKey = perRequestKey;
         this.connectionName = connectionName;
         this.redirect = redirect;
@@ -82,9 +87,10 @@ public class OAuthCookieValue {
             this.nonce = parts[NONCE_INDEX].isEmpty() ? null : new Nonce(parts[NONCE_INDEX]);
         }
 
-        //In OIDC with PKCE we also have code verifier
+        // In OIDC with PKCE we also have code verifier
         if (parts.length > 4) {
-            this.codeVerifier = parts[CODE_VERIFIER_INDEX].isEmpty() ? null : new CodeVerifier(parts[CODE_VERIFIER_INDEX]);
+            this.codeVerifier =
+                    parts[CODE_VERIFIER_INDEX].isEmpty() ? null : new CodeVerifier(parts[CODE_VERIFIER_INDEX]);
         }
     }
 
@@ -139,10 +145,14 @@ public class OAuthCookieValue {
     }
 
     public @NotNull String getValue() {
-        return  perRequestKey + '|' +
-                connectionName + '|' +
-                (redirect == null? "": redirect) + '|' +
-                (nonce == null? "": nonce.getValue()) + '|' +
-                (codeVerifier == null ? "" : codeVerifier.getValue());
+        return perRequestKey
+                + '|'
+                + connectionName
+                + '|'
+                + (redirect == null ? "" : redirect)
+                + '|'
+                + (nonce == null ? "" : nonce.getValue())
+                + '|'
+                + (codeVerifier == null ? "" : codeVerifier.getValue());
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointException.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointException.java
index 82f22a4..b7ef9f2 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointException.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointException.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -22,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
  * Signals that an exceptional condition has occurred while starting the OAuth flow
  */
 public class OAuthEntryPointException extends OAuthFlowException {
-    
+
     private static final long serialVersionUID = 1L;
 
     public OAuthEntryPointException(@NotNull String userFacingMessage, @NotNull Throwable cause) {
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServlet.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServlet.java
index 21479c8..94e617b 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServlet.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServlet.java
@@ -1,22 +1,26 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.osgi.service.component.annotations.ReferencePolicyOption.GREEDY;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 import java.net.URI;
@@ -25,10 +29,7 @@ import java.util.Map;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-
+import com.nimbusds.oauth2.sdk.id.Identifier;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -43,54 +44,58 @@ import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.nimbusds.oauth2.sdk.id.Identifier;
+import static org.osgi.service.component.annotations.ReferencePolicyOption.GREEDY;
 
-@Component(service = { Servlet.class },
-    property = { AuthConstants.AUTH_REQUIREMENTS +"=" + OAuthEntryPointServlet.PATH }
-)
+@Component(
+        service = {Servlet.class},
+        property = {AuthConstants.AUTH_REQUIREMENTS + "=" + OAuthEntryPointServlet.PATH})
 @SlingServletPaths(OAuthEntryPointServlet.PATH)
 public class OAuthEntryPointServlet extends SlingAllMethodsServlet {
 
     private static final long serialVersionUID = 1L;
 
     public static final String PATH = "/system/sling/oauth/entry-point"; // NOSONAR
-    
+
     private final Logger logger = LoggerFactory.getLogger(getClass());
-    
+
     private final Map<String, ClientConnection> connections;
 
     private final CryptoService cryptoService;
 
     @Activate
-    public OAuthEntryPointServlet(@Reference(policyOption = GREEDY) List<ClientConnection> connections,
+    public OAuthEntryPointServlet(
+            @Reference(policyOption = GREEDY) List<ClientConnection> connections,
             @Reference CryptoService cryptoService) {
-        this.connections = connections.stream()
-                .collect(Collectors.toMap( ClientConnection::name, Function.identity()));
+        this.connections = connections.stream().collect(Collectors.toMap(ClientConnection::name, Function.identity()));
         this.cryptoService = cryptoService;
     }
 
     @Override
     protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
             throws ServletException, IOException {
-        
+
         try {
             String desiredConnectionName = request.getParameter("c");
-            if ( desiredConnectionName == null ) {
+            if (desiredConnectionName == null) {
                 logger.debug("Missing mandatory request parameter 'c'");
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST);
                 return;
             }
 
             ClientConnection connection = connections.get(desiredConnectionName);
-            if ( connection == null ) {
+            if (connection == null) {
                 if (logger.isDebugEnabled()) {
-                    logger.debug("Client requested unknown connection '{}'; known: '{}'", desiredConnectionName, connections.keySet());
+                    logger.debug(
+                            "Client requested unknown connection '{}'; known: '{}'",
+                            desiredConnectionName,
+                            connections.keySet());
                 }
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST);
                 return;
             }
-                
-            var redirect = getAuthenticationRequestUri(connection, request, URI.create(OAuthCallbackServlet.getCallbackUri(request)));
+
+            var redirect = getAuthenticationRequestUri(
+                    connection, request, URI.create(OAuthCallbackServlet.getCallbackUri(request)));
             response.addCookie(redirect.cookie());
 
             response.sendRedirect(redirect.uri().toString());
@@ -98,10 +103,9 @@ public class OAuthEntryPointServlet extends SlingAllMethodsServlet {
             throw new OAuthEntryPointException("Internal error", e);
         }
     }
-    
-    private @NotNull RedirectTarget getAuthenticationRequestUri(@NotNull ClientConnection connection, 
-                                                                @NotNull SlingHttpServletRequest request, 
-                                                                @NotNull URI callbackUri) {
+
+    private @NotNull RedirectTarget getAuthenticationRequestUri(
+            @NotNull ClientConnection connection, @NotNull SlingHttpServletRequest request, @NotNull URI callbackUri) {
         ResolvedConnection conn = ResolvedOAuthConnection.resolve(connection);
 
         // TODO: Should we redirect to the target url when redirect is null?
@@ -110,6 +114,7 @@ public class OAuthEntryPointServlet extends SlingAllMethodsServlet {
         String perRequestKey = new Identifier().getValue();
         OAuthCookieValue oAuthCookieValue = new OAuthCookieValue(perRequestKey, connection.name(), redirect);
 
-        return RedirectHelper.buildRedirectTarget(new String[]{PATH}, callbackUri, conn, oAuthCookieValue, cryptoService);
+        return RedirectHelper.buildRedirectTarget(
+                new String[] {PATH}, callbackUri, conn, oAuthCookieValue, cryptoService);
     }
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthException.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthException.java
index 4d474fe..2085d66 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthException.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthException.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -27,5 +29,4 @@ public class OAuthException extends RuntimeException {
     public OAuthException(Throwable cause) {
         super(cause);
     }
-
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthFlowException.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthFlowException.java
index ea4cc01..4fdbaec 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthFlowException.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthFlowException.java
@@ -1,28 +1,30 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import org.jetbrains.annotations.NotNull;
-
 import javax.servlet.ServletException;
 
+import org.jetbrains.annotations.NotNull;
+
 /**
  * Superclass for all OAuth exception classes that propagate as servlet exceptions
- * 
+ *
  * <p>Its intent it is simplify exception handling for implementors by allowing them to install a
  * single error handler</p>
  */
@@ -33,4 +35,4 @@ public class OAuthFlowException extends ServletException {
     public OAuthFlowException(@NotNull String userFacingMessage, @NotNull Throwable rootCause) {
         super(userFacingMessage, rootCause);
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthStateManager.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthStateManager.java
index afa805e..65e5775 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthStateManager.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthStateManager.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -23,12 +25,13 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 public interface OAuthStateManager {
-    
+
     String PARAMETER_NAME_REDIRECT = "redirect";
     String COOKIE_NAME_REQUEST_KEY = "sling.oauth-request-key";
 
-    @NotNull State toNimbusState(@NotNull OAuthCookieValue state);
-    
-    @NotNull Optional<OAuthCookieValue> toOAuthState(@Nullable State state);
+    @NotNull
+    State toNimbusState(@NotNull OAuthCookieValue state);
 
+    @NotNull
+    Optional<OAuthCookieValue> toOAuthState(@Nullable State state);
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthToken.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthToken.java
index ca746a9..f0c7fd8 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthToken.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthToken.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -21,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
 
 /**
  * Information about an OAuth token
- * 
+ *
  * <p>This class encapsulated the known information about the token. It allows the client to
  * make decisions based on the possible states.</p>
  */
@@ -49,9 +51,9 @@ public class OAuthToken {
 
     /**
      * Returns the token value
-     * 
+     *
      * @return the value, in case the {@link #getState() state} is {@code OidcTokenState#VALID} and the value is not {@code null}.
-     * @throws IllegalStateException in case the {@link #getState() state} is not {@code OidcTokenState#VALID} or if the 
+     * @throws IllegalStateException in case the {@link #getState() state} is not {@code OidcTokenState#VALID} or if the
      * value is {@code null}.
      */
     public @NotNull String getValue() {
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresher.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresher.java
index 6f20c4b..cda6cb6 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresher.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresher.java
@@ -1,36 +1,38 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 import org.apache.sling.auth.oauth_client.ClientConnection;
-
 import org.jetbrains.annotations.NotNull;
 
 public interface OAuthTokenRefresher {
 
     /**
      * Refreshes the OAuth tokens based on the supplied refresh token
-     * 
-     * <p>It is the responsibility of the invoker to persist the returned tokens.</p> 
-     * 
+     *
+     * <p>It is the responsibility of the invoker to persist the returned tokens.</p>
+     *
      * @param connection The connection to refresh the tokens for
      * @param refreshToken An existing refresh token
      * @return OAuth tokens
      * @throws OAuthException in case anything goes wrong
      */
-    @NotNull OAuthTokens refreshTokens(@NotNull ClientConnection connection, @NotNull String refreshToken) throws OAuthException;
+    @NotNull
+    OAuthTokens refreshTokens(@NotNull ClientConnection connection, @NotNull String refreshToken) throws OAuthException;
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresherImpl.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresherImpl.java
index 4b04610..2d61849 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresherImpl.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenRefresherImpl.java
@@ -1,28 +1,26 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 import java.io.IOException;
 import java.net.URI;
 
-import org.apache.sling.auth.oauth_client.ClientConnection;
-import org.jetbrains.annotations.NotNull;
-import org.osgi.service.component.annotations.Component;
-
 import com.nimbusds.oauth2.sdk.AccessTokenResponse;
 import com.nimbusds.oauth2.sdk.AuthorizationGrant;
 import com.nimbusds.oauth2.sdk.ParseException;
@@ -35,6 +33,9 @@ import com.nimbusds.oauth2.sdk.auth.Secret;
 import com.nimbusds.oauth2.sdk.id.ClientID;
 import com.nimbusds.oauth2.sdk.token.RefreshToken;
 import com.nimbusds.oauth2.sdk.token.Tokens;
+import org.apache.sling.auth.oauth_client.ClientConnection;
+import org.jetbrains.annotations.NotNull;
+import org.osgi.service.component.annotations.Component;
 
 @Component
 public class OAuthTokenRefresherImpl implements OAuthTokenRefresher {
@@ -43,38 +44,42 @@ public class OAuthTokenRefresherImpl implements OAuthTokenRefresher {
     public @NotNull OAuthTokens refreshTokens(@NotNull ClientConnection connection, @NotNull String refreshToken) {
         return Converter.toSlingOAuthTokens(refreshTokensInternal(connection, refreshToken));
     }
-    
-    private static @NotNull Tokens refreshTokensInternal(@NotNull ClientConnection connection, @NotNull String refreshTokenString) throws OAuthException {
-         try {
+
+    private static @NotNull Tokens refreshTokensInternal(
+            @NotNull ClientConnection connection, @NotNull String refreshTokenString) throws OAuthException {
+        try {
             // Construct the grant from the saved refresh token
-             RefreshToken refreshToken = new RefreshToken(refreshTokenString);
-             AuthorizationGrant refreshTokenGrant = new RefreshTokenGrant(refreshToken);
-             
-             ResolvedConnection conn = ResolvedOAuthConnection.resolve(connection);
-            
-             // The credentials to authenticate the client at the token endpoint
-             ClientID clientID = new ClientID(conn.clientId());
-             Secret clientSecret = new Secret(conn.clientSecret());
-             ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
-            
-             // The token endpoint
-             URI tokenEndpoint = URI.create(conn.tokenEndpoint());
-            
-             // Make the token request
-             TokenRequest request = new TokenRequest.Builder(tokenEndpoint, clientAuth, refreshTokenGrant).build();
-            
-             AccessTokenResponse response = AccessTokenResponse.parse(request.toHTTPRequest().send());
-            
-             if (! response.indicatesSuccess()) {
-                 // We got an error response...
-                 TokenErrorResponse errorResponse = response.toErrorResponse();
-                 throw new OAuthException("Failed refreshing the access token " + errorResponse.getErrorObject().getCode() + " : " + errorResponse.getErrorObject().getDescription());
-             }
-            
-             AccessTokenResponse successResponse = response.toSuccessResponse();
-            
-             // Get the access token, the refresh token may be updated
-             return successResponse.getTokens();
+            RefreshToken refreshToken = new RefreshToken(refreshTokenString);
+            AuthorizationGrant refreshTokenGrant = new RefreshTokenGrant(refreshToken);
+
+            ResolvedConnection conn = ResolvedOAuthConnection.resolve(connection);
+
+            // The credentials to authenticate the client at the token endpoint
+            ClientID clientID = new ClientID(conn.clientId());
+            Secret clientSecret = new Secret(conn.clientSecret());
+            ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
+
+            // The token endpoint
+            URI tokenEndpoint = URI.create(conn.tokenEndpoint());
+
+            // Make the token request
+            TokenRequest request = new TokenRequest.Builder(tokenEndpoint, clientAuth, refreshTokenGrant).build();
+
+            AccessTokenResponse response =
+                    AccessTokenResponse.parse(request.toHTTPRequest().send());
+
+            if (!response.indicatesSuccess()) {
+                // We got an error response...
+                TokenErrorResponse errorResponse = response.toErrorResponse();
+                throw new OAuthException("Failed refreshing the access token "
+                        + errorResponse.getErrorObject().getCode() + " : "
+                        + errorResponse.getErrorObject().getDescription());
+            }
+
+            AccessTokenResponse successResponse = response.toSuccessResponse();
+
+            // Get the access token, the refresh token may be updated
+            return successResponse.getTokens();
         } catch (ParseException | IOException e) {
             throw new OAuthException(e);
         }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenStore.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenStore.java
index 9c6e5a0..e58f420 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenStore.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenStore.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -33,10 +35,10 @@ import org.jetbrains.annotations.NotNull;
 
 /**
  * Storage for OAuth Tokens
- * 
+ *
  * <p>This service allows access to storing and retrieving OAuth tokens. It is the responsibility of the caller
  * to ensure that the tokens are valid.</p>
- * 
+ *
  * <p>For methods that return {@link OAuthToken}, the state must be inspected before attempting to read the value.</p>
  */
 public interface OAuthTokenStore {
@@ -44,11 +46,18 @@ public interface OAuthTokenStore {
     String PROPERTY_NAME_ACCESS_TOKEN = "access_token";
     String PROPERTY_NAME_REFRESH_TOKEN = "refresh_token";
 
-    @NotNull OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException;
-    
-    @NotNull OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException;
-    
-    void persistTokens(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens) throws OAuthException;
-    
-    void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException;
+    @NotNull
+    OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException;
+
+    @NotNull
+    OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException;
+
+    void persistTokens(
+            @NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens)
+            throws OAuthException;
+
+    void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException;
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokens.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokens.java
index 86131cb..fa20514 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokens.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthTokens.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -43,4 +45,4 @@ public class OAuthTokens {
     public String refreshToken() {
         return refreshToken;
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthUris.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthUris.java
index 067430d..4ac4595 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthUris.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OAuthUris.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -28,21 +30,24 @@ public abstract class OAuthUris {
 
     /**
      * Generates a local URI to the Sling OAuth entry point servlet
-     * 
+     *
      * <p>The URI can be used as-is to send a redirect to the user and start the OAuth flow.</p>
-     * 
+     *
      * @param connection The connection to start the OAuth flow for
      * @param request The current request
      * @param redirectPath The local redirect path to use after completing the OAuth flow
      * @return a local URI
      */
-    public static @NotNull URI getOAuthEntryPointUri(@NotNull ClientConnection connection, @NotNull SlingHttpServletRequest request, @NotNull String redirectPath) {
+    public static @NotNull URI getOAuthEntryPointUri(
+            @NotNull ClientConnection connection,
+            @NotNull SlingHttpServletRequest request,
+            @NotNull String redirectPath) {
         StringBuilder uri = new StringBuilder();
         uri.append(request.getScheme()).append("://").append(request.getServerName());
-        boolean needsExplicitPort = ( "https".equals(request.getScheme()) && request.getServerPort() != 443 )
-                || ( "http".equals(request.getScheme()) && request.getServerPort() != 80 ) ;
-                
-        if ( needsExplicitPort ) {
+        boolean needsExplicitPort = ("https".equals(request.getScheme()) && request.getServerPort() != 443)
+                || ("http".equals(request.getScheme()) && request.getServerPort() != 80);
+
+        if (needsExplicitPort) {
             uri.append(':').append(request.getServerPort());
         }
         uri.append(OAuthEntryPointServlet.PATH).append("?c=").append(connection.name());
@@ -50,7 +55,7 @@ public abstract class OAuthUris {
 
         return URI.create(uri.toString());
     }
-    
+
     private OAuthUris() {
         // prevent instantiation
     }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationException.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationException.java
index e311262..6f8120e 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationException.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationException.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -20,6 +22,7 @@ class OidcAuthenticationException extends Exception {
     OidcAuthenticationException(String s, Exception e) {
         super(s, e);
     }
+
     OidcAuthenticationException(String s) {
         super(s);
     }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandler.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandler.java
index 4398b92..8b3026c 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandler.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandler.java
@@ -1,21 +1,37 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
 import com.nimbusds.jose.JOSEException;
 import com.nimbusds.jose.JWSAlgorithm;
 import com.nimbusds.jose.proc.BadJOSEException;
@@ -68,24 +84,7 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-@Component(
-        service = AuthenticationHandler.class,
-        immediate = true
-)
-
+@Component(service = AuthenticationHandler.class, immediate = true)
 @Designate(ocd = OidcAuthenticationHandler.Config.class, factory = true)
 public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHandler implements AuthenticationHandler {
 
@@ -101,7 +100,7 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
 
     private final String idp;
 
-    private  final String callbackUri;
+    private final String callbackUri;
 
     private final LoginCookieManager loginCookieManager;
 
@@ -119,50 +118,47 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
 
     @ObjectClassDefinition(
             name = "Apache Sling Oidc Authentication Handler",
-            description = "Apache Sling Oidc Authentication Handler Service"
-    )
-
+            description = "Apache Sling Oidc Authentication Handler Service")
     @interface Config {
-        @AttributeDefinition(name = "Path",
-                description = "Repository path for which this authentication handler should be used by Sling. If this is " +
-                        "empty, the authentication handler will be disabled. By default this is set to \"/\".")
+        @AttributeDefinition(
+                name = "Path",
+                description =
+                        "Repository path for which this authentication handler should be used by Sling. If this is "
+                                + "empty, the authentication handler will be disabled. By default this is set to \"/\".")
         String[] path() default {"/"};
 
-        @AttributeDefinition(name = "Sync Handler Configuration Name",
+        @AttributeDefinition(
+                name = "Sync Handler Configuration Name",
                 description = "Name of Sync Handler Configuration")
         String idp() default "oidc";
 
-        @AttributeDefinition(name = "Callback URI",
-                description = "Callback URI")
+        @AttributeDefinition(name = "Callback URI", description = "Callback URI")
         String callbackUri() default "callbackUri";
 
-        @AttributeDefinition(name = "Default Connection Name",
-                description = "Default Connection Name")
+        @AttributeDefinition(name = "Default Connection Name", description = "Default Connection Name")
         String defaultConnectionName() default "";
 
-        @AttributeDefinition(name = "PKCE Enabled",
-                description = "PKCE Enabled")
+        @AttributeDefinition(name = "PKCE Enabled", description = "PKCE Enabled")
         boolean pkceEnabled() default false;
 
-        @AttributeDefinition(name = "UserInfo Enabled",
-                description = "UserInfo Enabled")
+        @AttributeDefinition(name = "UserInfo Enabled", description = "UserInfo Enabled")
         boolean userInfoEnabled() default true;
-
     }
 
     @Activate
-    public OidcAuthenticationHandler(@Reference(policyOption = ReferencePolicyOption.GREEDY) @NotNull SlingRepository repository,
-                                     @NotNull BundleContext bundleContext, @Reference List<ClientConnection> connections,
-                                     @Reference OAuthStateManager stateManager,
-                                     Config config,
-                                     @Reference(cardinality = ReferenceCardinality.OPTIONAL, policyOption = ReferencePolicyOption.GREEDY) LoginCookieManager loginCookieManager,
-                                     @Reference(policyOption = ReferencePolicyOption.GREEDY) UserInfoProcessor userInfoProcessor,
-                                     @Reference CryptoService cryptoService
-    ) {
+    public OidcAuthenticationHandler(
+            @Reference(policyOption = ReferencePolicyOption.GREEDY) @NotNull SlingRepository repository,
+            @NotNull BundleContext bundleContext,
+            @Reference List<ClientConnection> connections,
+            @Reference OAuthStateManager stateManager,
+            Config config,
+            @Reference(cardinality = ReferenceCardinality.OPTIONAL, policyOption = ReferencePolicyOption.GREEDY)
+                    LoginCookieManager loginCookieManager,
+            @Reference(policyOption = ReferencePolicyOption.GREEDY) UserInfoProcessor userInfoProcessor,
+            @Reference CryptoService cryptoService) {
 
         this.repository = repository;
-        this.connections = connections.stream()
-                .collect(Collectors.toMap( ClientConnection::name, Function.identity()));
+        this.connections = connections.stream().collect(Collectors.toMap(ClientConnection::name, Function.identity()));
         this.stateManager = stateManager;
         this.idp = config.idp();
         this.callbackUri = config.callbackUri();
@@ -176,17 +172,16 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
 
         logger.debug("activate: registering ExternalIdentityProvider");
         bundleContext.registerService(
-                new String[]{ExternalIdentityProvider.class.getName(), CredentialsSupport.class.getName()}, new OidcIdentityProvider(idp),
+                new String[] {ExternalIdentityProvider.class.getName(), CredentialsSupport.class.getName()},
+                new OidcIdentityProvider(idp),
                 null);
 
         logger.info("OidcAuthenticationHandler successfully activated");
-
     }
 
-
-
     @Override
-    public AuthenticationInfo extractCredentials(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) {
+    public AuthenticationInfo extractCredentials(
+            @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) {
         logger.debug("inside extractCredentials");
 
         // Check if the request is authenticated by an oidc login token
@@ -196,24 +191,24 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
             return authInfo;
         }
 
-        //The request is not authenticated.
+        // The request is not authenticated.
         // 1. Extract nonce cookie and state cookie from the request
         StringBuffer requestURL = request.getRequestURL();
-        if ( request.getQueryString() != null ) {
+        if (request.getQueryString() != null) {
             requestURL.append('?').append(request.getQueryString());
         } else {
             // If there are no query parameters, the request is not for this authentication handler
             return null;
         }
-        State clientState; //state returned by the idp in the redirect request
-        String authCode; //authorization code returned by the idp in the redirect request
+        State clientState; // state returned by the idp in the redirect request
+        String authCode; // authorization code returned by the idp in the redirect request
         Cookie oauthCookie;
         AuthorizationResponse authResponse;
         try {
             authResponse = AuthorizationResponse.parse(new URI(requestURL.toString()));
         } catch (ParseException | URISyntaxException e) {
             // If we fail parsing the response, we consider the request not for this authentication handler
-            //The request may have some parameters that are not relevant for this authentication handler
+            // The request may have some parameters that are not relevant for this authentication handler
             logger.debug("Failed to parse authorization response: {}", e.getMessage(), e);
             return null;
         }
@@ -230,7 +225,7 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         // Set the redirect Attribute to the original redirect URI
         request.setAttribute(REDIRECT_ATTRIBUTE_NAME, oAuthCookieValue.redirect());
 
-        //2. Check if the State cookie match with the state in the request received from the idp
+        // 2. Check if the State cookie match with the state in the request received from the idp
         String stateFromRequest = clientState.getValue();
         String stateFromCookie = oAuthCookieValue.getState().getValue();
         if (!stateFromRequest.equals(stateFromCookie)) {
@@ -242,16 +237,18 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         String desiredConnectionName = oAuthCookieValue.connectionName();
         ClientConnection connection = connections.get(desiredConnectionName);
         if (connection == null) {
-            throw new IllegalArgumentException(String.format("Requested unknown connection '%s'", desiredConnectionName));
+            throw new IllegalArgumentException(
+                    String.format("Requested unknown connection '%s'", desiredConnectionName));
         }
         ResolvedConnection conn = ResolvedOidcConnection.resolve(connection);
 
         // 4. Exchange the authorization code for an access token, id token and possibly refresh token
-        TokenResponse tokenResponse = extractTokenResponse(authCode, conn, callbackUri, oAuthCookieValue.codeVerifier());
+        TokenResponse tokenResponse =
+                extractTokenResponse(authCode, conn, callbackUri, oAuthCookieValue.codeVerifier());
 
         // 5. Validate the ID token
         Nonce nonce = oAuthCookieValue.nonce();
-        IDTokenClaimsSet claims = validateIdToken(tokenResponse, (ResolvedOidcConnection) conn, nonce );
+        IDTokenClaimsSet claims = validateIdToken(tokenResponse, (ResolvedOidcConnection) conn, nonce);
 
         // 6. Make the request to userInfo
         String subject = claims.getSubject().getValue();
@@ -265,33 +262,52 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         return authInfo;
     }
 
-    private @NotNull OidcAuthCredentials extractCredentials(@NotNull OidcConnectionImpl connection, @NotNull String subject, @NotNull TokenResponse tokenResponse) {
+    private @NotNull OidcAuthCredentials extractCredentials(
+            @NotNull OidcConnectionImpl connection, @NotNull String subject, @NotNull TokenResponse tokenResponse) {
         if (userInfoEnabled) {
             HTTPResponse httpResponseUserInfo;
             UserInfoResponse userInfoResponse;
             try {
-                httpResponseUserInfo = new UserInfoRequest(new URI(connection.userInfoUrl()), tokenResponse.toSuccessResponse().getTokens().getAccessToken())
+                httpResponseUserInfo = new UserInfoRequest(
+                                new URI(connection.userInfoUrl()),
+                                tokenResponse.toSuccessResponse().getTokens().getAccessToken())
                         .toHTTPRequest()
                         .send();
                 userInfoResponse = UserInfoResponse.parse(httpResponseUserInfo);
                 if (!userInfoResponse.indicatesSuccess()) {
                     // The request failed, e.g. due to invalid or expired token
-                    logger.debug("UserInfo error. Received code: {}, message: {}", userInfoResponse.toErrorResponse().getErrorObject().getCode(), userInfoResponse.toErrorResponse().getErrorObject().getDescription());
-                    throw new RuntimeException(toErrorMessage("Error in userinfo response", userInfoResponse.toErrorResponse()));
+                    logger.debug(
+                            "UserInfo error. Received code: {}, message: {}",
+                            userInfoResponse.toErrorResponse().getErrorObject().getCode(),
+                            userInfoResponse.toErrorResponse().getErrorObject().getDescription());
+                    throw new RuntimeException(
+                            toErrorMessage("Error in userinfo response", userInfoResponse.toErrorResponse()));
                 }
 
                 // Extract the claims
                 UserInfo userInfo = userInfoResponse.toSuccessResponse().getUserInfo();
 
-                //process credentials
-                return userInfoProcessor.process(userInfo.toJSONObject().toJSONString(), tokenResponse.toSuccessResponse().toJSONObject().toJSONString(), subject, idp);
+                // process credentials
+                return userInfoProcessor.process(
+                        userInfo.toJSONObject().toJSONString(),
+                        tokenResponse.toSuccessResponse().toJSONObject().toJSONString(),
+                        subject,
+                        idp);
 
             } catch (IOException | URISyntaxException | ParseException e) {
                 logger.error("Error while processing UserInfo: {}", e.getMessage(), e);
                 throw new RuntimeException(e);
             }
         } else {
-            return userInfoProcessor.process(null, tokenResponse.toSuccessResponse().toSuccessResponse().toJSONObject().toJSONString(), subject, idp);
+            return userInfoProcessor.process(
+                    null,
+                    tokenResponse
+                            .toSuccessResponse()
+                            .toSuccessResponse()
+                            .toJSONObject()
+                            .toJSONString(),
+                    subject,
+                    idp);
         }
     }
 
@@ -303,14 +319,17 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
             }
             return authCode.getValue();
         }
-        throw new IllegalStateException(authResponse.toErrorResponse().getErrorObject().getDescription());
+        throw new IllegalStateException(
+                authResponse.toErrorResponse().getErrorObject().getDescription());
     }
 
-
-    private @NotNull TokenResponse extractTokenResponse(@NotNull String authCode, @NotNull ResolvedConnection conn,
-                                                               @NotNull String callbackUri, CodeVerifier codeVerifierCookie) {
+    private @NotNull TokenResponse extractTokenResponse(
+            @NotNull String authCode,
+            @NotNull ResolvedConnection conn,
+            @NotNull String callbackUri,
+            CodeVerifier codeVerifierCookie) {
         if (pkceEnabled && codeVerifierCookie == null) {
-            //This line of code should never be executed.
+            // This line of code should never be executed.
             throw new IllegalStateException("PKCE is enabled but no code verifier cookie found");
         }
 
@@ -327,33 +346,35 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
                 ClientSecretBasic clientCredentials = new ClientSecretBasic(clientId, clientSecret);
 
                 tokenRequest = new TokenRequest.Builder(
-                        tokenEndpoint,
-                        clientCredentials,
-                        new AuthorizationCodeGrant(code, new URI(callbackUri), codeVerifierCookie)
-                ).build();
+                                tokenEndpoint,
+                                clientCredentials,
+                                new AuthorizationCodeGrant(code, new URI(callbackUri), codeVerifierCookie))
+                        .build();
 
             } else if (pkceEnabled) {
                 tokenRequest = new TokenRequest.Builder(
-                        tokenEndpoint,
-                        clientId,
-                        new AuthorizationCodeGrant(code, new URI(callbackUri), new CodeVerifier(codeVerifierCookie.getValue()))
-                ).build();
+                                tokenEndpoint,
+                                clientId,
+                                new AuthorizationCodeGrant(
+                                        code, new URI(callbackUri), new CodeVerifier(codeVerifierCookie.getValue())))
+                        .build();
             } else {
                 Secret clientSecret = new Secret(conn.clientSecret());
 
                 ClientSecretBasic clientCredentials = new ClientSecretBasic(clientId, clientSecret);
 
                 tokenRequest = new TokenRequest.Builder(
-                        tokenEndpoint,
-                        clientCredentials,
-                        new AuthorizationCodeGrant(code, new URI(callbackUri))
-                ).build();
+                                tokenEndpoint,
+                                clientCredentials,
+                                new AuthorizationCodeGrant(code, new URI(callbackUri)))
+                        .build();
             }
 
             HTTPRequest httpRequest = tokenRequest.toHTTPRequest();
             // GitHub requires an explicitly set Accept header, otherwise the response is url encoded
             // https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github
-            // see also https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/107/support-application-x-www-form-urlencoded
+            // see also
+            // https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions/issues/107/support-application-x-www-form-urlencoded
             httpRequest.setAccept("application/json");
             HTTPResponse httpResponse = httpRequest.send();
 
@@ -361,7 +382,10 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
             TokenResponse tokenResponse = OIDCTokenResponseParser.parse(httpResponse);
 
             if (!tokenResponse.indicatesSuccess()) {
-                logger.debug("Token error. Received code: {}, message: {}", tokenResponse.toErrorResponse().getErrorObject().getCode(), tokenResponse.toErrorResponse().getErrorObject().getDescription());
+                logger.debug(
+                        "Token error. Received code: {}, message: {}",
+                        tokenResponse.toErrorResponse().getErrorObject().getCode(),
+                        tokenResponse.toErrorResponse().getErrorObject().getDescription());
                 throw new RuntimeException(toErrorMessage("Error in token response", tokenResponse.toErrorResponse()));
             }
             return tokenResponse.toSuccessResponse();
@@ -375,8 +399,8 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
             logger.error("Failed to parse token response: {}", e.getMessage(), e);
             throw new RuntimeException(e.getMessage());
         }
-
     }
+
     private static @NotNull Cookie extractCookie(@NotNull HttpServletRequest request, String cookieName) {
         Cookie[] cookies = request.getCookies();
         if (cookies == null) {
@@ -387,7 +411,8 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
                 return cookie;
             }
         }
-        throw new IllegalStateException(String.format("Failed state check: No request cookie named %s found", cookieName));
+        throw new IllegalStateException(
+                String.format("Failed state check: No request cookie named %s found", cookieName));
     }
 
     /**
@@ -406,16 +431,17 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
      * @param conn         The resolved OIDC connection.
      * @return The validated ID token claims set.
      */
-    private static @NotNull IDTokenClaimsSet validateIdToken(@NotNull TokenResponse tokenResponse,
-                                                             @NotNull ResolvedOidcConnection conn, Nonce nonce) {
+    private static @NotNull IDTokenClaimsSet validateIdToken(
+            @NotNull TokenResponse tokenResponse, @NotNull ResolvedOidcConnection conn, Nonce nonce) {
         Issuer issuer = new Issuer(conn.issuer());
         ClientID clientID = new ClientID(conn.clientId());
         try {
-            JWSAlgorithm jwsAlg = JWSAlgorithm.RS256; //TODO: Read from config
+            JWSAlgorithm jwsAlg = JWSAlgorithm.RS256; // TODO: Read from config
             URL jwkSetURL = conn.jwkSetURL().toURL();
 
             IDTokenValidator validator = new IDTokenValidator(issuer, clientID, jwsAlg, jwkSetURL);
-            return validator.validate(tokenResponse.toSuccessResponse().getTokens().toOIDCTokens().getIDToken(), nonce);
+            return validator.validate(
+                    tokenResponse.toSuccessResponse().getTokens().toOIDCTokens().getIDToken(), nonce);
         } catch (BadJOSEException | JOSEException | MalformedURLException e) {
             logger.error("Failed to validate token: {}", e.getMessage(), e);
             throw new RuntimeException(e.getMessage());
@@ -427,15 +453,12 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         ErrorObject errorObject = error.getErrorObject();
         StringBuilder message = new StringBuilder();
 
-        message.append(context)
-                .append(": ")
-                .append(errorObject.getCode());
+        message.append(context).append(": ").append(errorObject.getCode());
 
         message.append(". Status code: ").append(errorObject.getHTTPStatusCode());
 
         String description = errorObject.getDescription();
-        if ( description != null )
-            message.append(". ").append(description);
+        if (description != null) message.append(". ").append(description);
 
         return message.toString();
     }
@@ -451,13 +474,13 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         }
 
         String desiredConnectionName = request.getParameter("c");
-        if ( desiredConnectionName == null ) {
+        if (desiredConnectionName == null) {
             logger.debug("Missing mandatory request parameter 'c' using default connection");
             desiredConnectionName = defaultConnectionName;
         }
         try {
             ClientConnection connection = connections.get(desiredConnectionName);
-            if ( connection == null ) {
+            if (connection == null) {
                 logger.debug("Client requested unknown connection");
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Client requested unknown connection");
                 return false;
@@ -474,9 +497,8 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         }
     }
 
-    private @NotNull RedirectTarget getAuthenticationRequestUri(@NotNull ClientConnection connection,
-                                                                @NotNull HttpServletRequest request,
-                                                                @NotNull URI callbackUri) {
+    private @NotNull RedirectTarget getAuthenticationRequestUri(
+            @NotNull ClientConnection connection, @NotNull HttpServletRequest request, @NotNull URI callbackUri) {
 
         ResolvedConnection conn = ResolvedOidcConnection.resolve(connection);
 
@@ -491,7 +513,8 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
             codeVerifier = new CodeVerifier();
         }
 
-        OAuthCookieValue oAuthCookieValue = new OAuthCookieValue(perRequestKey, connection.name(), redirect, nonce, codeVerifier);
+        OAuthCookieValue oAuthCookieValue =
+                new OAuthCookieValue(perRequestKey, connection.name(), redirect, nonce, codeVerifier);
 
         return RedirectHelper.buildRedirectTarget(path, callbackUri, conn, oAuthCookieValue, cryptoService);
     }
@@ -500,16 +523,17 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
     public void dropCredentials(HttpServletRequest request, HttpServletResponse response) {
         // TODO: perform logout from Sling and redirect?
     }
-    
+
     @Override
-    public boolean authenticationSucceeded(HttpServletRequest request, HttpServletResponse response, AuthenticationInfo authInfo) {
+    public boolean authenticationSucceeded(
+            HttpServletRequest request, HttpServletResponse response, AuthenticationInfo authInfo) {
 
         if (loginCookieManager == null) {
             logger.debug("TokenUpdate service is not available");
             return super.authenticationSucceeded(request, response, authInfo);
         }
 
-        if (loginCookieManager.getLoginCookie(request) !=null) {
+        if (loginCookieManager.getLoginCookie(request) != null) {
             // A valid login cookie has been sent
             // According to AuthenticationFeedbackHandler javadoc we send because we did not send a redirect to the user
             deleteAuthenticationCookies(request.getRequestURI(), response);
@@ -528,7 +552,7 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
                 }
             }
 
-            String redirectUrl = (String)request.getAttribute(REDIRECT_ATTRIBUTE_NAME);
+            String redirectUrl = (String) request.getAttribute(REDIRECT_ATTRIBUTE_NAME);
             deleteAuthenticationCookies(request.getRequestURL().toString(), response);
             try {
                 response.sendRedirect(redirectUrl);
@@ -544,7 +568,8 @@ public class OidcAuthenticationHandler extends DefaultAuthenticationFeedbackHand
         deleteCookie(requestUri, response, OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
     }
 
-    private void deleteCookie(@NotNull String requestUri, @NotNull HttpServletResponse response, @NotNull String cookieName) {
+    private void deleteCookie(
+            @NotNull String requestUri, @NotNull HttpServletResponse response, @NotNull String cookieName) {
         Cookie cookie = new Cookie(cookieName, null);
         cookie.setMaxAge(0); // Marks the cookie for deletion
         cookie.setHttpOnly(true);
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcConnectionImpl.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcConnectionImpl.java
index e41a34d..bdca675 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcConnectionImpl.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcConnectionImpl.java
@@ -1,21 +1,25 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import java.net.URI;
+
 import org.apache.sling.auth.oauth_client.ClientConnection;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -26,7 +30,6 @@ import org.osgi.service.metatype.annotations.AttributeDefinition;
 import org.osgi.service.metatype.annotations.AttributeType;
 import org.osgi.service.metatype.annotations.Designate;
 import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import java.net.URI;
 
 // TODO - bad name
 @Component
@@ -36,13 +39,20 @@ public class OidcConnectionImpl implements ClientConnection {
     @ObjectClassDefinition(name = "OpenID Connect connection details")
     public @interface Config {
         String name();
+
         String baseUrl();
+
         String clientId();
-        @AttributeDefinition(type = AttributeType.PASSWORD) String clientSecret();
+
+        @AttributeDefinition(type = AttributeType.PASSWORD)
+        String clientSecret();
+
         String[] scopes();
+
         String[] additionalAuthorizationParameters();
 
-        String webconsole_configurationFactory_nameHint() default "Name: {name}, base URL: {baseUrl}, clientId: {clientId}";
+        String webconsole_configurationFactory_nameHint() default
+                "Name: {name}, base URL: {baseUrl}, clientId: {clientId}";
     }
 
     private final Config cfg;
@@ -53,20 +63,20 @@ public class OidcConnectionImpl implements ClientConnection {
         this.cfg = cfg;
         this.metadataRegistry = metadataRegistry;
     }
-    
+
     @Override
     public @NotNull String name() {
         return cfg.name();
     }
-    
+
     public @NotNull String authorizationEndpoint() {
         return metadataRegistry.getAuthorizationEndpoint(cfg.baseUrl()).toString();
     }
-    
+
     public @NotNull String tokenEndpoint() {
         return metadataRegistry.getTokenEndpoint(cfg.baseUrl()).toString();
     }
-    
+
     public @NotNull String clientId() {
         return cfg.clientId();
     }
@@ -74,7 +84,7 @@ public class OidcConnectionImpl implements ClientConnection {
     public @Nullable String clientSecret() {
         return cfg.clientSecret();
     }
-    
+
     public @NotNull String[] scopes() {
         return cfg.scopes();
     }
@@ -83,19 +93,23 @@ public class OidcConnectionImpl implements ClientConnection {
         return cfg.additionalAuthorizationParameters();
     }
 
-    @Nullable String baseUrl() {
+    @Nullable
+    String baseUrl() {
         return cfg.baseUrl();
     }
 
-    @NotNull String userInfoUrl() {
+    @NotNull
+    String userInfoUrl() {
         return metadataRegistry.getUserInfoEndpoint(cfg.baseUrl()).toString();
     }
 
-    @NotNull URI jwkSetURL() {
+    @NotNull
+    URI jwkSetURL() {
         return metadataRegistry.getJWKSetURI(cfg.baseUrl());
     }
 
-    @NotNull String issuer() {
+    @NotNull
+    String issuer() {
         return metadataRegistry.getIssuer(cfg.baseUrl());
     }
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProvider.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProvider.java
index f4639ea..06bcd35 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProvider.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProvider.java
@@ -1,21 +1,32 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.jcr.Credentials;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.jackrabbit.oak.spi.security.authentication.credentials.CredentialsSupport;
 import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
 import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
@@ -29,20 +40,12 @@ import org.apache.sling.auth.oauth_client.spi.OidcAuthCredentials;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import javax.jcr.Credentials;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameResolver, CredentialsSupport  {
+class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameResolver, CredentialsSupport {
 
     private final String name;
-    
+
     OidcIdentityProvider(@NotNull String name) {
-        this.name=name;
+        this.name = name;
     }
 
     @Override
@@ -58,7 +61,7 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
         return null;
     }
 
-    //Must return attributes to be set to the Token, but NOT profile information
+    // Must return attributes to be set to the Token, but NOT profile information
     @Override
     public @NotNull Map<String, ?> getAttributes(@NotNull Credentials credentials) {
         if (validCredentials(credentials)) {
@@ -70,7 +73,7 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
     @Override
     public boolean setAttributes(@NotNull Credentials credentials, @NotNull Map<String, ?> map) {
         if (validCredentials(credentials)) {
-            OidcAuthCredentials oidcAuthCredentials = (OidcAuthCredentials)credentials;
+            OidcAuthCredentials oidcAuthCredentials = (OidcAuthCredentials) credentials;
             map.keySet().forEach(key -> oidcAuthCredentials.setAttribute(key, (String) map.get(key)));
             return true;
         }
@@ -86,7 +89,7 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
     public @Nullable ExternalIdentity getIdentity(@NotNull ExternalIdentityRef externalIdentityRef) {
         if (isSameIdp(externalIdentityRef) && externalIdentityRef instanceof OidcGroupRef) {
             return new OidcGroup(externalIdentityRef);
-        } 
+        }
         return null;
     }
 
@@ -102,7 +105,7 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
         }
         return null;
     }
-    
+
     @Override
     public @Nullable ExternalGroup getGroup(@NotNull String s) {
         throw new UnsupportedOperationException();
@@ -119,13 +122,14 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
     }
 
     @Override
-    public @NotNull String fromExternalIdentityRef(@NotNull ExternalIdentityRef externalIdentityRef) throws ExternalIdentityException {
+    public @NotNull String fromExternalIdentityRef(@NotNull ExternalIdentityRef externalIdentityRef)
+            throws ExternalIdentityException {
         if (!isSameIdp(externalIdentityRef)) {
             throw new ExternalIdentityException("Foreign IDP " + externalIdentityRef.getString());
         }
         return externalIdentityRef.getId();
     }
-    
+
     private boolean validCredentials(@NotNull Credentials credentials) {
         if (credentials instanceof OidcAuthCredentials) {
             OidcAuthCredentials oidcAuthCredentials = (OidcAuthCredentials) credentials;
@@ -133,23 +137,23 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
         }
         return false;
     }
-    
+
     private boolean isSameIdp(@NotNull OidcAuthCredentials credentials) {
         return name.equals(credentials.getIdp());
     }
-    
+
     private boolean isSameIdp(@NotNull ExternalIdentityRef ref) {
         return name.equals(ref.getProviderName());
     }
-    
+
     private abstract static class OidcIdentity implements ExternalIdentity {
 
         private final ExternalIdentityRef ref;
-        
+
         private OidcIdentity(@NotNull ExternalIdentityRef ref) {
             this.ref = ref;
         }
-        
+
         @Override
         public @NotNull ExternalIdentityRef getExternalId() {
             return ref;
@@ -170,7 +174,7 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
             return "";
         }
     }
-    
+
     private final class OidcUser extends OidcIdentity implements ExternalUser {
 
         private final OidcAuthCredentials creds;
@@ -200,13 +204,13 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
             return new ExternalIdentityRef(creds.getUserId(), creds.getIdp());
         }
     }
-    
+
     private final class OidcGroup extends OidcIdentity implements ExternalGroup {
 
         OidcGroup(@NotNull ExternalIdentityRef ref) {
             super(ref);
         }
-        
+
         @Override
         public @NotNull Iterable<ExternalIdentityRef> getDeclaredGroups() {
             return Collections.emptyList();
@@ -222,11 +226,10 @@ class OidcIdentityProvider implements ExternalIdentityProvider, PrincipalNameRes
             return Collections.emptyList();
         }
     }
-    
+
     static class OidcGroupRef extends ExternalIdentityRef {
         private OidcGroupRef(@NotNull String id, @NotNull String idp) {
             super(id, idp);
         }
     }
-
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcProviderMetadataRegistry.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcProviderMetadataRegistry.java
index 87c659e..c16b2a2 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcProviderMetadataRegistry.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcProviderMetadataRegistry.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -21,19 +23,18 @@ import java.net.URI;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import org.jetbrains.annotations.NotNull;
-import org.osgi.service.component.annotations.Component;
-
 import com.nimbusds.oauth2.sdk.GeneralException;
 import com.nimbusds.oauth2.sdk.id.Issuer;
 import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata;
+import org.jetbrains.annotations.NotNull;
+import org.osgi.service.component.annotations.Component;
 
 /**
  * A registry for provider metadata
- * 
+ *
  * <p>Encapsulates the logic for retrieving the {@link OIDCProviderMetadata} for a given
  * connection.</p>
- * 
+ *
  * <p>Maintains a best-effort, unbounded, cache for the metadata, on the assumption that
  * there will be a small number of OIDC connections configured.</p>
  */
@@ -70,4 +71,4 @@ public class OidcProviderMetadataRegistry {
     public @NotNull String getIssuer(@NotNull String base) {
         return getProviderMetadata(base).getIssuer().getValue();
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcTokens.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcTokens.java
index 18dfce3..925c0f4 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcTokens.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/OidcTokens.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -25,7 +27,8 @@ public class OidcTokens {
     private final String refreshToken;
     private final String idToken;
 
-    public OidcTokens(@Nullable String accessToken, long expiresAt, @Nullable String refreshToken, @Nullable String idToken) {
+    public OidcTokens(
+            @Nullable String accessToken, long expiresAt, @Nullable String refreshToken, @Nullable String idToken) {
         this.accessToken = accessToken;
         this.expiresAt = expiresAt;
         this.refreshToken = refreshToken;
@@ -50,4 +53,4 @@ public class OidcTokens {
     public String idToken() {
         return idToken;
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectHelper.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectHelper.java
index 8a59d06..525d34c 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectHelper.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectHelper.java
@@ -1,21 +1,30 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.servlet.http.Cookie;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.stream.Collectors;
+
 import com.nimbusds.oauth2.sdk.ResponseType;
 import com.nimbusds.oauth2.sdk.Scope;
 import com.nimbusds.oauth2.sdk.id.ClientID;
@@ -28,30 +37,30 @@ import org.jetbrains.annotations.Nullable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.http.Cookie;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.stream.Collectors;
-
 class RedirectHelper {
 
     // We don't want leave the cookie lying around for a long time because it is not needed.
-    // At the same time, some OAuth user authentication flows take a long time due to 
+    // At the same time, some OAuth user authentication flows take a long time due to
     // consent, account selection, 2FA, etc. so we cannot make this too short.
     private static final int COOKIE_MAX_AGE_SECONDS = 300;
     private static final Logger logger = LoggerFactory.getLogger(RedirectHelper.class);
-    
+
     private RedirectHelper() {
         // Utility class
     }
 
-    static @NotNull RedirectTarget buildRedirectTarget(@NotNull String[] paths, @NotNull URI callbackUri, @NotNull ResolvedConnection conn, @NotNull OAuthCookieValue oAuthCookieValue, @NotNull CryptoService cryptoService) {
+    static @NotNull RedirectTarget buildRedirectTarget(
+            @NotNull String[] paths,
+            @NotNull URI callbackUri,
+            @NotNull ResolvedConnection conn,
+            @NotNull OAuthCookieValue oAuthCookieValue,
+            @NotNull CryptoService cryptoService) {
 
         String path = findLongestPathMatching(paths, callbackUri.getPath());
 
         // Set the cookie with state, connection name, redirect uri, nonce and codeverifier
-        Cookie requestKeyCookie = buildCookie(path, OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(oAuthCookieValue.getValue()));
+        Cookie requestKeyCookie = buildCookie(
+                path, OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(oAuthCookieValue.getValue()));
 
         // We build th redirect url to be sent to the browser
         URI authorizationEndpointUri = URI.create(conn.authorizationEndpoint());
@@ -60,13 +69,9 @@ class RedirectHelper {
         Scope scopes = new Scope(conn.scopes().toArray(new String[0]));
         AuthenticationRequest.Builder authRequestBuilder;
         authRequestBuilder = new AuthenticationRequest.Builder(
-                ResponseType.CODE,
-                scopes,
-                new ClientID(conn.clientId()),
-                callbackUri
-        )
-        .endpointURI(authorizationEndpointUri)
-        .state(oAuthCookieValue.getState());
+                        ResponseType.CODE, scopes, new ClientID(conn.clientId()), callbackUri)
+                .endpointURI(authorizationEndpointUri)
+                .state(oAuthCookieValue.getState());
 
         if (oAuthCookieValue.nonce() != null) {
             // For OAuth the nonce is not defined
@@ -92,14 +97,12 @@ class RedirectHelper {
         return new RedirectTarget(uri, requestKeyCookie);
     }
 
-    
     private static @NotNull Cookie buildCookie(@Nullable String path, @NotNull String name, @NotNull String value) {
         Cookie cookie = new Cookie(name, value);
         cookie.setHttpOnly(true);
         cookie.setSecure(true);
         cookie.setMaxAge(COOKIE_MAX_AGE_SECONDS);
-        if (path !=null)
-            cookie.setPath(path);
+        if (path != null) cookie.setPath(path);
         return cookie;
     }
 
@@ -117,7 +120,7 @@ class RedirectHelper {
             return null;
         }
 
-        if (urlPath == null || urlPath.isEmpty())  {
+        if (urlPath == null || urlPath.isEmpty()) {
             return null;
         }
 
@@ -139,5 +142,4 @@ class RedirectHelper {
             return descendant.startsWith(pattern);
         }
     }
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectTarget.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectTarget.java
index 2f99970..b2857ca 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectTarget.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/RedirectTarget.java
@@ -1,26 +1,29 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import org.jetbrains.annotations.NotNull;
-
 import javax.servlet.http.Cookie;
+
 import java.net.URI;
 
+import org.jetbrains.annotations.NotNull;
+
 public class RedirectTarget {
 
     private final @NotNull URI uri;
@@ -38,4 +41,4 @@ public class RedirectTarget {
     public @NotNull Cookie cookie() {
         return cookie;
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStore.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStore.java
index 30d09db..3087af3 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStore.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStore.java
@@ -1,23 +1,23 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.osgi.service.component.annotations.ConfigurationPolicy.REQUIRE;
-
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.auth.oauth_client.ClientConnection;
 import org.jetbrains.annotations.NotNull;
@@ -27,14 +27,15 @@ import org.osgi.service.component.annotations.Component;
 import org.osgi.service.metatype.annotations.AttributeDefinition;
 import org.osgi.service.metatype.annotations.Designate;
 import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
 import redis.clients.jedis.Jedis;
 import redis.clients.jedis.JedisPool;
 
+import static org.osgi.service.component.annotations.ConfigurationPolicy.REQUIRE;
+
 @Component(configurationPolicy = REQUIRE)
 @Designate(ocd = RedisOAuthTokenStore.Config.class)
 public class RedisOAuthTokenStore implements OAuthTokenStore {
-    
+
     @ObjectClassDefinition(name = "Redis OAuth Token Store")
     @interface Config {
         @AttributeDefinition(name = "Redis URL")
@@ -42,44 +43,46 @@ public class RedisOAuthTokenStore implements OAuthTokenStore {
     }
 
     private static final String KEY_PREFIX = "sling.oauth.tokens";
-    
+
     private static final String KEY_SEGMENT_ACCESS_TOKEN = "access_token";
     private static final String KEY_SEGMENT_REFRESH_TOKEN = "refresh_token";
-    
+
     private final JedisPool pool;
-    
+
     @Activate
     public RedisOAuthTokenStore(@NotNull Config cfg) {
         pool = new JedisPool(cfg.redisUrl());
     }
-    
+
     public void deactivate() {
         pool.close();
     }
 
     @Override
-    public @NotNull OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
+    public @NotNull OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
         String userId = resolver.getUserID();
-        
-        try ( Jedis jedis = pool.getResource()) {
+
+        try (Jedis jedis = pool.getResource()) {
             String accessToken = jedis.get(keyFor(userId, connection, KEY_SEGMENT_ACCESS_TOKEN));
-            if ( accessToken != null ) {
-                return new OAuthToken(TokenState.VALID , accessToken);
+            if (accessToken != null) {
+                return new OAuthToken(TokenState.VALID, accessToken);
             }
-            
+
             String refreshToken = jedis.get(keyFor(userId, connection, KEY_SEGMENT_REFRESH_TOKEN));
-            if ( refreshToken != null ) {
+            if (refreshToken != null) {
                 return new OAuthToken(TokenState.EXPIRED, null);
             }
-            
+
             return new OAuthToken(TokenState.MISSING, null);
         }
     }
 
     @Override
-    public @NotNull OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
+    public @NotNull OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
         String userId = resolver.getUserID();
-        
+
         try (Jedis jedis = pool.getResource()) {
             String refreshToken = jedis.get(keyFor(userId, connection, KEY_SEGMENT_REFRESH_TOKEN));
             if (refreshToken != null) {
@@ -91,34 +94,39 @@ public class RedisOAuthTokenStore implements OAuthTokenStore {
     }
 
     @Override
-    public void persistTokens(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens)
+    public void persistTokens(
+            @NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens)
             throws OAuthException {
         String userId = resolver.getUserID();
 
         try (Jedis jedis = pool.getResource()) {
-            setWithExpiry(jedis, keyFor(userId, connection, KEY_SEGMENT_ACCESS_TOKEN), tokens.accessToken(), tokens.expiresAt() );
-            if ( tokens.refreshToken() != null )
+            setWithExpiry(
+                    jedis,
+                    keyFor(userId, connection, KEY_SEGMENT_ACCESS_TOKEN),
+                    tokens.accessToken(),
+                    tokens.expiresAt());
+            if (tokens.refreshToken() != null)
                 jedis.set(keyFor(userId, connection, KEY_SEGMENT_REFRESH_TOKEN), tokens.refreshToken());
         }
     }
-    
+
     @Override
-    public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
-    	   String userId = resolver.getUserID();
+    public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
+        String userId = resolver.getUserID();
 
-           try (Jedis jedis = pool.getResource()) {
-        	   jedis.del(keyFor(userId, connection, KEY_SEGMENT_ACCESS_TOKEN));
-           }
-    	
+        try (Jedis jedis = pool.getResource()) {
+            jedis.del(keyFor(userId, connection, KEY_SEGMENT_ACCESS_TOKEN));
+        }
     }
-    
+
     private static void setWithExpiry(@NotNull Jedis jedis, @NotNull String key, @Nullable String value, long expiry) {
         jedis.set(key, value);
-        if ( expiry > 0 )
-            jedis.expire(key, expiry);
+        if (expiry > 0) jedis.expire(key, expiry);
     }
-    
-    private static String keyFor(@Nullable String principal, @NotNull ClientConnection connection, @Nullable String tokenType) {
+
+    private static String keyFor(
+            @Nullable String principal, @NotNull ClientConnection connection, @Nullable String tokenType) {
         return KEY_PREFIX + "." + principal + "." + connection.name() + "." + tokenType;
     }
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedConnection.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedConnection.java
index 716a699..2ec0ca4 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedConnection.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedConnection.java
@@ -1,28 +1,30 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import java.util.List;
+
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.List;
-
 abstract class ResolvedConnection {
-    
+
     private final String name;
     private final String authorizationEndpoint;
     private final String tokenEndpoint;
@@ -31,8 +33,14 @@ abstract class ResolvedConnection {
     private final List<String> scopes;
     private final List<String> additionalAuthorizationParameters;
 
-    ResolvedConnection(@NotNull String name, @NotNull String authorizationEndpoint, @NotNull String tokenEndpoint, @NotNull String clientId,
-                       @Nullable String clientSecret, @NotNull List<String> scopes, @NotNull List<String> additionalAuthorizationParameters) {
+    ResolvedConnection(
+            @NotNull String name,
+            @NotNull String authorizationEndpoint,
+            @NotNull String tokenEndpoint,
+            @NotNull String clientId,
+            @Nullable String clientSecret,
+            @NotNull List<String> scopes,
+            @NotNull List<String> additionalAuthorizationParameters) {
         this.name = name;
         this.authorizationEndpoint = authorizationEndpoint;
         this.tokenEndpoint = tokenEndpoint;
@@ -42,7 +50,6 @@ abstract class ResolvedConnection {
         this.additionalAuthorizationParameters = additionalAuthorizationParameters;
     }
 
-
     public @NotNull String name() {
         return name;
     }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOAuthConnection.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOAuthConnection.java
index f1d8d17..5aa325f 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOAuthConnection.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOAuthConnection.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -24,14 +26,27 @@ import org.jetbrains.annotations.NotNull;
 
 /**
  * An OAuth connection that has all configuration parameters materialised
- * 
+ *
  * <p>Serves as an internal abstraction over the client-facing {@link ClientConnection} and its implementations.</p>
  */
 class ResolvedOAuthConnection extends ResolvedConnection {
 
-    private ResolvedOAuthConnection(@NotNull String name, String authorizationEndpoint, String tokenEndpoint, String clientId,
-                                    String clientSecret, @NotNull List<String> scopes, @NotNull List<String> additionalAuthorizationParameters) {
-        super(name, authorizationEndpoint, tokenEndpoint, clientId, clientSecret, scopes, additionalAuthorizationParameters);
+    private ResolvedOAuthConnection(
+            @NotNull String name,
+            String authorizationEndpoint,
+            String tokenEndpoint,
+            String clientId,
+            String clientSecret,
+            @NotNull List<String> scopes,
+            @NotNull List<String> additionalAuthorizationParameters) {
+        super(
+                name,
+                authorizationEndpoint,
+                tokenEndpoint,
+                clientId,
+                clientSecret,
+                scopes,
+                additionalAuthorizationParameters);
     }
 
     static @NotNull ResolvedConnection resolve(@NotNull ClientConnection connection) {
@@ -44,10 +59,12 @@ class ResolvedOAuthConnection extends ResolvedConnection {
                     oidcConnection.clientId(),
                     oidcConnection.clientSecret(),
                     Arrays.asList(oidcConnection.scopes()),
-                    Arrays.asList(oidcConnection.additionalAuthorizationParameters())
-            );
+                    Arrays.asList(oidcConnection.additionalAuthorizationParameters()));
         }
-        throw new IllegalArgumentException(String.format("Unable to resolve %s (name=%s) of type %s",
-                ClientConnection.class.getSimpleName(), connection.name(), connection.getClass().getName()));
+        throw new IllegalArgumentException(String.format(
+                "Unable to resolve %s (name=%s) of type %s",
+                ClientConnection.class.getSimpleName(),
+                connection.name(),
+                connection.getClass().getName()));
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOidcConnection.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOidcConnection.java
index a825174..7cbb34b 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOidcConnection.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/ResolvedOidcConnection.java
@@ -1,29 +1,31 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import org.apache.sling.auth.oauth_client.ClientConnection;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
 import java.net.URI;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.sling.auth.oauth_client.ClientConnection;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 class ResolvedOidcConnection extends ResolvedConnection {
 
     private final URI jwkSetURL;
@@ -42,19 +44,35 @@ class ResolvedOidcConnection extends ResolvedConnection {
      * @param jwkSetURL the JWK Set URL, may be null
      * @param issuer the issuer URL
      */
-    private ResolvedOidcConnection(@NotNull String name, @NotNull String authorizationEndpoint, @NotNull String tokenEndpoint,
-                                   @NotNull String clientId, @Nullable String clientSecret, @NotNull List<String> scopes,
-                                   @NotNull List<String> additionalAuthorizationParameters, @Nullable URI jwkSetURL, @NotNull String issuer) {
-        super(name, authorizationEndpoint, tokenEndpoint, clientId, clientSecret, scopes, additionalAuthorizationParameters);
+    private ResolvedOidcConnection(
+            @NotNull String name,
+            @NotNull String authorizationEndpoint,
+            @NotNull String tokenEndpoint,
+            @NotNull String clientId,
+            @Nullable String clientSecret,
+            @NotNull List<String> scopes,
+            @NotNull List<String> additionalAuthorizationParameters,
+            @Nullable URI jwkSetURL,
+            @NotNull String issuer) {
+        super(
+                name,
+                authorizationEndpoint,
+                tokenEndpoint,
+                clientId,
+                clientSecret,
+                scopes,
+                additionalAuthorizationParameters);
         this.jwkSetURL = jwkSetURL;
         this.issuer = issuer;
     }
 
-    @Nullable URI jwkSetURL() {
+    @Nullable
+    URI jwkSetURL() {
         return jwkSetURL;
     }
 
-    @NotNull String issuer() {
+    @NotNull
+    String issuer() {
         return issuer;
     }
 
@@ -70,10 +88,12 @@ class ResolvedOidcConnection extends ResolvedConnection {
                     Arrays.asList(impl.scopes()),
                     Arrays.asList(impl.additionalAuthorizationParameters()),
                     impl.jwkSetURL(),
-                    impl.issuer()
-            );
+                    impl.issuer());
         }
-        throw new IllegalArgumentException(String.format("Unable to resolve %s (name=%s) of type %s",
-                ClientConnection.class.getSimpleName(), connection.name(), connection.getClass().getName()));
+        throw new IllegalArgumentException(String.format(
+                "Unable to resolve %s (name=%s) of type %s",
+                ClientConnection.class.getSimpleName(),
+                connection.name(),
+                connection.getClass().getName()));
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManager.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManager.java
index b066015..4b2f800 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManager.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManager.java
@@ -1,22 +1,33 @@
 /*
- * Licensed to the Sakai Foundation (SF) under one
- * or more contributor license agreements. See the NOTICE file
+ * 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 SF licenses this file
+ * 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
+ * with the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *   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.
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.jcr.Credentials;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
 import org.apache.commons.codec.binary.Base64;
 import org.apache.sling.auth.core.spi.AuthenticationInfo;
 import org.apache.sling.auth.oauth_client.spi.LoginCookieManager;
@@ -33,22 +44,10 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.Credentials;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.nio.charset.StandardCharsets;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-
 @Component(
         service = LoginCookieManager.class,
         immediate = true,
-        property = {
-                "service.ranking:Integer=10"
-        }
-)
+        property = {"service.ranking:Integer=10"})
 public class SlingLoginCookieManager implements LoginCookieManager {
 
     private static final Logger log = LoggerFactory.getLogger(SlingLoginCookieManager.class);
@@ -59,24 +58,18 @@ public class SlingLoginCookieManager implements LoginCookieManager {
 
     @ObjectClassDefinition(
             name = "Apache Sling Token Update Configuration for OIDC Authentication Handler",
-            description = "Apache Sling Token Update Configuration for OIDC Authentication Handler"
-    )
-
+            description = "Apache Sling Token Update Configuration for OIDC Authentication Handler")
     @interface SlingLoginCookieManagerConfig {
-        @AttributeDefinition(name = "tokenFile",
-                description = "Token File")
+        @AttributeDefinition(name = "tokenFile", description = "Token File")
         String tokenFile() default "cookie-tokens.bin";
 
-        @AttributeDefinition(name = "form_token_fastseed",
-                description = "Form Token Fast Seed")
+        @AttributeDefinition(name = "form_token_fastseed", description = "Form Token Fast Seed")
         boolean form_token_fastseed() default false;
 
-        @AttributeDefinition(name = "sessionTimeout",
-                description = "Session Timeout")
+        @AttributeDefinition(name = "sessionTimeout", description = "Session Timeout")
         long sessionTimeout() default 8 * 60 * 60 * 1000;
 
-        @AttributeDefinition(name = "cookieName",
-                description = "Cookie Name")
+        @AttributeDefinition(name = "cookieName", description = "Cookie Name")
         String cookieName() default "sling.oidcauth";
     }
 
@@ -92,26 +85,30 @@ public class SlingLoginCookieManager implements LoginCookieManager {
         this.cookieName = config.cookieName();
         this.tokenStore = new TokenStore(tokenFile, sessionTimeout, fastSeed);
     }
-    
+
     @Override
-    public void setLoginCookie(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, 
-                               @NotNull SlingRepository repository, @NotNull Credentials creds) {
+    public void setLoginCookie(
+            @NotNull HttpServletRequest request,
+            @NotNull HttpServletResponse response,
+            @NotNull SlingRepository repository,
+            @NotNull Credentials creds) {
 
         long expires = System.currentTimeMillis() + this.sessionTimeout;
 
         // get current authentication data, may be missing after first login
         String authData = null;
         try {
-            authData = tokenStore.encode(expires, ((OidcAuthCredentials)creds).getUserId());
-        } catch (NoSuchAlgorithmException|InvalidKeyException e) {
+            authData = tokenStore.encode(expires, ((OidcAuthCredentials) creds).getUserId());
+        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
             throw new RuntimeException(e);
-        } 
+        }
         String cookieValue = Base64.encodeBase64URLSafeString(authData.getBytes(StandardCharsets.UTF_8));
         setCookie(request, response, cookieName, cookieValue, (int) (sessionTimeout / 1000));
     }
 
     @Override
-    @Nullable public AuthenticationInfo verifyLoginCookie(@NotNull HttpServletRequest request) {
+    @Nullable
+    public AuthenticationInfo verifyLoginCookie(@NotNull HttpServletRequest request) {
         Cookie cookie = getLoginCookie(request);
         if (cookie == null) {
             return null;
@@ -164,8 +161,12 @@ public class SlingLoginCookieManager implements LoginCookieManager {
         return null;
     }
 
-    private static void setCookie(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response, 
-                           @NotNull final String name, @NotNull final String value, final int maxAge) {
+    private static void setCookie(
+            @NotNull final HttpServletRequest request,
+            @NotNull final HttpServletResponse response,
+            @NotNull final String name,
+            @NotNull final String value,
+            final int maxAge) {
         // set the cookie
         final StringBuilder cookie = new StringBuilder(name);
         cookie.append('=');
@@ -184,7 +185,7 @@ public class SlingLoginCookieManager implements LoginCookieManager {
 
     /**
      * Returns an absolute file indicating the file to use to persist the security
-    4 * tokens.
+     * 4 * tokens.
      * <p>
      * This method is not part of the API of this class and is package private to
      * enable unit tests.
@@ -195,7 +196,8 @@ public class SlingLoginCookieManager implements LoginCookieManager {
      *            The BundleContext to use to make an relative file absolute
      * @return The absolute file
      */
-    private static @NotNull File getTokenFile(@NotNull final String tokenFileName, @NotNull final BundleContext bundleContext) {
+    private static @NotNull File getTokenFile(
+            @NotNull final String tokenFileName, @NotNull final BundleContext bundleContext) {
         File tokenFile = new File(tokenFileName);
         if (tokenFile.isAbsolute()) {
             return tokenFile;
@@ -213,5 +215,4 @@ public class SlingLoginCookieManager implements LoginCookieManager {
 
         return tokenFile.getAbsoluteFile();
     }
-
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingUserInfoProcessorImpl.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingUserInfoProcessorImpl.java
index fc48958..28bbbca 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingUserInfoProcessorImpl.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/SlingUserInfoProcessorImpl.java
@@ -1,34 +1,34 @@
 /*
- * Licensed to the Sakai Foundation (SF) under one
- * or more contributor license agreements. See the NOTICE file
+ * 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 SF licenses this file
+ * 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
+ * with the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *   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.
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 import com.nimbusds.oauth2.sdk.ParseException;
 import com.nimbusds.oauth2.sdk.TokenResponse;
 import com.nimbusds.openid.connect.sdk.claims.UserInfo;
+import net.minidev.json.JSONArray;
 import net.minidev.json.JSONObject;
 import net.minidev.json.JSONValue;
-import net.minidev.json.JSONArray;
 import org.apache.sling.auth.oauth_client.spi.OidcAuthCredentials;
 import org.apache.sling.auth.oauth_client.spi.UserInfoProcessor;
 import org.apache.sling.commons.crypto.CryptoService;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
@@ -41,30 +41,21 @@ import org.slf4j.LoggerFactory;
 
 @Component(
         service = UserInfoProcessor.class,
-        property = {
-                "service.ranking:Integer=10"
-        }
-)
+        property = {"service.ranking:Integer=10"})
 @Designate(ocd = SlingUserInfoProcessorImpl.Config.class)
 public class SlingUserInfoProcessorImpl implements UserInfoProcessor {
 
     @ObjectClassDefinition(
             name = "Apache Sling Oidc UserInfo Processor",
-            description = "Apache Sling Oidc UserInfo Processor Service"
-    )
+            description = "Apache Sling Oidc UserInfo Processor Service")
     @interface Config {
-        @AttributeDefinition(
-                name = "storeAccessToken",
-                description = "Store access Token under User Node"
-        )
+        @AttributeDefinition(name = "storeAccessToken", description = "Store access Token under User Node")
         boolean storeAccessToken() default false;
-        @AttributeDefinition(
-                name = "storeRefreshToken",
-                description = "Store access Refresh under User Node"
-        )
+
+        @AttributeDefinition(name = "storeRefreshToken", description = "Store access Refresh under User Node")
         boolean storeRefreshToken() default false;
     }
-    
+
     private static final Logger logger = LoggerFactory.getLogger(SlingUserInfoProcessorImpl.class);
 
     private final CryptoService cryptoService;
@@ -72,19 +63,24 @@ public class SlingUserInfoProcessorImpl implements UserInfoProcessor {
     private final boolean storeRefreshToken;
 
     @Activate
-    public SlingUserInfoProcessorImpl(@Reference(policyOption = ReferencePolicyOption.GREEDY) CryptoService service, Config config) {
+    public SlingUserInfoProcessorImpl(
+            @Reference(policyOption = ReferencePolicyOption.GREEDY) CryptoService service, Config config) {
         this.cryptoService = service;
         this.storeAccessToken = config.storeAccessToken();
         this.storeRefreshToken = config.storeRefreshToken();
     }
-    
+
     @Override
-    public @NotNull OidcAuthCredentials process(@Nullable String stringUserInfo, @NotNull String stringTokenResponse,
-                                                @NotNull String oidcSubject, @NotNull String idp) {
+    public @NotNull OidcAuthCredentials process(
+            @Nullable String stringUserInfo,
+            @NotNull String stringTokenResponse,
+            @NotNull String oidcSubject,
+            @NotNull String idp) {
 
         TokenResponse tokenResponse = parseTokenResponse(stringTokenResponse);
         UserInfo userInfo = parseUserInfo(stringUserInfo);
-        OAuthTokens tokens = Converter.toSlingOAuthTokens(tokenResponse.toSuccessResponse().getTokens());
+        OAuthTokens tokens =
+                Converter.toSlingOAuthTokens(tokenResponse.toSuccessResponse().getTokens());
 
         // Create AuthenticationInfo object
         OidcAuthCredentials credentials = new OidcAuthCredentials(oidcSubject, idp);
@@ -101,7 +97,7 @@ public class SlingUserInfoProcessorImpl implements UserInfoProcessor {
             if (groups instanceof JSONArray) {
                 JSONArray groupJsonArray = (JSONArray) groups;
                 logger.debug("Groups: {}", groups);
-                //Convert the groups in a Set of Strings
+                // Convert the groups in a Set of Strings
                 groupJsonArray.forEach(group -> credentials.addGroup(group.toString()));
             }
 
@@ -112,20 +108,24 @@ public class SlingUserInfoProcessorImpl implements UserInfoProcessor {
                 }
             });
         }
-        //Store the Access Token on user node
+        // Store the Access Token on user node
         String accessToken = tokens.accessToken();
         if (storeAccessToken && accessToken != null) {
             credentials.setAttribute(OAuthTokenStore.PROPERTY_NAME_ACCESS_TOKEN, cryptoService.encrypt(accessToken));
         } else {
-            logger.debug("Access Token is null, omit adding as credentials attribute '{}'", OAuthTokenStore.PROPERTY_NAME_ACCESS_TOKEN);
+            logger.debug(
+                    "Access Token is null, omit adding as credentials attribute '{}'",
+                    OAuthTokenStore.PROPERTY_NAME_ACCESS_TOKEN);
         }
 
-        //Store the Refresh Token on user node
+        // Store the Refresh Token on user node
         String refreshToken = tokens.accessToken();
         if (storeRefreshToken && refreshToken != null) {
             credentials.setAttribute(OAuthTokenStore.PROPERTY_NAME_ACCESS_TOKEN, cryptoService.encrypt(refreshToken));
         } else {
-            logger.debug("Refresh Token is null, omit adding as credentials attribute '{}'", OAuthTokenStore.PROPERTY_NAME_REFRESH_TOKEN);
+            logger.debug(
+                    "Refresh Token is null, omit adding as credentials attribute '{}'",
+                    OAuthTokenStore.PROPERTY_NAME_REFRESH_TOKEN);
         }
 
         return credentials;
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenAccessImpl.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenAccessImpl.java
index 16b4358..5d375f7 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenAccessImpl.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenAccessImpl.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -32,46 +34,56 @@ import org.slf4j.LoggerFactory;
 
 @Component
 public class TokenAccessImpl implements OAuthTokenAccess {
-    
+
     private final Logger logger = LoggerFactory.getLogger(getClass());
-    
+
     private final OAuthTokenStore tokenStore;
     private final OAuthTokenRefresher tokenRefresher;
-    
+
     @Activate
     public TokenAccessImpl(@Reference OAuthTokenStore tokenStore, @Reference OAuthTokenRefresher tokenRefresher) {
         this.tokenStore = tokenStore;
         this.tokenRefresher = tokenRefresher;
     }
-    
+
     @Override
-    public @NotNull OAuthTokenResponse getAccessToken(@NotNull ClientConnection connection, @NotNull SlingHttpServletRequest request, @NotNull String redirectPath) {
-        
+    public @NotNull OAuthTokenResponse getAccessToken(
+            @NotNull ClientConnection connection,
+            @NotNull SlingHttpServletRequest request,
+            @NotNull String redirectPath) {
+
         ResourceResolver resolver = request.getResourceResolver();
         OAuthToken token = tokenStore.getAccessToken(connection, resolver);
-        
+
         if (logger.isDebugEnabled()) {
-            logger.debug("Accessing token for connection {} and user {}", connection.name(), request.getUserPrincipal());
+            logger.debug(
+                    "Accessing token for connection {} and user {}", connection.name(), request.getUserPrincipal());
         }
         // valid access token present -> return token
         if (token.getState() == TokenState.VALID) {
             if (logger.isDebugEnabled()) {
-                logger.debug("Returning valid access token for connection {} and user {}", connection.name(), request.getUserPrincipal());
+                logger.debug(
+                        "Returning valid access token for connection {} and user {}",
+                        connection.name(),
+                        request.getUserPrincipal());
             }
             return new OAuthTokenResponse(Optional.of(token.getValue()), connection, request, redirectPath);
         }
-        
+
         // expired token but refresh token present -> refresh and return
         if (token.getState() == TokenState.EXPIRED) {
             OAuthToken refreshToken = tokenStore.getRefreshToken(connection, resolver);
             if (refreshToken.getState() == TokenState.VALID) {
                 if (logger.isDebugEnabled()) {
-                    logger.debug("Refreshing expired access token for connection {} and user {}", connection.name(), request.getUserPrincipal());
+                    logger.debug(
+                            "Refreshing expired access token for connection {} and user {}",
+                            connection.name(),
+                            request.getUserPrincipal());
                 }
 
                 OAuthTokens newTokens = tokenRefresher.refreshTokens(connection, refreshToken.getValue());
                 tokenStore.persistTokens(connection, resolver, newTokens);
-                
+
                 // FIXME: newTokens.accessToken() may return null -> NPE
                 return new OAuthTokenResponse(Optional.of(newTokens.accessToken()), connection, request, redirectPath);
             }
@@ -79,24 +91,34 @@ public class TokenAccessImpl implements OAuthTokenAccess {
 
         // all other scenarios -> redirect
         if (logger.isDebugEnabled()) {
-            logger.debug("No valid access token found for connection {} and user {}", connection.name(), request.getUserPrincipal());
+            logger.debug(
+                    "No valid access token found for connection {} and user {}",
+                    connection.name(),
+                    request.getUserPrincipal());
         }
         return new OAuthTokenResponse(Optional.empty(), connection, request, redirectPath);
     }
-    
+
     @Override
-    public @NotNull OAuthTokenResponse clearAccessToken(@NotNull ClientConnection connection, @NotNull SlingHttpServletRequest request, @NotNull String redirectPath) {
+    public @NotNull OAuthTokenResponse clearAccessToken(
+            @NotNull ClientConnection connection,
+            @NotNull SlingHttpServletRequest request,
+            @NotNull String redirectPath) {
         if (logger.isDebugEnabled()) {
-            logger.debug("Clearing access token for connection {} and user {}", connection.name(), request.getUserPrincipal());
+            logger.debug(
+                    "Clearing access token for connection {} and user {}",
+                    connection.name(),
+                    request.getUserPrincipal());
         }
         tokenStore.clearAccessToken(connection, request.getResourceResolver());
         return new OAuthTokenResponse(Optional.empty(), connection, request, redirectPath);
     }
-    
+
     @Override
     public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) {
         if (logger.isDebugEnabled()) {
-            logger.debug("Clearing access token for connection {} and user {}", connection.name(), resolver.getUserID());
+            logger.debug(
+                    "Clearing access token for connection {} and user {}", connection.name(), resolver.getUserID());
         }
         tokenStore.clearAccessToken(connection, resolver);
     }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenState.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenState.java
index 56d350b..24945ef 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenState.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenState.java
@@ -1,21 +1,25 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 public enum TokenState {
-    VALID, EXPIRED, MISSING;
+    VALID,
+    EXPIRED,
+    MISSING;
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenStore.java b/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenStore.java
index 9ac427f..31580ef 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenStore.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/impl/TokenStore.java
@@ -1,29 +1,27 @@
 /*
- * Licensed to the Sakai Foundation (SF) under one
- * or more contributor license agreements. See the NOTICE file
+ * 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 SF licenses this file
+ * 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
+ * with the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *   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.
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.crypto.Mac;
 import javax.crypto.SecretKey;
 import javax.crypto.spec.SecretKeySpec;
+
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.File;
@@ -39,6 +37,10 @@ import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.util.concurrent.atomic.AtomicReferenceArray;
 
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * The <code>TokenStore</code> class provides the secure token hash
  * implementation used by the {@link OidcAuthenticationHandler} to generate,
@@ -110,8 +112,8 @@ class TokenStore {
      * @throws InvalidKeyException
      * @throws IllegalStateException
      */
-    TokenStore(@NotNull final File tokenFile, final long sessionTimeout,
-               final boolean fastSeed) throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException {
+    TokenStore(@NotNull final File tokenFile, final long sessionTimeout, final boolean fastSeed)
+            throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException {
 
         this.random = SecureRandom.getInstance(SHA1PRNG);
         this.ttl = sessionTimeout;
@@ -126,11 +128,11 @@ class TokenStore {
             random.setSeed(getFastEntropy());
         } else {
             log.info("Seeding the secure random number generator can take "
-                + "up to several minutes on some operating systems depending "
-                + "upon environment factors. If this is a problem for you, "
-                + "set the system property 'java.security.egd' to "
-                + "'file:/dev/./urandom' or enable the Fast Seed Generator "
-                + "in the Web Console");
+                    + "up to several minutes on some operating systems depending "
+                    + "upon environment factors. If this is a problem for you, "
+                    + "set the system property 'java.security.egd' to "
+                    + "'file:/dev/./urandom' or enable the Fast Seed Generator "
+                    + "in the Web Console");
         }
         byte[] b = new byte[20];
         random.nextBytes(b);
@@ -149,19 +151,19 @@ class TokenStore {
      * @throws NoSuchAlgorithmException
      * @throws InvalidKeyException
      */
-    @NotNull String encode(final long expires, final @NotNull String userId)
+    @NotNull
+    String encode(final long expires, final @NotNull String userId)
             throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException {
         int token = getActiveToken();
         SecretKey key = currentTokens.get(token);
         return encode(expires, userId, token, key);
     }
 
-    private static @NotNull String encode(final long expires, final @NotNull String userId,
-                                          final int token, final @NotNull SecretKey key) throws IllegalStateException,
-            NoSuchAlgorithmException, InvalidKeyException {
+    private static @NotNull String encode(
+            final long expires, final @NotNull String userId, final int token, final @NotNull SecretKey key)
+            throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException {
 
-        String cookiePayload = token + String.valueOf(expires)
-            + "@" + userId;
+        String cookiePayload = token + String.valueOf(expires) + "@" + userId;
         Mac m = Mac.getInstance(HMAC_SHA256);
         m.init(key);
         m.update(cookiePayload.getBytes(StandardCharsets.UTF_8));
@@ -218,22 +220,25 @@ class TokenStore {
             log.error("AuthNCookie value '{}' has expired {}ms ago", value, (System.currentTimeMillis() - cookieTime));
             return false;
         }
-        
+
         try {
             SecretKey secretKey = currentTokens.get(tokenNumber);
-            if ( secretKey == null ) {
+            if (secretKey == null) {
                 log.error("AuthNCookie value '{}' points to an unknown token number", value);
                 return false;
             }
             String hmac = encode(cookieTime, parts[2], tokenNumber, secretKey);
             return value.equals(hmac);
-        } catch (ArrayIndexOutOfBoundsException | InvalidKeyException | IllegalStateException | NoSuchAlgorithmException e) {
+        } catch (ArrayIndexOutOfBoundsException
+                | InvalidKeyException
+                | IllegalStateException
+                | NoSuchAlgorithmException e) {
             log.error(e.getMessage(), e);
         }
         log.error("AuthNCookie value '{}' is invalid", value);
         return false;
     }
-    
+
     private static boolean isExpired(long cookieTime) {
         return System.currentTimeMillis() >= cookieTime;
     }
@@ -244,12 +249,10 @@ class TokenStore {
      * @return the current token.
      */
     private synchronized int getActiveToken() {
-        if (System.currentTimeMillis() > nextUpdate
-            || currentTokens.get(currentToken) == null) {
+        if (System.currentTimeMillis() > nextUpdate || currentTokens.get(currentToken) == null) {
             // cycle so that during a typical ttl the tokens get completely
             // refreshed.
-            nextUpdate = System.currentTimeMillis() + ttl
-                / (currentTokens.length() - 1);
+            nextUpdate = System.currentTimeMillis() + ttl / (currentTokens.length() - 1);
             byte[] b = new byte[20];
             random.nextBytes(b);
 
@@ -269,11 +272,11 @@ class TokenStore {
      * Stores the current set of tokens to the token file
      */
     private void saveTokens() {
-            File parent = tokenFile.getAbsoluteFile().getParentFile();
-            log.info("Token File {} parent {} ", tokenFile, parent);
-            if (!parent.exists()) {
-                parent.mkdirs();
-            }
+        File parent = tokenFile.getAbsoluteFile().getParentFile();
+        log.info("Token File {} parent {} ", tokenFile, parent);
+        if (!parent.exists()) {
+            parent.mkdirs();
+        }
         try (DataOutputStream keyOutputStream = new DataOutputStream(new FileOutputStream(tmpTokenFile))) {
             keyOutputStream.writeInt(currentToken);
             keyOutputStream.writeLong(nextUpdate);
@@ -421,4 +424,4 @@ class TokenStore {
             value >>= 8;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/spi/LoginCookieManager.java b/src/main/java/org/apache/sling/auth/oauth_client/spi/LoginCookieManager.java
index 5b1febd..4791413 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/spi/LoginCookieManager.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/spi/LoginCookieManager.java
@@ -1,31 +1,33 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.spi;
 
-import org.apache.sling.auth.core.spi.AuthenticationInfo;
-import org.apache.sling.jcr.api.SlingRepository;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
 import javax.jcr.Credentials;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.sling.auth.core.spi.AuthenticationInfo;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * This class is responsible for managing authentication cookie.
  */
@@ -38,20 +40,25 @@ public interface LoginCookieManager {
      * @param repository
      * @param creds
      */
-    void setLoginCookie(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, 
-                        @NotNull SlingRepository repository, @NotNull Credentials creds);
+    void setLoginCookie(
+            @NotNull HttpServletRequest request,
+            @NotNull HttpServletResponse response,
+            @NotNull SlingRepository repository,
+            @NotNull Credentials creds);
 
     /**
      * Verify the login cookie in the request. If the Authentication Handler do not verify the cookie, return null.
      * @param request
      * @return AuthenticationInfo
      */
-    @Nullable AuthenticationInfo verifyLoginCookie(@NotNull HttpServletRequest request);
+    @Nullable
+    AuthenticationInfo verifyLoginCookie(@NotNull HttpServletRequest request);
 
     /**
      * Get the login cookie from the request. If the Authentication Handler do not verify the cookie, return null.
      * @param request
      * @return Cookie
      */
-    @Nullable Cookie getLoginCookie(@NotNull HttpServletRequest request);
+    @Nullable
+    Cookie getLoginCookie(@NotNull HttpServletRequest request);
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/spi/OidcAuthCredentials.java b/src/main/java/org/apache/sling/auth/oauth_client/spi/OidcAuthCredentials.java
index 631964a..be8c0ae 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/spi/OidcAuthCredentials.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/spi/OidcAuthCredentials.java
@@ -1,54 +1,41 @@
 /*
- * 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
+ * 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
+ *   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.
- */
-/*
- * 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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.spi;
 
-import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
 import javax.jcr.Credentials;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 public class OidcAuthCredentials implements Credentials {
 
     private final ExternalIdentityRef userId;
 
     private final String idp;
-    private final Map<String,Object> attributes = new HashMap<>();
+    private final Map<String, Object> attributes = new HashMap<>();
     private final Set<String> groups = new HashSet<>();
 
     public OidcAuthCredentials(@NotNull String userId, @NotNull String idp) {
@@ -56,15 +43,18 @@ public class OidcAuthCredentials implements Credentials {
         this.idp = idp;
     }
 
-    @NotNull public String getUserId() {
+    @NotNull
+    public String getUserId() {
         return userId.getId();
     }
 
-    @NotNull public String getIdp() {
+    @NotNull
+    public String getIdp() {
         return idp;
     }
 
-    @NotNull public Map<String,Object> getAttributes() {
+    @NotNull
+    public Map<String, Object> getAttributes() {
         return Collections.unmodifiableMap(attributes);
     }
 
@@ -73,8 +63,9 @@ public class OidcAuthCredentials implements Credentials {
             attributes.put(key, value);
         }
     }
-    
-    @Nullable public Object getAttribute(@NotNull String key) {
+
+    @Nullable
+    public Object getAttribute(@NotNull String key) {
         return attributes.get(key);
     }
 
@@ -82,7 +73,8 @@ public class OidcAuthCredentials implements Credentials {
         this.groups.add(group);
     }
 
-    @NotNull public Iterable<String> getGroups() {
+    @NotNull
+    public Iterable<String> getGroups() {
         return groups;
     }
- }
+}
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/spi/UserInfoProcessor.java b/src/main/java/org/apache/sling/auth/oauth_client/spi/UserInfoProcessor.java
index 6785c73..d794481 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/spi/UserInfoProcessor.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/spi/UserInfoProcessor.java
@@ -1,19 +1,20 @@
 /*
- * Licensed to the Sakai Foundation (SF) under one
- * or more contributor license agreements. See the NOTICE file
+ * 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 SF licenses this file
+ * 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
+ * with the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *   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.
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.sling.auth.oauth_client.spi;
 
@@ -43,6 +44,7 @@ public interface UserInfoProcessor {
      * @param idp
      * @return
      */
-    @NotNull OidcAuthCredentials process(@Nullable String userInfo, @NotNull String tokenResponse,
-                                         @NotNull String oidcSubject, @NotNull String idp);
+    @NotNull
+    OidcAuthCredentials process(
+            @Nullable String userInfo, @NotNull String tokenResponse, @NotNull String oidcSubject, @NotNull String idp);
 }
diff --git a/src/main/java/org/apache/sling/auth/oauth_client/support/OAuthEnabledSlingServlet.java b/src/main/java/org/apache/sling/auth/oauth_client/support/OAuthEnabledSlingServlet.java
index 036a2d3..2e9133d 100644
--- a/src/main/java/org/apache/sling/auth/oauth_client/support/OAuthEnabledSlingServlet.java
+++ b/src/main/java/org/apache/sling/auth/oauth_client/support/OAuthEnabledSlingServlet.java
@@ -1,32 +1,29 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.support;
 
-import static org.apache.sling.api.servlets.HttpConstants.METHOD_DELETE;
-import static org.apache.sling.api.servlets.HttpConstants.METHOD_GET;
-import static org.apache.sling.api.servlets.HttpConstants.METHOD_POST;
-import static org.apache.sling.api.servlets.HttpConstants.METHOD_PUT;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 import java.util.Objects;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -38,12 +35,18 @@ import org.apache.sling.auth.oauth_client.impl.TokenState;
 import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
+import static org.apache.sling.api.servlets.HttpConstants.METHOD_DELETE;
+import static org.apache.sling.api.servlets.HttpConstants.METHOD_GET;
+import static org.apache.sling.api.servlets.HttpConstants.METHOD_POST;
+import static org.apache.sling.api.servlets.HttpConstants.METHOD_PUT;
+
 /**
  * Support class for implementing OAuth-enabled servlets
- * 
+ *
  * <p>Features:</p>
- * 
- * <ul> 
+ *
+ * <ul>
  *  <li>Handles OAuth token retrieval and refresh</li>
  *  <li>Starts the authentication flow if no token is available</li>
  *  <li>Handles invalid access tokens ( {@link #isInvalidAccessTokenException(Exception)} )</li>
@@ -51,19 +54,19 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class OAuthEnabledSlingServlet extends SlingAllMethodsServlet {
 
-	private static final long serialVersionUID = 1L;
-	
-	private final Logger logger = LoggerFactory.getLogger(getClass());
+    private static final long serialVersionUID = 1L;
+
+    private final Logger logger = LoggerFactory.getLogger(getClass());
 
     private final ClientConnection connection;
 
     private final OAuthTokenAccess tokenAccess;
-	
+
     protected OAuthEnabledSlingServlet(@NotNull ClientConnection connection, @NotNull OAuthTokenAccess tokenAccess) {
         this.connection = Objects.requireNonNull(connection, "connection may not null");
         this.tokenAccess = Objects.requireNonNull(tokenAccess, "tokenAccess may not null");
     }
-    
+
     @Override
     protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
             throws ServletException, IOException {
@@ -75,103 +78,110 @@ public abstract class OAuthEnabledSlingServlet extends SlingAllMethodsServlet {
             throws ServletException, IOException {
         handleRequestWithToken(request, response, METHOD_POST);
     }
-    
+
     @Override
     protected void doDelete(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
             throws ServletException, IOException {
         handleRequestWithToken(request, response, METHOD_DELETE);
     }
-    
+
     @Override
     protected void doPut(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
             throws ServletException, IOException {
         handleRequestWithToken(request, response, METHOD_PUT);
     }
-    
+
     @Override
     protected void doGeneric(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
             throws ServletException, IOException {
         handleRequestWithToken(request, response, request.getMethod());
     }
-    
-	private void handleRequestWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String method)
-			throws ServletException, IOException {
-	    
-	    if ( request.getRemoteUser() == null ) {
+
+    private void handleRequestWithToken(
+            @NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String method)
+            throws ServletException, IOException {
+
+        if (request.getRemoteUser() == null) {
             response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "User is not authenticated");
             return;
-	    }
-
-	    String redirectPath = Objects.requireNonNull(getRedirectPath(request), "getRedirectPath() may not return null");
-	    
-	    if ( logger.isDebugEnabled() )
-	        logger.debug("Configured with connection (name={}) and redirectPath={}", connection.name(), redirectPath);
-	    
-	    OAuthTokenResponse tokenResponse = tokenAccess.getAccessToken(connection, request, redirectPath);
-	    if (tokenResponse.hasValidToken() ) {
-	        OAuthToken token = new OAuthToken(TokenState.VALID, tokenResponse.getTokenValue());
-	        try {
-	        switch ( method ) {
-                case METHOD_GET:
-                    doGetWithToken(request, response, token.getValue());
-                    break;
-                case METHOD_POST:
-                    doPostWithToken(request, response, token.getValue());
-                    break;
-                case METHOD_PUT:
-                    doPutWithToken(request, response, token.getValue());
-                    break;
-                case METHOD_DELETE:
-                    doDeleteWithToken(request, response, token.getValue());
-                    break;
-                default:
-                    doGenericWithToken(request, response, token.getValue());
-                    break;
-	        }
-        } catch (IOException | ServletException e) {
-            if (isInvalidAccessTokenException(e)) {
-                logger.warn("Invalid access token, clearing exiting token and restarting OAuth flow", e);
-                OAuthTokenResponse newTokenResponse = tokenAccess.clearAccessToken(connection, request, redirectPath);
-                response.sendRedirect(newTokenResponse.getRedirectUri().toString());
-            } else {
-                throw e;
+        }
+
+        String redirectPath = Objects.requireNonNull(getRedirectPath(request), "getRedirectPath() may not return null");
+
+        if (logger.isDebugEnabled())
+            logger.debug("Configured with connection (name={}) and redirectPath={}", connection.name(), redirectPath);
+
+        OAuthTokenResponse tokenResponse = tokenAccess.getAccessToken(connection, request, redirectPath);
+        if (tokenResponse.hasValidToken()) {
+            OAuthToken token = new OAuthToken(TokenState.VALID, tokenResponse.getTokenValue());
+            try {
+                switch (method) {
+                    case METHOD_GET:
+                        doGetWithToken(request, response, token.getValue());
+                        break;
+                    case METHOD_POST:
+                        doPostWithToken(request, response, token.getValue());
+                        break;
+                    case METHOD_PUT:
+                        doPutWithToken(request, response, token.getValue());
+                        break;
+                    case METHOD_DELETE:
+                        doDeleteWithToken(request, response, token.getValue());
+                        break;
+                    default:
+                        doGenericWithToken(request, response, token.getValue());
+                        break;
+                }
+            } catch (IOException | ServletException e) {
+                if (isInvalidAccessTokenException(e)) {
+                    logger.warn("Invalid access token, clearing exiting token and restarting OAuth flow", e);
+                    OAuthTokenResponse newTokenResponse =
+                            tokenAccess.clearAccessToken(connection, request, redirectPath);
+                    response.sendRedirect(newTokenResponse.getRedirectUri().toString());
+                } else {
+                    throw e;
+                }
             }
+        } else {
+            response.sendRedirect(tokenResponse.getRedirectUri().toString());
         }
-	    } else {
-	        response.sendRedirect(tokenResponse.getRedirectUri().toString());
-	    }
-	}
-
-	// TODO - do we need this as a protected method?
-	protected @NotNull String getRedirectPath(@NotNull SlingHttpServletRequest request) {
-	    return request.getRequestURI();
-	}
-
-	protected void doGetWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
-	        throws IOException, ServletException {
-	    handleMethodNotImplemented(request, response);
-	}
-
-	protected void doPostWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
-	        throws IOException, ServletException {
-	    handleMethodNotImplemented(request, response);
-	}
-
-	protected void doPutWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
-	        throws IOException, ServletException {
-	    handleMethodNotImplemented(request, response);
-	}
-
-	protected void doDeleteWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
-	        throws IOException, ServletException {
-	    handleMethodNotImplemented(request, response);
-	}
-	
-    protected void doGenericWithToken(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
+    }
+
+    // TODO - do we need this as a protected method?
+    protected @NotNull String getRedirectPath(@NotNull SlingHttpServletRequest request) {
+        return request.getRequestURI();
+    }
+
+    protected void doGetWithToken(
+            @NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
+            throws IOException, ServletException {
+        handleMethodNotImplemented(request, response);
+    }
+
+    protected void doPostWithToken(
+            @NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
             throws IOException, ServletException {
         handleMethodNotImplemented(request, response);
     }
-	
+
+    protected void doPutWithToken(
+            @NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
+            throws IOException, ServletException {
+        handleMethodNotImplemented(request, response);
+    }
+
+    protected void doDeleteWithToken(
+            @NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
+            throws IOException, ServletException {
+        handleMethodNotImplemented(request, response);
+    }
+
+    protected void doGenericWithToken(
+            @NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response, String accessToken)
+            throws IOException, ServletException {
+        handleMethodNotImplemented(request, response);
+    }
+
     protected boolean isInvalidAccessTokenException(Exception e) {
         return false;
     }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/AuthorizationCodeFlowIT.java b/src/test/java/org/apache/sling/auth/oauth_client/AuthorizationCodeFlowIT.java
index a77fe61..3a69665 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/AuthorizationCodeFlowIT.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/AuthorizationCodeFlowIT.java
@@ -1,25 +1,23 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
-import static java.lang.String.format;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertTrue;
-
 import java.io.IOException;
 import java.net.URI;
 import java.net.URLDecoder;
@@ -42,6 +40,10 @@ import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.nimbusds.jwt.SignedJWT;
+import dasniko.testcontainers.keycloak.KeycloakContainer;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.NameValuePair;
@@ -70,27 +72,28 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.nimbusds.jwt.SignedJWT;
-
-import dasniko.testcontainers.keycloak.KeycloakContainer;
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertTrue;
 
 class AuthorizationCodeFlowIT {
 
     private static final String IV_GENERATOR_REGISTRAR_PID = JasyptRandomIvGeneratorRegistrar.class.getName();
     private static final String PASSWORD_PROVIDER_PID = EnvironmentVariablePasswordProvider.class.getName();
     private static final String CRYPTO_SERVICE_PID = JasyptStandardPbeStringCryptoService.class.getName();
-    
+
     private static final String OIDC_CONFIG_PID = OidcConnectionImpl.class.getName();
     private static final String OAUTH_CONFIG_PID = OAuthConnectionImpl.class.getName();
     private static final int MAX_RETRY = 10;
     private static SupportBundle supportBundle;
 
-    private static final String OIDC_AUTHENTICATION_HANDLER_PID = "org.apache.sling.auth.oauth_client.impl.OidcAuthenticationHandler";
+    private static final String OIDC_AUTHENTICATION_HANDLER_PID =
+            "org.apache.sling.auth.oauth_client.impl.OidcAuthenticationHandler";
     private static final String SLING_AUTHENTICATOR_PID = "org.apache.sling.engine.impl.auth.SlingAuthenticator";
-    private static final String SYNC_HANDLER_PID = "org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler";
-    private static final String EXTERNAL_LOGIN_MODULE_FACTORY_PID = "org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalLoginModuleFactory";
+    private static final String SYNC_HANDLER_PID =
+            "org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler";
+    private static final String EXTERNAL_LOGIN_MODULE_FACTORY_PID =
+            "org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalLoginModuleFactory";
     public static final String TEST_PATH = "/content/test-1";
     private KeycloakContainer keycloak;
     private SlingClient sling;
@@ -103,7 +106,7 @@ class AuthorizationCodeFlowIT {
 
     @BeforeAll
     static void createSupportBundle(@TempDir Path tempDir) throws IOException {
-        
+
         supportBundle = new SupportBundle(tempDir);
         supportBundle.generate();
     }
@@ -115,13 +118,13 @@ class AuthorizationCodeFlowIT {
         // KEYCLOAK_URL=http://localhost:24098/
         // this is most usually done in an IDE, with both Keycloak and Sling running
         String existingKeyCloakUrl = System.getenv("KEYCLOAK_URL");
-        if ( existingKeyCloakUrl == null ) {
+        if (existingKeyCloakUrl == null) {
             keycloak = new KeycloakContainer("quay.io/keycloak/keycloak:20.0.3")
                     .withRealmImportFile("keycloak-import/sling.json");
             keycloak.start();
             keycloakPort = keycloak.getHttpPort();
         } else {
-            keycloakPort = URI.create(existingKeyCloakUrl).getPort(); 
+            keycloakPort = URI.create(existingKeyCloakUrl).getPort();
         }
     }
 
@@ -129,32 +132,35 @@ class AuthorizationCodeFlowIT {
     void initSling() throws ClientException, InterruptedException, TimeoutException {
 
         slingPort = Integer.getInteger("sling.http.port", 8080);
-        sling = SlingClient.Builder.create(URI.create("http://localhost:" + slingPort), "admin", "admin").disableRedirectHandling().build();
-        slingUser = SlingClient.Builder.create(URI.create("http://localhost:" + slingPort), null, null).disableRedirectHandling().build();
+        sling = SlingClient.Builder.create(URI.create("http://localhost:" + slingPort), "admin", "admin")
+                .disableRedirectHandling()
+                .build();
+        slingUser = SlingClient.Builder.create(URI.create("http://localhost:" + slingPort), null, null)
+                .disableRedirectHandling()
+                .build();
 
         // ensure all previous connections are cleaned up
         sling.adaptTo(OsgiConsoleClient.class).deleteConfiguration(OIDC_CONFIG_PID + ".keycloak");
-        
+
         // install the support bundle
         supportBundle.install(sling.adaptTo(OsgiConsoleClient.class));
     }
 
     @AfterEach
     void shutdownKeycloak() {
-        if ( keycloak != null )
-            keycloak.close();
+        if (keycloak != null) keycloak.close();
     }
-    
+
     @AfterEach
     void cleanupOsgiConfigs() throws ClientException {
 
         // the Sling testing clients do not offer a way of listing configurations, as assigned PIDs
         // are not predictable. So instead of running deleting test configs when the test starts
         // we fall back to cleaning after, which is hopefully reliable enough
-        for ( String pid : configPidsToCleanup )
+        for (String pid : configPidsToCleanup)
             sling.adaptTo(OsgiConsoleClient.class).deleteConfiguration(pid);
     }
-    
+
     @AfterEach
     void uninstallBundle() throws ClientException {
         supportBundle.uninstall(sling.adaptTo(OsgiConsoleClient.class));
@@ -162,94 +168,111 @@ class AuthorizationCodeFlowIT {
 
     @Test
     void accessTokenIsPresentOnSuccessfulLogin() throws Exception {
-        
+
         // configure Commons Crypto, see https://sling.apache.org/documentation/bundles/commons-crypto.html
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(IV_GENERATOR_REGISTRAR_PID +".sling-oauth", IV_GENERATOR_REGISTRAR_PID, 
-            Map.of("algorithm", "SHA1PRNG")
-        ));
-        
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(PASSWORD_PROVIDER_PID+".sling-oauth", PASSWORD_PROVIDER_PID,
-            Map.of("name", "IT_ENCRYPTION_PASSWORD")
-        ));
-        
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(CRYPTO_SERVICE_PID+".sling-oauth", CRYPTO_SERVICE_PID,
-            Map.of("algorithm", "PBEWITHHMACSHA512ANDAES_256", "names", "sling-oauth")
-        ));
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        IV_GENERATOR_REGISTRAR_PID + ".sling-oauth",
+                        IV_GENERATOR_REGISTRAR_PID,
+                        Map.of("algorithm", "SHA1PRNG")));
+
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        PASSWORD_PROVIDER_PID + ".sling-oauth",
+                        PASSWORD_PROVIDER_PID,
+                        Map.of("name", "IT_ENCRYPTION_PASSWORD")));
+
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        CRYPTO_SERVICE_PID + ".sling-oauth",
+                        CRYPTO_SERVICE_PID,
+                        Map.of("algorithm", "PBEWITHHMACSHA512ANDAES_256", "names", "sling-oauth")));
 
         // configure token store
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(JcrUserHomeOAuthTokenStore.class.getName(), null,
-                Map.of(
-                        "unused", "unused"
-                )
-            ));
-        
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(JcrUserHomeOAuthTokenStore.class.getName(), null, Map.of("unused", "unused")));
+
         String oidcConnectionName = "keycloak";
 
         // configure connection to keycloak
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(OAUTH_CONFIG_PID+ ".keycloak",OIDC_CONFIG_PID,
-                Map.of(
-                    "name", oidcConnectionName, 
-                    "baseUrl", "http://localhost:" + keycloakPort+"/realms/sling",
-                    "clientId", "oidc-test",
-                    "clientSecret", "wM2XIbxBTLJAac2rJSuHyKaoP8IWvSwJ",
-                    "scopes", "openid"
-                )
-            ));
-
-        
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        OAUTH_CONFIG_PID + ".keycloak",
+                        OIDC_CONFIG_PID,
+                        Map.of(
+                                "name", oidcConnectionName,
+                                "baseUrl", "http://localhost:" + keycloakPort + "/realms/sling",
+                                "clientId", "oidc-test",
+                                "clientSecret", "wM2XIbxBTLJAac2rJSuHyKaoP8IWvSwJ",
+                                "scopes", "openid")));
+
         // clean up any existing tokens
         String userPath = getUserPath(sling, sling.getUser());
         sling.deletePath(userPath + "/oauth-tokens/" + oidcConnectionName, 200);
         sling.doGet(userPath + "/oauth-tokens/" + oidcConnectionName, 404);
 
         // kick off oidc auth
-        SlingHttpResponse entryPointResponse = sling.doGet("/system/sling/oauth/entry-point", List.of(new BasicNameValuePair("c", oidcConnectionName)), 302);
+        SlingHttpResponse entryPointResponse = sling.doGet(
+                "/system/sling/oauth/entry-point", List.of(new BasicNameValuePair("c", oidcConnectionName)), 302);
         Header locationHeader = entryPointResponse.getFirstHeader("location");
-        assertThat(locationHeader.getElements()).as("Location header value from entry-point request")
-            .singleElement().asString().startsWith("http://localhost:" + keycloakPort);
+        assertThat(locationHeader.getElements())
+                .as("Location header value from entry-point request")
+                .singleElement()
+                .asString()
+                .startsWith("http://localhost:" + keycloakPort);
         String locationHeaderValue = locationHeader.getValue();
-        
+
         DefaultCookieSpec cookieSpec = new DefaultCookieSpec();
-        List<Cookie> cookies = cookieSpec.parse(entryPointResponse.getFirstHeader("set-cookie"), new CookieOrigin("localhost", slingPort, "/", true));
-        Optional<Cookie> oauthCookie = cookies.stream().filter( c -> c.getName().equals("sling.oauth-request-key") )
-            .findFirst();
-       
+        List<Cookie> cookies = cookieSpec.parse(
+                entryPointResponse.getFirstHeader("set-cookie"), new CookieOrigin("localhost", slingPort, "/", true));
+        Optional<Cookie> oauthCookie = cookies.stream()
+                .filter(c -> c.getName().equals("sling.oauth-request-key"))
+                .findFirst();
+
         assertThat(oauthCookie).as("OAuth cookie set by entry point servlet").isPresent();
         String oauthRequestKey = oauthCookie.get().getValue();
-        
+
         // load login form from keycloak
         HttpClient httpClient = HttpClient.newHttpClient();
-        HttpRequest renderLoginFormRequest = HttpRequest.newBuilder().uri(URI.create(locationHeaderValue)).build();
-        HttpResponse<Stream<String>> renderLoginFormResponse = httpClient.send(renderLoginFormRequest, BodyHandlers.ofLines());
-        List<String> matchingFormLines = renderLoginFormResponse.body()
+        HttpRequest renderLoginFormRequest =
+                HttpRequest.newBuilder().uri(URI.create(locationHeaderValue)).build();
+        HttpResponse<Stream<String>> renderLoginFormResponse =
+                httpClient.send(renderLoginFormRequest, BodyHandlers.ofLines());
+        List<String> matchingFormLines = renderLoginFormResponse
+                .body()
                 .filter(line -> line.contains("id=\"kc-form-login\""))
                 .collect(Collectors.toList());
         assertThat(matchingFormLines).as("lines matching form id").singleElement();
         String formLine = matchingFormLines.get(0);
         int actionAttrStart = formLine.indexOf("action=\"") + "action=\"".length();
         int actionAttrEnd = formLine.indexOf('"', actionAttrStart);
-        
+
         String actionAttr = formLine.substring(actionAttrStart, actionAttrEnd).replace("&amp;", "&");
-        
+
         List<String> authFormRequestCookies = renderLoginFormResponse.headers().allValues("set-cookie");
-        
+
         Map<String, String> authData = Map.of("username", "test", "password", "test", "credentialId", "");
         String requestBody = authData.entrySet().stream()
-            .map( e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
-            .collect(Collectors.joining("&"));
-        
+                .map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "="
+                        + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
+                .collect(Collectors.joining("&"));
+
         HttpRequest.Builder authenticateRequest = HttpRequest.newBuilder(URI.create(actionAttr))
                 .POST(BodyPublishers.ofString(requestBody))
                 .header("content-type", "application/x-www-form-urlencoded");
         authFormRequestCookies.forEach(cookie -> authenticateRequest.header("cookie", cookie));
-        
-        HttpResponse<String> authenticateResponse = httpClient.send(authenticateRequest.build(), BodyHandlers.ofString());
+
+        HttpResponse<String> authenticateResponse =
+                httpClient.send(authenticateRequest.build(), BodyHandlers.ofString());
         System.out.println(authenticateResponse.body());
-        Optional<String> authResponseLocationHeader = authenticateResponse.headers().firstValue("location");
-        assertThat(authResponseLocationHeader).as("Authentication response header").isPresent();
-        
+        Optional<String> authResponseLocationHeader =
+                authenticateResponse.headers().firstValue("location");
+        assertThat(authResponseLocationHeader)
+                .as("Authentication response header")
+                .isPresent();
+
         URI redirectUri = URI.create(authResponseLocationHeader.get());
-        System.out.println(redirectUri.getRawPath()+"?" + redirectUri.getRawQuery());
+        System.out.println(redirectUri.getRawPath() + "?" + redirectUri.getRawQuery());
         List<NameValuePair> params = Arrays.stream(redirectUri.getRawQuery().split("&"))
                 .map(s -> {
                     String[] parts = s.split("=");
@@ -260,19 +283,19 @@ class AuthorizationCodeFlowIT {
         List<Header> headers = new ArrayList<>();
         headers.add(new BasicHeader("Cookie", "sling.oauth-request-key=" + oauthRequestKey));
         sling.doGet(redirectUri.getRawPath(), params, headers, 204);
-        
-        JsonNode keycloakToken = sling.doGetJson(userPath + "/oauth-tokens/" + oidcConnectionName,0,  200);
+
+        JsonNode keycloakToken = sling.doGetJson(userPath + "/oauth-tokens/" + oidcConnectionName, 0, 200);
         String accesToken = keycloakToken.get("access_token").asText();
 
         // decrypt the token since it's stored encrypted in the user's home
         HttpEntity postBody = new UrlEncodedFormEntity(List.of(
                 new BasicNameValuePair("token", accesToken),
-                new BasicNameValuePair("cryptoServiceName", "sling-oauth")
-        ));
-        
+                new BasicNameValuePair("cryptoServiceName", "sling-oauth")));
+
         System.err.println(format("Decrypting %s ...", accesToken));
-        
-        String decryptedToken = sling.doPost("/system/sling/decrypt",  postBody, 200).getContent();
+
+        String decryptedToken =
+                sling.doPost("/system/sling/decrypt", postBody, 200).getContent();
         // validate that the JWT is valid; we trust what keycloak has returned but just want to ensure that
         // the token was stored correctly
         SignedJWT.parse(decryptedToken);
@@ -290,7 +313,7 @@ class AuthorizationCodeFlowIT {
 
     void accessTokenIsPresentOnSuccessfulAuthenticationHandlerLogin(boolean withPkce) throws Exception {
 
-        //Create a sample content with the word "Hello word"
+        // Create a sample content with the word "Hello word"
         Map<String, String> properties = Map.of("text", "Hello World");
 
         // Convert Map to List<NameValuePair>
@@ -305,114 +328,133 @@ class AuthorizationCodeFlowIT {
         sling.doPost(TEST_PATH, entity, 200, 201);
 
         // configure Commons Crypto, see https://sling.apache.org/documentation/bundles/commons-crypto.html
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(IV_GENERATOR_REGISTRAR_PID +".sling-oauth", IV_GENERATOR_REGISTRAR_PID,
-                Map.of("algorithm", "SHA1PRNG")
-        ));
-
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(PASSWORD_PROVIDER_PID+".sling-oauth", PASSWORD_PROVIDER_PID,
-                Map.of("name", "IT_ENCRYPTION_PASSWORD")
-        ));
-
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(CRYPTO_SERVICE_PID+".sling-oauth", CRYPTO_SERVICE_PID,
-                Map.of("algorithm", "PBEWITHHMACSHA512ANDAES_256", "names", "sling-oauth")
-        ));
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        IV_GENERATOR_REGISTRAR_PID + ".sling-oauth",
+                        IV_GENERATOR_REGISTRAR_PID,
+                        Map.of("algorithm", "SHA1PRNG")));
+
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        PASSWORD_PROVIDER_PID + ".sling-oauth",
+                        PASSWORD_PROVIDER_PID,
+                        Map.of("name", "IT_ENCRYPTION_PASSWORD")));
+
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        CRYPTO_SERVICE_PID + ".sling-oauth",
+                        CRYPTO_SERVICE_PID,
+                        Map.of("algorithm", "PBEWITHHMACSHA512ANDAES_256", "names", "sling-oauth")));
 
         // configure token store
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(JcrUserHomeOAuthTokenStore.class.getName(), null,
-                Map.of(
-                        "unused", "unused"
-                )
-        ));
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(JcrUserHomeOAuthTokenStore.class.getName(), null, Map.of("unused", "unused")));
 
         String oidcConnectionName = "keycloak";
 
         // configure connection to keycloak
-        if ( withPkce ) {
-            configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(OIDC_CONFIG_PID + ".keycloak", OIDC_CONFIG_PID,
-                    Map.of(
-                            "name", oidcConnectionName,
-                            "baseUrl", "http://localhost:" + keycloakPort + "/realms/sling",
-                            "clientId", "oidc-pkce",
-                            "pkceEnabled", "true",
-                            "scopes", new String[]{"openid"}
-                    )
-            ));
+        if (withPkce) {
+            configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                    .editConfiguration(
+                            OIDC_CONFIG_PID + ".keycloak",
+                            OIDC_CONFIG_PID,
+                            Map.of(
+                                    "name",
+                                    oidcConnectionName,
+                                    "baseUrl",
+                                    "http://localhost:" + keycloakPort + "/realms/sling",
+                                    "clientId",
+                                    "oidc-pkce",
+                                    "pkceEnabled",
+                                    "true",
+                                    "scopes",
+                                    new String[] {"openid"})));
         } else {
-            configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(OIDC_CONFIG_PID + ".keycloak", OIDC_CONFIG_PID,
-                    Map.of(
-                            "name", oidcConnectionName,
-                            "baseUrl", "http://localhost:" + keycloakPort + "/realms/sling",
-                            "clientId", "oidc-test",
-                            "clientSecret", "wM2XIbxBTLJAac2rJSuHyKaoP8IWvSwJ",
-                            "scopes", new String[]{"openid"}
-                    )
-            ));
+            configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                    .editConfiguration(
+                            OIDC_CONFIG_PID + ".keycloak",
+                            OIDC_CONFIG_PID,
+                            Map.of(
+                                    "name",
+                                    oidcConnectionName,
+                                    "baseUrl",
+                                    "http://localhost:" + keycloakPort + "/realms/sling",
+                                    "clientId",
+                                    "oidc-test",
+                                    "clientSecret",
+                                    "wM2XIbxBTLJAac2rJSuHyKaoP8IWvSwJ",
+                                    "scopes",
+                                    new String[] {"openid"})));
         }
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(SLING_AUTHENTICATOR_PID, null,
-                Map.of(
-                        "auth.annonymous", true,
-                        "auth.sudo.cookie", "sling.sudo",
-                        "sling.auth.requirements", new String[]{
-                            "+/libs/granite/oauth/content/authorization",
-                            "+"+ TEST_PATH
-                        }
-                        ,
-                        "auth.http.realm", "Sling (Development)",
-                        "auth.http", "preemptive",
-                        "auth.sudo.parameter", "sudo"
-
-                )
-        ));
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        SLING_AUTHENTICATOR_PID,
+                        null,
+                        Map.of(
+                                "auth.annonymous", true,
+                                "auth.sudo.cookie", "sling.sudo",
+                                "sling.auth.requirements",
+                                        new String[] {"+/libs/granite/oauth/content/authorization", "+" + TEST_PATH},
+                                "auth.http.realm", "Sling (Development)",
+                                "auth.http", "preemptive",
+                                "auth.sudo.parameter", "sudo")));
 
         Map<String, Object> syncHandlerConfig = Map.ofEntries(
                 Map.entry("user.expirationTime", "1s"),
                 Map.entry("group.expirationTime", "1s"),
                 Map.entry("user.membershipExpTime", "1s"),
-                Map.entry("user.propertyMapping", new String[]{
-                        "profile/familyName=profile/given_name",
-                        "profile/givenName=profile/name",
-                        "rep:fullname=cn",
-                        "profile/email=profile/email",
-                        "oauth-tokens"
+                Map.entry("user.propertyMapping", new String[] {
+                    "profile/familyName=profile/given_name",
+                    "profile/givenName=profile/name",
+                    "rep:fullname=cn",
+                    "profile/email=profile/email",
+                    "oauth-tokens"
                 }),
                 Map.entry("user.pathPrefix", "oidc"),
                 Map.entry("group.pathPrefix", "oidc"),
                 Map.entry("user.membershipNestingDepth", "1"),
-                Map.entry("handler.name", "oidc")
-        );
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(SYNC_HANDLER_PID + ".keycloak", SYNC_HANDLER_PID, syncHandlerConfig));
-
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(EXTERNAL_LOGIN_MODULE_FACTORY_PID+ ".keycloak", EXTERNAL_LOGIN_MODULE_FACTORY_PID,
-                Map.of(
-                            "sync.handlerName", "oidc",
-                            "idp.name", "oidc"
-                )
-        ));
-
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(SlingUserInfoProcessorImpl.class.getName(), null,
-                Map.of(
-                        "storeAccessToken", "true",
-                        "storeRefreshToken", "true"
-                )
-        ));
+                Map.entry("handler.name", "oidc"));
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(SYNC_HANDLER_PID + ".keycloak", SYNC_HANDLER_PID, syncHandlerConfig));
+
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        EXTERNAL_LOGIN_MODULE_FACTORY_PID + ".keycloak",
+                        EXTERNAL_LOGIN_MODULE_FACTORY_PID,
+                        Map.of(
+                                "sync.handlerName", "oidc",
+                                "idp.name", "oidc")));
+
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        SlingUserInfoProcessorImpl.class.getName(),
+                        null,
+                        Map.of(
+                                "storeAccessToken", "true",
+                                "storeRefreshToken", "true")));
 
         HashMap<String, Object> authenticationHandlerConfig = new HashMap<>();
         authenticationHandlerConfig.put("path", TEST_PATH);
         authenticationHandlerConfig.put("defaultConnectionName", oidcConnectionName);
         authenticationHandlerConfig.put("defaultRedirect", TEST_PATH + ".html");
-        authenticationHandlerConfig.put("callbackUri", "http://localhost:" + slingPort + TEST_PATH + "/j_security_check");
-
+        authenticationHandlerConfig.put(
+                "callbackUri", "http://localhost:" + slingPort + TEST_PATH + "/j_security_check");
 
         authenticationHandlerConfig.put("pkceEnabled", Boolean.toString(withPkce));
 
-        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class).editConfiguration(OIDC_AUTHENTICATION_HANDLER_PID + ".keycloak", OIDC_AUTHENTICATION_HANDLER_PID, authenticationHandlerConfig));
+        configPidsToCleanup.add(sling.adaptTo(OsgiConsoleClient.class)
+                .editConfiguration(
+                        OIDC_AUTHENTICATION_HANDLER_PID + ".keycloak",
+                        OIDC_AUTHENTICATION_HANDLER_PID,
+                        authenticationHandlerConfig));
         // clean up any existing tokens
         String userPath = getUserPath(sling, sling.getUser());
         sling.deletePath(userPath + "/oauth-tokens/" + oidcConnectionName, 200);
         sling.doGet(userPath + "/oauth-tokens/" + oidcConnectionName, 404);
 
         // kick off oidc auth
-        // Create a user-agent NameValues to simulate a browser and add it to a list of headers to be sent with the request
+        // Create a user-agent NameValues to simulate a browser and add it to a list of headers to be sent with the
+        // request
         Header userAgentHeader = new BasicHeader("User-Agent", "Mozilla/5.0");
 
         SlingHttpResponse entryPointResponse = null;
@@ -428,11 +470,17 @@ class AuthorizationCodeFlowIT {
             }
             // Otherwise, we wait for a while and retry
             Thread.sleep(100);
-
         }
-        assertThat(locationHeader.getElements()).as("Location header value from entry-point request")
-                .singleElement().asString().startsWith("http://localhost:" + keycloakPort);
-        assertThat(locationHeader.getElements()).as("Nonce is present in the redirect").singleElement().asString().contains("nonce");
+        assertThat(locationHeader.getElements())
+                .as("Location header value from entry-point request")
+                .singleElement()
+                .asString()
+                .startsWith("http://localhost:" + keycloakPort);
+        assertThat(locationHeader.getElements())
+                .as("Nonce is present in the redirect")
+                .singleElement()
+                .asString()
+                .contains("nonce");
 
         String locationHeaderValue = locationHeader.getValue();
 
@@ -446,12 +494,16 @@ class AuthorizationCodeFlowIT {
         // Assert that cookies are set
         assertTrue(cookies.stream()
                 .filter(cookie -> OAuthStateManager.COOKIE_NAME_REQUEST_KEY.equals(cookie.getName()))
-                .findFirst().isPresent());
+                .findFirst()
+                .isPresent());
         // load login form from keycloak
         HttpClient httpClient = HttpClient.newHttpClient();
-        HttpRequest renderLoginFormRequest = HttpRequest.newBuilder().uri(URI.create(locationHeaderValue)).build();
-        HttpResponse<Stream<String>> renderLoginFormResponse = httpClient.send(renderLoginFormRequest, BodyHandlers.ofLines());
-        List<String> matchingFormLines = renderLoginFormResponse.body()
+        HttpRequest renderLoginFormRequest =
+                HttpRequest.newBuilder().uri(URI.create(locationHeaderValue)).build();
+        HttpResponse<Stream<String>> renderLoginFormResponse =
+                httpClient.send(renderLoginFormRequest, BodyHandlers.ofLines());
+        List<String> matchingFormLines = renderLoginFormResponse
+                .body()
                 .filter(line -> line.contains("id=\"kc-form-login\""))
                 .collect(Collectors.toList());
         assertThat(matchingFormLines).as("lines matching form id").singleElement();
@@ -466,7 +518,8 @@ class AuthorizationCodeFlowIT {
         // Post credentials to keycloak
         Map<String, String> authData = Map.of("username", "test", "password", "test", "credentialId", "");
         String requestBody = authData.entrySet().stream()
-                .map( e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
+                .map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "="
+                        + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
                 .collect(Collectors.joining("&"));
 
         HttpRequest.Builder authenticateRequest = HttpRequest.newBuilder(URI.create(actionAttr))
@@ -474,13 +527,17 @@ class AuthorizationCodeFlowIT {
                 .header("content-type", "application/x-www-form-urlencoded");
         authFormRequestCookies.forEach(cookie -> authenticateRequest.header("cookie", cookie));
 
-        HttpResponse<String> authenticateResponse = httpClient.send(authenticateRequest.build(), BodyHandlers.ofString());
+        HttpResponse<String> authenticateResponse =
+                httpClient.send(authenticateRequest.build(), BodyHandlers.ofString());
 
         // Assert response from keycloak
-        Optional<String> authResponseLocationHeader = authenticateResponse.headers().firstValue("location");
-        assertThat(authResponseLocationHeader).as("Authentication response header").isPresent();
+        Optional<String> authResponseLocationHeader =
+                authenticateResponse.headers().firstValue("location");
+        assertThat(authResponseLocationHeader)
+                .as("Authentication response header")
+                .isPresent();
 
-        //Http Request on sling with code from keycloak. The login cookie (sling.oidcauth) will be created
+        // Http Request on sling with code from keycloak. The login cookie (sling.oidcauth) will be created
         URI redirectUri = URI.create(authResponseLocationHeader.get());
         List<NameValuePair> params = Arrays.stream(redirectUri.getRawQuery().split("&"))
                 .map(s -> {
@@ -497,7 +554,7 @@ class AuthorizationCodeFlowIT {
         headers.add(new BasicHeader("Cookie", cookieHeader));
         SlingHttpResponse authenticatedResponse = slingUser.doGet(redirectUri.getRawPath(), params, headers, 302);
         Header[] cookieHeaders = authenticatedResponse.getHeaders("set-cookie");
-        //retrieve the login-cookie header
+        // retrieve the login-cookie header
         Header loginCookieHeader = Arrays.stream(cookieHeaders)
                 .filter(header -> header.getValue().contains("sling.oidcauth"))
                 .findFirst()
@@ -506,36 +563,37 @@ class AuthorizationCodeFlowIT {
         headers = new ArrayList<>();
         headers.add(new BasicHeader("Cookie", loginCookieHeader.getValue()));
 
-        //Get the page from sling with login cookie
+        // Get the page from sling with login cookie
         slingUser.doGet(TEST_PATH + ".json", new ArrayList<>(), headers, 200);
     }
 
     private String getUserPath(SlingClient sling, String authorizableId) throws ClientException {
 
         ObjectNode usersJson = (ObjectNode) sling.doGetJson("/home/users", 2, 200);
-        for ( Map.Entry<String,JsonNode> user : toIterable(usersJson.fields()) ) {
+        for (Map.Entry<String, JsonNode> user : toIterable(usersJson.fields())) {
             JsonNode jsonNode = user.getValue().get("jcr:primaryType");
-            if ( jsonNode == null )
-                continue;
+            if (jsonNode == null) continue;
 
-            if ( jsonNode.isTextual() && "rep:AuthorizableFolder".equals(jsonNode.asText())) {
+            if (jsonNode.isTextual() && "rep:AuthorizableFolder".equals(jsonNode.asText())) {
                 ObjectNode node = (ObjectNode) user.getValue();
-                for ( Map.Entry<String, JsonNode> user2 : toIterable(node.fields()) ) {
+                for (Map.Entry<String, JsonNode> user2 : toIterable(node.fields())) {
                     JsonNode primaryType = user2.getValue().get("jcr:primaryType");
-                    if ( primaryType != null && primaryType.isTextual() && primaryType.asText().equals("rep:User")) {
+                    if (primaryType != null
+                            && primaryType.isTextual()
+                            && primaryType.asText().equals("rep:User")) {
                         JsonNode authorizableIdProp = user2.getValue().get("rep:authorizableId");
-                        if (authorizableId.equals(authorizableIdProp.asText()) )
+                        if (authorizableId.equals(authorizableIdProp.asText()))
                             return "/home/users/" + user.getKey() + "/" + user2.getKey();
                     }
                 }
             }
         }
 
-        throw new IllegalArgumentException(String.format("Unable to locate path for user with id '%s'", authorizableId));
+        throw new IllegalArgumentException(
+                String.format("Unable to locate path for user with id '%s'", authorizableId));
     }
 
     private static <T> Iterable<T> toIterable(Iterator<T> iterator) {
         return () -> iterator;
     }
-
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/InMemoryOAuthTokenStore.java b/src/test/java/org/apache/sling/auth/oauth_client/InMemoryOAuthTokenStore.java
index b9ba0e9..9136408 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/InMemoryOAuthTokenStore.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/InMemoryOAuthTokenStore.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
@@ -31,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
 
 /**
  * In-memory, volatile token store implementation
- * 
+ *
  * <p>This implementation exists for testing purposes only</p>
  */
 public class InMemoryOAuthTokenStore implements OAuthTokenStore {
@@ -100,53 +102,55 @@ public class InMemoryOAuthTokenStore implements OAuthTokenStore {
             return expires == null || expires.isAfter(Instant.now());
         }
     }
-    
+
     private final Map<Key, Value> storage = new HashMap<>();
 
     @Override
-    public void persistTokens(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens)
+    public void persistTokens(
+            @NotNull ClientConnection connection, @NotNull ResourceResolver resolver, @NotNull OAuthTokens tokens)
             throws OAuthException {
         storage.put(new Key(connection.name(), resolver.getUserID()), new Value(tokens));
     }
 
     @Override
-    public @NotNull OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
+    public @NotNull OAuthToken getRefreshToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
         Value value = storage.get(new Key(connection.name(), resolver.getUserID()));
         if (value == null || value.tokens == null || value.tokens.refreshToken() == null)
             return new OAuthToken(TokenState.MISSING, null);
-        
+
         return new OAuthToken(TokenState.VALID, value.tokens.refreshToken());
     }
 
     @Override
-    public @NotNull OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
+    public @NotNull OAuthToken getAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
         Value value = storage.get(new Key(connection.name(), resolver.getUserID()));
-        if (value == null || value.tokens == null || value.tokens.accessToken() == null )
+        if (value == null || value.tokens == null || value.tokens.accessToken() == null)
             return new OAuthToken(TokenState.MISSING, null);
-        
-        if (!value.isValid())
-            return new OAuthToken(TokenState.EXPIRED, value.tokens.accessToken());
-        
+
+        if (!value.isValid()) return new OAuthToken(TokenState.EXPIRED, value.tokens.accessToken());
+
         return new OAuthToken(TokenState.VALID, value.tokens.accessToken());
-        
     }
 
     @Override
-    public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver) throws OAuthException {
+    public void clearAccessToken(@NotNull ClientConnection connection, @NotNull ResourceResolver resolver)
+            throws OAuthException {
         Key key = new Key(connection.name(), resolver.getUserID());
         Value value = storage.get(key);
-        
+
         // preserve the refresh token is present
-        if ( value != null && value.tokens != null && value.tokens.refreshToken() != null ) {
+        if (value != null && value.tokens != null && value.tokens.refreshToken() != null) {
             OAuthTokens newTokens = new OAuthTokens(null, 0, value.tokens.refreshToken());
             storage.put(key, new Value(newTokens));
-        // remover all tokens if only the access token is present
-        } else if ( value != null ) {
+            // remover all tokens if only the access token is present
+        } else if (value != null) {
             storage.remove(key);
         }
     }
-    
+
     public Stream<OAuthTokens> allTokens() {
         return storage.values().stream().map(Value::tokens);
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/OAuthUrisTest.java b/src/test/java/org/apache/sling/auth/oauth_client/OAuthUrisTest.java
index ff00cc3..9b044f1 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/OAuthUrisTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/OAuthUrisTest.java
@@ -1,23 +1,23 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import java.net.URI;
 
 import org.apache.sling.auth.oauth_client.impl.MockOidcConnection;
@@ -27,21 +27,24 @@ import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 @ExtendWith(SlingContextExtension.class)
 class OAuthUrisTest {
 
     private final SlingContext context = new SlingContext();
-    
+
     @Test
     void testRedirectUri() {
-        URI redirectUri = OAuthUris.getOAuthEntryPointUri(MockOidcConnection.DEFAULT_CONNECTION, context.request(), "/foo");
-        
-        assertThat(redirectUri).as("redirect uri")
-            .hasScheme("http")    
-            .hasHost("localhost")
-            .hasNoPort()
-            .hasPath("/system/sling/oauth/entry-point")
-            .hasQuery("c=mock-oidc&redirect=/foo");
-    }
+        URI redirectUri =
+                OAuthUris.getOAuthEntryPointUri(MockOidcConnection.DEFAULT_CONNECTION, context.request(), "/foo");
 
+        assertThat(redirectUri)
+                .as("redirect uri")
+                .hasScheme("http")
+                .hasHost("localhost")
+                .hasNoPort()
+                .hasPath("/system/sling/oauth/entry-point")
+                .hasQuery("c=mock-oidc&redirect=/foo");
+    }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/TokenAccessImplTest.java b/src/test/java/org/apache/sling/auth/oauth_client/TokenAccessImplTest.java
index cd51f3a..5e97d60 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/TokenAccessImplTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/TokenAccessImplTest.java
@@ -1,24 +1,23 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
 import org.apache.sling.auth.oauth_client.impl.MockOidcConnection;
 import org.apache.sling.auth.oauth_client.impl.OAuthTokenRefresher;
 import org.apache.sling.auth.oauth_client.impl.OAuthTokenStore;
@@ -30,81 +29,84 @@ import org.jetbrains.annotations.NotNull;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 @ExtendWith(SlingContextExtension.class)
 class TokenAccessImplTest {
-    
+
     private final SlingContext slingContext = new SlingContext();
 
     @Test
     void missingAccessToken() {
-        
+
         OAuthTokenStore tokenStore = new InMemoryOAuthTokenStore();
-        
+
         TokenAccessImpl tokenAccess = new TokenAccessImpl(tokenStore, null);
-        
-        OAuthTokenResponse tokenResponse = tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
-        
-        assertThat(tokenResponse)
-            .as("tokenResponse")
-            .isNotNull()
-            .satisfies( tr -> {
-                assertThat(tr.hasValidToken()).as("hasValidToken").isFalse();
-                assertThrows(IllegalStateException.class, tr::getTokenValue, "getTokenValue");
-                assertThat(tr.getRedirectUri()).as("redirectUri")
+
+        OAuthTokenResponse tokenResponse =
+                tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
+
+        assertThat(tokenResponse).as("tokenResponse").isNotNull().satisfies(tr -> {
+            assertThat(tr.hasValidToken()).as("hasValidToken").isFalse();
+            assertThrows(IllegalStateException.class, tr::getTokenValue, "getTokenValue");
+            assertThat(tr.getRedirectUri())
+                    .as("redirectUri")
                     .isNotNull()
                     .asString()
                     .isNotBlank();
-            });
+        });
     }
-    
+
     @Test
     void presentAccessToken() {
         OAuthTokenStore tokenStore = new InMemoryOAuthTokenStore();
 
         TokenAccessImpl tokenAccess = new TokenAccessImpl(tokenStore, null);
-        
-        tokenStore.persistTokens(MockOidcConnection.DEFAULT_CONNECTION, slingContext.resourceResolver(), new OAuthTokens("access", 0, null));
-        
-        OAuthTokenResponse tokenResponse = tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
-        
-        assertThat(tokenResponse)
-            .as("tokenResponse")
-            .isNotNull()
-            .satisfies( tr -> {
-                assertThat(tr.hasValidToken()).as("hasValidToken").isTrue();
-                assertThat(tr.getTokenValue()).as("tokenValue").isEqualTo("access");
-                assertThrows(IllegalStateException.class, tr::getRedirectUri, "getRedirectUri");
-            });
+
+        tokenStore.persistTokens(
+                MockOidcConnection.DEFAULT_CONNECTION,
+                slingContext.resourceResolver(),
+                new OAuthTokens("access", 0, null));
+
+        OAuthTokenResponse tokenResponse =
+                tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
+
+        assertThat(tokenResponse).as("tokenResponse").isNotNull().satisfies(tr -> {
+            assertThat(tr.hasValidToken()).as("hasValidToken").isTrue();
+            assertThat(tr.getTokenValue()).as("tokenValue").isEqualTo("access");
+            assertThrows(IllegalStateException.class, tr::getRedirectUri, "getRedirectUri");
+        });
     }
-    
+
     @Test
     void refreshTokenUsed() {
-        
+
         OAuthTokens expiredTokens = new OAuthTokens("access", -1, "refresh");
         OAuthTokens refreshedTokens = new OAuthTokens("access2", 0, null);
-        
+
         OAuthTokenStore tokenStore = new InMemoryOAuthTokenStore();
 
         TokenAccessImpl tokenAccess = getTokenAccess(expiredTokens, refreshedTokens, tokenStore);
 
         tokenStore.persistTokens(MockOidcConnection.DEFAULT_CONNECTION, slingContext.resourceResolver(), expiredTokens);
-        
-        OAuthTokenResponse tokenResponse = tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
-        
-        assertThat(tokenResponse)
-            .as("tokenResponse")
-            .isNotNull()
-            .satisfies( tr -> {
-                assertThat(tr.hasValidToken()).as("hasValidToken").isTrue();
-                assertThat(tr.getTokenValue()).as("tokenValue").isEqualTo(refreshedTokens.accessToken());
-                assertThrows(IllegalStateException.class, tr::getRedirectUri, "getRedirectUri");
-            });
+
+        OAuthTokenResponse tokenResponse =
+                tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
+
+        assertThat(tokenResponse).as("tokenResponse").isNotNull().satisfies(tr -> {
+            assertThat(tr.hasValidToken()).as("hasValidToken").isTrue();
+            assertThat(tr.getTokenValue()).as("tokenValue").isEqualTo(refreshedTokens.accessToken());
+            assertThrows(IllegalStateException.class, tr::getRedirectUri, "getRedirectUri");
+        });
     }
 
-    private static @NotNull TokenAccessImpl getTokenAccess(OAuthTokens expiredTokens, OAuthTokens refreshedTokens, OAuthTokenStore tokenStore) {
+    private static @NotNull TokenAccessImpl getTokenAccess(
+            OAuthTokens expiredTokens, OAuthTokens refreshedTokens, OAuthTokenStore tokenStore) {
         OAuthTokenRefresher tokenRefresher = new OAuthTokenRefresher() {
             @Override
-            public @NotNull OAuthTokens refreshTokens(@NotNull ClientConnection connection, @NotNull String refreshToken) {
+            public @NotNull OAuthTokens refreshTokens(
+                    @NotNull ClientConnection connection, @NotNull String refreshToken) {
                 if (!refreshToken.equals(expiredTokens.refreshToken())) {
                     throw new IllegalArgumentException("Invalid refresh token");
                 }
@@ -117,42 +119,48 @@ class TokenAccessImplTest {
 
     @Test
     void clearAccessTokenWithResponse() {
-        
+
         OAuthTokenStore tokenStore = new InMemoryOAuthTokenStore();
 
         TokenAccessImpl tokenAccess = new TokenAccessImpl(tokenStore, null);
-        
-        tokenStore.persistTokens(MockOidcConnection.DEFAULT_CONNECTION, slingContext.resourceResolver(), new OAuthTokens("access", 0, null));
 
-        OAuthTokenResponse okResponse = tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
+        tokenStore.persistTokens(
+                MockOidcConnection.DEFAULT_CONNECTION,
+                slingContext.resourceResolver(),
+                new OAuthTokens("access", 0, null));
+
+        OAuthTokenResponse okResponse =
+                tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
         assertThat(okResponse.hasValidToken()).isTrue();
-        
-        OAuthTokenResponse clearResponse = tokenAccess.clearAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
-        
+
+        OAuthTokenResponse clearResponse =
+                tokenAccess.clearAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
+
         assertThat(clearResponse)
-            .as("tokenResponse after clear")
-            .isNotNull()
-            .extracting(OAuthTokenResponse::hasValidToken)
-            .isEqualTo(false);
+                .as("tokenResponse after clear")
+                .isNotNull()
+                .extracting(OAuthTokenResponse::hasValidToken)
+                .isEqualTo(false);
     }
-    
+
     @Test
     void clearAccessTokenWithoutResponse() {
-        
+
         InMemoryOAuthTokenStore tokenStore = new InMemoryOAuthTokenStore();
 
         TokenAccessImpl tokenAccess = new TokenAccessImpl(tokenStore, null);
-        
-        tokenStore.persistTokens(MockOidcConnection.DEFAULT_CONNECTION, slingContext.resourceResolver(), new OAuthTokens("access", 0, null));
 
-        OAuthTokenResponse okResponse = tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
+        tokenStore.persistTokens(
+                MockOidcConnection.DEFAULT_CONNECTION,
+                slingContext.resourceResolver(),
+                new OAuthTokens("access", 0, null));
+
+        OAuthTokenResponse okResponse =
+                tokenAccess.getAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.request(), "/");
         assertThat(okResponse.hasValidToken()).isTrue();
-        
+
         tokenAccess.clearAccessToken(MockOidcConnection.DEFAULT_CONNECTION, slingContext.resourceResolver());
-        
-        assertThat(tokenStore.allTokens())
-            .as("all persisted tokens")
-            .isEmpty();
-    }
 
+        assertThat(tokenStore.allTokens()).as("all persisted tokens").isEmpty();
+    }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/ConverterTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/ConverterTest.java
index 41b3528..66338a8 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/ConverterTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/ConverterTest.java
@@ -1,95 +1,95 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.jupiter.api.Test;
-
 import com.nimbusds.oauth2.sdk.token.AccessToken;
 import com.nimbusds.oauth2.sdk.token.BearerAccessToken;
 import com.nimbusds.oauth2.sdk.token.RefreshToken;
 import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
 
 class ConverterTest {
 
     @Test
     void convertToApiTokens_allSet() {
-        OIDCTokens nimbusTokens = new OIDCTokens("idToken", new BearerAccessToken("accessToken", 100, null), new RefreshToken("refreshToken"));
-        
+        OIDCTokens nimbusTokens = new OIDCTokens(
+                "idToken", new BearerAccessToken("accessToken", 100, null), new RefreshToken("refreshToken"));
+
         OidcTokens apiTokens = Converter.toApiOidcTokens(nimbusTokens);
-        
+
         assertThat(apiTokens.accessToken()).isEqualTo("accessToken");
         assertThat(apiTokens.expiresAt()).isEqualTo(100);
         assertThat(apiTokens.refreshToken()).isEqualTo("refreshToken");
         assertThat(apiTokens.idToken()).isEqualTo("idToken");
     }
 
-
     @Test
     void convertToApiTokens_accessOnly() {
         OIDCTokens nimbusTokens = new OIDCTokens(new BearerAccessToken("accessToken"), null);
-        
+
         OidcTokens apiTokens = Converter.toApiOidcTokens(nimbusTokens);
-        
+
         assertThat(apiTokens.accessToken()).isEqualTo("accessToken");
         assertThat(apiTokens.expiresAt()).isZero();
         assertThat(apiTokens.refreshToken()).isNull();
         assertThat(apiTokens.idToken()).isNull();
     }
-    
+
     @Test
     void convertToNimbusTokens_allSet() {
-        
+
         OidcTokens apiTokens = new OidcTokens("accessToken", 100, "refreshToken", "idToken");
-        
+
         OIDCTokens nimbusTokens = Converter.toNimbusOidcTokens(apiTokens);
-        
-        assertThat(nimbusTokens.getAccessToken()).as("access token")
-            .isNotNull()
-            .extracting(AccessToken::getValue, AccessToken::getLifetime)
-            .containsExactly("accessToken", 100l);
-        
-        assertThat(nimbusTokens.getRefreshToken()).as("refresh token")
-            .isNotNull()
-            .extracting(RefreshToken::getValue)
-            .isEqualTo("refreshToken");
-        
-        assertThat(nimbusTokens.getIDTokenString()).as("id token")
-            .isNotNull()
-            .isEqualTo("idToken");
+
+        assertThat(nimbusTokens.getAccessToken())
+                .as("access token")
+                .isNotNull()
+                .extracting(AccessToken::getValue, AccessToken::getLifetime)
+                .containsExactly("accessToken", 100l);
+
+        assertThat(nimbusTokens.getRefreshToken())
+                .as("refresh token")
+                .isNotNull()
+                .extracting(RefreshToken::getValue)
+                .isEqualTo("refreshToken");
+
+        assertThat(nimbusTokens.getIDTokenString()).as("id token").isNotNull().isEqualTo("idToken");
     }
-    
+
     @Test
     void convertToNimbusTokens_accessOnly() {
 
         OidcTokens apiTokens = new OidcTokens("accessToken", 0, null, null);
-        
+
         OIDCTokens nimbusTokens = Converter.toNimbusOidcTokens(apiTokens);
-        
-        assertThat(nimbusTokens.getAccessToken()).as("access token")
-            .isNotNull()
-            .extracting(AccessToken::getValue, AccessToken::getLifetime)
-            .containsExactly("accessToken", 0l);
-        
-        assertThat(nimbusTokens.getRefreshToken()).as("refresh token")
-            .isNull();
-        
-        assertThat(nimbusTokens.getIDTokenString()).as("id token")
-            .isNull();
+
+        assertThat(nimbusTokens.getAccessToken())
+                .as("access token")
+                .isNotNull()
+                .extracting(AccessToken::getValue, AccessToken::getLifetime)
+                .containsExactly("accessToken", 0l);
+
+        assertThat(nimbusTokens.getRefreshToken()).as("refresh token").isNull();
+
+        assertThat(nimbusTokens.getIDTokenString()).as("id token").isNull();
     }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthCookieValueManagerTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthCookieValueManagerTest.java
index 5225f5b..45601d6 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthCookieValueManagerTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/CryptoOAuthCookieValueManagerTest.java
@@ -1,65 +1,63 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
-import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.stream.Stream;
 
+import com.nimbusds.oauth2.sdk.id.State;
 import org.junit.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
 
-import com.nimbusds.oauth2.sdk.id.State;
+import static org.assertj.core.api.Assertions.assertThat;
 
 class CryptoOAuthCookieValueManagerTest {
-    
+
     static Stream<OAuthCookieValue> states() {
-        return Stream.of(new OAuthCookieValue("key1", "conn1", "redir1"),
-                new OAuthCookieValue("key2", "conn2", null)
-        );
+        return Stream.of(new OAuthCookieValue("key1", "conn1", "redir1"), new OAuthCookieValue("key2", "conn2", null));
     }
 
     @ParameterizedTest
     @MethodSource("states")
     void encryptAndDecryptSymmetry(OAuthCookieValue state) {
-        
+
         CryptoOAuthStateManager manager = new CryptoOAuthStateManager(new StubCryptoService());
-        
+
         State nimbusState = manager.toNimbusState(state);
-        
-        assertThat(nimbusState.getValue()).as("generated Nimbus state")
-            .doesNotContain(state.connectionName())
-            .doesNotContain(state.redirect() != null ? state.redirect(): "null") // workaround for null redirects
-            .isNotBlank();
-        
-        assertThat(manager.toOAuthState(nimbusState)).as("decoded OAuth state")
-            .contains(state);
+
+        assertThat(nimbusState.getValue())
+                .as("generated Nimbus state")
+                .doesNotContain(state.connectionName())
+                .doesNotContain(state.redirect() != null ? state.redirect() : "null") // workaround for null redirects
+                .isNotBlank();
+
+        assertThat(manager.toOAuthState(nimbusState)).as("decoded OAuth state").contains(state);
     }
-    
+
     @Test
     void identicalInputsGenerateDifferentOutputs() {
-        
+
         CryptoOAuthStateManager manager = new CryptoOAuthStateManager(new StubCryptoService());
-        
+
         State firstState = manager.toNimbusState(states().findFirst().get());
         State secondState = manager.toNimbusState(states().findFirst().get());
-        
-        assertThat(firstState.getValue()).as("generated states are different")
-            .isNotEqualTo(secondState.getValue());
-    }
 
+        assertThat(firstState.getValue()).as("generated states are different").isNotEqualTo(secondState.getValue());
+    }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/InMemoryOAuthTokenStoreTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/InMemoryOAuthTokenStoreTest.java
index ebc24d9..dab644c 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/InMemoryOAuthTokenStoreTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/InMemoryOAuthTokenStoreTest.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -25,7 +27,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
 @Testcontainers
 public class InMemoryOAuthTokenStoreTest extends TokenStoreTestSupport<InMemoryOAuthTokenStore> {
 
-    
     InMemoryOAuthTokenStoreTest() {
         super(MockOidcConnection.DEFAULT_CONNECTION, new SlingContext(ResourceResolverType.JCR_MOCK));
     }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStoreTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStoreTest.java
index 3196d8a..0ba6071 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStoreTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/JcrUserHomeOAuthTokenStoreTest.java
@@ -1,25 +1,26 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import javax.jcr.RepositoryException;
 
+import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
@@ -29,17 +30,17 @@ import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.junit5.SlingContext;
 import org.junit.jupiter.api.BeforeEach;
 
-import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
+import static org.assertj.core.api.Assertions.assertThat;
 
 class JcrUserHomeOAuthTokenStoreTest extends TokenStoreTestSupport<JcrUserHomeOAuthTokenStore> {
-    
+
     private CryptoService cryptoService;
-    
+
     @BeforeEach
     void init() {
         cryptoService = new StubCryptoService();
     }
-    
+
     JcrUserHomeOAuthTokenStoreTest() {
         super(MockOidcConnection.DEFAULT_CONNECTION, new SlingContext(ResourceResolverType.JCR_OAK));
     }
@@ -48,38 +49,34 @@ class JcrUserHomeOAuthTokenStoreTest extends TokenStoreTestSupport<JcrUserHomeOA
     JcrUserHomeOAuthTokenStore createTokenStore() {
         return new JcrUserHomeOAuthTokenStore(cryptoService);
     }
-    
+
     @Override
     protected void getAccessToken_valid_postCheck(OIDCTokens input) throws RepositoryException {
-        
+
         // validate that encryption is applied when storing the access token
-        
+
         Resource connectionResource = getConnectionResource(connection);
 
         ValueMap connectionProps = connectionResource.getValueMap();
         assertThat(connectionProps)
-            .as("stored tokens for connection")
-            .containsOnlyKeys("jcr:primaryType", "access_token");
-        
+                .as("stored tokens for connection")
+                .containsOnlyKeys("jcr:primaryType", "access_token");
+
         assertThat(connectionProps.get("access_token", String.class))
-            .as("encrypted access token")
-            .isNotEqualTo(input.getAccessToken().getValue())
-            .isEqualTo(cryptoService.encrypt(input.getAccessToken().getValue()));
+                .as("encrypted access token")
+                .isNotEqualTo(input.getAccessToken().getValue())
+                .isEqualTo(cryptoService.encrypt(input.getAccessToken().getValue()));
     }
-    
+
     private Resource getConnectionResource(ClientConnection connection) throws RepositoryException {
         String userPath = context.resourceResolver().adaptTo(User.class).getPath();
         Resource userHomeResource = context.resourceResolver().getResource(userPath);
         Resource oidcTokensResource = userHomeResource.getChild("oauth-tokens");
 
-        assertThat(oidcTokensResource)
-            .describedAs("oauth-tokens resource")
-            .isNotNull();
+        assertThat(oidcTokensResource).describedAs("oauth-tokens resource").isNotNull();
 
         Resource connectionResource = oidcTokensResource.getChild(connection.name());
-        assertThat(connectionResource)
-            .as("oauth-tokens/connection resource")
-            .isNotNull();
+        assertThat(connectionResource).as("oauth-tokens/connection resource").isNotNull();
         return connectionResource;
     }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/MockOidcConnection.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/MockOidcConnection.java
index ff18073..ede4d38 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/MockOidcConnection.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/MockOidcConnection.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -22,27 +24,69 @@ import org.jetbrains.annotations.NotNull;
 import org.osgi.util.converter.Converters;
 
 public class MockOidcConnection extends OidcConnectionImpl {
-    public static final MockOidcConnection DEFAULT_CONNECTION = new MockOidcConnection(new String[] {"openid"}, "mock-oidc", "client-id", "client-secret", "https://example.com", new String[0]);
-    
-    public MockOidcConnection(String[] scopes, String name, String clientId, String clientSecret, String baseUrl,
+    public static final MockOidcConnection DEFAULT_CONNECTION = new MockOidcConnection(
+            new String[] {"openid"}, "mock-oidc", "client-id", "client-secret", "https://example.com", new String[0]);
+
+    public MockOidcConnection(
+            String[] scopes,
+            String name,
+            String clientId,
+            String clientSecret,
+            String baseUrl,
             String[] additionalAuthorizationParameters) {
-        super(Converters.standardConverter().convert(Map.of("name", name, "baseUrl", baseUrl, "clientId", clientId, "clientSecret", clientSecret, "scopes", scopes, "additionalAuthorizationParameters", additionalAuthorizationParameters))
-                .to(Config.class), null);
+        super(
+                Converters.standardConverter()
+                        .convert(Map.of(
+                                "name",
+                                name,
+                                "baseUrl",
+                                baseUrl,
+                                "clientId",
+                                clientId,
+                                "clientSecret",
+                                clientSecret,
+                                "scopes",
+                                scopes,
+                                "additionalAuthorizationParameters",
+                                additionalAuthorizationParameters))
+                        .to(Config.class),
+                null);
     }
 
-    public MockOidcConnection(String[] scopes, String name, String clientId, String clientSecret, String baseUrl,
-                              String[] additionalAuthorizationParameters, OidcProviderMetadataRegistry metadataRegistry) {
-        super(Converters.standardConverter().convert(Map.of("name", name, "baseUrl", baseUrl, "clientId", clientId, "clientSecret", clientSecret, "scopes", scopes, "additionalAuthorizationParameters", additionalAuthorizationParameters))
-                .to(Config.class), metadataRegistry);
+    public MockOidcConnection(
+            String[] scopes,
+            String name,
+            String clientId,
+            String clientSecret,
+            String baseUrl,
+            String[] additionalAuthorizationParameters,
+            OidcProviderMetadataRegistry metadataRegistry) {
+        super(
+                Converters.standardConverter()
+                        .convert(Map.of(
+                                "name",
+                                name,
+                                "baseUrl",
+                                baseUrl,
+                                "clientId",
+                                clientId,
+                                "clientSecret",
+                                clientSecret,
+                                "scopes",
+                                scopes,
+                                "additionalAuthorizationParameters",
+                                additionalAuthorizationParameters))
+                        .to(Config.class),
+                metadataRegistry);
     }
 
     @Override
     public @NotNull String authorizationEndpoint() {
         return baseUrl() + "/authorize";
     }
-    
+
     @Override
     public @NotNull String tokenEndpoint() {
         return baseUrl() + "/token";
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/MockRequest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/MockRequest.java
index 308df47..1b3b87a 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/MockRequest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/MockRequest.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -30,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpUpgradeHandler;
 import javax.servlet.http.Part;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -45,6 +48,7 @@ public class MockRequest implements HttpServletRequest {
 
     ArrayList<Cookie> cookies;
     HashMap<String, Object> attributes = new HashMap<>();
+
     @Override
     public String getAuthType() {
         // TODO
@@ -437,7 +441,8 @@ public class MockRequest implements HttpServletRequest {
     }
 
     @Override
-    public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
+    public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse)
+            throws IllegalStateException {
         // TODO
         return null;
     }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/MockResponse.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/MockResponse.java
index 15c35ed..771d0ec 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/MockResponse.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/MockResponse.java
@@ -1,24 +1,27 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -31,7 +34,7 @@ public class MockResponse implements HttpServletResponse {
     ArrayList<Cookie> cookies = new ArrayList();
     HashMap<String, String> headers = new HashMap<>();
     String sendRedirect = null;
-    int error=0;
+    int error = 0;
     String errorMessage = null;
 
     @Override
@@ -42,6 +45,7 @@ public class MockResponse implements HttpServletResponse {
     public List<Cookie> getCookies() {
         return cookies;
     }
+
     @Override
     public boolean containsHeader(String name) {
         // TODO
@@ -85,6 +89,7 @@ public class MockResponse implements HttpServletResponse {
     public String getErrorMessage() {
         return errorMessage;
     }
+
     @Override
     public void sendError(int sc) throws IOException {
         // TODO
@@ -101,8 +106,7 @@ public class MockResponse implements HttpServletResponse {
     }
 
     @Override
-    public void setDateHeader(String name, long date) {
-    }
+    public void setDateHeader(String name, long date) {}
 
     @Override
     public void addDateHeader(String name, long date) {
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServletTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServletTest.java
index f8f1f63..26d455f 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServletTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthCallbackServletTest.java
@@ -1,24 +1,26 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static java.lang.String.format;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -28,10 +30,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
+import com.sun.net.httpserver.HttpServer;
 import org.apache.sling.auth.oauth_client.ClientConnection;
 import org.apache.sling.auth.oauth_client.InMemoryOAuthTokenStore;
 import org.apache.sling.commons.crypto.CryptoService;
@@ -42,7 +41,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
-import com.sun.net.httpserver.HttpServer;
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
 
 @ExtendWith(SlingContextExtension.class)
 class OAuthCallbackServletTest {
@@ -50,7 +51,7 @@ class OAuthCallbackServletTest {
     private static final String MOCK_OIDC_PARAM = "mock-oidc-param";
 
     private final SlingContext context = new SlingContext();
-    
+
     private HttpServer tokenEndpointServer;
 
     private InMemoryOAuthTokenStore tokenStore;
@@ -58,27 +59,36 @@ class OAuthCallbackServletTest {
     private OAuthCallbackServlet servlet;
 
     private CryptoService cryptoService;
-    
-    
+
     @BeforeEach
     void setUp() throws IOException {
         tokenEndpointServer = HttpServer.create(new InetSocketAddress(0), 0);
         tokenEndpointServer.start();
-        
+
         int bindPort = tokenEndpointServer.getAddress().getPort();
 
         List<ClientConnection> connections = new ArrayList<>(Arrays.asList(
                 MockOidcConnection.DEFAULT_CONNECTION,
-                new MockOidcConnection(new String[] {"openid"}, MOCK_OIDC_PARAM, "client-id", "client-secret", "http://example.com", new String[] { "access_type=offline" } ),
-                new MockOidcConnection(new String[] {"openid"},"mock-oidc-local", "client-id", "client-secret", "http://localhost:" + bindPort, new String[0])
-            )
-       );
-        
+                new MockOidcConnection(
+                        new String[] {"openid"},
+                        MOCK_OIDC_PARAM,
+                        "client-id",
+                        "client-secret",
+                        "http://example.com",
+                        new String[] {"access_type=offline"}),
+                new MockOidcConnection(
+                        new String[] {"openid"},
+                        "mock-oidc-local",
+                        "client-id",
+                        "client-secret",
+                        "http://localhost:" + bindPort,
+                        new String[0])));
+
         tokenStore = new InMemoryOAuthTokenStore();
         cryptoService = new StubCryptoService();
         servlet = new OAuthCallbackServlet(connections, tokenStore, new StubOAuthStateManager(), cryptoService);
     }
-    
+
     @AfterEach
     void tearDown() {
         tokenEndpointServer.stop(0);
@@ -86,82 +96,83 @@ class OAuthCallbackServletTest {
 
     @Test
     void missingConnectionParameter() throws ServletException, IOException {
-        
+
         servlet.service(context.request(), context.response());
-        
-        assertThat(context.response().getStatus()).as("response code")
-            .isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
+
+        assertThat(context.response().getStatus()).as("response code").isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
     }
 
     @Test
     void malformedStateParameter() throws ServletException, IOException {
 
         context.request().setQueryString("?code=foo&state=bar");
-        
+
         servlet.service(context.request(), context.response());
-        
-        assertThat(context.response().getStatus()).as("response code")
-            .isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
+
+        assertThat(context.response().getStatus()).as("response code").isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
     }
-    
+
     @Test
     void missingStateCookie() throws ServletException, IOException {
 
-        String state = URLEncoder.encode(format("%s|bar", MockOidcConnection.DEFAULT_CONNECTION.name()), StandardCharsets.UTF_8);
-        
+        String state = URLEncoder.encode(
+                format("%s|bar", MockOidcConnection.DEFAULT_CONNECTION.name()), StandardCharsets.UTF_8);
+
         context.request().setQueryString(format("code=foo&state=%s", state));
-        
+
         servlet.service(context.request(), context.response());
-        
-        assertThat(context.response().getStatus()).as("response code")
-            .isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
+
+        assertThat(context.response().getStatus()).as("response code").isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
     }
-    
+
     @Test
     void invalidStateCookie() {
-        
+
         String cookieValue = String.format("baz|%s", MockOidcConnection.DEFAULT_CONNECTION.name());
-        
+
         context.request().setQueryString(format("code=foo&state=bar"));
-        context.request().addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
-        
-        OAuthCallbackException thrown = assertThrowsExactly(OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
+        context.request()
+                .addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
+
+        OAuthCallbackException thrown = assertThrowsExactly(
+                OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
         assertThat(thrown).hasMessage("State check failed");
     }
-    
+
     @Test
     void errorCode() {
-        
+
         String cookieValue = format("bar|%s", MockOidcConnection.DEFAULT_CONNECTION.name());
-        
+
         context.request().setQueryString(format("error=access_denied&state=%s", "bar"));
-        context.request().addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
-        
-        OAuthCallbackException thrown = assertThrowsExactly(OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
+        context.request()
+                .addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
+
+        OAuthCallbackException thrown = assertThrowsExactly(
+                OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
         assertThat(thrown).hasMessage("Authentication failed");
     }
 
     @Test
     void unreachableTokenEndpoint() {
-        
+
         // the token endpoint has no handler configured, will result in a 404
 
         String cookieValue = "bar|mock-oidc-local";
-        
+
         context.request().setQueryString(format("code=foo&state=%s", "bar"));
-        context.request().addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
-        
-        OAuthCallbackException thrown = assertThrowsExactly(OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
-        
-        assertThat(thrown)
-            .hasMessage("Token exchange error")
-            .cause()
-            .hasMessageContaining("code: 404");
+        context.request()
+                .addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
+
+        OAuthCallbackException thrown = assertThrowsExactly(
+                OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
+
+        assertThat(thrown).hasMessage("Token exchange error").cause().hasMessageContaining("code: 404");
     }
-    
+
     @Test
     void errorResponseFromTokenEndpoint() {
-        
+
         tokenEndpointServer.createContext("/token", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
             String response = "{\"error\":\"invalid_request\"}";
@@ -169,20 +180,19 @@ class OAuthCallbackServletTest {
             exchange.getResponseBody().write(response.getBytes());
             exchange.close();
         });
-        
+
         String cookieValue = "bar|mock-oidc-local";
-        
+
         context.request().setQueryString(format("code=foo&state=%s", "bar"));
-        context.request().addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
-        
-        OAuthCallbackException thrown = assertThrowsExactly(OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
-        
-        assertThat(thrown)
-            .hasMessage("Token exchange error")
-            .cause()
-            .hasMessageContaining("invalid_request");
+        context.request()
+                .addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
+
+        OAuthCallbackException thrown = assertThrowsExactly(
+                OAuthCallbackException.class, () -> servlet.service(context.request(), context.response()));
+
+        assertThat(thrown).hasMessage("Token exchange error").cause().hasMessageContaining("invalid_request");
     }
-    
+
     @Test
     void successfulCallback() throws IOException, ServletException {
 
@@ -192,7 +202,7 @@ class OAuthCallbackServletTest {
     }
 
     private void successfulExecution(String cookieValue) throws IOException, ServletException {
-        
+
         tokenEndpointServer.createContext("/token", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
             String response = "{\"access_token\":\"Token\", \"token_type\":\"Bearer\"}";
@@ -200,31 +210,31 @@ class OAuthCallbackServletTest {
             exchange.getResponseBody().write(response.getBytes());
             exchange.close();
         });
-        
+
         String state = "bar";
-        
+
         context.request().setQueryString(format("code=foo&state=%s", state));
-        context.request().addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
-        
+        context.request()
+                .addCookie(new Cookie(OAuthStateManager.COOKIE_NAME_REQUEST_KEY, cryptoService.encrypt(cookieValue)));
+
         servlet.service(context.request(), context.response());
-        
+
         assertThat(tokenStore.allTokens())
-            .hasSize(1)
-            .element(0)
-            .isNotNull()
-            .extracting( OAuthTokens::accessToken )
-            .isEqualTo("Token");
+                .hasSize(1)
+                .element(0)
+                .isNotNull()
+                .extracting(OAuthTokens::accessToken)
+                .isEqualTo("Token");
     }
-    
+
     @Test
     void successfulCallbackWithRedirect() throws IOException, ServletException {
         successfulExecution("bar|mock-oidc-local|/local-redirect");
 
-        assertThat(context.response().getStatus()).as("response code")
-            .isEqualTo(HttpServletResponse.SC_FOUND);
-        
+        assertThat(context.response().getStatus()).as("response code").isEqualTo(HttpServletResponse.SC_FOUND);
+
         assertThat(context.response().getHeader("Location"))
-            .as("location header")
-            .isEqualTo("/local-redirect");
-    }    
+                .as("location header")
+                .isEqualTo("/local-redirect");
+    }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServletTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServletTest.java
index dd7b790..f86d008 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServletTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthEntryPointServletTest.java
@@ -1,22 +1,25 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 import java.net.URI;
@@ -24,9 +27,6 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.sling.auth.oauth_client.ClientConnection;
 import org.apache.sling.testing.mock.sling.junit5.SlingContext;
 import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension;
@@ -35,76 +35,81 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 @ExtendWith(SlingContextExtension.class)
 class OAuthEntryPointServletTest {
 
     private static final String MOCK_OIDC_PARAM = "mock-oidc-param";
-    
+
     private final SlingContext context = new SlingContext();
     private OAuthEntryPointServlet servlet;
-    
+
     @BeforeEach
     void initServlet() {
         List<ClientConnection> connections = Arrays.asList(
                 MockOidcConnection.DEFAULT_CONNECTION,
-                new MockOidcConnection(new String[] {"openid"}, MOCK_OIDC_PARAM, "client-id", "client-secret", "http://example.com", new String[] { "access_type=offline" } )
-            );
-        servlet =  new OAuthEntryPointServlet(connections, new StubCryptoService());
+                new MockOidcConnection(
+                        new String[] {"openid"},
+                        MOCK_OIDC_PARAM,
+                        "client-id",
+                        "client-secret",
+                        "http://example.com",
+                        new String[] {"access_type=offline"}));
+        servlet = new OAuthEntryPointServlet(connections, new StubCryptoService());
     }
-    
+
     @Test
     void testRedirectWithValidConnection() throws ServletException, IOException {
 
         context.request().setQueryString("c=" + MockOidcConnection.DEFAULT_CONNECTION.name());
         MockSlingHttpServletResponse response = context.response();
-        
+
         servlet.service(context.request(), response);
-        
+
         URI location = URI.create(Objects.requireNonNull(response.getHeader("Location"), "location header"));
-        
-        assertThat(location).as("authentication request uri")
-            .hasScheme("https")
-            .hasHost("example.com")
-            .hasPath("/authorize")
-            .hasParameter("scope", "openid")
-            .hasParameter("response_type", "code")
-            .hasParameter("client_id", "client-id")
-            .hasParameter("redirect_uri", "http://localhost/system/sling/oauth/callback")
-            .hasParameter("state");        
+
+        assertThat(location)
+                .as("authentication request uri")
+                .hasScheme("https")
+                .hasHost("example.com")
+                .hasPath("/authorize")
+                .hasParameter("scope", "openid")
+                .hasParameter("response_type", "code")
+                .hasParameter("client_id", "client-id")
+                .hasParameter("redirect_uri", "http://localhost/system/sling/oauth/callback")
+                .hasParameter("state");
     }
-    
+
     @Test
     void redirectWithValidConnectionAndCustomParameter() throws ServletException, IOException {
-     
+
         context.request().setQueryString("c=" + MOCK_OIDC_PARAM);
         MockSlingHttpServletResponse response = context.response();
-        
+
         servlet.service(context.request(), response);
-        
+
         URI location = URI.create(Objects.requireNonNull(response.getHeader("Location"), "location header"));
-        
-        assertThat(location).as("authentication request uri")
-            .hasParameter("access_type", "offline");
+
+        assertThat(location).as("authentication request uri").hasParameter("access_type", "offline");
     }
-    
+
     @Test
     void missingConnectionParameter() throws ServletException, IOException {
-        
+
         servlet.service(context.request(), context.response());
-        
-        assertThat(context.response().getStatus()).as("response code")
-            .isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
+
+        assertThat(context.response().getStatus()).as("response code").isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
     }
-    
+
     @Test
     void invalidConnectionParameter() throws ServletException, IOException {
-        
+
         context.request().setQueryString("c=invalid");
-        
+
         MockSlingHttpServletResponse response = context.response();
         servlet.service(context.request(), response);
-        
-        assertThat(context.response().getStatus()).as("response code")
-            .isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
+
+        assertThat(context.response().getStatus()).as("response code").isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
     }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenTest.java
index 34c44d4..3d96040 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/OAuthTokenTest.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -53,7 +55,7 @@ class OAuthTokenTest {
         OAuthToken token = new OAuthToken(TokenState.MISSING, null);
         assertSame(TokenState.MISSING, token.getState());
     }
-    
+
     @Test
     void testGetValueMissingState() {
         OAuthToken token = new OAuthToken(TokenState.MISSING, null);
@@ -75,4 +77,4 @@ class OAuthTokenTest {
             assertEquals("Can't retrieve a token value when the token state is EXPIRED", e.getMessage());
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandlerTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandlerTest.java
index 42547ef..d79e5ba 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandlerTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandlerTest.java
@@ -1,21 +1,38 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import com.nimbusds.jose.JOSEException;
 import com.nimbusds.jose.JWSAlgorithm;
 import com.nimbusds.jose.JWSHeader;
@@ -45,20 +62,6 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.osgi.framework.BundleContext;
 
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doThrow;
@@ -84,7 +87,6 @@ class OidcAuthenticationHandlerTest {
     private CryptoService cryptoService = new StubCryptoService();
     HttpServer idpServer;
 
-
     @BeforeEach
     void initServlet() throws IOException {
         tokenEndpointServer = createHttpServer();
@@ -94,7 +96,7 @@ class OidcAuthenticationHandlerTest {
         bundleContext = mock(BundleContext.class);
         config = mock(OidcAuthenticationHandler.Config.class);
         when(config.idp()).thenReturn("myIdP");
-        when(config.path()).thenReturn(new String[]{"/"});
+        when(config.path()).thenReturn(new String[] {"/"});
         loginCookieManager = mock(LoginCookieManager.class);
 
         SlingUserInfoProcessorImpl.Config userInfoConfig = mock(SlingUserInfoProcessorImpl.Config.class);
@@ -136,7 +138,8 @@ class OidcAuthenticationHandlerTest {
         when(request.getQueryString()).thenReturn("state=part1%7Cpart2");
         when(request.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080"));
 
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
         assertEquals("No authorization code found in authorization response", exception.getMessage());
     }
 
@@ -150,17 +153,18 @@ class OidcAuthenticationHandlerTest {
 
     @Test
     void extractCredentialsWithoutAnyCookies() {
-        //Test without any cookie
+        // Test without any cookie
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1%7Cpart2");
         when(request.getCookies()).thenReturn(null);
 
-        IllegalStateException exception = assertThrows(IllegalStateException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        IllegalStateException exception = assertThrows(
+                IllegalStateException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
         assertEquals("Failed state check: No cookies found", exception.getMessage());
     }
 
     @Test
     void extractCredentialsWithLoginCookie() {
-        //Test without any cookie
+        // Test without any cookie
         when(loginCookieManager.verifyLoginCookie(request)).thenReturn(AuthenticationInfo.FAIL_AUTH);
         createOidcAuthenticationHandler();
 
@@ -169,15 +173,20 @@ class OidcAuthenticationHandlerTest {
 
     @Test
     void extractCredentialsWithoutExpectedCookies() {
-        //Test without the expected cookie
+        // Test without the expected cookie
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1%7Cpart2");
         when(request.getCookies()).thenReturn(null);
 
-        //Test with a cookie that not match
+        // Test with a cookie that not match
         Cookie cookie = mock(Cookie.class);
-        when(request.getCookies()).thenReturn(new Cookie[]{cookie});
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
-        assertEquals(String.format("Failed state check: No request cookie named %s found", OAuthStateManager.COOKIE_NAME_REQUEST_KEY), exception.getMessage());
+        when(request.getCookies()).thenReturn(new Cookie[] {cookie});
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        assertEquals(
+                String.format(
+                        "Failed state check: No request cookie named %s found",
+                        OAuthStateManager.COOKIE_NAME_REQUEST_KEY),
+                exception.getMessage());
     }
 
     @Test
@@ -186,10 +195,12 @@ class OidcAuthenticationHandlerTest {
         when(stateCookie.getName()).thenReturn(OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
         when(stateCookie.getValue()).thenReturn(cryptoService.encrypt("non-matchpart1|mock-oidc-param|redirect|nonce"));
 
-        when(request.getCookies()).thenReturn(new Cookie[]{stateCookie});
+        when(request.getCookies()).thenReturn(new Cookie[] {stateCookie});
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1%7Cpart2");
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
-        assertEquals("Failed state check: request keys from client and server are not the same", exception.getMessage());
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        assertEquals(
+                "Failed state check: request keys from client and server are not the same", exception.getMessage());
     }
 
     @Test
@@ -197,10 +208,13 @@ class OidcAuthenticationHandlerTest {
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1&nonce=nonce");
         Cookie stateCookie = mock(Cookie.class);
         when(stateCookie.getName()).thenReturn(OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
-        when(stateCookie.getValue()).thenReturn(cryptoService.encrypt("part1|invalid-connection|redirect|nonce|0123456789012345678901234567890123456789123"));
+        when(stateCookie.getValue())
+                .thenReturn(cryptoService.encrypt(
+                        "part1|invalid-connection|redirect|nonce|0123456789012345678901234567890123456789123"));
 
-        when(request.getCookies()).thenReturn(new Cookie[]{stateCookie});
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        when(request.getCookies()).thenReturn(new Cookie[] {stateCookie});
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
         assertEquals("Requested unknown connection 'invalid-connection'", exception.getMessage());
     }
 
@@ -209,8 +223,7 @@ class OidcAuthenticationHandlerTest {
     void extractCredentials_WithMatchingState_WithValidConnection_WithInvalidRequestResponse() {
         idpServer.createContext("/token", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
-            String responseMsg = "{\"error\":\"invalid_request\"," +
-                    "\"error_description\":\"Invalid request\"}";
+            String responseMsg = "{\"error\":\"invalid_request\"," + "\"error_description\":\"Invalid request\"}";
 
             exchange.sendResponseHeaders(400, responseMsg.length());
             exchange.getResponseBody().write(responseMsg.getBytes());
@@ -218,12 +231,13 @@ class OidcAuthenticationHandlerTest {
         });
 
         connections.add(new MockOidcConnection(
-                new String[]{"openid"},
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:" + idpServer.getAddress().getPort(),
-                new String[]{"access_type=offline"}, getOidcProviderMetadataRegistry()));
+                new String[] {"access_type=offline"},
+                getOidcProviderMetadataRegistry()));
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
@@ -233,9 +247,10 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
 
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
-        assertEquals("Error in token response: invalid_request. Status code: 400. Invalid request", exception.getMessage());
-
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        assertEquals(
+                "Error in token response: invalid_request. Status code: 400. Invalid request", exception.getMessage());
     }
 
     // The idp return a string that is not a valid json
@@ -250,16 +265,17 @@ class OidcAuthenticationHandlerTest {
             exchange.close();
         });
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
 
         connections.add(new MockOidcConnection(
-                new String[]{"openid"},
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:" + idpServer.getAddress().getPort(),
-                new String[]{"access_type=offline"}, getOidcProviderMetadataRegistry()));
+                new String[] {"access_type=offline"},
+                getOidcProviderMetadataRegistry()));
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
@@ -269,9 +285,9 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
 
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
         assertEquals("Invalid JSON", exception.getMessage());
-
     }
 
     // The configured idp is an invalid host
@@ -286,18 +302,18 @@ class OidcAuthenticationHandlerTest {
             exchange.close();
         });
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
 
         when(oidcProviderMetadataRegistry.getTokenEndpoint(anyString())).thenReturn(new URI("http://jfdljfioewms"));
         connections.add(new MockOidcConnection(
-                new String[]{"openid"},
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://jfdljfioewms",
-                new String[]{"access_type=offline"}, getOidcProviderMetadataRegistry("http://jfdljfioewms")));
-
+                new String[] {"access_type=offline"},
+                getOidcProviderMetadataRegistry("http://jfdljfioewms")));
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
@@ -307,7 +323,8 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
 
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
         assertEquals("java.net.UnknownHostException: jfdljfioewms", exception.getMessage());
     }
 
@@ -323,18 +340,18 @@ class OidcAuthenticationHandlerTest {
             exchange.close();
         });
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
 
         when(oidcProviderMetadataRegistry.getTokenEndpoint(anyString())).thenReturn(new URI("http://jfdljfioewms"));
         connections.add(new MockOidcConnection(
-                new String[]{"openid"},
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "httjfdljfioewms",
-                new String[]{"access_type=offline"}, getOidcProviderMetadataRegistry("httjfdljfioewms")));
-
+                new String[] {"access_type=offline"},
+                getOidcProviderMetadataRegistry("httjfdljfioewms")));
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
@@ -344,129 +361,158 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
 
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
         assertEquals("URI is not absolute", exception.getMessage());
-
     }
 
     @Test
     void extractCredentials_WithMatchingState_WithValidConnection_WithInvalidIdToken() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
-
-        RSAKey wrongRsaJWK = new RSAKeyGenerator(2048)
-                .keyID("456")
-                .generate();
-
-        //Test with an id token signed by another key, and expired
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(wrongRsaJWK, "client-id", ISSUER), rsaJWK, "http://localhost:4567", createMockCookies(), false));
-        assertEquals("Signed JWT rejected: Another algorithm expected, or no matching key(s) found", exception.getMessage());
-
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
+
+        RSAKey wrongRsaJWK = new RSAKeyGenerator(2048).keyID("456").generate();
+
+        // Test with an id token signed by another key, and expired
+        RuntimeException exception = assertThrows(
+                RuntimeException.class,
+                () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                        createIdToken(wrongRsaJWK, "client-id", ISSUER),
+                        rsaJWK,
+                        "http://localhost:4567",
+                        createMockCookies(),
+                        false));
+        assertEquals(
+                "Signed JWT rejected: Another algorithm expected, or no matching key(s) found", exception.getMessage());
     }
 
     @Test
     void extractCredentials_WithMatchingState_WithValidConnection_WithWrongClientId() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
-
-        //Test with an id token with a wrong client id
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(rsaJWK, "wrong-client-id", ISSUER), rsaJWK, "http://localhost:4567", createMockCookies(), false));
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
+
+        // Test with an id token with a wrong client id
+        RuntimeException exception = assertThrows(
+                RuntimeException.class,
+                () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                        createIdToken(rsaJWK, "wrong-client-id", ISSUER),
+                        rsaJWK,
+                        "http://localhost:4567",
+                        createMockCookies(),
+                        false));
         assertEquals("Unexpected JWT audience: [wrong-client-id]", exception.getMessage());
     }
 
     @Test
     void extractCredentials_WithMatchingState_WithValidConnection_WithWrongIssuer() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
-
-        //Test with an id token signed but with a wrong issuer
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(rsaJWK, "client-id", "wrong-issuer"), rsaJWK, "http://localhost:4567", createMockCookies(), false));
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
+
+        // Test with an id token signed but with a wrong issuer
+        RuntimeException exception = assertThrows(
+                RuntimeException.class,
+                () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                        createIdToken(rsaJWK, "client-id", "wrong-issuer"),
+                        rsaJWK,
+                        "http://localhost:4567",
+                        createMockCookies(),
+                        false));
         assertEquals("Unexpected JWT issuer: wrong-issuer", exception.getMessage());
     }
 
     @Test
     void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUserInfo() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
         when(config.userInfoEnabled()).thenReturn(true);
-        //Test with an id token signed by another key, and expired
-        AuthenticationInfo authInfo = extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(rsaJWK, "client-id", ISSUER), rsaJWK, "http://localhost:4567", createMockCookies(), false);
+        // Test with an id token signed by another key, and expired
+        AuthenticationInfo authInfo = extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                createIdToken(rsaJWK, "client-id", ISSUER),
+                rsaJWK,
+                "http://localhost:4567",
+                createMockCookies(),
+                false);
         assertEquals("1234567890", authInfo.get("user.name"));
-        assertEquals("testUser", ((OidcAuthCredentials) authInfo.get("user.jcr.credentials")).getAttribute("profile/name"));
+        assertEquals(
+                "testUser", ((OidcAuthCredentials) authInfo.get("user.jcr.credentials")).getAttribute("profile/name"));
     }
 
     @Test
-    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUserInfo_WithInvalidNonce() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
+    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUserInfo_WithInvalidNonce()
+            throws JOSEException {
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
         when(config.userInfoEnabled()).thenReturn(true);
 
         Cookie stateCookie = mock(Cookie.class);
         when(stateCookie.getName()).thenReturn(OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
         when(stateCookie.getValue()).thenReturn(cryptoService.encrypt("part1|mock-oidc-param|redirect|invalid-nonce"));
 
-
-        //Test with an id token signed by another key, and expired
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(rsaJWK, "client-id", ISSUER), rsaJWK, "http://localhost:4567", new Cookie[]{stateCookie}, false));
+        // Test with an id token signed by another key, and expired
+        RuntimeException exception = assertThrows(
+                RuntimeException.class,
+                () -> extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                        createIdToken(rsaJWK, "client-id", ISSUER),
+                        rsaJWK,
+                        "http://localhost:4567",
+                        new Cookie[] {stateCookie},
+                        false));
         assertEquals("Unexpected JWT nonce (nonce) claim: nonce", exception.getMessage());
     }
 
     @Test
-    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUserInfo_WithPkceEnabledWithCookie() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
+    void
+            extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUserInfo_WithPkceEnabledWithCookie()
+                    throws JOSEException {
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
         when(config.userInfoEnabled()).thenReturn(true);
         when(config.pkceEnabled()).thenReturn(true);
 
         Cookie stateCookie = mock(Cookie.class);
         when(stateCookie.getName()).thenReturn(OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
-        when(stateCookie.getValue()).thenReturn(cryptoService.encrypt("part1|mock-oidc-param|redirect|nonce|12345678901234567890123456789012345678901234"));
-
-
-        when(request.getCookies()).thenReturn(new Cookie[]{stateCookie});
-
-
-        AuthenticationInfo authInfo = extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(rsaJWK, "client-id", ISSUER), rsaJWK, "http://localhost:4567", new Cookie[]{stateCookie}, true);
-        //Remark: presence of state and code verifier parameter are checked inside extractCredentials_WithMatchingState_WithValidConnection_WithIdToken
+        when(stateCookie.getValue())
+                .thenReturn(cryptoService.encrypt(
+                        "part1|mock-oidc-param|redirect|nonce|12345678901234567890123456789012345678901234"));
+
+        when(request.getCookies()).thenReturn(new Cookie[] {stateCookie});
+
+        AuthenticationInfo authInfo = extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                createIdToken(rsaJWK, "client-id", ISSUER),
+                rsaJWK,
+                "http://localhost:4567",
+                new Cookie[] {stateCookie},
+                true);
+        // Remark: presence of state and code verifier parameter are checked inside
+        // extractCredentials_WithMatchingState_WithValidConnection_WithIdToken
         assertEquals("1234567890", authInfo.get("user.name"));
     }
 
-
     @Test
-    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithoutUserInfo() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
+    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithoutUserInfo()
+            throws JOSEException {
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
         when(config.userInfoEnabled()).thenReturn(false);
-        //Test with an id token signed by another key, and expired
-        AuthenticationInfo authInfo = extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(createIdToken(rsaJWK, "client-id", ISSUER), rsaJWK, "http://localhost:4567", createMockCookies(), false);
+        // Test with an id token signed by another key, and expired
+        AuthenticationInfo authInfo = extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+                createIdToken(rsaJWK, "client-id", ISSUER),
+                rsaJWK,
+                "http://localhost:4567",
+                createMockCookies(),
+                false);
         assertEquals("1234567890", authInfo.get("user.name"));
     }
 
     // Test with a valid id token but with an invalid user info response that return error
     @Test
-    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithInvalidUserInfo() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
+    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithInvalidUserInfo()
+            throws JOSEException {
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
         when(config.userInfoEnabled()).thenReturn(true);
 
         idpServer.createContext("/token", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
             String responseMsg;
             try {
-                responseMsg = "{\"access_token\":\"myAccessToken\"," +
-                        "\"expires_in\":\"360\"," +
-                        "\"refresh_token\":\"3600\"," +
-                        "\"refresh_expires_in\":\"36000\"," +
-                        "\"id_token\":\"" + createIdToken(rsaJWK, "client-id", ISSUER) + "\"," +
-                        "\"token_type\":\"Bearer\"}";
+                responseMsg = "{\"access_token\":\"myAccessToken\"," + "\"expires_in\":\"360\","
+                        + "\"refresh_token\":\"3600\","
+                        + "\"refresh_expires_in\":\"36000\","
+                        + "\"id_token\":\""
+                        + createIdToken(rsaJWK, "client-id", ISSUER) + "\"," + "\"token_type\":\"Bearer\"}";
             } catch (JOSEException e) {
                 throw new RuntimeException(e);
             }
@@ -478,30 +524,33 @@ class OidcAuthenticationHandlerTest {
 
         idpServer.createContext("/userinfo", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
-            String responseMsg = "{\"error\":\"invalid_request\"," +
-                    "\"error_description\":\"Invalid request\"}";
+            String responseMsg = "{\"error\":\"invalid_request\"," + "\"error_description\":\"Invalid request\"}";
 
             exchange.sendResponseHeaders(400, responseMsg.length());
             exchange.getResponseBody().write(responseMsg.getBytes());
             exchange.close();
         });
 
-        configureWellKnownOidcMetadata(idpServer, rsaJWK, idpServer.getAddress().getHostName() + ":" + idpServer.getAddress().getPort());
+        configureWellKnownOidcMetadata(
+                idpServer,
+                rsaJWK,
+                idpServer.getAddress().getHostName() + ":"
+                        + idpServer.getAddress().getPort());
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = getOidcProviderMetadataRegistry();
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:" + idpServer.getAddress().getPort(),
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
         when(config.callbackUri()).thenReturn("http://redirect");
 
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1");
@@ -510,10 +559,12 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
 
-
-        //Test with an id token signed by another key, and expired
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
-        assertEquals("Error in userinfo response: invalid_request. Status code: 400. Invalid request", exception.getMessage());
+        // Test with an id token signed by another key, and expired
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        assertEquals(
+                "Error in userinfo response: invalid_request. Status code: 400. Invalid request",
+                exception.getMessage());
     }
 
     @NotNull
@@ -527,30 +578,30 @@ class OidcAuthenticationHandlerTest {
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
         when(oidcProviderMetadataRegistry.getJWKSetURI(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/jwks.json"));
         when(oidcProviderMetadataRegistry.getIssuer(mockIdPUrl)).thenReturn(ISSUER);
-        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/authorize"));
+        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl))
+                .thenReturn(URI.create(mockIdPUrl + "/authorize"));
         when(oidcProviderMetadataRegistry.getTokenEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/token"));
-        when(oidcProviderMetadataRegistry.getUserInfoEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/userinfo"));
+        when(oidcProviderMetadataRegistry.getUserInfoEndpoint(mockIdPUrl))
+                .thenReturn(URI.create(mockIdPUrl + "/userinfo"));
         return oidcProviderMetadataRegistry;
     }
 
     // Test with a valid id token but with an invalid user info response that a non-json string
     @Test
-    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUnparsableUserInfo() throws JOSEException {
-        RSAKey rsaJWK = new RSAKeyGenerator(2048)
-                .keyID("123")
-                .generate();
+    void extractCredentials_WithMatchingState_WithValidConnection_WithValidIdToken_WithUnparsableUserInfo()
+            throws JOSEException {
+        RSAKey rsaJWK = new RSAKeyGenerator(2048).keyID("123").generate();
         when(config.userInfoEnabled()).thenReturn(true);
 
         idpServer.createContext("/token", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
             String responseMsg;
             try {
-                responseMsg = "{\"access_token\":\"myAccessToken\"," +
-                        "\"expires_in\":\"360\"," +
-                        "\"refresh_token\":\"3600\"," +
-                        "\"refresh_expires_in\":\"36000\"," +
-                        "\"id_token\":\"" + createIdToken(rsaJWK, "client-id", ISSUER) + "\"," +
-                        "\"token_type\":\"Bearer\"}";
+                responseMsg = "{\"access_token\":\"myAccessToken\"," + "\"expires_in\":\"360\","
+                        + "\"refresh_token\":\"3600\","
+                        + "\"refresh_expires_in\":\"36000\","
+                        + "\"id_token\":\""
+                        + createIdToken(rsaJWK, "client-id", ISSUER) + "\"," + "\"token_type\":\"Bearer\"}";
             } catch (JOSEException e) {
                 throw new RuntimeException(e);
             }
@@ -569,22 +620,26 @@ class OidcAuthenticationHandlerTest {
             exchange.close();
         });
 
-        configureWellKnownOidcMetadata(idpServer, rsaJWK, idpServer.getAddress().getHostName() + ":" + idpServer.getAddress().getPort());
+        configureWellKnownOidcMetadata(
+                idpServer,
+                rsaJWK,
+                idpServer.getAddress().getHostName() + ":"
+                        + idpServer.getAddress().getPort());
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = getOidcProviderMetadataRegistry();
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:" + idpServer.getAddress().getPort(),
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
         when(config.callbackUri()).thenReturn("http://redirect");
 
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1");
@@ -593,13 +648,15 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
 
-
-        //Test with an id token signed by another key, and expired
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
-        assertEquals("com.nimbusds.oauth2.sdk.ParseException: Couldn't parse UserInfo claims: Invalid JSON", exception.getMessage());
+        // Test with an id token signed by another key, and expired
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.extractCredentials(request, response));
+        assertEquals(
+                "com.nimbusds.oauth2.sdk.ParseException: Couldn't parse UserInfo claims: Invalid JSON",
+                exception.getMessage());
     }
 
-    //make sure we to not raise an exception trying to fetch the state parameter
+    // make sure we to not raise an exception trying to fetch the state parameter
     @Test
     void extractCredentials_WithParameters() {
         request = mock(HttpServletRequest.class);
@@ -640,19 +697,20 @@ class OidcAuthenticationHandlerTest {
         return signedJWT.serialize();
     }
 
-    private AuthenticationInfo extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(String idToken, RSAKey rsaJWK, String baseUrl, Cookie[] cookies, boolean withPkce) {
+    private AuthenticationInfo extractCredentials_WithMatchingState_WithValidConnection_WithIdToken(
+            String idToken, RSAKey rsaJWK, String baseUrl, Cookie[] cookies, boolean withPkce) {
         idpServer.createContext("/token", exchange -> {
             if (withPkce) {
-                assertTrue(new String(exchange.getRequestBody().readAllBytes()).contains("code_verifier=12345678901234567890123456789012345678901234"));
+                assertTrue(new String(exchange.getRequestBody().readAllBytes())
+                        .contains("code_verifier=12345678901234567890123456789012345678901234"));
             }
 
             exchange.getResponseHeaders().add("Content-Type", "application/json");
-            String responseMsg = "{\"access_token\":\"myAccessToken\"," +
-                    "\"expires_in\":\"360\"," +
-                    "\"refresh_token\":\"3600\"," +
-                    "\"refresh_expires_in\":\"36000\"," +
-                    "\"id_token\":\"" + idToken + "\"," +
-                    "\"token_type\":\"Bearer\"}";
+            String responseMsg = "{\"access_token\":\"myAccessToken\"," + "\"expires_in\":\"360\","
+                    + "\"refresh_token\":\"3600\","
+                    + "\"refresh_expires_in\":\"36000\","
+                    + "\"id_token\":\""
+                    + idToken + "\"," + "\"token_type\":\"Bearer\"}";
 
             exchange.sendResponseHeaders(200, responseMsg.length());
             exchange.getResponseBody().write(responseMsg.getBytes());
@@ -660,11 +718,8 @@ class OidcAuthenticationHandlerTest {
         });
         idpServer.createContext("/userinfo", exchange -> {
             exchange.getResponseHeaders().add("Content-Type", "application/json");
-            String responseMsg = "{" +
-                    "\"sub\":\"1234567890\"," +
-                    "\"name\":\"testUser\"," +
-                    "\"groups\":[\"testGroup\"]" +
-                    "}";
+            String responseMsg =
+                    "{" + "\"sub\":\"1234567890\"," + "\"name\":\"testUser\"," + "\"groups\":[\"testGroup\"]" + "}";
 
             exchange.sendResponseHeaders(200, responseMsg.length());
             exchange.getResponseBody().write(responseMsg.getBytes());
@@ -675,16 +730,16 @@ class OidcAuthenticationHandlerTest {
 
         when(config.callbackUri()).thenReturn("http://redirect");
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = getOidcProviderMetadataRegistry();
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:" + idpServer.getAddress().getPort(),
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
         when(config.callbackUri()).thenReturn("http://redirect");
 
         when(request.getQueryString()).thenReturn("code=authorizationCode&state=part1");
@@ -692,15 +747,16 @@ class OidcAuthenticationHandlerTest {
 
         createOidcAuthenticationHandler();
         return oidcAuthenticationHandler.extractCredentials(request, response);
-
     }
 
     private Cookie[] createMockCookies() {
         Cookie stateCookie = mock(Cookie.class);
         when(stateCookie.getName()).thenReturn(OAuthStateManager.COOKIE_NAME_REQUEST_KEY);
-        when(stateCookie.getValue()).thenReturn(cryptoService.encrypt("part1|mock-oidc-param|redirect|nonce|0123456789012345678901234567890123456789123"));
+        when(stateCookie.getValue())
+                .thenReturn(cryptoService.encrypt(
+                        "part1|mock-oidc-param|redirect|nonce|0123456789012345678901234567890123456789123"));
 
-        return new Cookie[]{stateCookie};
+        return new Cookie[] {stateCookie};
     }
 
     private void configureWellKnownOidcMetadata(HttpServer server, RSAKey rsaJWK, String baseUrl) {
@@ -734,19 +790,18 @@ class OidcAuthenticationHandlerTest {
             exchange.sendResponseHeaders(200, responseMsg.length());
             exchange.close();
         });
-
     }
 
     private void createOidcAuthenticationHandler() {
-        oidcAuthenticationHandler = new OidcAuthenticationHandler(repository,
+        oidcAuthenticationHandler = new OidcAuthenticationHandler(
+                repository,
                 bundleContext,
                 connections,
                 oauthStateManager,
                 config,
                 loginCookieManager,
                 userInfoProcessor,
-                cryptoService
-        );
+                cryptoService);
     }
 
     private HttpServer createHttpServer() throws IOException {
@@ -758,58 +813,61 @@ class OidcAuthenticationHandlerTest {
     @Test
     void requestCredentialsDefaultConnectionIOException() throws IOException {
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
         String mockIdPUrl = "http://localhost:8080";
         when(oidcProviderMetadataRegistry.getJWKSetURI(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/jwks.json"));
         when(oidcProviderMetadataRegistry.getIssuer(mockIdPUrl)).thenReturn(ISSUER);
-        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/authorize"));
+        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl))
+                .thenReturn(URI.create(mockIdPUrl + "/authorize"));
         when(oidcProviderMetadataRegistry.getTokenEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/token"));
 
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:8080",
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
 
         when(config.defaultConnectionName()).thenReturn(MOCK_OIDC_PARAM);
         when(config.callbackUri()).thenReturn("http://redirect");
         when(config.pkceEnabled()).thenReturn(false);
-        when(config.path()).thenReturn(new String[]{"/"});
+        when(config.path()).thenReturn(new String[] {"/"});
 
         createOidcAuthenticationHandler();
 
         // Test the Exception on response
         response = mock(HttpServletResponse.class);
         when(request.getRequestURI()).thenReturn("http://localhost:8080");
-        //mock to trow an exception when response.sendRedirect is called
+        // mock to trow an exception when response.sendRedirect is called
         doThrow(new IOException("Mocked Exception")).when(response).sendRedirect(anyString());
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> oidcAuthenticationHandler.requestCredentials(request, response));
+        RuntimeException exception = assertThrows(
+                RuntimeException.class, () -> oidcAuthenticationHandler.requestCredentials(request, response));
         assertEquals("java.io.IOException: Mocked Exception", exception.getMessage());
     }
 
     @Test
     void requestCredentialsDefaultConnectionWithNonce() {
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
         String mockIdPUrl = "http://localhost:8080";
         when(oidcProviderMetadataRegistry.getJWKSetURI(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/jwks.json"));
         when(oidcProviderMetadataRegistry.getIssuer(mockIdPUrl)).thenReturn(ISSUER);
-        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/authorize"));
+        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl))
+                .thenReturn(URI.create(mockIdPUrl + "/authorize"));
         when(oidcProviderMetadataRegistry.getTokenEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/token"));
 
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:8080",
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
 
         when(config.defaultConnectionName()).thenReturn(MOCK_OIDC_PARAM);
         when(config.callbackUri()).thenReturn("http://redirect");
@@ -821,48 +879,48 @@ class OidcAuthenticationHandlerTest {
         createOidcAuthenticationHandler();
         assertTrue(oidcAuthenticationHandler.requestCredentials(request, mockResponse));
         assertTrue(mockResponse.getCookies().stream().anyMatch(cookie -> {
-                            if (OAuthStateManager.COOKIE_NAME_REQUEST_KEY.equals(cookie.getName())) {
-                                OAuthCookieValue oauthCookieValue = new OAuthCookieValue(cookie.getValue(), cryptoService);
-
-                                //Verify that state is present in request and in cookie
-                                assertTrue(mockResponse.getSendRedirect().contains("state=" + oauthCookieValue.perRequestKey()));
+            if (OAuthStateManager.COOKIE_NAME_REQUEST_KEY.equals(cookie.getName())) {
+                OAuthCookieValue oauthCookieValue = new OAuthCookieValue(cookie.getValue(), cryptoService);
 
-                                //Verify that nonce is present in request and in cookie
-                                assertTrue(mockResponse.getSendRedirect().contains("nonce=" + oauthCookieValue.nonce().getValue()));
+                // Verify that state is present in request and in cookie
+                assertTrue(mockResponse.getSendRedirect().contains("state=" + oauthCookieValue.perRequestKey()));
 
-                                //Verify that codeVerifier is not present cookie and request
-                                assertNull(oauthCookieValue.codeVerifier());
-                                assertFalse(mockResponse.getSendRedirect().contains("code_verifier="));
+                // Verify that nonce is present in request and in cookie
+                assertTrue(mockResponse
+                        .getSendRedirect()
+                        .contains("nonce=" + oauthCookieValue.nonce().getValue()));
 
-                                // Verify that the redirect URI in the cookie is correct
-                                assertTrue(oauthCookieValue.redirect().equals("http://localhost"));
-                                return true;
-                            }
-                            return false;
-                        }
-                )
-        );
+                // Verify that codeVerifier is not present cookie and request
+                assertNull(oauthCookieValue.codeVerifier());
+                assertFalse(mockResponse.getSendRedirect().contains("code_verifier="));
 
+                // Verify that the redirect URI in the cookie is correct
+                assertTrue(oauthCookieValue.redirect().equals("http://localhost"));
+                return true;
+            }
+            return false;
+        }));
     }
 
     @Test
     void requestCredentialsDefaultConnectionWithPkce() {
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
         String mockIdPUrl = "http://localhost:8080";
         when(oidcProviderMetadataRegistry.getJWKSetURI(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/jwks.json"));
         when(oidcProviderMetadataRegistry.getIssuer(mockIdPUrl)).thenReturn(ISSUER);
-        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/authorize"));
+        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl))
+                .thenReturn(URI.create(mockIdPUrl + "/authorize"));
         when(oidcProviderMetadataRegistry.getTokenEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/token"));
 
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:8080",
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
 
         when(config.defaultConnectionName()).thenReturn(MOCK_OIDC_PARAM);
         when(config.callbackUri()).thenReturn("http://redirect");
@@ -871,7 +929,7 @@ class OidcAuthenticationHandlerTest {
         MockResponse mockResponse = new MockResponse();
 
         when(config.pkceEnabled()).thenReturn(true);
-        when(config.path()).thenReturn(new String[]{"/"});
+        when(config.path()).thenReturn(new String[] {"/"});
 
         when(request.getRequestURI()).thenReturn("http://localhost");
 
@@ -887,18 +945,23 @@ class OidcAuthenticationHandlerTest {
                 assertTrue(mockResponse.getSendRedirect().contains("code_challenge_method=S256"));
                 CodeVerifier codeVerifier = new CodeVerifier(cookieParts[OAuthCookieValue.CODE_VERIFIER_INDEX]);
 
-                String codeChallenge = mockResponse.getSendRedirect().split("code_challenge=")[1].split("&")[0];
+                String codeChallenge = mockResponse.getSendRedirect()
+                        .split("code_challenge=")[1]
+                        .split("&")[0];
                 CodeChallenge computedCodeChallenge = CodeChallenge.compute(CodeChallengeMethod.S256, codeVerifier);
                 assertEquals(codeChallenge, computedCodeChallenge.getValue());
 
                 // Verify that steate in the cookie matches with state in the redirect
-                assertEquals(cookieParts[OAuthCookieValue.STATE_INDEX], mockResponse.getSendRedirect().split("state=")[1].split("&")[0]);
+                assertEquals(
+                        cookieParts[OAuthCookieValue.STATE_INDEX],
+                        mockResponse.getSendRedirect().split("state=")[1].split("&")[0]);
 
                 // Verify that nonce in the cookie matches with nonce in the redirect
-                assertEquals(cookieParts[OAuthCookieValue.NONCE_INDEX],
-                        URLDecoder.decode(
-                                mockResponse.getSendRedirect().split("nonce=")[1].split("&")[0])
-                );
+                assertEquals(
+                        cookieParts[OAuthCookieValue.NONCE_INDEX],
+                        URLDecoder.decode(mockResponse.getSendRedirect()
+                                .split("nonce=")[1]
+                                .split("&")[0]));
 
                 // Verify the redirect URI in the cookie is correct
                 assertTrue(cookieParts[OAuthCookieValue.REDIRECT_INDEX].equals("http://localhost"));
@@ -914,22 +977,23 @@ class OidcAuthenticationHandlerTest {
     @Test
     void requestCredentialsUnknownConnection() {
 
-        //This is the class used by Sling to configure the Authentication Handler
+        // This is the class used by Sling to configure the Authentication Handler
         OidcProviderMetadataRegistry oidcProviderMetadataRegistry = mock(OidcProviderMetadataRegistry.class);
         String mockIdPUrl = "http://localhost:8080";
         when(oidcProviderMetadataRegistry.getJWKSetURI(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/jwks.json"));
         when(oidcProviderMetadataRegistry.getIssuer(mockIdPUrl)).thenReturn(ISSUER);
-        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/authorize"));
+        when(oidcProviderMetadataRegistry.getAuthorizationEndpoint(mockIdPUrl))
+                .thenReturn(URI.create(mockIdPUrl + "/authorize"));
         when(oidcProviderMetadataRegistry.getTokenEndpoint(mockIdPUrl)).thenReturn(URI.create(mockIdPUrl + "/token"));
 
-        connections.add(new MockOidcConnection(new String[]{"openid"},
+        connections.add(new MockOidcConnection(
+                new String[] {"openid"},
                 MOCK_OIDC_PARAM,
                 "client-id",
                 "client-secret",
                 "http://localhost:8080",
-                new String[]{"access_type=offline"},
-                oidcProviderMetadataRegistry)
-        );
+                new String[] {"access_type=offline"},
+                oidcProviderMetadataRegistry));
 
         when(config.defaultConnectionName()).thenReturn(MOCK_OIDC_PARAM);
         when(config.callbackUri()).thenReturn("http://redirect");
@@ -953,7 +1017,8 @@ class OidcAuthenticationHandlerTest {
     void authenticationSucceededLoginManagerNotAvailable() {
         loginCookieManager = null;
         createOidcAuthenticationHandler();
-        assertFalse(oidcAuthenticationHandler.authenticationSucceeded(request, response, new AuthenticationInfo("oidc", "testUser")));
+        assertFalse(oidcAuthenticationHandler.authenticationSucceeded(
+                request, response, new AuthenticationInfo("oidc", "testUser")));
     }
 
     @Test
@@ -961,7 +1026,8 @@ class OidcAuthenticationHandlerTest {
         when(request.getRequestURI()).thenReturn("http://localhost:8080");
         when(loginCookieManager.getLoginCookie(request)).thenReturn(new Cookie("test", "test"));
         createOidcAuthenticationHandler();
-        assertFalse(oidcAuthenticationHandler.authenticationSucceeded(request, response, new AuthenticationInfo("oidc", "testUser")));
+        assertFalse(oidcAuthenticationHandler.authenticationSucceeded(
+                request, response, new AuthenticationInfo("oidc", "testUser")));
     }
 
     @Test
@@ -992,7 +1058,6 @@ class OidcAuthenticationHandlerTest {
             }
             return false;
         }));
-
     }
 
     @Test
@@ -1004,8 +1069,10 @@ class OidcAuthenticationHandlerTest {
 
         OAuthConnectionImpl oauthClientConnection = mock(OAuthConnectionImpl.class);
         when(oauthClientConnection.name()).thenReturn("test");
-        RuntimeException exception = assertThrows(RuntimeException.class, () -> ResolvedOidcConnection.resolve(oauthClientConnection));
-        assertEquals("Unable to resolve ClientConnection (name=test) of type org.apache.sling.auth.oauth_client.impl.OAuthConnectionImpl", exception.getMessage());
+        RuntimeException exception =
+                assertThrows(RuntimeException.class, () -> ResolvedOidcConnection.resolve(oauthClientConnection));
+        assertEquals(
+                "Unable to resolve ClientConnection (name=test) of type org.apache.sling.auth.oauth_client.impl.OAuthConnectionImpl",
+                exception.getMessage());
     }
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProviderTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProviderTest.java
index 66f2e05..3ac44ab 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProviderTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/OidcIdentityProviderTest.java
@@ -1,21 +1,30 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.jcr.Credentials;
+import javax.jcr.SimpleCredentials;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
 import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException;
 import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
@@ -25,13 +34,6 @@ import org.apache.sling.auth.oauth_client.impl.OidcIdentityProvider.OidcGroupRef
 import org.apache.sling.auth.oauth_client.spi.OidcAuthCredentials;
 import org.junit.jupiter.api.Test;
 
-import javax.jcr.Credentials;
-import javax.jcr.SimpleCredentials;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -114,7 +116,7 @@ class OidcIdentityProviderTest {
         OidcIdentityProvider test = new OidcIdentityProvider("test");
         ExternalIdentity externalIdentity = test.getIdentity(groupRef);
         assertNotNull(externalIdentity);
-        
+
         assertEquals(Collections.emptyList(), externalIdentity.getDeclaredGroups());
         assertEquals(Collections.emptyMap(), externalIdentity.getProperties());
     }
@@ -136,8 +138,9 @@ class OidcIdentityProviderTest {
         credentials.addGroup("group1");
         ExternalIdentity externalIdentity = test.authenticate(credentials);
         assertNotNull(externalIdentity);
-        
-        ExternalIdentityRef group = externalIdentity.getDeclaredGroups().iterator().next();
+
+        ExternalIdentityRef group =
+                externalIdentity.getDeclaredGroups().iterator().next();
         assertEquals("group1", group.getId());
         assertEquals("test", group.getProviderName());
         assertEquals("token", externalIdentity.getProperties().get(TokenConstants.TOKEN_ATTRIBUTE));
@@ -154,7 +157,7 @@ class OidcIdentityProviderTest {
         Credentials credentials = new OidcAuthCredentials("userId", "wrong-idp");
         assertNull(test.authenticate(credentials));
     }
-    
+
     @Test
     void authenticateUnsupportedCredentials() {
         OidcIdentityProvider test = new OidcIdentityProvider("test");
@@ -173,14 +176,15 @@ class OidcIdentityProviderTest {
     }
 
     @Test
-    void fromExternalIdentityRefFailure()  {
+    void fromExternalIdentityRefFailure() {
         OidcGroupRef groupRef = mock(OidcGroupRef.class);
         when(groupRef.getProviderName()).thenReturn("test");
         when(groupRef.getId()).thenReturn("test");
         when(groupRef.getString()).thenReturn("test");
 
         OidcIdentityProvider test = new OidcIdentityProvider("wrong-idp");
-        ExternalIdentityException exception = assertThrows(ExternalIdentityException.class, () -> test.fromExternalIdentityRef(groupRef));
+        ExternalIdentityException exception =
+                assertThrows(ExternalIdentityException.class, () -> test.fromExternalIdentityRef(groupRef));
         assertEquals("Foreign IDP test", exception.getMessage());
     }
 
@@ -194,7 +198,6 @@ class OidcIdentityProviderTest {
     void getGroup() {
         OidcIdentityProvider test = new OidcIdentityProvider("test");
         assertThrows(UnsupportedOperationException.class, () -> test.getGroup("groupId"));
-
     }
 
     @Test
@@ -208,4 +211,4 @@ class OidcIdentityProviderTest {
         OidcIdentityProvider test = new OidcIdentityProvider("test");
         assertThrows(UnsupportedOperationException.class, test::listGroups);
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/RedirectHelperTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/RedirectHelperTest.java
index 8d02a25..4403c78 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/RedirectHelperTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/RedirectHelperTest.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -83,4 +85,4 @@ class RedirectHelperTest {
         String result = RedirectHelper.findLongestPathMatching(paths, url);
         assertEquals("/a/b", result);
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStoreTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStoreTest.java
index 91fc05a..86966d6 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStoreTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/RedisOAuthTokenStoreTest.java
@@ -1,23 +1,26 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
 import java.util.Map;
 
+import com.redis.testcontainers.RedisContainer;
 import org.apache.sling.auth.oauth_client.impl.RedisOAuthTokenStore.Config;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
 import org.apache.sling.testing.mock.sling.junit5.SlingContext;
@@ -27,24 +30,23 @@ import org.testcontainers.junit.jupiter.Container;
 import org.testcontainers.junit.jupiter.Testcontainers;
 import org.testcontainers.utility.DockerImageName;
 
-import com.redis.testcontainers.RedisContainer;
-
 @Testcontainers
 public class RedisOAuthTokenStoreTest extends TokenStoreTestSupport<RedisOAuthTokenStore> {
 
     @Container
     private final RedisContainer redis = new RedisContainer(DockerImageName.parse("redis:6.2.6"));
-    
+
     RedisOAuthTokenStoreTest() {
         super(MockOidcConnection.DEFAULT_CONNECTION, new SlingContext(ResourceResolverType.JCR_MOCK));
     }
 
     @Override
-    @NotNull RedisOAuthTokenStore createTokenStore() {
+    @NotNull
+    RedisOAuthTokenStore createTokenStore() {
         Config cfg = Converters.standardConverter()
-            .convert(Map.of("redisUrl", redis.getRedisURI()))
-            .to(RedisOAuthTokenStore.Config.class);
-        
+                .convert(Map.of("redisUrl", redis.getRedisURI()))
+                .to(RedisOAuthTokenStore.Config.class);
+
         return new RedisOAuthTokenStore(cfg);
     }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
index a4c500d..292b54e 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/SlingLoginCookieManagerTest.java
@@ -1,21 +1,31 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+import java.io.File;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+
 import org.apache.sling.auth.core.spi.AuthenticationInfo;
 import org.apache.sling.auth.oauth_client.spi.OidcAuthCredentials;
 import org.apache.sling.jcr.api.SlingRepository;
@@ -26,13 +36,6 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 import org.osgi.framework.BundleContext;
 
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import java.io.File;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Base64;
-
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -42,7 +45,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class SlingLoginCookieManagerTest {
-    
+
     private static final String COOKIE_NAME = "sling.oidcauth";
 
     private final MockRequest request = new MockRequest();
@@ -53,7 +56,8 @@ class SlingLoginCookieManagerTest {
 
     @BeforeEach
     void setup() throws NoSuchAlgorithmException, InvalidKeyException {
-        SlingLoginCookieManager.SlingLoginCookieManagerConfig config = mock(SlingLoginCookieManager.SlingLoginCookieManagerConfig.class);
+        SlingLoginCookieManager.SlingLoginCookieManagerConfig config =
+                mock(SlingLoginCookieManager.SlingLoginCookieManagerConfig.class);
 
         File tokenFile = new File(tempFolder, "cookie-tokens.bin");
 
@@ -64,7 +68,7 @@ class SlingLoginCookieManagerTest {
 
         BundleContext bundleContext = mock(BundleContext.class);
         when(bundleContext.getDataFile("cookie-tokens")).thenReturn(tokenFile);
-        
+
         slingLoginCookieManager = new SlingLoginCookieManager(config, bundleContext);
     }
 
@@ -79,7 +83,7 @@ class SlingLoginCookieManagerTest {
         assertNotNull(cookie);
 
         assertEquals("sling.oidcauth", cookie.getName());
-        assertTrue(new String (Base64.getDecoder().decode(cookie.getValue())).endsWith("testUser"));
+        assertTrue(new String(Base64.getDecoder().decode(cookie.getValue())).endsWith("testUser"));
 
         request.addCookie(cookie);
         assertEquals(cookie, slingLoginCookieManager.getLoginCookie(request));
@@ -88,12 +92,11 @@ class SlingLoginCookieManagerTest {
         assertNotNull(authInfo);
         assertInstanceOf(OidcAuthCredentials.class, authInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS));
         assertEquals("testUser", authInfo.getUser());
-
     }
 
     @Test
     void verifyNoLoginCookie() {
-        //No cookies are set
+        // No cookies are set
         assertNull(slingLoginCookieManager.verifyLoginCookie(request));
     }
 
@@ -106,18 +109,17 @@ class SlingLoginCookieManagerTest {
 
     @Test
     void verifyLoginCookieOtherNoLoginCookie() {
-        Cookie cookie1 = new Cookie("test1", "test" );
+        Cookie cookie1 = new Cookie("test1", "test");
         request.addCookie(cookie1);
-        Cookie cookie2 = new Cookie("test2", "test" );
+        Cookie cookie2 = new Cookie("test2", "test");
         request.addCookie(cookie2);
 
         assertNull(slingLoginCookieManager.verifyLoginCookie(request));
     }
 
-
     @Test
     void verifyLoginCookieInvalidValue() {
-        Cookie cookie = new Cookie("sling.oidcauth", Base64.getEncoder().encodeToString("invalidValue".getBytes()) );
+        Cookie cookie = new Cookie("sling.oidcauth", Base64.getEncoder().encodeToString("invalidValue".getBytes()));
         request.addCookie(cookie);
         assertNull(slingLoginCookieManager.verifyLoginCookie(request));
     }
@@ -169,5 +171,4 @@ class SlingLoginCookieManagerTest {
 
         return cookie;
     }
-
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoService.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoService.java
index e15b23b..70f3a1c 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoService.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoService.java
@@ -1,28 +1,30 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-
 import java.util.Base64;
 
 import org.apache.sling.commons.crypto.CryptoService;
 import org.jetbrains.annotations.NotNull;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 class StubCryptoService implements CryptoService {
 
     @Override
@@ -34,5 +36,4 @@ class StubCryptoService implements CryptoService {
     public @NotNull String decrypt(@NotNull String cipherText) {
         return new String(Base64.getDecoder().decode(cipherText), UTF_8);
     }
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoServiceTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoServiceTest.java
index f696802..ed50791 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoServiceTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/StubCryptoServiceTest.java
@@ -1,25 +1,27 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import org.junit.jupiter.api.Test;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 class StubCryptoServiceTest {
 
     @Test
@@ -27,11 +29,10 @@ class StubCryptoServiceTest {
         StubCryptoService stubCryptoService = new StubCryptoService();
         assertThat(stubCryptoService.decrypt(stubCryptoService.encrypt("test"))).isEqualTo("test");
     }
-    
+
     @org.junit.Test
     void encryptIsNotEqualToInput() {
         StubCryptoService stubCryptoService = new StubCryptoService();
         assertThat(stubCryptoService.encrypt("test")).isNotEqualTo("test");
     }
-
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/StubOAuthStateManager.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/StubOAuthStateManager.java
index cb08a8d..0b1c942 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/StubOAuthStateManager.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/StubOAuthStateManager.java
@@ -1,18 +1,20 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
@@ -27,11 +29,11 @@ class StubOAuthStateManager extends CryptoOAuthStateManager {
             public @NotNull String encrypt(@NotNull String message) {
                 return message;
             }
-            
+
             @Override
             public @NotNull String decrypt(@NotNull String ciphertext) {
                 return ciphertext;
             }
         });
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTest.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTest.java
index 641010b..a2fdede 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTest.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTest.java
@@ -18,12 +18,6 @@
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import org.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
 import java.io.File;
 import java.io.IOException;
 import java.math.BigInteger;
@@ -35,6 +29,12 @@ import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
 
+import org.awaitility.Awaitility;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
@@ -49,9 +49,7 @@ public class TokenStoreTest {
 
     @Parameterized.Parameters(name = "name={1}")
     public static Collection<Object[]> parameters() {
-        return List.of(
-                new Object[] { false, "fastSeed = false" },
-                new Object[] { true, "fastSeed = true" });
+        return List.of(new Object[] {false, "fastSeed = false"}, new Object[] {true, "fastSeed = true"});
     }
 
     private final boolean fastSeed;
@@ -59,11 +57,11 @@ public class TokenStoreTest {
     private String encodedToken;
     private File tokenFile;
     private int additionalFileIndex;
-    
+
     public TokenStoreTest(boolean fastSeed, String name) {
         this.fastSeed = fastSeed;
     }
-    
+
     private File additionalTokenFile() {
         return new File(tokenFile.getParent(), tokenFile.getName() + "-" + additionalFileIndex++);
     }
@@ -82,28 +80,23 @@ public class TokenStoreTest {
 
     @Test
     public void invalidTokensTest() {
-        final String [] invalid = {
-            "1@21@3",
-            "1@-@3",
-            "nothing",
-            "0@bad@token"
-        };
+        final String[] invalid = {"1@21@3", "1@-@3", "nothing", "0@bad@token"};
         for (String token : invalid) {
             assertFalse(store.isValid(token));
-        }        
+        }
     }
 
     @Test
     public void expiredTokenTest() throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException {
         final String expired = store.encode(1, USER_ID);
         Awaitility.await("expiredToken")
-            .atMost(Duration.ofSeconds(5))
-            .pollDelay(Duration.ofMillis(50))
-            .pollInterval(Duration.ofMillis(50))
-            .until(() -> !store.isValid(expired));
+                .atMost(Duration.ofSeconds(5))
+                .pollDelay(Duration.ofMillis(50))
+                .pollInterval(Duration.ofMillis(50))
+                .until(() -> !store.isValid(expired));
         assertFalse(store.isValid(expired));
     }
-    
+
     @Test
     public void loadTokenFileTest() throws Exception {
         final TokenStore newStore = new TokenStore(tokenFile, SESSION_TIMEOUT_MSEC, fastSeed);
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTestSupport.java b/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTestSupport.java
index ece70fa..24e9631 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTestSupport.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/impl/TokenStoreTestSupport.java
@@ -1,25 +1,28 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.impl;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import java.util.concurrent.TimeUnit;
 
+import com.nimbusds.oauth2.sdk.token.BearerAccessToken;
+import com.nimbusds.oauth2.sdk.token.RefreshToken;
+import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
 import org.apache.sling.jackrabbit.usermanager.impl.AuthorizableAdapterFactory;
 import org.apache.sling.testing.mock.sling.junit5.SlingContext;
 import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension;
@@ -28,13 +31,11 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
-import com.nimbusds.oauth2.sdk.token.BearerAccessToken;
-import com.nimbusds.oauth2.sdk.token.RefreshToken;
-import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /**
  * Support class for testing invariants of {@link OAuthTokenStore} implementations.
- * 
+ *
  * @param <T> type of TokenStore to test
  */
 @ExtendWith(SlingContextExtension.class)
@@ -47,141 +48,147 @@ public abstract class TokenStoreTestSupport<T extends OAuthTokenStore> {
         this.connection = connection;
         this.context = context;
     }
-    
+
     abstract @NotNull T createTokenStore();
 
     @BeforeEach
     public void registerAdapterFactories() {
         context.registerInjectActivateService(new AuthorizableAdapterFactory());
     }
-    
+
     @Test
     void getAccessToken_missing() {
-        
+
         T tokenStore = createTokenStore();
-        
+
         OAuthToken accessToken = tokenStore.getAccessToken(connection, context.resourceResolver());
-        
-        assertThat(accessToken).as("access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isEqualTo( TokenState.MISSING );
+
+        assertThat(accessToken)
+                .as("access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isEqualTo(TokenState.MISSING);
     }
-    
+
     @Test
     void getAccessToken_valid() throws Exception {
-        
+
         OIDCTokens tokens = new OIDCTokens(new BearerAccessToken(12), null);
 
         T tokenStore = createTokenStore();
         tokenStore.persistTokens(connection, context.resourceResolver(), Converter.toSlingOAuthTokens(tokens));
-        
+
         OAuthToken accessToken = tokenStore.getAccessToken(connection, context.resourceResolver());
-        assertThat(accessToken).as("access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState , OAuthToken::getValue )
-            .containsExactly( TokenState.VALID, tokens.getAccessToken().getValue() );
-        
+        assertThat(accessToken)
+                .as("access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState, OAuthToken::getValue)
+                .containsExactly(TokenState.VALID, tokens.getAccessToken().getValue());
+
         getAccessToken_valid_postCheck(tokens);
     }
-    
-    protected void getAccessToken_valid_postCheck(OIDCTokens input) throws Exception { 
+
+    protected void getAccessToken_valid_postCheck(OIDCTokens input) throws Exception {
         // nothing to do by default
     }
-    
 
     @Test
     void getAccessToken_notYetExpired() {
-        
+
         OIDCTokens tokens = new OIDCTokens(new BearerAccessToken(12, 3600, null), null);
-        
+
         T tokenStore = createTokenStore();
         tokenStore.persistTokens(connection, context.resourceResolver(), Converter.toSlingOAuthTokens(tokens));
 
         OAuthToken accessToken = tokenStore.getAccessToken(connection, context.resourceResolver());
-        assertThat(accessToken).as("access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isEqualTo( TokenState.VALID);
-    }    
+        assertThat(accessToken)
+                .as("access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isEqualTo(TokenState.VALID);
+    }
 
     @Test
     void getAccessToken_expired() throws InterruptedException {
-        
+
         int lifetimeSeconds = 1;
         OIDCTokens tokens = new OIDCTokens(new BearerAccessToken(12, lifetimeSeconds, null), null);
-        
+
         T tokenStore = createTokenStore();
         tokenStore.persistTokens(connection, context.resourceResolver(), Converter.toSlingOAuthTokens(tokens));
 
         // wait for the token to expire
-        Thread.sleep( TimeUnit.SECONDS.toMillis( 2 * lifetimeSeconds ) );
-        
+        Thread.sleep(TimeUnit.SECONDS.toMillis(2 * lifetimeSeconds));
+
         OAuthToken accessToken = tokenStore.getAccessToken(connection, context.resourceResolver());
-        assertThat(accessToken).as("access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isIn( TokenState.EXPIRED, TokenState.MISSING ); // TODO - should be EXPIRED but Redis supports only MISSING
-            
+        assertThat(accessToken)
+                .as("access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isIn(
+                        TokenState.EXPIRED,
+                        TokenState.MISSING); // TODO - should be EXPIRED but Redis supports only MISSING
     }
-    
+
     @Test
     void getRefreshToken_valid() {
         OIDCTokens tokens = new OIDCTokens(new BearerAccessToken(12), new RefreshToken(12));
 
         T tokenStore = createTokenStore();
         tokenStore.persistTokens(connection, context.resourceResolver(), Converter.toSlingOAuthTokens(tokens));
-        
+
         OAuthToken refreshToken = tokenStore.getRefreshToken(connection, context.resourceResolver());
-        assertThat(refreshToken).as("refresh token")
-            .isNotNull()
-            .extracting( OAuthToken::getState , OAuthToken::getValue )
-            .containsExactly( TokenState.VALID, tokens.getRefreshToken().getValue() );
+        assertThat(refreshToken)
+                .as("refresh token")
+                .isNotNull()
+                .extracting(OAuthToken::getState, OAuthToken::getValue)
+                .containsExactly(TokenState.VALID, tokens.getRefreshToken().getValue());
     }
-    
+
     @Test
     void getRefreshToken_missing() {
-        
+
         T tokenStore = createTokenStore();
-        
+
         OAuthToken refreshToken = tokenStore.getRefreshToken(connection, context.resourceResolver());
-        assertThat(refreshToken).as("refresh token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isEqualTo( TokenState.MISSING);
+        assertThat(refreshToken)
+                .as("refresh token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isEqualTo(TokenState.MISSING);
     }
-    
+
     @Test
     void clearAccessToken() {
         T tokenStore = createTokenStore();
-            
+
         OIDCTokens tokens = new OIDCTokens(new BearerAccessToken(12), null);
         tokenStore.persistTokens(connection, context.resourceResolver(), Converter.toSlingOAuthTokens(tokens));
 
         assertThat(tokenStore.getAccessToken(connection, context.resourceResolver()))
-            .as("persisted access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isEqualTo( TokenState.VALID );
+                .as("persisted access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isEqualTo(TokenState.VALID);
 
         tokenStore.clearAccessToken(connection, context.resourceResolver());
-        
+
         assertThat(tokenStore.getAccessToken(connection, context.resourceResolver()))
-            .as("cleared access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isEqualTo( TokenState.MISSING );
+                .as("cleared access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isEqualTo(TokenState.MISSING);
     }
-    
+
     @Test
     void clearAccessToken_missingAlready() {
         T tokenStore = createTokenStore();
         tokenStore.clearAccessToken(connection, context.resourceResolver());
-        
+
         assertThat(tokenStore.getAccessToken(connection, context.resourceResolver()))
-            .as("access token")
-            .isNotNull()
-            .extracting( OAuthToken::getState )
-            .isEqualTo( TokenState.MISSING );
+                .as("access token")
+                .isNotNull()
+                .extracting(OAuthToken::getState)
+                .isEqualTo(TokenState.MISSING);
     }
 }
diff --git a/src/test/java/org/apache/sling/auth/oauth_client/itbundle/DecryptOAuthTokenServlet.java b/src/test/java/org/apache/sling/auth/oauth_client/itbundle/DecryptOAuthTokenServlet.java
index 7435e5a..c6629f2 100644
--- a/src/test/java/org/apache/sling/auth/oauth_client/itbundle/DecryptOAuthTokenServlet.java
+++ b/src/test/java/org/apache/sling/auth/oauth_client/itbundle/DecryptOAuthTokenServlet.java
@@ -1,31 +1,31 @@
 /*
- * 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
+ * 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
+ *   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.
+ * 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.
  */
 package org.apache.sling.auth.oauth_client.itbundle;
 
-import static java.lang.String.format;
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.servlet.Servlet;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
@@ -43,58 +43,61 @@ import org.osgi.service.component.annotations.ReferencePolicyOption;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static java.lang.String.format;
+
 @Component(service = Servlet.class)
 @SlingServletPaths("/system/sling/decrypt")
 public class DecryptOAuthTokenServlet extends SlingAllMethodsServlet {
-    
+
     private static final long serialVersionUID = 1L;
-    
+
     private final Logger logger = LoggerFactory.getLogger(getClass());
-    private final Map<String,CryptoService> cryptoServicesByName = new HashMap<>();
-    
+    private final Map<String, CryptoService> cryptoServicesByName = new HashMap<>();
+
     @Activate
-    public DecryptOAuthTokenServlet(@Reference(
-            service=CryptoService.class,
-            cardinality = ReferenceCardinality.MULTIPLE,
-            policy = ReferencePolicy.DYNAMIC,
-            policyOption = ReferencePolicyOption.GREEDY) 
-        List<ServiceReference<CryptoService>> cryptoServices, BundleContext ctx) {
-        
-        cryptoServices.forEach( sr -> {
-           CryptoService cs = ctx.getService(sr);
-           String[] cryptoNames = (String[]) sr.getProperty("names");
-            for (String cryptoName : cryptoNames)
-                cryptoServicesByName.put(cryptoName, cs);
+    public DecryptOAuthTokenServlet(
+            @Reference(
+                            service = CryptoService.class,
+                            cardinality = ReferenceCardinality.MULTIPLE,
+                            policy = ReferencePolicy.DYNAMIC,
+                            policyOption = ReferencePolicyOption.GREEDY)
+                    List<ServiceReference<CryptoService>> cryptoServices,
+            BundleContext ctx) {
+
+        cryptoServices.forEach(sr -> {
+            CryptoService cs = ctx.getService(sr);
+            String[] cryptoNames = (String[]) sr.getProperty("names");
+            for (String cryptoName : cryptoNames) cryptoServicesByName.put(cryptoName, cs);
         });
 
         logger.info("Collected cryptoServices with names: {}", cryptoServicesByName.keySet());
     }
 
     @Override
-    protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws IOException {
+    protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
+            throws IOException {
         String token = request.getParameter("token");
         if (token == null) {
             response.sendError(400, "Missing 'token' parameter");
             return;
         }
-        
+
         String cryptoServiceName = request.getParameter("cryptoServiceName");
         if (cryptoServiceName == null) {
             response.sendError(400, "Missing 'cryptoServiceName' parameter");
             return;
         }
-        
+
         CryptoService cryptoService = cryptoServicesByName.get(cryptoServiceName);
         if (cryptoService == null) {
             response.sendError(400, format("Unknown cryptoService  parameter '%s'", cryptoServiceName));
             return;
         }
-        
+
... 427 lines suppressed ...