You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/10 10:43:31 UTC

(camel) branch shiro created (now d44cce7587a)

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

davsclaus pushed a change to branch shiro
in repository https://gitbox.apache.org/repos/asf/camel.git


      at d44cce7587a CAMEL-20491: camel-shiro - Upgrade to 2.0 that is jakarta ee compatible

This branch includes the following new commits:

     new d44cce7587a CAMEL-20491: camel-shiro - Upgrade to 2.0 that is jakarta ee compatible

The 1 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.



(camel) 01/01: CAMEL-20491: camel-shiro - Upgrade to 2.0 that is jakarta ee compatible

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

davsclaus pushed a commit to branch shiro
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d44cce7587ad1b1ab89a305006ba909077645063
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 10 11:43:13 2024 +0100

    CAMEL-20491: camel-shiro - Upgrade to 2.0 that is jakarta ee compatible
---
 components/camel-shiro/pom.xml                            |  8 ++++++--
 .../component/shiro/security/ShiroSecurityHelper.java     |  4 ++--
 .../component/shiro/security/ShiroSecurityPolicy.java     | 15 +++++++--------
 .../component/shiro/security/ShiroSecurityProcessor.java  | 10 +++++-----
 .../shiro/security/ShiroSecurityTokenInjector.java        |  6 +++---
 .../modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc    |  4 ++++
 parent/pom.xml                                            |  2 +-
 7 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/components/camel-shiro/pom.xml b/components/camel-shiro/pom.xml
index 939f005050b..473cbfecc6c 100644
--- a/components/camel-shiro/pom.xml
+++ b/components/camel-shiro/pom.xml
@@ -44,8 +44,12 @@
         </dependency>
         <dependency>
             <groupId>org.apache.shiro</groupId>
-            <artifactId>shiro-core</artifactId>
-            <classifier>jakarta</classifier>
+            <artifactId>shiro-jakarta-ee</artifactId>
+            <version>${shiro-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-crypto-cipher</artifactId>
             <version>${shiro-version}</version>
         </dependency>
 
diff --git a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityHelper.java b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityHelper.java
index 488c50e6d83..51b46fe1000 100644
--- a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityHelper.java
+++ b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityHelper.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.shiro.security;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.shiro.crypto.CipherService;
-import org.apache.shiro.util.ByteSource;
+import org.apache.shiro.crypto.cipher.CipherService;
+import org.apache.shiro.lang.util.ByteSource;
 
 public final class ShiroSecurityHelper {
 
diff --git a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java
index 6ca0b64e9e4..f31a7310fae 100644
--- a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java
+++ b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityPolicy.java
@@ -26,11 +26,10 @@ import org.apache.camel.spi.AuthorizationPolicy;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.Permission;
 import org.apache.shiro.config.Ini;
-import org.apache.shiro.config.IniSecurityManagerFactory;
-import org.apache.shiro.crypto.AesCipherService;
-import org.apache.shiro.crypto.CipherService;
+import org.apache.shiro.crypto.cipher.AesCipherService;
+import org.apache.shiro.crypto.cipher.CipherService;
+import org.apache.shiro.ini.IniSecurityManagerFactory;
 import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.util.Factory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,15 +55,15 @@ public class ShiroSecurityPolicy implements AuthorizationPolicy {
 
     public ShiroSecurityPolicy(String iniResourcePath) {
         this();
-        Factory<SecurityManager> factory = new IniSecurityManagerFactory(iniResourcePath);
-        securityManager = factory.getInstance();
+        Ini ini = new Ini();
+        ini.loadFromPath(iniResourcePath);
+        securityManager = new IniSecurityManagerFactory(ini).getInstance();
         SecurityUtils.setSecurityManager(securityManager);
     }
 
     public ShiroSecurityPolicy(Ini ini) {
         this();
-        Factory<SecurityManager> factory = new IniSecurityManagerFactory(ini);
-        securityManager = factory.getInstance();
+        securityManager = new IniSecurityManagerFactory(ini).getInstance();
         SecurityUtils.setSecurityManager(securityManager);
     }
 
diff --git a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityProcessor.java b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityProcessor.java
index e32584d7546..05002aefc69 100644
--- a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityProcessor.java
+++ b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityProcessor.java
@@ -31,9 +31,10 @@ import org.apache.shiro.authc.LockedAccountException;
 import org.apache.shiro.authc.UnknownAccountException;
 import org.apache.shiro.authc.UsernamePasswordToken;
 import org.apache.shiro.authz.Permission;
-import org.apache.shiro.codec.Base64;
+import org.apache.shiro.crypto.cipher.ByteSourceBroker;
+import org.apache.shiro.lang.codec.Base64;
+import org.apache.shiro.lang.util.ByteSource;
 import org.apache.shiro.subject.Subject;
-import org.apache.shiro.util.ByteSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -113,9 +114,8 @@ public class ShiroSecurityProcessor extends DelegateAsyncProcessor {
                     exchange);
         }
 
-        ByteSource decryptedToken = policy.getCipherService().decrypt(encryptedToken.getBytes(), policy.getPassPhrase());
-
-        ShiroSecurityToken securityToken = ShiroSecurityHelper.deserialize(decryptedToken.getBytes());
+        ByteSourceBroker decryptedToken = policy.getCipherService().decrypt(encryptedToken.getBytes(), policy.getPassPhrase());
+        ShiroSecurityToken securityToken = ShiroSecurityHelper.deserialize(decryptedToken.getClonedBytes());
 
         Subject currentUser = SecurityUtils.getSubject();
 
diff --git a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityTokenInjector.java b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityTokenInjector.java
index 353c5cecc8b..6fbd4cfe565 100644
--- a/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityTokenInjector.java
+++ b/components/camel-shiro/src/main/java/org/apache/camel/component/shiro/security/ShiroSecurityTokenInjector.java
@@ -18,9 +18,9 @@ package org.apache.camel.component.shiro.security;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.shiro.crypto.AesCipherService;
-import org.apache.shiro.crypto.CipherService;
-import org.apache.shiro.util.ByteSource;
+import org.apache.shiro.crypto.cipher.AesCipherService;
+import org.apache.shiro.crypto.cipher.CipherService;
+import org.apache.shiro.lang.util.ByteSource;
 
 public class ShiroSecurityTokenInjector implements Processor {
     private byte[] passPhrase;
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
index 98e2921388b..338038f69f1 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
@@ -222,6 +222,10 @@ calls the `/api-doc` endpoint.
 
 Added a Cookie Handler allowing the addition, retrieval and expiry of Cookies.
 
+=== camel-shiro
+
+Upgraded Apache Shiro from 1.13 to 2.0.
+
 === camel-twilio
 
 Upgraded to Twilio 10.1.0 which removed `call-feedback` and `call-feedback-summary` from the available APIs,
diff --git a/parent/pom.xml b/parent/pom.xml
index 401d4e5b864..2996276bda7 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -414,7 +414,7 @@
         <rxjava2-version>2.2.21</rxjava2-version>
         <saxon-version>12.4</saxon-version>
         <scala-datasonnet-version>2.13.13</scala-datasonnet-version>
-        <shiro-version>1.13.0</shiro-version>
+        <shiro-version>2.0.0</shiro-version>
         <slack-api-model-version>1.38.1</slack-api-model-version>
         <slf4j-api-version>2.0.12</slf4j-api-version>
         <slf4j-version>2.0.12</slf4j-version>