Skip to content

Commit

Permalink
CAMEL-20491: camel-shiro - Upgrade to 2.0 that is jakarta ee compatib…
Browse files Browse the repository at this point in the history
…le (#13430)
  • Loading branch information
davsclaus committed Mar 10, 2024
1 parent 0b65390 commit 198a8b1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
8 changes: 6 additions & 2 deletions components/camel-shiro/pom.xml
Expand Up @@ -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>

Expand Down
Expand Up @@ -19,8 +19,8 @@
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 {

Expand Down
Expand Up @@ -26,11 +26,10 @@
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;

Expand All @@ -56,15 +55,15 @@ public ShiroSecurityPolicy() {

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);
}

Expand Down
Expand Up @@ -31,9 +31,10 @@
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;

Expand Down Expand Up @@ -113,9 +114,8 @@ private void applySecurityPolicy(Exchange exchange) throws Exception {
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();

Expand Down
Expand Up @@ -18,9 +18,9 @@

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;
Expand Down
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion parent/pom.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 198a8b1

Please sign in to comment.