You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lp...@apache.org on 2026/06/17 12:56:39 UTC
(shiro) 08/08: chore: additional and supporting updates
This is an automated email from the ASF dual-hosted git repository.
lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git
commit b3811723e233439249d0e11d5635d62c140f5ce0
Author: lprimak <le...@flowlogix.com>
AuthorDate: Tue Jun 16 15:33:40 2026 -0500
chore: additional and supporting updates
---
.jenkins.groovy | 9 +-
3.X-NOTES | 27 --
.../session/mgt/eis/RandomSessionIdGenerator.java | 72 ------
.../org/apache/shiro/util/JavaEnvironment.java | 181 --------------
integration-tests/guice/pom.xml | 6 +-
.../org/apache/shiro/lang/io/XmlSerializer.java | 83 -------
samples/spring-boot-3-web/README.md | 18 --
.../shiro/samples/AccountInfoController.java | 52 ----
.../org/apache/shiro/samples/HelloController.java | 61 -----
.../org/apache/shiro/samples/LoginController.java | 34 ---
.../shiro/samples/RestrictedErrorController.java | 57 -----
.../main/java/org/apache/shiro/samples/WebApp.java | 98 --------
.../src/main/resources/META-INF/NOTICE | 15 --
.../src/main/resources/application.properties | 26 --
.../src/main/resources/log4j2.properties | 28 ---
.../src/main/resources/templates/account-info.html | 39 ---
.../src/main/resources/templates/error.html | 39 ---
.../main/resources/templates/fragments/head.html | 58 -----
.../src/main/resources/templates/hello.html | 45 ----
.../src/main/resources/templates/login.html | 93 -------
.../web-jakarta/src/main/resources/META-INF/NOTICE | 15 --
samples/web-jakarta/src/main/resources/log4j2.xml | 71 ------
.../web-jakarta/src/main/webapp/WEB-INF/shiro.ini | 62 -----
.../web-jakarta/src/main/webapp/WEB-INF/web.xml | 43 ----
.../web-jakarta/src/main/webapp/account/index.jsp | 36 ---
samples/web-jakarta/src/main/webapp/home.jsp | 69 ------
samples/web-jakarta/src/main/webapp/include.jsp | 22 --
samples/web-jakarta/src/main/webapp/index.jsp | 21 --
samples/web-jakarta/src/main/webapp/login.jsp | 110 ---------
samples/web-jakarta/src/main/webapp/logout.jsp | 34 ---
samples/web-jakarta/src/main/webapp/style.css | 47 ----
.../web/jakarta/JakartaAbstractContainerIT.java | 73 ------
samples/web-jakarta/src/test/resources/log4j2.xml | 52 ----
.../shiro/test/WebAppContainerIntegrationIT.java | 59 -----
.../org/apache/shiro/cache/ehcache/EhCache.java | 247 -------------------
.../apache/shiro/cache/ehcache/EhCacheManager.java | 273 ---------------------
.../apache/shiro/cache/ehcache/package-info.java | 23 --
support/ehcache/src/main/resources/META-INF/NOTICE | 15 --
.../org/apache/shiro/cache/ehcache/ehcache.xml | 106 --------
.../shiro/cache/ehcache/EhCacheManagerTest.java | 203 ---------------
support/ehcache/src/test/resources/log4j2-test.xml | 62 -----
.../hazelcast/cache/HazelcastCacheManager.java | 246 -------------------
.../apache/shiro/hazelcast/cache/package-info.java | 23 --
.../hazelcast/src/main/resources/META-INF/NOTICE | 15 --
.../cache/HazelcastCacheManagerTest.groovy | 156 ------------
.../hazelcast/src/test/resources/log4j2-test.xml | 62 -----
.../config/AbstractShiroBeanConfiguration.java | 42 ----
.../remoting/SecureRemoteInvocationExecutor.java | 124 ----------
.../remoting/SecureRemoteInvocationFactory.java | 144 -----------
.../shiro/spring/web/ShiroUrlPathHelper.java | 42 ----
.../web/config/ShiroRequestMappingConfig.java | 33 ---
.../shiro/spring/web/ShiroUrlPathHelperTest.groovy | 46 ----
.../SecureRemoteInvocationFactoryTest.java | 119 ---------
.../AbstractAuthorizationAnnotationTest.java | 2 +-
.../AuthorizationAttributeSourceAdvisorTest.java | 2 +-
.../DapcAuthorizationAnnotationTest.java | 2 +-
.../SchemaAuthorizationAnnotationTest.java | 2 +-
.../spring/web/ShiroFilterFactoryBeanTest.java | 13 +-
...> ShiroWebConfigurationSameSiteStrictTest.java} | 7 +-
...oWebConfigurationSameSiteStrictTest.properties} | 0
60 files changed, 21 insertions(+), 3743 deletions(-)
diff --git a/.jenkins.groovy b/.jenkins.groovy
index dc680ebfd..60619c1da 100644
--- a/.jenkins.groovy
+++ b/.jenkins.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-def deployableBranch = env.BRANCH_NAME ==~ /(1.13.x|2.x|3.x|4.x|main)/
+def deployableBranch = env.BRANCH_NAME ==~ /(main|4.x)/
def latestSupportedJDK = 'jdk_25_latest'
def builtinVersion = '999-SNAPSHOT'
def nextVersion
@@ -107,10 +107,9 @@ pipeline {
def parts = latestRelease.tokenize('.')
def nextPatch = parts[2].toInteger() + 1
nextVersion = "${parts[0]}.${parts[1]}.${nextPatch}-SNAPSHOT"
- if (env.BRANCH_NAME == '2.x') {
- nextVersion = '2.0.0-SNAPSHOT'
- }
- if (env.BRANCH_NAME == '3.x') {
+ if (env.BRANCH_NAME == '4.x') {
+ nextVersion = '4.0.0-SNAPSHOT'
+ } else if (parts[0].toInteger() < 3) {
nextVersion = '3.0.0-SNAPSHOT'
}
diff --git a/3.X-NOTES b/3.X-NOTES
deleted file mode 100644
index 2d0da900f..000000000
--- a/3.X-NOTES
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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.
-
-This is not an official release notes document. It exists for Shiro developers
-to jot down their notes while working in the source code. These notes will be
-combined with Jira’s auto-generated release notes during a release for the
-total set.
-
-###########################################################
-# 3.X NOTES
-###########################################################
-
-- Module Support/Quartz removed.
diff --git a/core/src/main/java/org/apache/shiro/session/mgt/eis/RandomSessionIdGenerator.java b/core/src/main/java/org/apache/shiro/session/mgt/eis/RandomSessionIdGenerator.java
deleted file mode 100644
index 0689b8ab2..000000000
--- a/core/src/main/java/org/apache/shiro/session/mgt/eis/RandomSessionIdGenerator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.shiro.session.mgt.eis;
-
-import org.apache.shiro.session.Session;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.util.Random;
-
-/**
- * Generates session IDs by using a {@link Random} instance to generate random IDs. The default {@code Random}
- * implementation is a {@link java.security.SecureRandom SecureRandom} with the {@code SHA1PRNG} algorithm.
- *
- * @since 1.0
- * @deprecated since 2.2.1. Use {@link JavaUuidSessionIdGenerator} instead, as this class is no longer considered
- * secure by modern standards.
- */
-@Deprecated(forRemoval = true, since = "2.2.1")
-public class RandomSessionIdGenerator implements SessionIdGenerator {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(RandomSessionIdGenerator.class);
-
- private static final String RANDOM_NUM_GENERATOR_ALGORITHM_NAME = "SHA1PRNG";
- private Random random;
-
- public RandomSessionIdGenerator() {
- try {
- this.random = java.security.SecureRandom.getInstance(RANDOM_NUM_GENERATOR_ALGORITHM_NAME);
- } catch (java.security.NoSuchAlgorithmException e) {
- LOGGER.debug("The SecureRandom SHA1PRNG algorithm is not available on the current platform. Using the "
- + "platform's default SecureRandom algorithm.", e);
- this.random = new java.security.SecureRandom();
- }
- }
-
- public Random getRandom() {
- return this.random;
- }
-
- public void setRandom(Random random) {
- this.random = random;
- }
-
- /**
- * Returns the String value of the configured {@link Random}'s {@link Random#nextLong() nextLong()} invocation.
- *
- * @param session the {@link Session} instance to which the ID will be applied.
- * @return the String value of the configured {@link Random}'s {@link Random#nextLong()} invocation.
- */
- public Serializable generateId(Session session) {
- //ignore the argument - just call the Random:
- return Long.toString(getRandom().nextLong());
- }
-}
diff --git a/core/src/main/java/org/apache/shiro/util/JavaEnvironment.java b/core/src/main/java/org/apache/shiro/util/JavaEnvironment.java
deleted file mode 100644
index 1735a5b0e..000000000
--- a/core/src/main/java/org/apache/shiro/util/JavaEnvironment.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.shiro.util;
-
-/**
- * Internal helper class used to find the Java/JDK version
- * that Shiro is operating within, to allow for automatically
- * adapting to the present platform's capabilities.
- *
- * <p>Note that Shiro does not support 1.2 or earlier JVMs - only 1.3 and later.
- *
- * <p><em>This class was borrowed and heavily based upon a nearly identical version found in
- * the <a href="http://www.springframework.org/">Spring Framework</a>, with minor modifications.
- * The original author names and copyright (Apache 2.0) has been left in place. A special
- * thanks to Rod Johnson, Juergen Hoeller, and Rick Evans for making this available.</em>
- *
- * @since 0.2
- * @deprecated This class is no longer used in Shiro and will be removed in the next major version.
- */
-@Deprecated
-public abstract class JavaEnvironment {
-
- /**
- * Constant identifying the 1.3.x JVM (JDK 1.3).
- */
- public static final int JAVA_13 = 0;
-
- /**
- * Constant identifying the 1.4.x JVM (J2SE 1.4).
- */
- public static final int JAVA_14 = 1;
-
- /**
- * Constant identifying the 1.5 JVM (Java 5).
- */
- public static final int JAVA_15 = 2;
-
- /**
- * Constant identifying the 1.6 JVM (Java 6).
- */
- public static final int JAVA_16 = 3;
-
- /**
- * Constant identifying the 1.7 JVM.
- */
- public static final int JAVA_17 = 4;
-
- /**
- * Constant identifying the 1.8 JVM.
- */
- public static final int JAVA_18 = 5;
-
- /**
- * The virtual machine version, i.e. <code>System.getProperty("java.version");</code>.
- */
- private static final String VERSION;
-
- /**
- * The virtual machine <em>major</em> version. For example, with a <code>version</code> of
- * <code>1.5.6_10</code>, this would be <code>1.5</code>
- */
- private static final int MAJOR_VERSION;
-
- /**
- * Static code initialization block that sets the
- * <code>version</code> and <code>majorVersion</code> Class constants
- * upon initialization.
- */
- static {
- VERSION = System.getProperty("java.version");
- // version String should look like "1.4.2_10"
-
-// NOTE: JDK 1.9 will be versioned differently '9' and/or 9.x.x
-// https://blogs.oracle.com/java-platform-group/entry/a_new_jdk_9_version
-
- if (VERSION.contains("1.8.")) {
- MAJOR_VERSION = JAVA_18;
- } else if (VERSION.contains("1.7.")) {
- MAJOR_VERSION = JAVA_17;
- } else if (VERSION.contains("1.6.")) {
- MAJOR_VERSION = JAVA_16;
- } else if (VERSION.contains("1.5.")) {
- MAJOR_VERSION = JAVA_15;
- } else if (VERSION.contains("1.4.")) {
- MAJOR_VERSION = JAVA_14;
- } else {
- // else leave 1.3 as default (it's either 1.3 or unknown)
- MAJOR_VERSION = JAVA_13;
- }
- }
-
-
- /**
- * Return the full Java version string, as returned by
- * <code>System.getProperty("java.version")</code>.
- *
- * @return the full Java version string
- * @see System#getProperty(String)
- */
- public static String getVersion() {
- return VERSION;
- }
-
- /**
- * Get the major version code. This means we can do things like
- * <code>if (getMajorVersion() < JAVA_14)</code>.
- *
- * @return a code comparable to the JAVA_XX codes in this class
- * @see #JAVA_13
- * @see #JAVA_14
- * @see #JAVA_15
- * @see #JAVA_16
- * @see #JAVA_17
- * @see #JAVA_18
- */
- public static int getMajorVersion() {
- return MAJOR_VERSION;
- }
-
- /**
- * Convenience method to determine if the current JVM is at least Java 1.4.
- *
- * @return <code>true</code> if the current JVM is at least Java 1.4
- * @see #getMajorVersion()
- * @see #JAVA_14
- * @see #JAVA_15
- * @see #JAVA_16
- * @see #JAVA_17
- * @see #JAVA_18
- */
- public static boolean isAtLeastVersion14() {
- return getMajorVersion() >= JAVA_14;
- }
-
- /**
- * Convenience method to determine if the current JVM is at least
- * Java 1.5 (Java 5).
- *
- * @return <code>true</code> if the current JVM is at least Java 1.5
- * @see #getMajorVersion()
- * @see #JAVA_15
- * @see #JAVA_16
- * @see #JAVA_17
- * @see #JAVA_18
- */
- public static boolean isAtLeastVersion15() {
- return getMajorVersion() >= JAVA_15;
- }
-
- /**
- * Convenience method to determine if the current JVM is at least
- * Java 1.6 (Java 6).
- *
- * @return <code>true</code> if the current JVM is at least Java 1.6
- * @see #getMajorVersion()
- * @see #JAVA_15
- * @see #JAVA_16
- * @see #JAVA_17
- * @see #JAVA_18
- * @since 1.2
- */
- public static boolean isAtLeastVersion16() {
- return getMajorVersion() >= JAVA_16;
- }
-}
diff --git a/integration-tests/guice/pom.xml b/integration-tests/guice/pom.xml
index dd3670ea4..d93747057 100644
--- a/integration-tests/guice/pom.xml
+++ b/integration-tests/guice/pom.xml
@@ -27,9 +27,9 @@
<version>999-SNAPSHOT</version>
</parent>
- <artifactId>shiro-its-guice</artifactId>
- <name>Apache Shiro :: ITs :: Guice</name>
- <packaging>war</packaging>
+ <artifactId>shiro-its-guice</artifactId>
+ <name>Apache Shiro :: ITs :: Guice</name>
+ <packaging>war</packaging>
<properties>
<groups>none()</groups>
diff --git a/lang/src/main/java/org/apache/shiro/lang/io/XmlSerializer.java b/lang/src/main/java/org/apache/shiro/lang/io/XmlSerializer.java
deleted file mode 100644
index f577c9c02..000000000
--- a/lang/src/main/java/org/apache/shiro/lang/io/XmlSerializer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.shiro.lang.io;
-
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-/**
- * Serializer implementation that uses the JavaBeans
- * {@link java.beans.XMLEncoder XMLEncoder} and {@link java.beans.XMLDecoder XMLDecoder} to serialize
- * and deserialize, respectively.
- * <p/>
- * <b>NOTE:</b> The JavaBeans XMLEncoder/XMLDecoder only successfully encode/decode objects when they are
- * JavaBeans compatible!
- *
- * @since 0.9
- * @deprecated This class should not be used directly because of insecure XMLEncoder/XMLDecoder usage.
- */
-@Deprecated(forRemoval = true)
-public class XmlSerializer implements Serializer {
-
- /**
- * Serializes the specified <code>source</code> into a byte[] array by using the
- * {@link java.beans.XMLEncoder XMLEncoder} to encode the object out to a
- * {@link java.io.ByteArrayOutputStream ByteArrayOutputStream}, where the resulting byte[] array is returned.
- *
- * @param source the Object to convert into a byte[] array.
- * @return the byte[] array representation of the XML encoded output.
- */
- public byte[] serialize(Object source) {
- if (source == null) {
- String msg = "argument cannot be null.";
- throw new IllegalArgumentException(msg);
- }
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(bos));
- encoder.writeObject(source);
- encoder.close();
-
- return bos.toByteArray();
- }
-
- /**
- * Deserializes the specified <code>serialized</code> source back into an Object by using a
- * {@link java.io.ByteArrayInputStream ByteArrayInputStream} to wrap the argument and then decode this
- * stream via an {@link java.beans.XMLDecoder XMLDecoder}, where the
- * {@link java.beans.XMLDecoder#readObject() readObject} call results in the original Object to return.
- *
- * @param serialized the byte[] array representation of the XML encoded output.
- * @return the original source Object in reconstituted form.
- */
- public Object deserialize(byte[] serialized) {
- if (serialized == null) {
- throw new IllegalArgumentException("Argument cannot be null.");
- }
- ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
- XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(bis));
- Object o = decoder.readObject();
- decoder.close();
- return o;
- }
-}
diff --git a/samples/spring-boot-3-web/README.md b/samples/spring-boot-3-web/README.md
deleted file mode 100644
index 7317e6447..000000000
--- a/samples/spring-boot-3-web/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-Apache Shiro + Spring Boot 3 Web Example
-========================================
-
-A Spring Boot example web application that show the usage of a user login, checking permissions, and annotation
-protected methods.
-
-Run the Example
----------------
-
-```bash
-mvn spring-boot:run
-```
-
-Browse to `http://localhost:8080/`
-
-Or deploy to Heroku:
-
-[](https://heroku.com/deploy?template=https://github.com/bdemers/heroku-examples-runner&env\[ARTIFACT_ID\]=samples-spring-boot-web&&env\[RUNNER\]=spring-boot)
diff --git a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/AccountInfoController.java b/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/AccountInfoController.java
deleted file mode 100644
index 5c75380ec..000000000
--- a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/AccountInfoController.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.shiro.samples;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authz.annotation.RequiresRoles;
-import org.apache.shiro.subject.PrincipalCollection;
-import org.apache.shiro.subject.Subject;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-
-@Controller
-public class AccountInfoController {
-
- @RequiresRoles("admin")
- @RequestMapping("/account-info")
- public String home(Model model) {
-
- String name = "World";
-
- Subject subject = SecurityUtils.getSubject();
-
- PrincipalCollection principalCollection = subject.getPrincipals();
-
- if (principalCollection != null && !principalCollection.isEmpty()) {
- name = principalCollection.getPrimaryPrincipal().toString();
- }
-
- model.addAttribute("name", name);
-
- return "account-info";
- }
-
-}
diff --git a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/HelloController.java b/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/HelloController.java
deleted file mode 100644
index 2861c2406..000000000
--- a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/HelloController.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.shiro.samples;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.subject.PrincipalCollection;
-import org.apache.shiro.subject.Subject;
-import org.apache.shiro.util.CollectionUtils;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import jakarta.servlet.http.HttpServletRequest;
-
-import java.util.Collection;
-import java.util.Map;
-
-@Controller
-public class HelloController {
-
- @SuppressWarnings("Duplicates")
- @RequestMapping("/")
- public String home(HttpServletRequest request, Model model) {
-
- String name = "World";
-
- Subject subject = SecurityUtils.getSubject();
-
- PrincipalCollection principalCollection = subject.getPrincipals();
-
- if (principalCollection != null && !principalCollection.isEmpty()) {
- Collection<Map> principalMaps = subject.getPrincipals().byType(Map.class);
- if (CollectionUtils.isEmpty(principalMaps)) {
- name = subject.getPrincipal().toString();
- } else {
- name = (String) principalMaps.iterator().next().get("username");
- }
- }
-
- model.addAttribute("name", name);
-
- return "hello";
- }
-
-}
diff --git a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/LoginController.java b/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/LoginController.java
deleted file mode 100644
index f90fe337a..000000000
--- a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/LoginController.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.shiro.samples;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-
-@Controller
-public class LoginController {
-
- @RequestMapping("/login.html")
- public String loginTemplate() {
-
- return "login";
- }
-
-}
diff --git a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/RestrictedErrorController.java b/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/RestrictedErrorController.java
deleted file mode 100644
index 35a46721f..000000000
--- a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/RestrictedErrorController.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.shiro.samples;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.servlet.error.ErrorAttributes;
-import org.springframework.boot.web.servlet.error.ErrorController;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.context.request.ServletWebRequest;
-
-import jakarta.servlet.http.HttpServletRequest;
-
-import java.util.Map;
-import static org.springframework.boot.web.error.ErrorAttributeOptions.Include.MESSAGE;
-import static org.springframework.boot.web.error.ErrorAttributeOptions.Include.STATUS;
-import static org.springframework.boot.web.error.ErrorAttributeOptions.of;
-
-/**
- *
- */
-@Controller
-public class RestrictedErrorController implements ErrorController {
- private static final String ERROR_PATH = "/error";
-
- @Autowired
- private ErrorAttributes errorAttributes;
-
- public String getErrorPath() {
- return ERROR_PATH;
- }
-
- @RequestMapping(ERROR_PATH)
- String error(HttpServletRequest request, Model model) {
- Map<String, Object> errorMap = errorAttributes.getErrorAttributes(
- new ServletWebRequest(request), of(STATUS, MESSAGE));
- model.addAttribute("errors", errorMap);
- return "error";
- }
-}
diff --git a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/WebApp.java b/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/WebApp.java
deleted file mode 100644
index c347ed875..000000000
--- a/samples/spring-boot-3-web/src/main/java/org/apache/shiro/samples/WebApp.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.shiro.samples;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authz.AuthorizationException;
-import org.apache.shiro.realm.Realm;
-import org.apache.shiro.realm.text.TextConfigurationRealm;
-import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
-import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
-import org.apache.shiro.subject.Subject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpStatus;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * NOPMD
- */
-@Configuration
-@ControllerAdvice
-@SpringBootApplication
-public class WebApp {
-
- private static Logger log = LoggerFactory.getLogger(WebApp.class);
-
- public static void main(String[] args) {
-
- SpringApplication.run(WebApp.class, args);
- }
-
- @ExceptionHandler(AuthorizationException.class)
- @ResponseStatus(HttpStatus.FORBIDDEN)
- public String handleException(AuthorizationException e, Model model) {
-
- // you could return a 404 here instead (this is how github handles 403, so the user does NOT know there is a
- // resource at that location)
- log.debug("AuthorizationException was thrown", e);
-
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("status", HttpStatus.FORBIDDEN.value());
- map.put("message", "No message available");
- model.addAttribute("errors", map);
-
- return "error";
- }
-
- @Bean
- public Realm realm() {
- TextConfigurationRealm realm = new TextConfigurationRealm();
- realm.setUserDefinitions("joe.coder=password,user\n" + "jill.coder=password,admin");
-
- realm.setRoleDefinitions("admin=read,write\n" + "user=read");
- realm.setCachingEnabled(true);
- return realm;
- }
-
- @Bean
- public ShiroFilterChainDefinition shiroFilterChainDefinition() {
- DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
- // need to accept POSTs from the login form
- chainDefinition.addPathDefinition("/login.html", "authc");
- chainDefinition.addPathDefinition("/logout", "logout");
- return chainDefinition;
- }
-
- @ModelAttribute(name = "subject")
- public Subject subject() {
- return SecurityUtils.getSubject();
- }
-}
diff --git a/samples/spring-boot-3-web/src/main/resources/META-INF/NOTICE b/samples/spring-boot-3-web/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index bdc909e8c..000000000
--- a/samples/spring-boot-3-web/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,15 +0,0 @@
-Apache Shiro
-Copyright 2008-2020 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-The implementation for org.apache.shiro.util.SoftHashMap is based
-on initial ideas from Dr. Heinz Kabutz's publicly posted version
-available at http://www.javaspecialists.eu/archive/Issue015.html,
-with continued modifications.
-
-Certain parts (StringUtils, IpAddressMatcher, etc.) of the source
-code for this product was copied for simplicity and to reduce
-dependencies from the source code developed by the Spring Framework
-Project (http://www.springframework.org).
diff --git a/samples/spring-boot-3-web/src/main/resources/application.properties b/samples/spring-boot-3-web/src/main/resources/application.properties
deleted file mode 100644
index d4a9810ea..000000000
--- a/samples/spring-boot-3-web/src/main/resources/application.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# 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.
-#
-
-shiro.loginUrl = /login.html
-
-# Let Shiro Manage the sessions
-shiro.userNativeSessionManager = true
-
-# disable URL session rewriting
-shiro.sessionManager.sessionIdUrlRewritingEnabled = false
diff --git a/samples/spring-boot-3-web/src/main/resources/log4j2.properties b/samples/spring-boot-3-web/src/main/resources/log4j2.properties
deleted file mode 100644
index 9ff7959ac..000000000
--- a/samples/spring-boot-3-web/src/main/resources/log4j2.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# 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.
-#
-# Root logger configuration
-rootLogger.level = info
-rootLogger.appenderRef.stdout.ref = STDOUT
-
-# Console appender configuration
-appender.stdout.type = Console
-appender.stdout.name = STDOUT
-appender.stdout.layout.type = PatternLayout
-# Use %highlight to add color to the log level and %cyan for the logger name
-appender.stdout.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %highlight{%-5level} %cyan{%c{1.}} - %msg%n
diff --git a/samples/spring-boot-3-web/src/main/resources/templates/account-info.html b/samples/spring-boot-3-web/src/main/resources/templates/account-info.html
deleted file mode 100644
index 4470db0bc..000000000
--- a/samples/spring-boot-3-web/src/main/resources/templates/account-info.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<!--
- ~ 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.
- -->
-<html xmlns:th="http://www.thymeleaf.org">
-<head>
- <title>Account Info</title>
- <!--/*/ <th:block th:insert="~{fragments/head :: head}"/> /*/-->
-</head>
-<body>
-<div class="container">
- <h1 th:text="'Account Info Page for: ' + ${name} + '!'"/>
-
- <a th:href="@{/}" class="btn btn-primary">Home</a>
-
- <form id="logoutForm" th:action="@{/logout}" method="post">
- <input type="submit" class="btn btn-danger" value="Logout"/>
- </form>
-
-</div>
-<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
-<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
-</body>
-</html>
diff --git a/samples/spring-boot-3-web/src/main/resources/templates/error.html b/samples/spring-boot-3-web/src/main/resources/templates/error.html
deleted file mode 100644
index 719c081d8..000000000
--- a/samples/spring-boot-3-web/src/main/resources/templates/error.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!--
- ~ 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.
- -->
-<html xmlns:th="http://www.thymeleaf.org">
-<head>
- <!--/*/ <th:block th:insert="~{fragments/head :: head}"/> /*/-->
-</head>
-<body>
-<div class="container-fluid">
- <div class="row">
- <div class="box col-md-6 col-md-offset-3">
- <div class="custom-header">
- <img src="https://shiro.apache.org/images/apache-shiro-logo.png"/>
- </div>
- <div class="logo">
- <h1 th:text="${errors.status}"></h1>
- </div>
- <p class="lead text-muted" th:text="${errors.message}">Unauthorized</p>
- <a href="/" class="btn btn-primary">Go Home</a>
- </div>
- </div>
-</div>
-</body>
-</html>
diff --git a/samples/spring-boot-3-web/src/main/resources/templates/fragments/head.html b/samples/spring-boot-3-web/src/main/resources/templates/fragments/head.html
deleted file mode 100644
index 9b9e2978b..000000000
--- a/samples/spring-boot-3-web/src/main/resources/templates/fragments/head.html
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE html>
-<!--
- ~ 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.
- -->
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:fragment="head">
- <meta charset="utf-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <meta name="viewport" content="width=device-width"/>
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,300,400italic,400,600italic,600,700italic,700,800italic,800"
- rel="stylesheet" type="text/css"/>
- <link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"
- type="text/css"/>
-
- <style>
- body {
- margin-top: 60px;
- }
-
- .box {
- padding: 50px;
- text-align: center;
- vertical-align: middle;
- }
-
- .custom-header {
- /*background-color: #161616;*/
- border: 2px solid #3254a0;
- }
- </style>
-
- <!--[if lt IE 9]>
- <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.2/html5shiv.js"></script>
- <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
- <![endif]-->
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
- <script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
-</head>
-<body>
-<p>Nothing to see here, move along.</p>
-</body>
-</html>
diff --git a/samples/spring-boot-3-web/src/main/resources/templates/hello.html b/samples/spring-boot-3-web/src/main/resources/templates/hello.html
deleted file mode 100644
index 87748fa54..000000000
--- a/samples/spring-boot-3-web/src/main/resources/templates/hello.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html>
-<!--
- ~ 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.
- -->
-<html xmlns:th="http://www.thymeleaf.org">
-<head>
- <title>Getting Started: Serving Web Content</title>
- <!--/*/ <th:block th:insert="~{fragments/head :: head}"/> /*/-->
-</head>
-<body>
-<div class="container">
- <h1 th:text="'Hello, ' + ${name} + '!'"/>
-
- <div th:unless="${subject.authenticated}">
- <a th:href="@{/login.html}" class="btn btn-primary">Login</a>
- </div>
- <div th:if="${subject.authenticated}">
- <h4 th:text="'Principal: ' + ${subject.principal}"></h4>
- <form id="logoutForm" th:action="@{/logout}" method="post">
- <input type="submit" class="btn btn-danger" value="Logout"/>
- </form>
- </div>
-
- <h4><a th:href="@{/account-info}" class="btn btn-primary">Account info</a> (Requires 'admin' role.)</h4>
-
-</div>
-<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
-<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
-</body>
-</html>
diff --git a/samples/spring-boot-3-web/src/main/resources/templates/login.html b/samples/spring-boot-3-web/src/main/resources/templates/login.html
deleted file mode 100644
index 8b0735b45..000000000
--- a/samples/spring-boot-3-web/src/main/resources/templates/login.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<!DOCTYPE html>
-<!--
- ~ 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.
- -->
-<html>
-<head>
- <title>Getting Started: Serving Web Content</title>
- <!--/*/ <th:block th:insert="~{fragments/head :: head}"/> /*/-->
-</head>
-<body>
-<div class="container">
-
-
- <div class="row">
- <div class="col-md-4 col-md-offset-4">
- <p>Here are a few sample accounts to play with from the text-based Realm</p>
- <table class="table">
- <thead>
- <tr>
- <th>Username</th>
- <th>Password</th>
- <th>Roles</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>joe.coder</td>
- <td>password</td>
- <td>user</td>
- </tr>
- <tr>
- <td>jill.coder</td>
- <td>password</td>
- <td>admin</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
-
- <div class="row">
- <div class="col-md-4 col-md-offset-4">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">Login</h3>
- </div>
- <div class="panel-body">
- <form name="loginform" action="" method="POST" accept-charset="UTF-8" role="form">
- <fieldset>
- <div class="form-group">
- <input class="form-control" placeholder="Username or Email" name="username"
- type="text"/>
- </div>
- <div class="form-group">
- <input class="form-control" placeholder="Password" name="password" type="password"
- value=""/>
- </div>
-
- <input class="btn btn-lg btn-success btn-block" type="submit" value="Login"/>
- </fieldset>
- </form>
- </div>
- </div>
- </div>
- </div>
-</div>
-
-<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
-<script src="https://code.jquery.com/jquery.js"></script>
-<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
-<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
-<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-<!--[if lt IE 9]>
-<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
-<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
-<![endif]-->
-</body>
-</html>
diff --git a/samples/web-jakarta/src/main/resources/META-INF/NOTICE b/samples/web-jakarta/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index bdc909e8c..000000000
--- a/samples/web-jakarta/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,15 +0,0 @@
-Apache Shiro
-Copyright 2008-2020 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-The implementation for org.apache.shiro.util.SoftHashMap is based
-on initial ideas from Dr. Heinz Kabutz's publicly posted version
-available at http://www.javaspecialists.eu/archive/Issue015.html,
-with continued modifications.
-
-Certain parts (StringUtils, IpAddressMatcher, etc.) of the source
-code for this product was copied for simplicity and to reduce
-dependencies from the source code developed by the Spring Framework
-Project (http://www.springframework.org).
diff --git a/samples/web-jakarta/src/main/resources/log4j2.xml b/samples/web-jakarta/src/main/resources/log4j2.xml
deleted file mode 100644
index 4dea7a8b6..000000000
--- a/samples/web-jakarta/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<Configuration name="ConfigTest" status="ERROR" monitorInterval="5">
- <!--
- ~ 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.
- -->
-
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="org.springframework" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.ehcache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.quartz" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro" level="info" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro.util.ThreadContext" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.eclipse.jetty.annotations.AnnotationParser" level="error" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="warn">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git a/samples/web-jakarta/src/main/webapp/WEB-INF/shiro.ini b/samples/web-jakarta/src/main/webapp/WEB-INF/shiro.ini
deleted file mode 100644
index 6465310aa..000000000
--- a/samples/web-jakarta/src/main/webapp/WEB-INF/shiro.ini
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# 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.
-
-# INI configuration is very powerful and flexible, while still remaining succinct.
-# Please https://shiro.apache.org/configuration.html and
-# https://shiro.apache.org/web.html for more.
-
-[main]
-listener = org.apache.shiro.config.ogdl.event.LoggingBeanEventListener
-
-shiro.loginUrl = /login.jsp
-shiro.postOnlyLogout = true
-
-sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
-sessionManager.sessionIdCookie.sameSite = NONE
-
-securityManager.sessionManager = $sessionManager
-securityManager.sessionManager.sessionIdUrlRewritingEnabled = false
-
-
-# We need to set the cipherKey, if you want the rememberMe cookie to work after restarting or on multiple nodes.
-# YOU MUST SET THIS TO A UNIQUE STRING
-securityManager.rememberMeManager.cipherKey = kPH+bIxk5D2deZiIxcaaaA==
-
-[users]
-# format: username = password, role1, role2, ..., roleN
-root = secret,admin
-guest = guest,guest
-presidentskroob = 12345,president
-darkhelmet = ludicrousspeed,darklord,schwartz
-lonestarr = vespa,goodguy,schwartz
-
-[roles]
-# format: roleName = permission1, permission2, ..., permissionN
-admin = *
-schwartz = lightsaber:*
-goodguy = winnebago:drive:eagle5
-
-[urls]
-# The /login.jsp is not restricted to authenticated users (otherwise no one could log in!), but
-# the 'authc' filter must still be specified for it so it can process that url's
-# login submissions. It is 'smart' enough to allow those requests through as specified by the
-# shiro.loginUrl above.
-/login.jsp = authc
-/logout = logout
-/account/** = authc
-/remoting/** = authc, roles[b2bClient], perms["remote:invoke:lan,wan"]
diff --git a/samples/web-jakarta/src/main/webapp/WEB-INF/web.xml b/samples/web-jakarta/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index a3c09ecd4..000000000
--- a/samples/web-jakarta/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?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 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.
- -->
-<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
- version="6.0">
-
- <listener>
- <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
- </listener>
-
- <filter>
- <filter-name>ShiroFilter</filter-name>
- <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>ShiroFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
-
-</web-app>
diff --git a/samples/web-jakarta/src/main/webapp/account/index.jsp b/samples/web-jakarta/src/main/webapp/account/index.jsp
deleted file mode 100644
index 82bb95494..000000000
--- a/samples/web-jakarta/src/main/webapp/account/index.jsp
+++ /dev/null
@@ -1,36 +0,0 @@
-<%--
- ~ 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.
- --%>
-<%@ include file="../include.jsp" %>
-
-<html>
-<head>
- <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
-</head>
-<body>
-
-<h2>Users only</h2>
-
-<p>You are currently logged in.</p>
-
-<p><a href="<c:url value="/home.jsp"/>">Return to the home page.</a></p>
-
-<p><a href="<c:url value="/logout"/>" onclick="document.getElementById('logout_form').submit();return false;">Log out.</a></p>
-<form id="logout_form" action="<c:url value="/logout"/>" method="post"></form>
-</body>
-</html>
diff --git a/samples/web-jakarta/src/main/webapp/home.jsp b/samples/web-jakarta/src/main/webapp/home.jsp
deleted file mode 100644
index ae46cde48..000000000
--- a/samples/web-jakarta/src/main/webapp/home.jsp
+++ /dev/null
@@ -1,69 +0,0 @@
-<%--
- ~ 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.
- --%>
-<%@ include file="include.jsp" %>
-
-<html>
-<head>
- <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
- <title>Apache Shiro Quickstart</title>
-</head>
-<body>
-
-<h1>Apache Shiro Quickstart</h1>
-
-<p>Hi <shiro:guest>Guest</shiro:guest><shiro:user><shiro:principal/></shiro:user>!
- ( <shiro:user> <a href="<c:url value="/logout"/>" onclick="document.getElementById('logout_form').submit();return false;">logout</a> </shiro:user>
- <shiro:guest><a href="<c:url value="/login.jsp"/>">Log in</a> (sample accounts provided)</shiro:guest> )
-</p>
-
-<p>Welcome to the Apache Shiro Quickstart sample application.
- This page represents the home page of any web application.</p>
-
-<shiro:user><p>Visit your <a href="<c:url value="/account"/>">account page</a>.</p></shiro:user>
-<shiro:guest><p>If you want to access the user-only <a href="<c:url value="/account"/>">account page</a>,
- you will need to log-in first.</p></shiro:guest>
-
-<h2>Roles</h2>
-
-<p>To show some taglibs, here are the roles you have and don't have. Log out and log back in under different user
- accounts to see different roles.</p>
-
-<h3>Roles you have</h3>
-
-<p>
- <shiro:hasRole name="admin">admin<br/></shiro:hasRole>
- <shiro:hasRole name="president">president<br/></shiro:hasRole>
- <shiro:hasRole name="darklord">darklord<br/></shiro:hasRole>
- <shiro:hasRole name="goodguy">goodguy<br/></shiro:hasRole>
- <shiro:hasRole name="schwartz">schwartz<br/></shiro:hasRole>
-</p>
-
-<h3>Roles you DON'T have</h3>
-
-<p>
- <shiro:lacksRole name="admin">admin<br/></shiro:lacksRole>
- <shiro:lacksRole name="president">president<br/></shiro:lacksRole>
- <shiro:lacksRole name="darklord">darklord<br/></shiro:lacksRole>
- <shiro:lacksRole name="goodguy">goodguy<br/></shiro:lacksRole>
- <shiro:lacksRole name="schwartz">schwartz<br/></shiro:lacksRole>
-</p>
-
-<form id="logout_form" action="<c:url value="/logout"/>" method="post"></form>
-</body>
-</html>
diff --git a/samples/web-jakarta/src/main/webapp/include.jsp b/samples/web-jakarta/src/main/webapp/include.jsp
deleted file mode 100644
index 8472daca1..000000000
--- a/samples/web-jakarta/src/main/webapp/include.jsp
+++ /dev/null
@@ -1,22 +0,0 @@
-<%--
- ~ 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.
- --%>
-<%@ page import="org.apache.shiro.SecurityUtils" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
diff --git a/samples/web-jakarta/src/main/webapp/index.jsp b/samples/web-jakarta/src/main/webapp/index.jsp
deleted file mode 100644
index ec60ad16c..000000000
--- a/samples/web-jakarta/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,21 +0,0 @@
-<%--
- ~ 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.
- --%>
-
-<%-- Forward the user to the home page --%>
-<jsp:forward page="home.jsp"/>
diff --git a/samples/web-jakarta/src/main/webapp/login.jsp b/samples/web-jakarta/src/main/webapp/login.jsp
deleted file mode 100644
index c80ee54c8..000000000
--- a/samples/web-jakarta/src/main/webapp/login.jsp
+++ /dev/null
@@ -1,110 +0,0 @@
-<%--
- ~ 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.
- --%>
-<%@ include file="include.jsp" %>
-
-<html>
-<head>
- <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
-</head>
-<body>
-
-<h2>Please Log in</h2>
-
-<shiro:guest>
- <p>Here are a few sample accounts to play with in the default text-based Realm (used for this
- demo and test installs only). Do you remember the movie these names came from? ;)</p>
-
-
- <style type="text/css">
- table.sample {
- border-width: 1px;
- border-style: outset;
- border-color: blue;
- border-collapse: separate;
- background-color: rgb(255, 255, 240);
- }
-
- table.sample th {
- border-width: 1px;
- padding: 1px;
- border-style: none;
- border-color: blue;
- background-color: rgb(255, 255, 240);
- }
-
- table.sample td {
- border-width: 1px;
- padding: 1px;
- border-style: none;
- border-color: blue;
- background-color: rgb(255, 255, 240);
- }
- </style>
-
-
- <table class="sample">
- <thead>
- <tr>
- <th>Username</th>
- <th>Password</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>root</td>
- <td>secret</td>
- </tr>
- <tr>
- <td>presidentskroob</td>
- <td>12345</td>
- </tr>
- <tr>
- <td>darkhelmet</td>
- <td>ludicrousspeed</td>
- </tr>
- <tr>
- <td>lonestarr</td>
- <td>vespa</td>
- </tr>
- </tbody>
- </table>
- <br/><br/>
-</shiro:guest>
-
-<form name="loginform" action="" method="post">
- <table align="left" border="0" cellspacing="0" cellpadding="3">
- <tr>
- <td>Username:</td>
- <td><input type="text" name="username" maxlength="30"></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type="password" name="password" maxlength="30"></td>
- </tr>
- <tr>
- <td colspan="2" align="left"><input type="checkbox" name="rememberMe"><font size="2">Remember Me</font></td>
- </tr>
- <tr>
- <td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td>
- </tr>
- </table>
-</form>
-
-</body>
-</html>
diff --git a/samples/web-jakarta/src/main/webapp/logout.jsp b/samples/web-jakarta/src/main/webapp/logout.jsp
deleted file mode 100644
index 440ec1c09..000000000
--- a/samples/web-jakarta/src/main/webapp/logout.jsp
+++ /dev/null
@@ -1,34 +0,0 @@
-<%--
- ~ 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.
- --%>
-<%@ include file="include.jsp" %>
-
-<html>
-<head>
- <link type="text/css" rel="stylesheet" href="<c:url value="/style.css"/>"/>
-</head>
-<body onload="document.getElementById('logout_form').submit();return false;">
-
-<h2>If you are not automatically redirected, click the 'Logout' button.</h2>
-
-<form id="logout_form" name="logout_form" action="<c:url value="/logout"/>" method="post">
- <input type="submit" value="Logout">
-</form>
-
-</body>
-</html>
diff --git a/samples/web-jakarta/src/main/webapp/style.css b/samples/web-jakarta/src/main/webapp/style.css
deleted file mode 100644
index c3e3944cf..000000000
--- a/samples/web-jakarta/src/main/webapp/style.css
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-body {
- margin: 15px 0 0 15px;
- padding: 1px; /*background: #2370cf;*/
- font: 12px 'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
- color: #000;
-}
-
-table, td {
- font: 12px 'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
- color: #000;
-}
-
-h1 {
- font: 24px;
-}
-
-img {
- border: thin black solid;
-}
-
-#contentBox {
- text-align: center;
- width: 50%;
- margin: auto;
- margin-top: 50px;
- color: black;
- background: #eee;
- border: thick black solid;
-}
diff --git a/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java b/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java
deleted file mode 100644
index c6abdae9a..000000000
--- a/samples/web-jakarta/src/test/java/org/apache/shiro/test/web/jakarta/JakartaAbstractContainerIT.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.shiro.test.web.jakarta;
-
-import org.apache.meecrowave.Meecrowave;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public abstract class JakartaAbstractContainerIT {
-
- protected static Meecrowave meecrowave;
-
- @BeforeAll
- public static void startContainer() {
- final File root = new File(getWarDir());
- try {
- meecrowave = new Meecrowave(new Meecrowave.Builder().randomHttpPort());
- meecrowave.getConfiguration().addGlobalContextCustomizer(
- ctx -> ctx.setJarScanner(new org.apache.tomcat.util.scan.StandardJarScanner()));
- meecrowave.start();
- meecrowave.deployWebapp("/", root);
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
-
- protected static String getBaseUri() {
- return "http://localhost:" + meecrowave.getConfiguration().getHttpPort() + "/";
- }
-
- protected static String getWarDir() {
- File[] warFiles = new File("target").listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".war");
- }
- });
-
- assertThat(warFiles.length)
- .as("Expected only one war file in target directory, run 'mvn clean' and try again")
- .isEqualTo(1);
-
- return warFiles[0].getAbsolutePath().replaceFirst("\\.war$", "");
- }
-
- @AfterAll
- public static void stopContainer() {
- if (meecrowave != null) {
- meecrowave.close();
- }
- }
-}
diff --git a/samples/web-jakarta/src/test/resources/log4j2.xml b/samples/web-jakarta/src/test/resources/log4j2.xml
deleted file mode 100644
index 2dde25ba4..000000000
--- a/samples/web-jakarta/src/test/resources/log4j2.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<Configuration name="ConfigTest" status="INFO" monitorInterval="5">
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="org.springframework" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.ehcache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.quartz" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro" level="info" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro.util.ThreadContext" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.eclipse.jetty.annotations.AnnotationParser" level="error" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="warn">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git a/samples/web/src/test/java/org/apache/shiro/test/WebAppContainerIntegrationIT.java b/samples/web/src/test/java/org/apache/shiro/test/WebAppContainerIntegrationIT.java
deleted file mode 100644
index 02bc5518c..000000000
--- a/samples/web/src/test/java/org/apache/shiro/test/WebAppContainerIntegrationIT.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.shiro.test;
-
-import org.apache.shiro.testing.web.AbstractContainerIT;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.htmlunit.ElementNotFoundException;
-import org.htmlunit.FailingHttpStatusCodeException;
-import org.htmlunit.WebClient;
-import org.htmlunit.html.HtmlForm;
-import org.htmlunit.html.HtmlPage;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-public class WebAppContainerIntegrationIT extends AbstractContainerIT {
-
- protected final WebClient webClient = new WebClient();
-
- @BeforeEach
- public void logOut() throws IOException {
- // Make sure we are logged out
- final HtmlPage homePage = webClient.getPage(getTlsBaseUri());
- try {
- homePage.getAnchorByHref("/logout").click();
- } catch (ElementNotFoundException e) {
- //Ignore
- }
- }
-
- @Test
- void logIn() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
-
- HtmlPage page = webClient.getPage(getTlsBaseUri() + "login.jsp");
- HtmlForm form = page.getFormByName("loginform");
- form.getInputByName("username").setValueAttribute("root");
- form.getInputByName("password").setValueAttribute("secret");
- page = form.getInputByName("submit").click();
- // This'll throw an exception if not logged in
- page.getAnchorByHref("/logout");
- }
-}
diff --git a/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCache.java b/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCache.java
deleted file mode 100644
index 358eb3923..000000000
--- a/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCache.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * 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.shiro.cache.ehcache;
-
-import java.util.LinkedList;
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * Shiro {@link org.apache.shiro.cache.Cache} implementation that wraps an {@link org.ehcache.core.Ehcache} instance.
- *
- * @param <K> K
- * @param <V> V
- * @since 0.2
- */
-public class EhCache<K, V> implements Cache<K, V> {
-
- /**
- * Private internal log instance.
- */
- private static final Logger LOGGER = LoggerFactory.getLogger(EhCache.class);
-
- /**
- * The wrapped Ehcache instance.
- */
- private org.ehcache.Cache<K, V> cache;
-
- /**
- * Constructs a new EhCache instance with the given cache.
- *
- * @param cache - delegate EhCache instance this Shiro cache instance will wrap.
- */
- public EhCache(org.ehcache.Cache<K, V> cache) {
- if (cache == null) {
- throw new IllegalArgumentException("Cache argument cannot be null.");
- }
- this.cache = cache;
- }
-
- /**
- * Gets a value of an element which matches the given key.
- *
- * @param key the key of the element to return.
- * @return The value placed into the cache with an earlier put, or null if not found or expired
- */
- public V get(K key) throws CacheException {
- try {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("Getting object from cache [{}] for key [{}]", cache, key);
- }
- if (key == null) {
- return null;
- } else {
- V element = cache.get(key);
- if (element == null) {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("Element for [{}] is null.", key);
- }
- return null;
- } else {
- return element;
- }
- }
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- /**
- * Puts an object into the cache.
- *
- * @param key the key.
- * @param value the value.
- */
- public V put(K key, V value) throws CacheException {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("Putting object in cache [{}] for key [{}]", cache, key);
- }
- try {
- V previous = get(key);
- cache.put(key, value);
- return previous;
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- /**
- * Removes the element which matches the key.
- *
- * <p>If no element matches, nothing is removed and no Exception is thrown.</p>
- *
- * @param key the key of the element to remove
- */
- public V remove(K key) throws CacheException {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("Removing object from cache [{}] for key [{}]", cache, key);
- }
- try {
- V previous = get(key);
- cache.remove(key);
- return previous;
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- /**
- * Removes all elements in the cache, but leaves the cache in a usable state.
- */
- public void clear() throws CacheException {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("Clearing all objects from cache [{}]", cache);
- }
- try {
- cache.removeAll(keys());
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- public int size() {
- try {
- int size = 0;
- for (org.ehcache.Cache.Entry<K, V> ignored : cache) {
- size++;
- }
- return size;
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- public Set<K> keys() {
- try {
- List<K> keys = new LinkedList<>();
- for (org.ehcache.Cache.Entry<K, V> entry : cache) {
- keys.add(entry.getKey());
- }
-
- if (!isEmpty(keys)) {
- return Collections.unmodifiableSet(new LinkedHashSet<>(keys));
- } else {
- return Collections.emptySet();
- }
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- public Collection<V> values() {
- try {
- Set<K> keys = keys();
- if (!isEmpty(keys)) {
- List<V> values = new ArrayList<>(keys.size());
- for (K key : keys) {
- V value = get(key);
- if (value != null) {
- values.add(value);
- }
- }
- return Collections.unmodifiableList(values);
- } else {
- return Collections.emptyList();
- }
- } catch (Throwable t) {
- throw new CacheException(t);
- }
- }
-
- /**
- * Returns the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
- * number is unknown or cannot be calculated.
- *
- * @return the size (in bytes) that this EhCache is using in memory (RAM), or <code>-1</code> if that
- * number is unknown or cannot be calculated.
- */
- public long getMemoryUsage() {
- return -1;
- }
-
- /**
- * Returns the size (in bytes) that this EhCache's memory store is using (RAM), or <code>-1</code> if
- * that number is unknown or cannot be calculated.
- *
- * @return the size (in bytes) that this EhCache's memory store is using (RAM), or <code>-1</code> if
- * that number is unknown or cannot be calculated.
- */
- public long getMemoryStoreSize() {
- return -1;
- }
-
- /**
- * Returns the size (in bytes) that this EhCache's disk store is consuming or <code>-1</code> if
- * that number is unknown or cannot be calculated.
- *
- * @return the size (in bytes) that this EhCache's disk store is consuming or <code>-1</code> if
- * that number is unknown or cannot be calculated.
- */
- public long getDiskStoreSize() {
- return -1;
- }
-
- /**
- * Returns "EhCache [" + cache + "]"
- *
- * @return "EhCache [" + cache + "]"
- */
- public String toString() {
- return "EhCache [" + cache + "]";
- }
-
- //////////////////////////
- // From CollectionUtils //
- //////////////////////////
- // CollectionUtils cannot be removed from shiro-core until 2.0 as it has a dependency on PrincipalCollection
-
- private static boolean isEmpty(Collection<?> c) {
- return c == null || c.isEmpty();
- }
-}
diff --git a/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCacheManager.java b/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCacheManager.java
deleted file mode 100644
index 985276bea..000000000
--- a/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCacheManager.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * 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.shiro.cache.ehcache;
-
-import java.io.Serializable;
-import java.net.URL;
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-import org.apache.shiro.cache.CacheManager;
-import org.apache.shiro.lang.io.ResourceUtils;
-import org.apache.shiro.lang.util.Destroyable;
-import org.apache.shiro.lang.util.Initializable;
-import org.ehcache.config.CacheConfiguration;
-import org.ehcache.config.builders.CacheManagerBuilder;
-import org.ehcache.xml.XmlConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Shiro {@code CacheManager} implementation utilizing the Ehcache framework for all cache functionality.
- * <p/>
- * This class can {@link #setCacheManager(org.ehcache.CacheManager) accept} a manually configured
- * {@link org.ehcache.CacheManager org.ehcache.CacheManager} instance,
- * or an {@code ehcache.xml} path location can be specified instead and one will be constructed. If neither are
- * specified, Shiro's failsafe <code><a href="./ehcache.xml">ehcache.xml</a></code> file will be used by default.
- * <p/>
- * This implementation requires EhCache 1.2 and above. Make sure EhCache 1.1 or earlier
- * is not in the classpath or it will not work.
- * <p/>
- * Please see the <a href="http://ehcache.org" target="_top">Ehcache website</a> for their documentation.
- *
- * @see <a href="http://ehcache.org" target="_top">The Ehcache website</a>
- * @since 0.2
- */
-public class EhCacheManager implements CacheManager, Initializable, Destroyable {
-
- /**
- * This class's private log instance.
- */
- private static final Logger LOGGER = LoggerFactory.getLogger(EhCacheManager.class);
-
- /**
- * The EhCache cache manager used by this implementation to create caches.
- */
- protected org.ehcache.CacheManager manager;
-
- /**
- * Indicates if the CacheManager instance was implicitly/automatically created by this instance, indicating that
- * it should be automatically cleaned up as well on shutdown.
- */
- private boolean cacheManagerImplicitlyCreated;
-
- /**
- * Classpath file location of the ehcache CacheManager config file.
- */
- private String cacheManagerConfigFile = "classpath:org/apache/shiro/cache/ehcache/ehcache.xml";
-
- /**
- * Default no argument constructor
- */
- public EhCacheManager() {
- }
-
- /**
- * Returns the wrapped Ehcache {@link org.ehcache.CacheManager CacheManager} instance.
- *
- * @return the wrapped Ehcache {@link org.ehcache.CacheManager CacheManager} instance.
- */
- public org.ehcache.CacheManager getCacheManager() {
- return manager;
- }
-
- /**
- * Sets the wrapped Ehcache {@link org.ehcache.CacheManager CacheManager} instance.
- *
- * @param manager the wrapped Ehcache {@link org.ehcache.CacheManager CacheManager} instance.
- */
- public void setCacheManager(org.ehcache.CacheManager manager) {
- this.manager = manager;
- }
-
- /**
- * Returns the resource location of the config file used to initialize a new
- * EhCache CacheManager instance. The string can be any resource path supported by the
- * {@link org.apache.shiro.lang.io.ResourceUtils#getInputStreamForPath(String)} call.
- * <p/>
- * This property is ignored if the CacheManager instance is injected directly - that is, it is only used to
- * lazily create a CacheManager if one is not already provided.
- *
- * @return the resource location of the config file used to initialize the wrapped
- * EhCache CacheManager instance.
- */
- public String getCacheManagerConfigFile() {
- return this.cacheManagerConfigFile;
- }
-
- /**
- * Sets the resource location of the config file used to initialize the wrapped
- * EhCache CacheManager instance. The string can be any resource path supported by the
- * {@link org.apache.shiro.lang.io.ResourceUtils#getInputStreamForPath(String)} call.
- * <p/>
- * This property is ignored if the CacheManager instance is injected directly - that is, it is only used to
- * lazily create a CacheManager if one is not already provided.
- *
- * @param classpathLocation resource location of the config file used to create the wrapped
- * EhCache CacheManager instance.
- */
- public void setCacheManagerConfigFile(String classpathLocation) {
- this.cacheManagerConfigFile = classpathLocation;
- }
-
- /**
- * Acquires the InputStream for the ehcache configuration file using
- * {@link ResourceUtils#getInputStreamForPath(String) ResourceUtils.getInputStreamForPath} with the
- * path returned from {@link #getCacheManagerConfigFile() getCacheManagerConfigFile()}.
- *
- * @return the InputStream for the ehcache configuration file.
- */
- protected InputStream getCacheManagerConfigFileInputStream() {
- String configFile = getCacheManagerConfigFile();
- try {
- return ResourceUtils.getInputStreamForPath(configFile);
- } catch (IOException e) {
- throw new IllegalStateException("Unable to obtain input stream for cacheManagerConfigFile ["
- + configFile + "]", e);
- }
- }
-
- /**
- * Acquires the URL for the ehcache configuration file using
- * {@link ResourceUtils#getURLForPath(String) ResourceUtils.getURLForPath} with the
- * path returned from {@link #getCacheManagerConfigFile() getCacheManagerConfigFile()}.
- *
- * @return the URL for the ehcache configuration file.
- */
- protected URL getCacheManagerConfigFileUrl() {
- final var configFile = getCacheManagerConfigFile();
- try {
- return ResourceUtils.getURLForPath(configFile);
- } catch (IOException e) {
- throw new IllegalStateException("Unable to parse cacheManagerConfigFile ["
- + configFile + "]", e);
- }
- }
-
- /**
- * Loads an existing EhCache from the cache manager, or starts a new cache if one is not found.
- *
- * @param name the name of the cache to load/create.
- */
- @Override
- public final <K, V> Cache<K, V> getCache(String name)
- throws CacheException {
-
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("Acquiring EhCache instance named [{}]", name);
- }
-
- try {
- org.ehcache.Cache<K, V> cache = (org.ehcache.Cache<K, V>) ensureCacheManager()
- .getCache(name, Serializable.class, Serializable.class);
- if (cache == null) {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Cache with name '{}' does not yet exist. Creating now.", name);
- }
- CacheConfiguration<K, V> config = (CacheConfiguration<K, V>) new XmlConfiguration(getCacheManagerConfigFileUrl())
- .newCacheConfigurationBuilderFromTemplate("default", Serializable.class, Serializable.class)
- .build();
- cache = manager.createCache(name, config);
-
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Added EhCache named [{}]", name);
- }
- } else {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Using existing EHCache named [{}]", name);
- }
- }
- return new EhCache<>(cache);
- } catch (IllegalArgumentException | IllegalStateException | ReflectiveOperationException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Initializes this instance.
- * <p/>
- * If a {@link #setCacheManager CacheManager} has been
- * explicitly set (e.g. via Dependency Injection or programmatically) prior to calling this
- * method, this method does nothing.
- * <p/>
- * However, if no {@code CacheManager} has been set, the default Ehcache singleton will be initialized, where
- * Ehcache will look for an {@code ehcache.xml} file at the root of the classpath. If one is not found,
- * Ehcache will use its own failsafe configuration file.
- * <p/>
- * Because Shiro cannot use the failsafe defaults (fail-safe expunges cached objects after 2 minutes,
- * something not desirable for Shiro sessions), this class manages an internal default configuration for
- * this case.
- *
- * @throws org.apache.shiro.cache.CacheException if there are any CacheExceptions thrown by EhCache.
- * @see org.ehcache.CacheManager#createCache(String, org.ehcache.config.CacheConfiguration)
- */
- public final void init() throws CacheException {
- ensureCacheManager();
- }
-
- private org.ehcache.CacheManager ensureCacheManager() {
- try {
- if (this.manager == null) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("cacheManager property not set. Constructing CacheManager instance... ");
- }
- final XmlConfiguration xmlConfig = new XmlConfiguration(getCacheManagerConfigFileUrl());
- this.manager = CacheManagerBuilder.newCacheManager(xmlConfig);
- this.manager.init();
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("instantiated Ehcache CacheManager instance.");
- }
- cacheManagerImplicitlyCreated = true;
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("implicit cacheManager created successfully.");
- }
- }
- return this.manager;
- } catch (Exception e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Shuts-down the wrapped Ehcache CacheManager <b>only if implicitly created</b>.
- * <p/>
- * If another component injected
- * a non-null CacheManager into this instance before calling {@link #init() init}, this instance expects that same
- * component to also destroy the CacheManager instance, and it will not attempt to do so.
- */
- public void destroy() {
- if (cacheManagerImplicitlyCreated) {
- try {
- org.ehcache.CacheManager cacheMgr = getCacheManager();
- cacheMgr.close();
- } catch (Throwable t) {
- if (LOGGER.isWarnEnabled()) {
- LOGGER.warn("Unable to cleanly shutdown implicitly created CacheManager instance. "
- + "Ignoring (shutting down)...", t);
- }
- } finally {
- this.manager = null;
- this.cacheManagerImplicitlyCreated = false;
- }
- }
- }
-
-}
diff --git a/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/package-info.java b/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/package-info.java
deleted file mode 100644
index 72faf544f..000000000
--- a/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-/**
- * <a href="http://ehcache.sourceforge.net" target="_top">Ehcache</a>-based implementations of Shiro's
- * cache interfaces.
- */
-package org.apache.shiro.cache.ehcache;
diff --git a/support/ehcache/src/main/resources/META-INF/NOTICE b/support/ehcache/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index bdc909e8c..000000000
--- a/support/ehcache/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,15 +0,0 @@
-Apache Shiro
-Copyright 2008-2020 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-The implementation for org.apache.shiro.util.SoftHashMap is based
-on initial ideas from Dr. Heinz Kabutz's publicly posted version
-available at http://www.javaspecialists.eu/archive/Issue015.html,
-with continued modifications.
-
-Certain parts (StringUtils, IpAddressMatcher, etc.) of the source
-code for this product was copied for simplicity and to reduce
-dependencies from the source code developed by the Spring Framework
-Project (http://www.springframework.org).
diff --git a/support/ehcache/src/main/resources/org/apache/shiro/cache/ehcache/ehcache.xml b/support/ehcache/src/main/resources/org/apache/shiro/cache/ehcache/ehcache.xml
deleted file mode 100644
index e232e922f..000000000
--- a/support/ehcache/src/main/resources/org/apache/shiro/cache/ehcache/ehcache.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-<!--
- ~ 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.
- -->
-<config xmlns="http://www.ehcache.org/v3"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.ehcache.org/v3 https://www.ehcache.org/schema/ehcache-core-3.3.xsd">
-
- <!-- Sets the path to the directory where cache .data files are created.
-
- If the path is a Java System Property it is replaced by
- its value in the running VM. The following properties are translated:
-
- user.home - User's home directory
- user.dir - User's current working directory
- java.io.tmpdir - Default temp file path
- -->
- <persistence directory="${java.io.tmpdir}/shiro-ehcache"/>
-
-
- <!--Default Cache configuration. These will applied to caches programmatically created through
- the CacheManager.
-
- The following attributes are required:
-
- maxElementsInMemory - Sets the maximum number of objects that will be created in memory
- eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the
- element is never expired.
- overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
- has reached the maxInMemory limit.
-
- The following attributes are optional:
- timeToIdleSeconds - Sets the time to idle for an element before it expires.
- i.e. The maximum amount of time between accesses before an element expires
- Is only used if the element is not eternal.
- Optional attribute. A value of 0 means that an Element can idle for infinity.
- The default value is 0.
- timeToLiveSeconds - Sets the time to live for an element before it expires.
- i.e. The maximum time between creation time and when an element expires.
- Is only used if the element is not eternal.
- Optional attribute. A value of 0 means that and Element can live for infinity.
- The default value is 0.
- diskPersistent - Whether the disk store persists between restarts of the Virtual Machine.
- The default value is false.
- diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
- is 120 seconds.
- memoryStoreEvictionPolicy - Policy would be enforced upon reaching the maxElementsInMemory limit. Default
- policy is Least Recently Used (specified as LRU). Other policies available -
- First In First Out (specified as FIFO) and Less Frequently Used
- (specified as LFU)
- -->
-
- <cache-template name="default">
- <expiry>
- <ttl>120</ttl>
- </expiry>
- <heap>10000</heap>
- </cache-template>
-
- <!-- We want eternal="true" and no timeToIdle or timeToLive settings because Shiro manages session
- expirations explicitly. If we set it to false and then set corresponding timeToIdle and timeToLive properties,
- ehcache would evict sessions without Shiro's knowledge, which would cause many problems
- (e.g. "My Shiro session timeout is 30 minutes - why isn't a session available after 2 minutes?"
- Answer - ehcache expired it due to the timeToIdle property set to 120 seconds.)
-
- diskPersistent=true since we want an enterprise session management feature - ability to use sessions after
- even after a JVM restart. -->
- <cache alias="shiro-activeSessionCache">
- <key-type>java.io.Serializable</key-type>
- <value-type>java.io.Serializable</value-type>
- <expiry>
- <none/>
- </expiry>
- <resources>
- <heap>10000</heap>
- <disk persistent="true" unit="MB">50</disk>
- </resources>
- </cache>
-
- <cache alias="org.apache.shiro.realm.text.PropertiesRealm-0-accounts">
- <key-type>java.io.Serializable</key-type>
- <value-type>java.io.Serializable</value-type>
- <expiry>
- <none/>
- </expiry>
- <resources>
- <heap>10000</heap>
- <disk persistent="true" unit="MB">50</disk>
- </resources>
- </cache>
-
-</config>
diff --git a/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java b/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java
deleted file mode 100644
index 1efcb201f..000000000
--- a/support/ehcache/src/test/java/org/apache/shiro/cache/ehcache/EhCacheManagerTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * 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.shiro.cache.ehcache;
-
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.lang.util.LifecycleUtils;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.Isolated;
-
-import java.util.Collection;
-import java.util.Set;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * TODO - Class JavaDoc
- *
- * @since May 11, 2010 12:41:38 PM
- */
-@Isolated
-public class EhCacheManagerTest {
-
- private EhCacheManager cacheManager;
-
- @BeforeEach
- public void setUp() {
- cacheManager = new EhCacheManager();
- }
-
- @AfterEach
- public void tearDown() {
- LifecycleUtils.destroy(cacheManager);
- }
-
- @Test
- void testCacheManagerCreationDuringInit() {
- org.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
- cacheManager.init();
- //now assert that an internal CacheManager has been created:
- ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
- }
-
- @Test
- void testLazyCacheManagerCreationWithoutCallingInit() {
- org.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
-
- //don't call init here - the ehcache CacheManager should be lazily created
- //because of the default Shiro ehcache.xml file in the classpath. Just acquire a cache:
- Cache<String, String> cache = cacheManager.getCache("test");
-
- //now assert that an internal CacheManager has been created:
- ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
-
- assertThat(cache).isNotNull();
- cache.put("hello", "world");
- String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- }
-
- @Test
- void testRemove() {
- org.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
-
- Cache<String, String> cache = cacheManager.getCache("test");
-
- ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
-
- assertThat(cache).isNotNull();
- cache.put("hello", "world");
- cache.put("hello2", "world2");
- String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
-
- assertThat(cache.remove("hello")).isEqualTo("world");
- assertThat(cache.size()).isEqualTo(1);
- assertThat(cache.remove("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(0);
-
- assertThat(cache.remove("blah")).isNull();
- }
-
- @Test
- void testClear() {
- org.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
-
- Cache<String, String> cache = cacheManager.getCache("test");
-
- ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
-
- assertThat(cache).isNotNull();
- cache.put("hello", "world");
- cache.put("hello2", "world2");
- String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
-
- cache.clear();
- assertThat(cache.size()).isEqualTo(0);
-
- assertThat(cache.get("hello")).isNull();
- }
-
- @Test
- void testKeys() {
- org.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
-
- Cache<String, String> cache = cacheManager.getCache("test");
-
- ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
-
- assertThat(cache).isNotNull();
- cache.put("hello", "world");
- cache.put("hello2", "world2");
- String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
-
- Set<String> keys = cache.keys();
- assertThat(keys).hasSize(2);
- assertThat(keys).contains("hello");
- assertThat(keys).contains("hello2");
-
- assertThat(cache.remove("hello")).isEqualTo("world");
- assertThat(cache.size()).isEqualTo(1);
-
- keys = cache.keys();
- assertThat(keys).hasSize(1);
- assertThat(keys).contains("hello2");
-
- assertThat(cache.remove("blah")).isNull();
- }
-
- @Test
- void testValues() {
- org.ehcache.CacheManager ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNull();
-
- Cache<String, String> cache = cacheManager.getCache("test");
-
- ehCacheManager = cacheManager.getCacheManager();
- assertThat(ehCacheManager).isNotNull();
-
- assertThat(cache).isNotNull();
- cache.put("hello", "world");
- cache.put("hello2", "world2");
- String value = cache.get("hello");
- assertThat(value).isNotNull();
- assertThat(value).isEqualTo("world");
- assertThat(cache.get("hello2")).isEqualTo("world2");
- assertThat(cache.size()).isEqualTo(2);
-
- Collection<String> values = cache.values();
- assertThat(values).hasSize(2);
- assertThat(values).contains("world");
- assertThat(values).contains("world2");
-
- assertThat(cache.remove("hello")).isEqualTo("world");
- assertThat(cache.size()).isEqualTo(1);
-
- values = cache.values();
- assertThat(values).hasSize(1);
- assertThat(values).contains("world2");
-
- assertThat(cache.remove("blah")).isNull();
- }
-
-}
diff --git a/support/ehcache/src/test/resources/log4j2-test.xml b/support/ehcache/src/test/resources/log4j2-test.xml
deleted file mode 100644
index bd8c3cb39..000000000
--- a/support/ehcache/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<Configuration name="ConfigTest" status="ERROR" monitorInterval="5">
- <!--
- ~ 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.
- -->
-
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="org.apache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.ehcache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro" level="info" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro.util.ThreadContext" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="warn">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git a/support/hazelcast/src/main/java/org/apache/shiro/hazelcast/cache/HazelcastCacheManager.java b/support/hazelcast/src/main/java/org/apache/shiro/hazelcast/cache/HazelcastCacheManager.java
deleted file mode 100644
index 691c9692a..000000000
--- a/support/hazelcast/src/main/java/org/apache/shiro/hazelcast/cache/HazelcastCacheManager.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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.shiro.hazelcast.cache;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import org.apache.shiro.lang.ShiroException;
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-import org.apache.shiro.cache.CacheManager;
-import org.apache.shiro.cache.MapCache;
-import org.apache.shiro.lang.util.Destroyable;
-import org.apache.shiro.lang.util.Initializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-
-/**
- * A {@code CacheManager} implementation backed by <a href="http://www.hazelcast.com/">Hazelcast</a>,
- * "an open source clustering and highly scalable data distribution platform for Java"
- * <p/>
- * This implementation interacts with a {@link HazelcastInstance} to
- * {@link HazelcastInstance#getMap(String) acquire} named {@link java.util.concurrent.ConcurrentMap ConcurrentMap}
- * instances. Those clustered/distributed Map instances are then wrapped and made available to {@code CacheManager}
- * callers as {@link MapCache} instances via {@link #getCache(String)}.
- * <h2>Configuration</h2>
- * This implementation's backing {@code HazelcastInstance} can be configured in one of three ways:
- * <ol>
- * <li>Doing nothing and leveraging default Hazelcast configuration mechanisms</li>
- * <li>Supplying an already-existing {@code HazelcastInstance}</li>
- * <li>Supplying a {@link Config} instance and using that to create a new {@code HazelcastInstance}</li>
- * </ol>
- * <h3>Default Configuration</h3>
- * If you simply instantiate a {@code HazelcastCacheManager} and do nothing further, its backing
- * {@link HazelcastInstance} instance will be created automatically by calling
- * {@link Hazelcast#newHazelcastInstance(com.hazelcast.config.Config) Hazelcast.newHazelcastInstance(null)}.
- * <p/>
- * The null argument instructs Hazelcast to use whatever default configuration mechanism it has at its disposal,
- * usually a {@code hazelcast.xml} file at the root of the classpath, or if that is not present, the
- * {@code hazelcast-default.xml} file contained in the Hazelcast {@code .jar} file itself.
- * <p/>
- * <h3>An existing {@code HazelcastInstance}</h3>
- * If you have created a {@code HazelcastInstance} outside of Shiro's knowledge/control, you can simply configure it
- * to be used by calling {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) setHazelcastInstance}.
- * <p/>
- * <h3>A {@link Config} instance</h3>
- * If you do not want to use the above two options, you can have programmatic control over all of Hazelcast's
- * configuration by <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">creating and configuring a
- * Config instance</a>.
- * <p/>
- * Once constructed, you can set it via {@link #setConfig(com.hazelcast.config.Config) setConfig(config)}. This config
- * instance will be used to acquire a new Hazelcast instance by calling
- * {@link Hazelcast#newHazelcastInstance(Config) Hazelcast.newHazelcastInstance(config)}
- *
- * @see <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">Hazelcast Configuration Documentation</a>
- * @since 1.3
- */
-public class HazelcastCacheManager implements CacheManager, Initializable, Destroyable {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HazelcastCacheManager.class);
-
- private boolean implicitlyCreated;
- private HazelcastInstance hazelcastInstance;
- private Config config;
-
- /**
- * Returns a {@link MapCache} instance representing the named Hazelcast-managed
- * {@link com.hazelcast.core.IMap IMap}. The Hazelcast Map is obtained by calling
- * {@link HazelcastInstance#getMap(String) hazelcastInstance.getMap(name)}.
- *
- * @param name the name of the cache to acquire.
- * @param <K> the type of map key
- * @param <V> the type of map value
- * @return a {@link MapCache} instance representing the named Hazelcast-managed {@link com.hazelcast.core.IMap IMap}.
- * @throws CacheException
- * @see HazelcastInstance#getMap(String)
- * @see #ensureHazelcastInstance()
- */
- public <K, V> Cache<K, V> getCache(String name) throws CacheException {
- //returned map is a ConcurrentMap
- Map<K, V> map = ensureHazelcastInstance().getMap(name);
- return new MapCache<K, V>(name, map);
- }
-
- /**
- * Ensures that this implementation has a backing {@link HazelcastInstance}, and if not, implicitly creates one
- * via {@link #createHazelcastInstance()}.
- *
- * @return the backing (potentially newly created) {@code HazelcastInstance}.
- * @see #createHazelcastInstance()
- * @see HazelcastInstance
- */
- protected HazelcastInstance ensureHazelcastInstance() {
- if (this.hazelcastInstance == null) {
- this.hazelcastInstance = createHazelcastInstance();
- this.implicitlyCreated = true;
- }
- return this.hazelcastInstance;
- }
-
- /**
- * Initializes this instance by {@link #ensureHazelcastInstance() ensuring} there is a backing
- * {@link HazelcastInstance}.
- *
- * @throws ShiroException
- * @see #ensureHazelcastInstance()
- * @see HazelcastInstance
- */
- public void init() throws ShiroException {
- ensureHazelcastInstance();
- }
-
- /**
- * Implicitly creates and returns a new {@link HazelcastInstance} that will be used to back this implementation.
- * This implementation calls:
- * <pre>
- * return Hazelcast.newHazelcastInstance(this.config);
- * </pre>
- * using any {@link #setConfig(com.hazelcast.config.Config) configured} {@code Config} object. If no config
- * object has been specified, {@code this.config} will be {@code null}, thereby using Hazelcast's
- * <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">default configuration mechanism</a>.
- * <p/>
- * Can be overridden by subclasses for custom creation behavior.
- *
- * @return a new {@link HazelcastInstance} that will be used to back this implementation
- * @see Hazelcast#newHazelcastInstance(com.hazelcast.config.Config)
- * @see Config
- */
- protected HazelcastInstance createHazelcastInstance() {
- return Hazelcast.newHazelcastInstance(this.config);
- }
-
- //needed for unit tests only - not part of Shiro's public API
-
- /**
- * NOT PART OF SHIRO'S ACCESSIBLE API. DO NOT DEPEND ON THIS. This method was added for testing purposes only.
- * <p/>
- * Returns {@code true} if this {@code HazelcastCacheManager} instance implicitly created the backing
- * {@code HazelcastInstance}, or {@code false} if one was externally provided via
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) setHazelcastInstance}.
- *
- * @return {@code true} if this {@code HazelcastCacheManager} instance implicitly created the backing
- * {@code HazelcastInstance}, or {@code false} if one was externally provided via
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) setHazelcastInstance}.
- */
- protected final boolean isImplicitlyCreated() {
- return this.implicitlyCreated;
- }
-
- /**
- * Destroys any {@link #ensureHazelcastInstance() implicitly created} backing {@code HazelcastInstance}. If the
- * backing Hazelcast was not implicitly created (i.e. because it was configured externally and supplied via
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) setHazelcastInstance}), this method does
- * nothing.
- *
- * @throws Exception if there is a problem shutting down
- */
- public void destroy() throws Exception {
- if (this.implicitlyCreated) {
- try {
- this.hazelcastInstance.getLifecycleService().shutdown();
- } catch (Throwable t) {
- if (LOGGER.isWarnEnabled()) {
- LOGGER.warn("Unable to cleanly shutdown implicitly created HazelcastInstance. "
- + "Ignoring (shutting down)...", t);
- }
- } finally {
- this.hazelcastInstance = null;
- this.implicitlyCreated = false;
- }
- }
- }
-
- /**
- * Returns the {@code HazelcastInstance} from which named {@link java.util.concurrent.ConcurrentMap ConcurrentMap}
- * instances will be acquired to create {@link MapCache} instances.
- *
- * @return the {@code HazelcastInstance} from which named {@link java.util.concurrent.ConcurrentMap ConcurrentMap}
- * instances will be acquired to create {@link MapCache} instances.
- */
- public HazelcastInstance getHazelcastInstance() {
- return hazelcastInstance;
- }
-
- /**
- * Sets the {@code HazelcastInstance} from which named {@link java.util.concurrent.ConcurrentMap ConcurrentMap}
- * instances will be acquired to create {@link MapCache} instances.
- *
- * @param hazelcastInstance the {@code HazelcastInstance} from which named
- * {@link java.util.concurrent.ConcurrentMap ConcurrentMap} instances will be acquired to create
- * {@link MapCache} instances.
- */
- public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
- this.hazelcastInstance = hazelcastInstance;
- }
-
- /**
- * Returns the Hazelcast {@code Config} object to use to create a backing {@code HazelcastInstance} if one is not
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) supplied}, or {@code null} if the
- * default <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">Hazelcast configuration
- * mechanisms</a> will be used.
- *
- * @return the Hazelcast {@code Config} object to use to create a backing {@code HazelcastInstance} if one is not
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) supplied}, or {@code null} if the
- * default <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">Hazelcast configuration
- * mechanisms</a> will be used.
- * @see Hazelcast#newHazelcastInstance(com.hazelcast.config.Config)
- */
- public Config getConfig() {
- return config;
- }
-
- /**
- * Sets the Hazelcast {@code Config} object to use to create a backing {@code HazelcastInstance} if one is not
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) supplied}. {@code null} can be set if the
- * default <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">Hazelcast configuration
- * mechanisms</a> will be used.
- *
- * @param config the Hazelcast {@code Config} object to use to create a backing {@code HazelcastInstance} if one is not
- * {@link #setHazelcastInstance(com.hazelcast.core.HazelcastInstance) supplied}, or {@code null} if the
- * default <a href="http://www.hazelcast.com/docs/2.5/manual/multi_html/ch12.html">Hazelcast configuration
- * mechanisms</a> will be used.
- */
- public void setConfig(Config config) {
- this.config = config;
- }
-
-}
diff --git a/support/hazelcast/src/main/java/org/apache/shiro/hazelcast/cache/package-info.java b/support/hazelcast/src/main/java/org/apache/shiro/hazelcast/cache/package-info.java
deleted file mode 100644
index 572a05688..000000000
--- a/support/hazelcast/src/main/java/org/apache/shiro/hazelcast/cache/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-/**
- * <a href="http://ehcache.sourceforge.net" target="_top">Ehcache</a>-based implementations of Shiro's
- * cache interfaces.
- */
-package org.apache.shiro.hazelcast.cache;
diff --git a/support/hazelcast/src/main/resources/META-INF/NOTICE b/support/hazelcast/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index bdc909e8c..000000000
--- a/support/hazelcast/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,15 +0,0 @@
-Apache Shiro
-Copyright 2008-2020 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-The implementation for org.apache.shiro.util.SoftHashMap is based
-on initial ideas from Dr. Heinz Kabutz's publicly posted version
-available at http://www.javaspecialists.eu/archive/Issue015.html,
-with continued modifications.
-
-Certain parts (StringUtils, IpAddressMatcher, etc.) of the source
-code for this product was copied for simplicity and to reduce
-dependencies from the source code developed by the Spring Framework
-Project (http://www.springframework.org).
diff --git a/support/hazelcast/src/test/groovy/org/apache/shiro/hazelcast/cache/HazelcastCacheManagerTest.groovy b/support/hazelcast/src/test/groovy/org/apache/shiro/hazelcast/cache/HazelcastCacheManagerTest.groovy
deleted file mode 100644
index a35eb0d3c..000000000
--- a/support/hazelcast/src/test/groovy/org/apache/shiro/hazelcast/cache/HazelcastCacheManagerTest.groovy
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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.shiro.hazelcast.cache
-
-import com.hazelcast.config.Config
-import com.hazelcast.core.HazelcastInstance
-import com.hazelcast.core.LifecycleService
-import org.junit.jupiter.api.BeforeAll
-import org.junit.jupiter.api.Test
-
-import static org.junit.jupiter.api.Assertions.assertFalse
-import static org.junit.jupiter.api.Assertions.assertNull
-import static org.junit.jupiter.api.Assertions.assertNotNull
-import static org.junit.jupiter.api.Assertions.assertSame
-import static org.junit.jupiter.api.Assertions.assertTrue
-import static org.mockito.Mockito.*
-
-/**
- * Unit tests for {@link HazelcastCacheManager}.
- *
- * @since 1.3
- */
-class HazelcastCacheManagerTest {
-
- @BeforeAll
- static void setUpLogging() {
- System.setProperty("hazelcast.logging.type", "log4j2")
- }
-
- @Test
- void testGetSetHazelcastInstance() {
-
- // given
- HazelcastInstance hc = mock(HazelcastInstance)
- def manager = new HazelcastCacheManager();
-
- // when
- manager.hazelcastInstance = hc
-
- // then
- assertSame hc, manager.hazelcastInstance
- }
-
- @Test
- void testCustomConfig() {
-
- // given
- Config config = mock(Config)
- def manager = new HazelcastCacheManager();
-
- // when
- manager.config = config
-
- // then
- assertSame config, manager.config
- }
-
- @Test
- void testImplicitlyCreated() {
-
- // given
- HazelcastInstance hazelcastInstance = mock(HazelcastInstance)
-
- HazelcastCacheManager manager = spy(HazelcastCacheManager);
- when(manager.createHazelcastInstance()).then(args -> hazelcastInstance)
-
- // when
- manager.init()
-
- // then
- assertTrue manager.implicitlyCreated
- manager.destroy()
- }
-
- @Test
- void testDestroy() {
-
- // given
- LifecycleService lifecycleService = mock(LifecycleService)
-
- HazelcastInstance hazelcastInstance = spy(HazelcastInstance)
- when(hazelcastInstance.getLifecycleService()).then(args -> lifecycleService)
-
- HazelcastCacheManager manager = spy(HazelcastCacheManager);
- when(manager.createHazelcastInstance()).then(args -> hazelcastInstance)
-
-
- // when
- manager.init()
- manager.destroy()
-
- // then
- assertFalse manager.implicitlyCreated
- assertNull manager.hazelcastInstance
- verify(hazelcastInstance).getLifecycleService()
- verify(manager).createHazelcastInstance()
- }
-
- @Test
- void testDestroyExplicit() {
-
- // given
- HazelcastInstance hazelcastInstance = mock(HazelcastInstance)
- HazelcastCacheManager manager = new HazelcastCacheManager()
- manager.hazelcastInstance = hazelcastInstance
-
- // when
- manager.init()
- manager.destroy()
-
- // then
- assertNotNull manager.hazelcastInstance
- assertFalse manager.implicitlyCreated
- }
-
- @Test
- void testUncleanShutdown() {
-
- // given
- LifecycleService lifecycleService = mock(LifecycleService)
- when(lifecycleService.shutdown()).thenThrow(new IllegalStateException())
-
- HazelcastInstance hazelcastInstance = mock(HazelcastInstance)
- when(hazelcastInstance.getLifecycleService()).then(args -> lifecycleService)
-
- HazelcastCacheManager manager = spy(HazelcastCacheManager);
- when(manager.createHazelcastInstance()).then(args -> hazelcastInstance)
-
- // when
- manager.init()
- manager.destroy()
-
- // then
- assertFalse manager.implicitlyCreated
- verify(lifecycleService).shutdown()
- verify(hazelcastInstance).getLifecycleService()
- verify(manager).createHazelcastInstance()
- }
-
-}
diff --git a/support/hazelcast/src/test/resources/log4j2-test.xml b/support/hazelcast/src/test/resources/log4j2-test.xml
deleted file mode 100644
index 455736eb4..000000000
--- a/support/hazelcast/src/test/resources/log4j2-test.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<!--
- ~ 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.
- -->
-
-<Configuration name="ConfigTest" status="ERROR" monitorInterval="5">
- <!--
- ~ 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.
- -->
-
- <Appenders>
- <Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="com.hazelcast" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro" level="info" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Logger name="org.apache.shiro.util.ThreadContext" level="warn" additivity="false">
- <AppenderRef ref="Console"/>
- </Logger>
- <Root level="error">
- <AppenderRef ref="Console"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git a/support/spring/src/main/java/org/apache/shiro/spring/config/AbstractShiroBeanConfiguration.java b/support/spring/src/main/java/org/apache/shiro/spring/config/AbstractShiroBeanConfiguration.java
deleted file mode 100644
index b2f087ae8..000000000
--- a/support/spring/src/main/java/org/apache/shiro/spring/config/AbstractShiroBeanConfiguration.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.shiro.spring.config;
-
-import org.apache.shiro.event.EventBus;
-import org.apache.shiro.event.support.DefaultEventBus;
-import org.apache.shiro.spring.LifecycleBeanPostProcessor;
-import org.apache.shiro.spring.ShiroEventBusBeanPostProcessor;
-
-/**
- * @since 1.4.0
- */
-public class AbstractShiroBeanConfiguration {
-
- protected LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
- return new LifecycleBeanPostProcessor();
- }
-
- protected EventBus eventBus() {
- return new DefaultEventBus();
- }
-
- protected ShiroEventBusBeanPostProcessor shiroEventBusAwareBeanPostProcessor() {
- return new ShiroEventBusBeanPostProcessor(eventBus());
- }
-}
diff --git a/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java b/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java
deleted file mode 100644
index 9d77fb255..000000000
--- a/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.shiro.spring.remoting;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.subject.ExecutionException;
-import org.apache.shiro.subject.Subject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.remoting.support.DefaultRemoteInvocationExecutor;
-import org.springframework.remoting.support.RemoteInvocation;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.Callable;
-
-
-/**
- * An implementation of the Spring {@link org.springframework.remoting.support.RemoteInvocationExecutor}
- * that binds a {@code sessionId} to the incoming thread to make it available to the {@code SecurityManager}
- * implementation during the thread execution. The {@code SecurityManager} implementation can use this sessionId
- * to reconstitute the {@code Subject} instance based on persistent state in the corresponding {@code Session}.
- *
- * @since 0.1
- */
-public class SecureRemoteInvocationExecutor extends DefaultRemoteInvocationExecutor {
-
- //TODO - complete JavaDoc
-
- /*--------------------------------------------
- | C O N S T A N T S |
- ============================================*/
-
- /*--------------------------------------------
- | I N S T A N C E V A R I A B L E S |
- ============================================*/
- private static final Logger LOGGER = LoggerFactory.getLogger(SecureRemoteInvocationExecutor.class);
-
- /**
- * The SecurityManager used to retrieve realms that should be associated with the
- * created <tt>Subject</tt>s upon remote invocation.
- */
- private SecurityManager securityManager;
-
- /*--------------------------------------------
- | C O N S T R U C T O R S |
- ============================================*/
-
- /*--------------------------------------------
- | A C C E S S O R S / M O D I F I E R S |
- ============================================*/
-
- public void setSecurityManager(org.apache.shiro.mgt.SecurityManager securityManager) {
- this.securityManager = securityManager;
- }
-
- /*--------------------------------------------
- | M E T H O D S |
- ============================================*/
- @SuppressWarnings({"unchecked"})
- public Object invoke(final RemoteInvocation invocation, final Object targetObject)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-
- try {
- SecurityManager securityManager =
- this.securityManager != null ? this.securityManager : SecurityUtils.getSecurityManager();
-
- Subject.Builder builder = new Subject.Builder(securityManager);
-
- String host = (String) invocation.getAttribute(SecureRemoteInvocationFactory.HOST_KEY);
- if (host != null) {
- builder.host(host);
- }
-
- Serializable sessionId = invocation.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY);
- if (sessionId != null) {
- builder.sessionId(sessionId);
- } else {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("RemoteInvocation did not contain a Shiro Session id attribute under "
- + "key [" + SecureRemoteInvocationFactory.SESSION_ID_KEY + "]. A Subject based "
- + "on an existing Session will not be available during the method invocation.");
- }
- }
-
- Subject subject = builder.buildSubject();
- return subject.execute(new Callable() {
- public Object call() throws Exception {
- return SecureRemoteInvocationExecutor.super.invoke(invocation, targetObject);
- }
- });
- } catch (ExecutionException e) {
- Throwable cause = e.getCause();
- if (cause instanceof NoSuchMethodException) {
- throw (NoSuchMethodException) cause;
- } else if (cause instanceof IllegalAccessException) {
- throw (IllegalAccessException) cause;
- } else if (cause instanceof InvocationTargetException) {
- throw (InvocationTargetException) cause;
- } else {
- throw new InvocationTargetException(cause);
- }
- } catch (Throwable t) {
- throw new InvocationTargetException(t);
- }
- }
-}
diff --git a/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java b/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java
deleted file mode 100644
index 01de9e9d9..000000000
--- a/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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.shiro.spring.remoting;
-
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.session.Session;
-import org.apache.shiro.session.mgt.NativeSessionManager;
-import org.apache.shiro.session.mgt.SessionKey;
-import org.apache.shiro.session.mgt.SessionManager;
-import org.apache.shiro.subject.Subject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.remoting.support.DefaultRemoteInvocationFactory;
-import org.springframework.remoting.support.RemoteInvocation;
-import org.springframework.remoting.support.RemoteInvocationFactory;
-
-import java.io.Serializable;
-
-/**
- * A {@link RemoteInvocationFactory} that passes the session ID to the server via a
- * {@link RemoteInvocation} {@link RemoteInvocation#getAttribute(String) attribute}.
- * This factory is the client-side part of
- * the Shiro Spring remoting invocation. A {@link SecureRemoteInvocationExecutor} should
- * be used to export the server-side remote services to ensure that the appropriate
- * Subject and Session are bound to the remote thread during execution.
- *
- * @since 0.1
- */
-public class SecureRemoteInvocationFactory extends DefaultRemoteInvocationFactory {
-
- /**
- * session id key.
- */
- public static final String SESSION_ID_KEY = SecureRemoteInvocationFactory.class.getName() + ".SESSION_ID_KEY";
-
- /**
- * host key.
- */
- public static final String HOST_KEY = SecureRemoteInvocationFactory.class.getName() + ".HOST_KEY";
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SecureRemoteInvocationFactory.class);
- private static final String SESSION_ID_SYSTEM_PROPERTY_NAME = "shiro.session.id";
-
- private String sessionId;
-
- public SecureRemoteInvocationFactory() {
- }
-
- public SecureRemoteInvocationFactory(String sessionId) {
- this();
- this.sessionId = sessionId;
- }
-
- /**
- * Creates a {@link RemoteInvocation} with the current session ID as an
- * {@link RemoteInvocation#getAttribute(String) attribute}.
- *
- * @param mi the method invocation that the remote invocation should be based on.
- * @return a remote invocation object containing the current session ID as an attribute.
- */
- @SuppressWarnings({"checkstyle:CyclomaticComplexity", "checkstyle:NPathComplexity"})
- public RemoteInvocation createRemoteInvocation(MethodInvocation mi) {
-
- Serializable sessionId = null;
- String host = null;
- boolean sessionManagerMethodInvocation = false;
-
- //If the calling MI is for a remoting SessionManager delegate, we need to acquire the session ID from the method
- //argument and NOT interact with SecurityUtils/subject.getSession to avoid a stack overflow
- Class miDeclaringClass = mi.getMethod().getDeclaringClass();
- if (SessionManager.class.equals(miDeclaringClass) || NativeSessionManager.class.equals(miDeclaringClass)) {
- sessionManagerMethodInvocation = true;
- //for SessionManager calls, all method calls except the 'start' methods require a SessionKey
- // as the first argument, so just get it from there:
- if (!mi.getMethod().getName().equals("start")) {
- SessionKey key = (SessionKey) mi.getArguments()[0];
- sessionId = key.getSessionId();
- }
- }
-
- //tried the delegate. Use the injected session id if given
- if (sessionId == null) {
- sessionId = this.sessionId;
- }
-
- // If sessionId is null, only then try the Subject:
- if (sessionId == null) {
- try {
- // HACK Check if can get the securityManager - this'll cause an exception if it's not set
- SecurityUtils.getSecurityManager();
- if (!sessionManagerMethodInvocation) {
- Subject subject = SecurityUtils.getSubject();
- Session session = subject.getSession(false);
- if (session != null) {
- sessionId = session.getId();
- host = session.getHost();
- }
- }
- } catch (Exception e) {
- LOGGER.trace("No security manager set. Trying next to get session id from system property");
- }
- }
- //No call to the sessionManager, and the Subject doesn't have a session. Try a system property
- //as a last result:
- if (sessionId == null) {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.trace("No Session found for the currently executing subject via subject.getSession(false). "
- + "Attempting to revert back to the 'shiro.session.id' system property...");
- }
- sessionId = System.getProperty(SESSION_ID_SYSTEM_PROPERTY_NAME);
- if (sessionId == null && LOGGER.isTraceEnabled()) {
- LOGGER.trace("No 'shiro.session.id' system property found. Heuristics have been exhausted; "
- + "RemoteInvocation will not contain a sessionId.");
- }
- }
-
- RemoteInvocation ri = new RemoteInvocation(mi);
- if (sessionId != null) {
- ri.addAttribute(SESSION_ID_KEY, sessionId);
- }
- if (host != null) {
- ri.addAttribute(HOST_KEY, host);
- }
-
- return ri;
- }
-}
diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroUrlPathHelper.java b/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroUrlPathHelper.java
deleted file mode 100644
index ecce70f7d..000000000
--- a/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroUrlPathHelper.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.shiro.spring.web;
-
-import org.apache.shiro.web.util.WebUtils;
-import org.springframework.web.util.UrlPathHelper;
-
-import jakarta.servlet.http.HttpServletRequest;
-
-/**
- * A Spring UrlPathHelper that uses Shiro's path resolution logic.
- *
- * @since 1.7.0
- */
-public class ShiroUrlPathHelper extends UrlPathHelper {
-
- @Override
- public String getPathWithinApplication(HttpServletRequest request) {
- return WebUtils.getPathWithinApplication(request);
- }
-
- @Override
- public String getPathWithinServletMapping(HttpServletRequest request) {
- return WebUtils.getPathWithinApplication(request);
- }
-}
diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroRequestMappingConfig.java b/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroRequestMappingConfig.java
deleted file mode 100644
index 56f4cad08..000000000
--- a/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroRequestMappingConfig.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.shiro.spring.web.config;
-
-import org.apache.shiro.spring.web.ShiroUrlPathHelper;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
-
-@Configuration
-public class ShiroRequestMappingConfig {
-
- public ShiroRequestMappingConfig(
- @Qualifier("requestMappingHandlerMapping") RequestMappingHandlerMapping requestMappingHandlerMapping) {
- requestMappingHandlerMapping.setUrlPathHelper(new ShiroUrlPathHelper());
- }
-}
diff --git a/support/spring/src/test/groovy/org/apache/shiro/spring/web/ShiroUrlPathHelperTest.groovy b/support/spring/src/test/groovy/org/apache/shiro/spring/web/ShiroUrlPathHelperTest.groovy
deleted file mode 100644
index eb092bed5..000000000
--- a/support/spring/src/test/groovy/org/apache/shiro/spring/web/ShiroUrlPathHelperTest.groovy
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.shiro.spring.web
-
-import org.junit.jupiter.api.Test
-import org.springframework.mock.web.MockHttpServletRequest
-import org.springframework.web.util.UrlPathHelper
-
-import static org.hamcrest.MatcherAssert.assertThat
-import static org.hamcrest.Matchers.equalTo
-
-/**
- * Tests a couple known differences between the stock and the ShiroUrlPathHelper
- */
-class ShiroUrlPathHelperTest {
-
- @Test
- void testGetPathWithinApplication() {
- MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/%2e%2e")
- assertThat new UrlPathHelper().getPathWithinApplication(request), equalTo("/foo/..")
- assertThat new ShiroUrlPathHelper().getPathWithinApplication(request), equalTo("/")
- }
-
- @Test
- void testGetPathWithinServletMapping() {
- MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/%2e%2e")
- assertThat new UrlPathHelper().getPathWithinServletMapping(request), equalTo("/foo/..")
- assertThat new ShiroUrlPathHelper().getPathWithinServletMapping(request), equalTo("/")
- }
-}
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java b/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
deleted file mode 100644
index e06d83ab4..000000000
--- a/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.shiro.spring.remoting;
-
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.shiro.session.mgt.DefaultSessionKey;
-import org.apache.shiro.session.mgt.SessionKey;
-import org.apache.shiro.session.mgt.SessionManager;
-import org.apache.shiro.util.ThreadContext;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.springframework.remoting.support.RemoteInvocation;
-
-import java.lang.reflect.Method;
-import java.util.UUID;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-/**
- * //TODO - Class JavaDoc!
- */
-public class SecureRemoteInvocationFactoryTest {
-
- @BeforeEach
- public void setup() {
- ThreadContext.remove();
- }
-
- @AfterEach
- public void tearDown() {
- ThreadContext.remove();
- }
-
- protected Method getMethod(String name, Class clazz) {
- Method[] methods = clazz.getMethods();
- for (Method method : methods) {
- if (method.getName().equals(name)) {
- return method;
- }
- }
- throw new IllegalStateException("'" + name + "' method should exist.");
- }
-
- @Test
- void testSessionManagerProxyStartRemoteInvocation() throws Exception {
-
- SecureRemoteInvocationFactory factory = new SecureRemoteInvocationFactory();
-
- MethodInvocation mi = createMock(MethodInvocation.class);
- Method startMethod = getMethod("start", SessionManager.class);
- expect(mi.getMethod()).andReturn(startMethod).anyTimes();
-
- Object[] args = {"localhost"};
- expect(mi.getArguments()).andReturn(args).anyTimes();
-
- replay(mi);
-
- RemoteInvocation ri = factory.createRemoteInvocation(mi);
-
- verify(mi);
-
- assertThat(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY)).isNull();
- }
-
- @Test
- void testSessionManagerProxyNonStartRemoteInvocation() throws Exception {
-
- SecureRemoteInvocationFactory factory = new SecureRemoteInvocationFactory();
-
- MethodInvocation mi = createMock(MethodInvocation.class);
- Method method = getMethod("getSession", SessionManager.class);
- expect(mi.getMethod()).andReturn(method).anyTimes();
-
- String dummySessionId = UUID.randomUUID().toString();
- SessionKey sessionKey = new DefaultSessionKey(dummySessionId);
- Object[] args = {sessionKey};
- expect(mi.getArguments()).andReturn(args).anyTimes();
-
- replay(mi);
-
- RemoteInvocation ri = factory.createRemoteInvocation(mi);
-
- verify(mi);
-
- assertThat(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY)).isEqualTo(dummySessionId);
- }
-
- /*@Test
- public void testNonSessionManagerCall() throws Exception {
-
- SecureRemoteInvocationFactory factory = new SecureRemoteInvocationFactory();
-
- MethodInvocation mi = createMock(MethodInvocation.class);
- Method method = getMethod("login", SecurityManager.class);
- expect(mi.getMethod()).andReturn(method).anyTimes();
- }*/
-
-}
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java
index 9f34b5d35..224194deb 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AbstractAuthorizationAnnotationTest.java
@@ -40,7 +40,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOf
* @since 1.1
*/
@SpringJUnitConfig
-public abstract class AbstractAuthorizationAnnotationTest {
+abstract class AbstractAuthorizationAnnotationTest {
@Autowired
protected TestService testService;
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java
index a44ba4c13..f0fb90f62 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisorTest.java
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
-public class AuthorizationAttributeSourceAdvisorTest {
+class AuthorizationAttributeSourceAdvisorTest {
static class Secured {
@RequiresAuthentication
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java
index 5c2274ee8..b669b9423 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DapcAuthorizationAnnotationTest.java
@@ -34,7 +34,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOf
* @since 1.1
*/
@SpringJUnitConfig
-public class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
+class DapcAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
@Test
void testGuestInterfaceFailure() {
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java
index f6a4cc1e4..67d56c9f9 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/SchemaAuthorizationAnnotationTest.java
@@ -30,5 +30,5 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
* @since 1.1
*/
@SpringJUnitConfig
-public class SchemaAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
+class SchemaAuthorizationAnnotationTest extends AbstractAuthorizationAnnotationTest {
}
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java b/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java
index 6b746e87b..8541146d8 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java
@@ -35,6 +35,8 @@ import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,12 +51,11 @@ import static org.easymock.EasyMock.verify;
*
* @since 1.0
*/
-//@RunWith(SpringJUnit4ClassRunner.class)
-//@ContextConfiguration(locations = {"/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.xml"})
-public class ShiroFilterFactoryBeanTest {
-
+@SpringJUnitWebConfig
+@ContextConfiguration(locations = {"/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.xml"})
+class ShiroFilterFactoryBeanTest {
@Test
- void testFilterDefinition() {
+ void filterDefinition() {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.xml");
@@ -79,7 +80,7 @@ public class ShiroFilterFactoryBeanTest {
* @throws Exception if there is any unexpected error
*/
@Test
- void testFilterDefinitionWithInit() throws Exception {
+ void filterDefinitionWithInit() throws Exception {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.xml");
diff --git a/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java b/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationSameSiteStrictTest.java
similarity index 96%
rename from support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java
rename to support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationSameSiteStrictTest.java
index 1fc716fe5..0778081df 100644
--- a/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.java
+++ b/support/spring/src/test/java/org/apache/shiro/spring/web/config/ShiroWebConfigurationSameSiteStrictTest.java
@@ -29,17 +29,16 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
-@SpringJUnitConfig(classes = {EventBusTestConfiguration.class, RealmTestConfiguration.class, ShiroWebConfiguration.class})
@TestPropertySource
-public class ShiroWebConfigurationTestSameSiteStrict {
-
+@SpringJUnitConfig(classes = {EventBusTestConfiguration.class, RealmTestConfiguration.class, ShiroWebConfiguration.class})
+class ShiroWebConfigurationSameSiteStrictTest {
@Autowired
ShiroWebConfiguration shiroWebConfiguration;
@Test
void testStrictSameSite() {
// given
- // org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.properties
+ // org/apache/shiro/spring/web/config/ShiroWebConfigurationSameSiteStrictTest.properties
// then
assertThat(shiroWebConfiguration.sessionIdCookieSameSite).isEqualTo(Cookie.SameSiteOptions.STRICT);
diff --git a/support/spring/src/test/resources/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.properties b/support/spring/src/test/resources/org/apache/shiro/spring/web/config/ShiroWebConfigurationSameSiteStrictTest.properties
similarity index 100%
rename from support/spring/src/test/resources/org/apache/shiro/spring/web/config/ShiroWebConfigurationTestSameSiteStrict.properties
rename to support/spring/src/test/resources/org/apache/shiro/spring/web/config/ShiroWebConfigurationSameSiteStrictTest.properties