You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2021/06/21 11:12:57 UTC

[sling-org-apache-sling-commons-crypto] branch master updated (af5f492 -> 49b28e0)

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

olli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-crypto.git.


    from af5f492  suppress warnings for rule java:S112
     new 94e7105  test GET request with no crypto services available and deactivation with no service tracker
     new abc1646  use dynamic resolution directive with Import-Package header
     new 56f4263  SLING-10499 Provide a salt provider using a secure random number generator
     new 49b28e0  remove workaround for missing java exports (KARAF-7176)

The 4 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:
 bnd.bnd                                            | 25 ++++-----
 .../internal/EncryptWebConsolePlugin.java          |  4 +-
 .../internal/EncryptWebConsolePluginTest.java      | 59 ++++++++++++++++++++++
 3 files changed, 70 insertions(+), 18 deletions(-)
 create mode 100644 src/test/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePluginTest.java

[sling-org-apache-sling-commons-crypto] 02/04: use dynamic resolution directive with Import-Package header

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-crypto.git

commit abc16460b69017213f9f75f649665cb0e394ab5e
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Jun 21 13:10:52 2021 +0200

    use dynamic resolution directive with Import-Package header
---
 bnd.bnd | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
index d80c63f..c053c3a 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -1,20 +1,12 @@
 Bundle-DocURL: https://sling.apache.org/documentation/bundles/commons-crypto.html
 
-DynamicImport-Package:\
-  javax.servlet,\
-  javax.servlet.http,\
-  org.jasypt.encryption.pbe,\
-  org.jasypt.iv,\
-  org.jasypt.registry,\
-  org.jasypt.salt
-
 Import-Package:\
-  javax.servlet;resolution:=optional,\
-  javax.servlet.http;resolution:=optional,\
-  org.jasypt.encryption.pbe;resolution:=optional,\
-  org.jasypt.iv;resolution:=optional,\
-  org.jasypt.registry;resolution:=optional,\
-  org.jasypt.salt;resolution:=optional,\
+  javax.servlet;resolution:=dynamic,\
+  javax.servlet.http;resolution:=dynamic,\
+  org.jasypt.encryption.pbe;resolution:=dynamic,\
+  org.jasypt.iv;resolution:=dynamic,\
+  org.jasypt.registry;resolution:=dynamic,\
+  org.jasypt.salt;resolution:=dynamic,\
   *
 
 Require-Capability:\

[sling-org-apache-sling-commons-crypto] 03/04: SLING-10499 Provide a salt provider using a secure random number generator

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-crypto.git

commit 56f426370358fedd4c25a907b80c60580c7b73cb
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Jun 21 13:12:02 2021 +0200

    SLING-10499 Provide a salt provider using a secure random number generator
    
    fix Require-Capability header
---
 bnd.bnd | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bnd.bnd b/bnd.bnd
index c053c3a..70ab586 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -11,6 +11,7 @@ Import-Package:\
 
 Require-Capability:\
   osgi.service;filter:="(objectClass=org.apache.sling.commons.crypto.PasswordProvider)";effective:=active;resolution:=optional,\
+  osgi.service;filter:="(objectClass=org.apache.sling.commons.crypto.SaltProvider)";effective:=active;resolution:=optional,\
   osgi.service;filter:="(objectClass=org.jasypt.iv.IvGenerator)";effective:=active;resolution:=optional
 
 -noimportjava: true
@@ -19,6 +20,8 @@ Require-Capability:\
   org.apache.sling.bnd.plugin.headers.parameters.remove.Plugin;\
     'Require-Capability'='osgi.service;filter:="(objectClass=org.apache.sling.commons.crypto.PasswordProvider)";effective:=active',\
   org.apache.sling.bnd.plugin.headers.parameters.remove.Plugin;\
+    'Require-Capability'='osgi.service;filter:="(objectClass=org.apache.sling.commons.crypto.SaltProvider)";effective:=active',\
+  org.apache.sling.bnd.plugin.headers.parameters.remove.Plugin;\
     'Require-Capability'='osgi.service;filter:="(objectClass=org.jasypt.iv.IvGenerator)";effective:=active'
 
 -removeheaders:\

[sling-org-apache-sling-commons-crypto] 01/04: test GET request with no crypto services available and deactivation with no service tracker

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-crypto.git

commit 94e710519cc2dbf73b0934f53082fc7ef2ac8064
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Jun 21 12:33:26 2021 +0200

    test GET request with no crypto services available and deactivation with no service tracker
---
 .../internal/EncryptWebConsolePlugin.java          |  4 +-
 .../internal/EncryptWebConsolePluginTest.java      | 59 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePlugin.java b/src/main/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePlugin.java
index ce144e9..bbd6bdc 100644
--- a/src/main/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePlugin.java
+++ b/src/main/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePlugin.java
@@ -67,14 +67,14 @@ public class EncryptWebConsolePlugin extends HttpServlet {
     }
 
     @Activate
-    private void activate(final BundleContext bundleContext) {
+    protected void activate(final BundleContext bundleContext) {
         this.bundleContext = bundleContext;
         tracker = new ServiceTracker<>(bundleContext, CryptoService.class, null);
         tracker.open();
     }
 
     @Deactivate
-    private void deactivate() {
+    protected void deactivate() {
         this.bundleContext = null;
         if (Objects.nonNull(tracker)) {
             tracker.close();
diff --git a/src/test/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePluginTest.java b/src/test/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePluginTest.java
new file mode 100644
index 0000000..12fd57b
--- /dev/null
+++ b/src/test/java/org/apache/sling/commons/crypto/webconsole/internal/EncryptWebConsolePluginTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.commons.crypto.webconsole.internal;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class EncryptWebConsolePluginTest {
+
+    @Test
+    public void testGetWithNoCryptoServicesAvailable() throws ServletException, IOException {
+        final BundleContext bundleContext = mock(BundleContext.class);
+        final HttpServletRequest request = mock(HttpServletRequest.class);
+        final StringWriter stringWriter = new StringWriter();
+        final PrintWriter printWriter = new PrintWriter(stringWriter, true);
+        final HttpServletResponse response = mock(HttpServletResponse.class);
+        when(response.getWriter()).thenReturn(printWriter);
+        final EncryptWebConsolePlugin plugin = new EncryptWebConsolePlugin();
+        plugin.activate(bundleContext);
+        plugin.doGet(request, response);
+        plugin.deactivate();
+        assertThat(stringWriter.toString()).contains("<p>No crypto service available</p>");
+    }
+
+    @Test
+    public void testDeactivateWithNoServiceTracker() {
+        final EncryptWebConsolePlugin plugin = new EncryptWebConsolePlugin();
+        plugin.deactivate();
+    }
+
+}

[sling-org-apache-sling-commons-crypto] 04/04: remove workaround for missing java exports (KARAF-7176)

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

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-crypto.git

commit 49b28e06b46549af8e9200dd4f8ce42d887ec5a0
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Jun 21 13:12:47 2021 +0200

    remove workaround for missing java exports (KARAF-7176)
---
 bnd.bnd | 2 --
 1 file changed, 2 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
index 70ab586..902ac8b 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -14,8 +14,6 @@ Require-Capability:\
   osgi.service;filter:="(objectClass=org.apache.sling.commons.crypto.SaltProvider)";effective:=active;resolution:=optional,\
   osgi.service;filter:="(objectClass=org.jasypt.iv.IvGenerator)";effective:=active;resolution:=optional
 
--noimportjava: true
-
 -plugin:\
   org.apache.sling.bnd.plugin.headers.parameters.remove.Plugin;\
     'Require-Capability'='osgi.service;filter:="(objectClass=org.apache.sling.commons.crypto.PasswordProvider)";effective:=active',\