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

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-core.git


The following commit(s) were added to refs/heads/master by this push:
     new f50b1f9  SLING-9632 : Migrate from PropertiesUtil to Converters
f50b1f9 is described below

commit f50b1f9828c9688e3d4ae4ea2cf67196ef372154
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed Aug 5 13:58:14 2020 +0200

    SLING-9632 : Migrate from PropertiesUtil to Converters
---
 pom.xml                                                      | 12 +++++++++---
 .../sling/auth/core/impl/AuthenticationHandlerHolder.java    |  8 ++++----
 .../org/apache/sling/auth/core/impl/PathBasedHolder.java     | 12 +++++-------
 .../org/apache/sling/auth/core/impl/SlingAuthenticator.java  |  4 ++--
 .../auth/core/impl/SlingAuthenticatorServiceListener.java    |  6 +++---
 5 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5dd5b1b..d53b354 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,9 +75,15 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.osgi</artifactId>
-            <version>2.2.0</version>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.util.function</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.util.converter</artifactId>
+            <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git 
a/src/main/java/org/apache/sling/auth/core/impl/AuthenticationHandlerHolder.java
 
b/src/main/java/org/apache/sling/auth/core/impl/AuthenticationHandlerHolder.java
index 066362b..a36ccb6 100644
--- 
a/src/main/java/org/apache/sling/auth/core/impl/AuthenticationHandlerHolder.java
+++ 
b/src/main/java/org/apache/sling/auth/core/impl/AuthenticationHandlerHolder.java
@@ -28,8 +28,8 @@ import org.apache.sling.auth.core.AuthUtil;
 import org.apache.sling.auth.core.spi.AuthenticationFeedbackHandler;
 import org.apache.sling.auth.core.spi.AuthenticationHandler;
 import org.apache.sling.auth.core.spi.AuthenticationInfo;
-import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.osgi.framework.ServiceReference;
+import org.osgi.util.converter.Converters;
 
 /**
  * The <code>AuthenticationHandlerHolder</code> class represents an
@@ -53,11 +53,11 @@ final class AuthenticationHandlerHolder extends
             final ServiceReference serviceReference) {
         super(fullPath, serviceReference);
 
-        final String browserOnly = 
PropertiesUtil.toString(serviceReference.getProperty(AuthConstants.AUTH_HANDLER_BROWSER_ONLY),
 null);
+        final String browserOnly = 
Converters.standardConverter().convert(serviceReference.getProperty(AuthConstants.AUTH_HANDLER_BROWSER_ONLY)).to(String.class);
 
         // assign the fields
         this.handler = handler;
-        this.authType = 
PropertiesUtil.toString(serviceReference.getProperty(TYPE_PROPERTY), null);
+        this.authType = 
Converters.standardConverter().convert(serviceReference.getProperty(TYPE_PROPERTY)).to(String.class);
         this.browserOnlyRequestCredentials = 
"true".equalsIgnoreCase(browserOnly)
             || "yes".equalsIgnoreCase(browserOnly);
     }
@@ -151,4 +151,4 @@ final class AuthenticationHandlerHolder extends
         final String requestLogin = AuthUtil.getAttributeOrParameter(request, 
REQUEST_LOGIN_PARAMETER, null);
         return requestLogin == null || authType.equals(requestLogin);
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/auth/core/impl/PathBasedHolder.java 
b/src/main/java/org/apache/sling/auth/core/impl/PathBasedHolder.java
index 2fc09eb..26d0379 100644
--- a/src/main/java/org/apache/sling/auth/core/impl/PathBasedHolder.java
+++ b/src/main/java/org/apache/sling/auth/core/impl/PathBasedHolder.java
@@ -18,9 +18,9 @@
  */
 package org.apache.sling.auth.core.impl;
 
-import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.util.converter.Converters;
 
 /**
  * The <code>PathBasedHolder</code> provides the basic abstraction for managing
@@ -135,15 +135,13 @@ public abstract class PathBasedHolder implements 
Comparable<PathBasedHolder> {
             return "Apache Sling Request Authenticator";
         }
 
-        final String descr = PropertiesUtil.toString(
-            serviceReference.getProperty(Constants.SERVICE_DESCRIPTION), null);
+        final String descr = 
Converters.standardConverter().convert(serviceReference.getProperty(Constants.SERVICE_DESCRIPTION)).to(String.class);
         if (descr != null) {
             return descr;
         }
 
-        return "Service "
-            + PropertiesUtil.toString(
-                serviceReference.getProperty(Constants.SERVICE_ID), "unknown");
+        final String id = 
Converters.standardConverter().convert(serviceReference.getProperty(Constants.SERVICE_ID)).defaultValue("unknown").to(String.class);
+        return "Service ".concat(id);
     }
 
     /**
@@ -220,4 +218,4 @@ public abstract class PathBasedHolder implements 
Comparable<PathBasedHolder> {
 
         return false;
     }
-}
\ No newline at end of file
+}
diff --git 
a/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java 
b/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
index 0ee22b3..4a25f19 100644
--- a/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
+++ b/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
@@ -59,7 +59,6 @@ import org.apache.sling.auth.core.spi.AuthenticationHandler;
 import org.apache.sling.auth.core.spi.AuthenticationInfo;
 import org.apache.sling.auth.core.spi.AuthenticationInfoPostProcessor;
 import org.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler;
-import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -84,6 +83,7 @@ import org.osgi.service.metatype.annotations.AttributeType;
 import org.osgi.service.metatype.annotations.Designate;
 import org.osgi.service.metatype.annotations.ObjectClassDefinition;
 import org.osgi.service.metatype.annotations.Option;
+import org.osgi.util.converter.Converters;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -1722,7 +1722,7 @@ public class SlingAuthenticator implements Authenticator,
         }
 
         private void bindAuthHandler(final Object handler, final 
ServiceReference ref) {
-            final String paths[] = 
PropertiesUtil.toStringArray(ref.getProperty(AuthenticationHandler.PATH_PROPERTY));
+            final String[] paths = 
Converters.standardConverter().convert(ref.getProperty(AuthenticationHandler.PATH_PROPERTY)).to(String[].class);
             if (paths != null && paths.length > 0) {
 
                 // generate the holders
diff --git 
a/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticatorServiceListener.java
 
b/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticatorServiceListener.java
index 45a0bba..f1c0c1a 100644
--- 
a/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticatorServiceListener.java
+++ 
b/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticatorServiceListener.java
@@ -25,13 +25,13 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.sling.auth.core.AuthConstants;
-import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.osgi.framework.AllServiceListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceReference;
+import org.osgi.util.converter.Converters;
 
 public class SlingAuthenticatorServiceListener implements AllServiceListener {
 
@@ -122,7 +122,7 @@ public class SlingAuthenticatorServiceListener implements 
AllServiceListener {
      * @param ref The service reference
      */
     private void addService(final ServiceReference<?> ref) {
-        final String[] authReqPaths = 
PropertiesUtil.toStringArray(ref.getProperty(AuthConstants.AUTH_REQUIREMENTS));
+        final String[] authReqPaths = 
Converters.standardConverter().convert(ref.getProperty(AuthConstants.AUTH_REQUIREMENTS)).to(String[].class);
         if ( authReqPaths != null ) {
             final Set<String> paths = buildPathsSet(authReqPaths);
 
@@ -146,7 +146,7 @@ public class SlingAuthenticatorServiceListener implements 
AllServiceListener {
      * @param ref The service reference
      */
     private void modifiedService(final ServiceReference<?> ref) {
-        final String[] authReqPaths = 
PropertiesUtil.toStringArray(ref.getProperty(AuthConstants.AUTH_REQUIREMENTS));
+        final String[] authReqPaths = 
Converters.standardConverter().convert(ref.getProperty(AuthConstants.AUTH_REQUIREMENTS)).to(String[].class);
         if ( authReqPaths != null ) {
             final Set<String> oldPaths = 
regProps.get(ref.getProperty(Constants.SERVICE_ID));
             if ( oldPaths == null ) {

Reply via email to