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

enapps-enorman pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-extensions-webconsolesecurityprovider.git


The following commit(s) were added to refs/heads/master by this push:
     new 63e203d  SLING-13176 Update to Parent 66 and apply spotless formatting 
(#5)
63e203d is described below

commit 63e203df023ba1e63587b9d045b56b90a55a4e37
Author: Eric Norman <[email protected]>
AuthorDate: Fri Apr 24 13:00:51 2026 -0700

    SLING-13176 Update to Parent 66 and apply spotless formatting (#5)
    
    also bump bundle version to 2.0.0
---
 .sling-module.json                                 |  5 ++
 pom.xml                                            | 96 ++++++++++++----------
 .../AbstractWebConsoleSecurityProvider.java        |  6 +-
 .../internal/Activator.java                        | 26 +++---
 .../internal/ServicesListener.java                 | 85 +++++++++++--------
 .../internal/SlingWebConsoleSecurityProvider.java  | 35 ++++----
 .../internal/SlingWebConsoleSecurityProvider2.java | 50 +++++------
 .../internal/ServiceListenerTest.java              | 92 ++++++++++++---------
 8 files changed, 218 insertions(+), 177 deletions(-)

diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..1cac683
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,5 @@
+{
+  "jenkins": {
+    "jdks": [17,21]
+  }
+}
diff --git a/pom.xml b/pom.xml
index 877c58e..6724557 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-    <!--
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
         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
@@ -19,54 +19,40 @@
 
     <modelVersion>4.0.0</modelVersion>
     <parent>
-        <artifactId>sling-bundle-parent</artifactId>
         <groupId>org.apache.sling</groupId>
-        <version>48</version>
+        <artifactId>sling-bundle-parent</artifactId>
+        <version>66</version>
         <relativePath />
     </parent>
 
-    <groupId>org.apache.sling</groupId>
     
<artifactId>org.apache.sling.extensions.webconsolesecurityprovider</artifactId>
-    <version>1.2.9-SNAPSHOT</version>
+    <version>2.0.0-SNAPSHOT</version>
 
     <name>Apache Sling Web Console Security Provider</name>
-    <description>
-        WebConsoleSecurityProvider for the Apache Felix Web Console using the
-        Apache Sling Auth Core bundle to authenticate users.
-    </description>
+    <description>WebConsoleSecurityProvider for the Apache Felix Web Console 
using the
+        Apache Sling Auth Core bundle to authenticate users.</description>
 
     <scm>
         
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-extensions-webconsolesecurityprovider.git</connection>
         
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-extensions-webconsolesecurityprovider.git</developerConnection>
-        
<url>https://github.com/apache/sling-org-apache-sling-extensions-webconsolesecurityprovider.git</url>
-      <tag>HEAD</tag>
-  </scm>
+        <tag>HEAD</tag>
+        
<url>https://github.com/apache/sling-org-apache-sling-extensions-webconsolesecurityprovider/tree/${project.scm.tag}</url>
+    </scm>
 
     <properties>
         <site.jira.version.id>12315265</site.jira.version.id>
+        <sling.java.version>17</sling.java.version>
     </properties>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <configuration>
-                    <skip>true</skip>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
     <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>osgi.core</artifactId>
+            <artifactId>org.osgi.framework</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.service.cm</artifactId>
-            <version>1.5.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -90,10 +76,12 @@
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>javax.jcr</groupId>
             <artifactId>jcr</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -104,24 +92,46 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
         </dependency>
-        
+
         <dependency>
-               <groupId>org.apache.sling</groupId>
-               
<artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
-               <version>3.3.0</version>
-               <scope>test</scope>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.resource</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
+            <version>3.3.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>provided</scope>
         </dependency>
-               <dependency>
-                   <groupId>junit</groupId>
-                   <artifactId>junit</artifactId>
-                   <scope>test</scope>
-               </dependency>
-               <dependency>
-                   <groupId>org.mockito</groupId>
-                   <artifactId>mockito-core</artifactId>
-                   <version>4.6.1</version>
-                   <scope>test</scope>
-               </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/AbstractWebConsoleSecurityProvider.java
 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/AbstractWebConsoleSecurityProvider.java
index 35421b7..3595c0e 100644
--- 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/AbstractWebConsoleSecurityProvider.java
+++ 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/AbstractWebConsoleSecurityProvider.java
@@ -34,8 +34,7 @@ import org.slf4j.LoggerFactory;
  * This is the common base class for the two provider implementations.
  * It handles the configuration of the service.
  */
-public abstract class AbstractWebConsoleSecurityProvider
-    implements WebConsoleSecurityProvider, ManagedService {
+public abstract class AbstractWebConsoleSecurityProvider implements 
WebConsoleSecurityProvider, ManagedService {
 
     // name of the property providing list of authorized users
     private static final String PROP_USERS = "users";
@@ -59,8 +58,7 @@ public abstract class AbstractWebConsoleSecurityProvider
      * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
      */
     @Override
-    public void updated(final Dictionary<String, ?> properties)
-            throws ConfigurationException {
+    public void updated(final Dictionary<String, ?> properties) throws 
ConfigurationException {
         this.users = toSet(properties == null ? null : 
properties.get(PROP_USERS), PROP_GROUPS_DEFAULT_USER);
         this.groups = toSet(properties == null ? null : 
properties.get(PROP_GROUPS), null);
     }
diff --git 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java
 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java
index 0339c5d..127203c 100644
--- 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.java
+++ 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/Activator.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.extensions.webconsolesecurityprovider.internal;
 
diff --git 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
index 0225e12..708f8da 100644
--- 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
+++ 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 package org.apache.sling.extensions.webconsolesecurityprovider.internal;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -50,7 +68,7 @@ public class ServicesListener {
     private static final String AUTH_SUPPORT_CLASS = 
"org.apache.sling.auth.core.AuthenticationSupport";
     private static final String AUTHENTICATOR_CLASS = 
"org.apache.sling.api.auth.Authenticator";
     private static final String REPO_CLASS = "javax.jcr.Repository";
-    
+
     protected static final String WEBCONSOLE_AUTH_TYPE = 
"sling.webconsole.authType";
     protected static final String JCR_AUTH = "jcrAuth";
     protected static final String SLING_AUTH = "slingAuth";
@@ -90,7 +108,7 @@ public class ServicesListener {
 
     /** The registration for the provider2 */
     private ServiceRegistration<?> provider2Reg;
-    
+
     /** Auth type */
     final AuthType authType;
 
@@ -113,28 +131,28 @@ public class ServicesListener {
 
     AuthType getAuthType() {
         final String webConsoleAuthType = 
bundleContext.getProperty(WEBCONSOLE_AUTH_TYPE);
-        if ( webConsoleAuthType != null ) {
-            if ( webConsoleAuthType.equals(JCR_AUTH) ) {
+        if (webConsoleAuthType != null) {
+            if (webConsoleAuthType.equals(JCR_AUTH)) {
                 return AuthType.JCR;
-            } else if ( webConsoleAuthType.equals(SLING_AUTH) ) {
+            } else if (webConsoleAuthType.equals(SLING_AUTH)) {
                 return AuthType.SLING;
             }
-            logger.error("Ignoring invalid auth type for webconsole security 
provider {}",  this.authType);
+            logger.error("Ignoring invalid auth type for webconsole security 
provider {}", this.authType);
         }
         return AuthType.DEFAULT;
     }
 
     State getTargetState(final boolean slingAvailable, final boolean 
jcrAvailable) {
-        if ( !slingAvailable && !jcrAvailable ) {
+        if (!slingAvailable && !jcrAvailable) {
             return State.NONE;
         }
-        if ( this.authType == AuthType.JCR && jcrAvailable ) {
+        if (this.authType == AuthType.JCR && jcrAvailable) {
             return State.PROVIDER_JCR;
         }
-        if ( this.authType == AuthType.SLING && slingAvailable ) {
+        if (this.authType == AuthType.SLING && slingAvailable) {
             return State.PROVIDER_SLING;
         }
-        if ( this.authType == AuthType.DEFAULT ) {
+        if (this.authType == AuthType.DEFAULT) {
             return slingAvailable ? State.PROVIDER_SLING : State.PROVIDER_JCR;
         }
         return State.NONE;
@@ -150,17 +168,18 @@ public class ServicesListener {
             final Object authenticator = this.authListener.getService();
             final Object repository = this.repositoryListener.getService();
 
-            final State targetState = this.getTargetState(authSupport != null 
&& authenticator != null, repository != null);
-            if ( this.registrationState != targetState ) {
-                if ( targetState != State.PROVIDER_JCR ) {
+            final State targetState =
+                    this.getTargetState(authSupport != null && authenticator 
!= null, repository != null);
+            if (this.registrationState != targetState) {
+                if (targetState != State.PROVIDER_JCR) {
                     this.unregisterProviderJcr();
                 }
-                if ( targetState != State.PROVIDER_SLING ) {
+                if (targetState != State.PROVIDER_SLING) {
                     this.unregisterProviderSling();
                 }
-                if ( targetState == State.PROVIDER_JCR ) {
+                if (targetState == State.PROVIDER_JCR) {
                     this.registerProviderJcr(repository);
-                } else if ( targetState == State.PROVIDER_SLING ) {
+                } else if (targetState == State.PROVIDER_SLING) {
                     this.registerProviderSling(authSupport, authenticator);
                 }
                 this.registrationState = targetState;
@@ -169,14 +188,14 @@ public class ServicesListener {
     }
 
     private void unregisterProviderSling() {
-        if ( this.provider2Reg != null ) {
+        if (this.provider2Reg != null) {
             this.provider2Reg.unregister();
             this.provider2Reg = null;
         }
     }
 
     private void unregisterProviderJcr() {
-        if ( this.providerReg != null ) {
+        if (this.providerReg != null) {
             this.providerReg.unregister();
             this.providerReg = null;
         }
@@ -189,8 +208,9 @@ public class ServicesListener {
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put("webconsole.security.provider.id", 
"org.apache.sling.extensions.webconsolesecurityprovider2");
         this.provider2Reg = this.bundleContext.registerService(
-            new String[] {ManagedService.class.getName(), 
WebConsoleSecurityProvider.class.getName()},
-                          new SlingWebConsoleSecurityProvider2(authSupport, 
authenticator), props);
+                new String[] {ManagedService.class.getName(), 
WebConsoleSecurityProvider.class.getName()},
+                new SlingWebConsoleSecurityProvider2(authSupport, 
authenticator),
+                props);
     }
 
     private void registerProviderJcr(final Object repository) {
@@ -200,7 +220,9 @@ public class ServicesListener {
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put("webconsole.security.provider.id", 
"org.apache.sling.extensions.webconsolesecurityprovider");
         this.providerReg = this.bundleContext.registerService(
-            new String[] {ManagedService.class.getName(), 
WebConsoleSecurityProvider.class.getName()}, new 
SlingWebConsoleSecurityProvider(repository), props);
+                new String[] {ManagedService.class.getName(), 
WebConsoleSecurityProvider.class.getName()},
+                new SlingWebConsoleSecurityProvider(repository),
+                props);
     }
 
     /**
@@ -241,14 +263,13 @@ public class ServicesListener {
          */
         public void start() {
             try {
-                bundleContext.addServiceListener(this, "("
-                        + Constants.OBJECTCLASS + "=" + serviceName + ")");
+                bundleContext.addServiceListener(this, "(" + 
Constants.OBJECTCLASS + "=" + serviceName + ")");
             } catch (final InvalidSyntaxException ise) {
                 // this should really never happen
                 throw new RuntimeException("Unexpected exception occured.", 
ise);
             }
             final ServiceReference<?> ref = 
bundleContext.getServiceReference(serviceName);
-            if ( ref != null ) {
+            if (ref != null) {
                 this.retainService(ref);
             }
         }
@@ -276,24 +297,24 @@ public class ServicesListener {
             synchronized (lock) {
                 boolean hadService = this.service != null;
                 boolean getService = this.reference == null;
-                if ( !getService ) {
+                if (!getService) {
                     final int result = this.reference.compareTo(ref);
-                    if ( result < 0 ) {
+                    if (result < 0) {
                         bundleContext.ungetService(this.reference);
                         this.service = null;
                         getService = true;
                     }
                 }
-                if ( getService ) {
+                if (getService) {
                     this.reference = ref;
                     this.service = bundleContext.getService(this.reference);
-                    if ( this.service == null ) {
+                    if (this.service == null) {
                         this.reference = null;
                     } else {
                         notifyChange();
                     }
                 }
-                if ( hadService && this.service == null ) {
+                if (hadService && this.service == null) {
                     notifyChange();
                 }
             }
@@ -304,7 +325,7 @@ public class ServicesListener {
          */
         private void releaseService(final ServiceReference<?> ref) {
             synchronized (lock) {
-                if ( this.reference != null && this.reference.compareTo(ref) 
== 0) {
+                if (this.reference != null && this.reference.compareTo(ref) == 
0) {
                     this.service = null;
                     bundleContext.ungetService(this.reference);
                     this.reference = null;
@@ -320,9 +341,9 @@ public class ServicesListener {
         public void serviceChanged(final ServiceEvent event) {
             if (event.getType() == ServiceEvent.REGISTERED) {
                 this.retainService(event.getServiceReference());
-            } else if ( event.getType() == ServiceEvent.UNREGISTERING ) {
+            } else if (event.getType() == ServiceEvent.UNREGISTERING) {
                 this.releaseService(event.getServiceReference());
-            } else if ( event.getType() == ServiceEvent.MODIFIED ) {
+            } else if (event.getType() == ServiceEvent.MODIFIED) {
                 notifyChange();
             }
         }
diff --git 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider.java
 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider.java
index 197b762..1b91b38 100644
--- 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider.java
+++ 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider.java
@@ -18,14 +18,14 @@
  */
 package org.apache.sling.extensions.webconsolesecurityprovider.internal;
 
-import java.util.Iterator;
-
 import javax.jcr.Credentials;
 import javax.jcr.LoginException;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
+import java.util.Iterator;
+
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
@@ -49,7 +49,7 @@ public class SlingWebConsoleSecurityProvider extends 
AbstractWebConsoleSecurityP
     private Repository repository;
 
     public SlingWebConsoleSecurityProvider(final Object repository) {
-        this.repository = (Repository)repository;
+        this.repository = (Repository) repository;
     }
 
     // ---------- SCR integration
@@ -83,8 +83,8 @@ public class SlingWebConsoleSecurityProvider extends 
AbstractWebConsoleSecurityP
      */
     @Override
     public Object authenticate(String userName, String password) {
-        final Credentials creds = new SimpleCredentials(userName,
-            (password == null) ? new char[0] : password.toCharArray());
+        final Credentials creds =
+                new SimpleCredentials(userName, (password == null) ? new 
char[0] : password.toCharArray());
         Session session = null;
         try {
             session = repository.login(creds);
@@ -107,28 +107,25 @@ public class SlingWebConsoleSecurityProvider extends 
AbstractWebConsoleSecurityP
                         }
                     }
 
-                    logger.debug(
-                        "authenticate: User {} is denied Web Console access",
-                        userName);
+                    logger.debug("authenticate: User {} is denied Web Console 
access", userName);
                 } else {
-                    logger.error(
-                        "authenticate: Expected user ID {} to refer to a user",
-                        userId);
+                    logger.error("authenticate: Expected user ID {} to refer 
to a user", userId);
                 }
             } else {
                 logger.info(
-                    "authenticate: Jackrabbit Session required to grant access 
to the Web Console for {}; got {}",
-                    userName, session.getClass());
+                        "authenticate: Jackrabbit Session required to grant 
access to the Web Console for {}; got {}",
+                        userName,
+                        session.getClass());
             }
         } catch (final LoginException re) {
             logger.info(
-                "authenticate: User "
-                    + userName
-                    + " failed to authenticate with the repository for Web 
Console access",
-                re);
+                    "authenticate: User "
+                            + userName
+                            + " failed to authenticate with the repository for 
Web Console access",
+                    re);
         } catch (final Exception re) {
-            logger.info("authenticate: Generic problem trying grant User "
-                + userName + " access to the Web Console", re);
+            logger.info(
+                    "authenticate: Generic problem trying grant User " + 
userName + " access to the Web Console", re);
         } finally {
             if (session != null) {
                 session.logout();
diff --git 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider2.java
 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider2.java
index 5322091..30be211 100644
--- 
a/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider2.java
+++ 
b/src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/SlingWebConsoleSecurityProvider2.java
@@ -18,13 +18,13 @@
  */
 package org.apache.sling.extensions.webconsolesecurityprovider.internal;
 
-import java.util.Iterator;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import java.util.Iterator;
+
 import org.apache.felix.webconsole.WebConsoleSecurityProvider3;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
@@ -47,43 +47,40 @@ import org.apache.sling.auth.core.AuthenticationSupport;
  * only registered as a security provider service once such a JCR Repository is
  * available.
  */
-public class SlingWebConsoleSecurityProvider2
-    extends AbstractWebConsoleSecurityProvider
-    implements WebConsoleSecurityProvider3 {
+public class SlingWebConsoleSecurityProvider2 extends 
AbstractWebConsoleSecurityProvider
+        implements WebConsoleSecurityProvider3 {
 
     private final AuthenticationSupport authentiationSupport;
 
     private final Authenticator authenticator;
 
     public SlingWebConsoleSecurityProvider2(final Object support, final Object 
authenticator) {
-        this.authentiationSupport = (AuthenticationSupport)support;
-        this.authenticator = (Authenticator)authenticator;
+        this.authentiationSupport = (AuthenticationSupport) support;
+        this.authenticator = (Authenticator) authenticator;
     }
 
     /**
      * @see 
org.apache.felix.webconsole.WebConsoleSecurityProvider2#authenticate(javax.servlet.http.HttpServletRequest,
 javax.servlet.http.HttpServletResponse)
      */
     @Override
-    public boolean authenticate(final HttpServletRequest request,
-            final HttpServletResponse response) {
-        if ( this.authentiationSupport.handleSecurity(request, response) ) {
+    public boolean authenticate(final HttpServletRequest request, final 
HttpServletResponse response) {
+        if (this.authentiationSupport.handleSecurity(request, response)) {
             // get ResourceResolver (set by AuthenticationSupport)
             Object resolverObject = 
request.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_RESOLVER);
-            final ResourceResolver resolver = (resolverObject instanceof 
ResourceResolver)
-                    ? (ResourceResolver) resolverObject
-                    : null;
-            if ( resolver != null ) {
+            final ResourceResolver resolver =
+                    (resolverObject instanceof ResourceResolver) ? 
(ResourceResolver) resolverObject : null;
+            if (resolver != null) {
                 final Session session = resolver.adaptTo(Session.class);
-                if ( session != null ) {
+                if (session != null) {
                     try {
                         final User u = this.authenticate(session);
-                        if ( u != null ) {
+                        if (u != null) {
                             request.setAttribute(USER_ATTRIBUTE, u);
                             return true;
                         }
                     } catch (final Exception re) {
-                        logger.info("authenticate: Generic problem trying 
grant User "
-                            + " access to the Web Console", re);
+                        logger.info(
+                                "authenticate: Generic problem trying grant 
User " + " access to the Web Console", re);
                     }
                 }
             }
@@ -113,29 +110,26 @@ public class SlingWebConsoleSecurityProvider2
 
                 // check users
                 if (users.contains(userId)) {
-                    return (User)a;
+                    return (User) a;
                 }
 
                 // check groups
                 Iterator<Group> gi = a.memberOf();
                 while (gi.hasNext()) {
                     if (groups.contains(gi.next().getID())) {
-                        return (User)a;
+                        return (User) a;
                     }
                 }
 
-                logger.info(
-                    "authenticate: User {} is denied Web Console access",
-                    userId);
+                logger.info("authenticate: User {} is denied Web Console 
access", userId);
             } else {
-                logger.error(
-                    "authenticate: Expected user ID {} to refer to a user",
-                    userId);
+                logger.error("authenticate: Expected user ID {} to refer to a 
user", userId);
             }
         } else {
             logger.info(
-                "authenticate: Jackrabbit Session required to grant access to 
the Web Console for {}; got {}",
-                userId, session.getClass());
+                    "authenticate: Jackrabbit Session required to grant access 
to the Web Console for {}; got {}",
+                    userId,
+                    session.getClass());
         }
         return null;
     }
diff --git 
a/src/test/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServiceListenerTest.java
 
b/src/test/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServiceListenerTest.java
index b59b190..322d154 100644
--- 
a/src/test/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServiceListenerTest.java
+++ 
b/src/test/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServiceListenerTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 package org.apache.sling.extensions.webconsolesecurityprovider.internal;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -18,10 +36,6 @@ package 
org.apache.sling.extensions.webconsolesecurityprovider.internal;
  * under the License.
  */
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
 import javax.jcr.Repository;
 
 import org.apache.felix.webconsole.WebConsoleSecurityProvider;
@@ -37,67 +51,69 @@ import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.osgi.framework.BundleContext;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 public class ServiceListenerTest {
 
     @Rule
     public OsgiContext context = new OsgiContext();
-    
+
     @Mock
     Repository repository;
-    
+
     @Mock
     AuthenticationSupport authenticationSupport;
-    
+
     @Mock
     Authenticator authenticator;
-    
-    
+
     ServicesListener listener;
-    
+
     @Before
     public void setup() {
         MockitoAnnotations.openMocks(this);
-
     }
-    
+
     @After
     public void shutdown() {
         listener.deactivate();
     }
-    
+
     @Test
     public void testDefaultAuth() {
         listener = new 
ServicesListener(wrapForValidProperties(context.bundleContext()));
         assertNoSecurityProviderRegistered();
-        
-        context.registerService(Repository.class,repository);
+
+        context.registerService(Repository.class, repository);
         listener.notifyChange();
         assertRepositoryRegistered();
 
         context.registerService(AuthenticationSupport.class, 
authenticationSupport);
         listener.notifyChange();
         assertRepositoryRegistered();
-        
+
         context.registerService(Authenticator.class, authenticator);
         listener.notifyChange();
         assertSlingAuthRegistered();
     }
-    
+
     @Test
     public void testWithSlingAuth() {
         try {
             System.setProperty(ServicesListener.WEBCONSOLE_AUTH_TYPE, 
ServicesListener.SLING_AUTH);
             listener = new 
ServicesListener(wrapForValidProperties(context.bundleContext()));
             assertNoSecurityProviderRegistered();
-            
-            context.registerService(Repository.class,repository);
+
+            context.registerService(Repository.class, repository);
             listener.notifyChange();
             assertNoSecurityProviderRegistered();
 
             context.registerService(AuthenticationSupport.class, 
authenticationSupport);
             listener.notifyChange();
             assertNoSecurityProviderRegistered();
-            
+
             context.registerService(Authenticator.class, authenticator);
             listener.notifyChange();
             assertSlingAuthRegistered();
@@ -112,17 +128,17 @@ public class ServiceListenerTest {
             System.setProperty(ServicesListener.WEBCONSOLE_AUTH_TYPE, 
ServicesListener.JCR_AUTH);
             listener = new 
ServicesListener(wrapForValidProperties(context.bundleContext()));
             assertNoSecurityProviderRegistered();
-            
+
             // no matter what is registered, always the auth against the repo 
needs to be there
-            
-            context.registerService(Repository.class,repository);
+
+            context.registerService(Repository.class, repository);
             listener.notifyChange();
             assertRepositoryRegistered();
-    
+
             context.registerService(AuthenticationSupport.class, 
authenticationSupport);
             listener.notifyChange();
             assertRepositoryRegistered();
-            
+
             context.registerService(Authenticator.class, authenticator);
             listener.notifyChange();
             assertRepositoryRegistered();
@@ -191,26 +207,24 @@ public class ServiceListenerTest {
     }
 
     // Helpers
-    
-    private void assertRepositoryRegistered() { 
-        assertTrue("Expected to have the repository 
registered",getSecurityProvider() instanceof SlingWebConsoleSecurityProvider);
+
+    private void assertRepositoryRegistered() {
+        assertTrue(
+                "Expected to have the repository registered",
+                getSecurityProvider() instanceof 
SlingWebConsoleSecurityProvider);
     }
-    
+
     private void assertSlingAuthRegistered() {
-        assertTrue("Expected to have SlingAuth 
registered",getSecurityProvider() instanceof SlingWebConsoleSecurityProvider2); 
+        assertTrue(
+                "Expected to have SlingAuth registered",
+                getSecurityProvider() instanceof 
SlingWebConsoleSecurityProvider2);
     }
-    
-    private void assertNoSecurityProviderRegistered () {
+
+    private void assertNoSecurityProviderRegistered() {
         assertNull(getSecurityProvider());
     }
-    
+
     private WebConsoleSecurityProvider getSecurityProvider() {
         return context.getService(WebConsoleSecurityProvider.class);
     }
-    
-  
-
-    
-    
-    
 }


Reply via email to