diff --git a/tigon-shiro-cas/src/main/resources/spring/spring-shiro-cas.xml b/tigon-shiro-cas/src/main/resources/spring/spring-shiro-cas.xml index a4e690b..50b5b8d 100644 --- a/tigon-shiro-cas/src/main/resources/spring/spring-shiro-cas.xml +++ b/tigon-shiro-cas/src/main/resources/spring/spring-shiro-cas.xml @@ -19,13 +19,13 @@ - - + + - + @@ -35,34 +35,45 @@ - - - + + - + - - + - + - - - - + + + + + + + + + + + + + + + + + diff --git a/tigon-shiro-core/pom.xml b/tigon-shiro-core/pom.xml index 5f95473..95f9031 100644 --- a/tigon-shiro-core/pom.xml +++ b/tigon-shiro-core/pom.xml @@ -21,6 +21,10 @@ org.springframework.boot spring-boot + + org.springframework + spring-web + me.chyxion.tigon tigon-sequence diff --git a/tigon-shiro-core/src/main/java/me/chyxion/tigon/shiro/FilterChainDefinitionMap.java b/tigon-shiro-core/src/main/java/me/chyxion/tigon/shiro/FilterChainDefinitionMap.java index 751306e..279d2ae 100644 --- a/tigon-shiro-core/src/main/java/me/chyxion/tigon/shiro/FilterChainDefinitionMap.java +++ b/tigon-shiro-core/src/main/java/me/chyxion/tigon/shiro/FilterChainDefinitionMap.java @@ -1,13 +1,9 @@ package me.chyxion.tigon.shiro; +import java.util.*; import lombok.Getter; -import lombok.Setter; -import java.util.Set; -import java.util.Properties; import java.io.IOException; import java.io.InputStream; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import lombok.extern.slf4j.Slf4j; import javax.annotation.PostConstruct; import org.springframework.core.io.Resource; @@ -19,43 +15,57 @@ import org.springframework.core.io.Resource; */ @Slf4j @Getter -@Setter -public class FilterChainDefinitionMap extends LinkedHashMap { - private Resource configLocation; +public class FilterChainDefinitionMap extends LinkedHashMap { + private final Resource configLocation; - @PostConstruct - void init() throws IOException { + public FilterChainDefinitionMap(final Resource configLocation) { + this.configLocation = configLocation; + } + + public FilterChainDefinitionMap(final Resource configLocation, final Map map) { + super(map); + this.configLocation = configLocation; + } + + @PostConstruct + void init() throws IOException { log.info("Load shiro filter chain definition from config location [{}].", configLocation); - final InputStream authIn = configLocation != null && configLocation.exists() ? - configLocation.getInputStream() : - FilterChainDefinitionMap.class - .getResourceAsStream("/shiro/auth.properties"); - - if (authIn != null) { - final Properties props = new OrderedProperties(); - try { - props.load(authIn); - } - catch (IOException e) { - throw new IllegalStateException( - "Load shiro filter chain definition config error caused", e); - } - finally { - if (authIn != null) { - try { - authIn.close(); - } - catch (IOException e) { - // ignore + if (configLocation != null && configLocation.exists()) { + final InputStream authIn = configLocation.getInputStream(); + if (authIn != null) { + final Properties props = new OrderedProperties(); + try { + props.load(authIn); + } + catch (final IOException e) { + throw new IllegalStateException( + "Load shiro filter chain definition config error caused", e); + } + finally { + if (authIn != null) { + try { + authIn.close(); + } + catch (IOException e) { + // ignore + } } } - } - for (String name : props.stringPropertyNames()) { - put(name, props.getProperty(name)); + for (final String path : props.stringPropertyNames()) { + final String auth = props.getProperty(path); + log.info("Shiro filter chain definition [{}] -> [{}] added.", path, auth); + put(path, auth); + } } - } + else { + log.info("No input stream load from shiro filter chain definition config location [{}], ignore.", configLocation); + } + } + else { + log.info("Shiro filter chain definition config location [{}] does not exist, ignore.", configLocation); + } } @Slf4j diff --git a/tigon-shiro-core/src/main/resources/spring/spring-tigon-shiro-core.xml b/tigon-shiro-core/src/main/resources/spring/spring-tigon-shiro-core.xml index ea43565..36aaa0b 100644 --- a/tigon-shiro-core/src/main/resources/spring/spring-tigon-shiro-core.xml +++ b/tigon-shiro-core/src/main/resources/spring/spring-tigon-shiro-core.xml @@ -17,26 +17,26 @@ + value="${tigon.shiro.session.timeout:1800000}"/> + value="${tigon.shiro.session.validation.scheduler.enabled:false}" /> + value="${tigon.shiro.session.validation.interval:3600000}" /> - - + + - - - - - - - - + + + + + + + + @@ -45,14 +45,13 @@ - - - + + + - + @@ -63,13 +62,13 @@ - + - +