Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lejingw/shiro-example
Browse files Browse the repository at this point in the history
git commit -m '1'Merge branch 'master' of github.com:lejingw/shiro-example
  • Loading branch information
lejingw committed Mar 15, 2014
2 parents ef79764 + 4578a74 commit 109d541
Show file tree
Hide file tree
Showing 18 changed files with 476 additions and 913 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<property name="authenticationCacheName" value="authenticationCache"/>
<property name="authorizationCachingEnabled" value="true"/>
<property name="authorizationCacheName" value="authorizationCache"/>
<property name="casServerUrlPrefix" value="https://localhost:8443/chapter14-server"/>
<property name="casService" value="https://localhost:9443/chapter14-client/cas"/>
<property name="casServerUrlPrefix" value="https://localhost:8443/chapter15-server"/>
<property name="casService" value="https://localhost:9443/chapter15-client/cas"/>
</bean>

<!--<bean id="casRealm" class="org.apache.shiro.cas.CasRealm">-->
Expand All @@ -41,8 +41,8 @@
<!--<property name="defaultPermissions" value="user:create,user:update"/>-->
<!--<property name="roleAttributeNames" value="roles"/>-->
<!--<property name="permissionAttributeNames" value="permissions"/>-->
<!--<property name="casServerUrlPrefix" value="https://localhost:8443/chapter14-server"/>-->
<!--<property name="casService" value="https://localhost:9443/chapter14-client/cas"/>-->
<!--<property name="casServerUrlPrefix" value="https://localhost:8443/chapter15-server"/>-->
<!--<property name="casService" value="https://localhost:9443/chapter15-client/cas"/>-->
<!--</bean>-->


Expand Down Expand Up @@ -95,6 +95,7 @@
</bean>

<bean id="casSubjectFactory" class="org.apache.shiro.cas.CasSubjectFactory"/>

<!-- 安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="casRealm"/>
Expand All @@ -117,7 +118,7 @@
<!-- Shiro的Web过滤器 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="https://localhost:8443/chapter14-server/login?service=https://localhost:9443/chapter14-client/cas"/>
<property name="loginUrl" value="https://localhost:8443/chapter15-server/login?service=https://localhost:9443/chapter15-client/cas"/>
<property name="successUrl" value="/"/>
<property name="filters">
<util:map>
Expand Down
1,075 changes: 190 additions & 885 deletions shiro-example-chapter15-server/cas.log

Large diffs are not rendered by default.

212 changes: 212 additions & 0 deletions shiro-example-chapter15-server/perfStats.log
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,215 @@ Tag Avg(ms) Min
Performance Statistics 2014-02-13 21:47:00 - 2014-02-13 21:48:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:25:00 - 2014-03-05 11:26:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:28:00 - 2014-03-05 11:29:00
Tag Avg(ms) Min Max Std Dev Count
AUTHENTICATE 26.0 26 26 0.0 1
CREATE_TICKET_GRANTING_TICKET 37.0 37 37 0.0 1
GRANT_SERVICE_TICKET 1.0 1 1 0.0 1

Performance Statistics 2014-03-05 11:29:00 - 2014-03-05 11:30:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:30:00 - 2014-03-05 11:31:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:31:00 - 2014-03-05 11:32:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:32:00 - 2014-03-05 11:33:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:33:00 - 2014-03-05 11:34:00
Tag Avg(ms) Min Max Std Dev Count
AUTHENTICATE 33.0 33 33 0.0 1
CREATE_TICKET_GRANTING_TICKET 33.0 33 33 0.0 1
GRANT_SERVICE_TICKET 0.0 0 0 0.0 1

Performance Statistics 2014-03-05 11:34:00 - 2014-03-05 11:35:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:35:00 - 2014-03-05 11:36:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:36:00 - 2014-03-05 11:37:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:37:00 - 2014-03-05 11:38:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:38:00 - 2014-03-05 11:39:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:44:00 - 2014-03-05 11:45:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:45:00 - 2014-03-05 11:46:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:46:00 - 2014-03-05 11:47:00
Tag Avg(ms) Min Max Std Dev Count
AUTHENTICATE 6.0 6 6 0.0 1
CREATE_TICKET_GRANTING_TICKET 18.0 18 18 0.0 1

Performance Statistics 2014-03-05 11:47:00 - 2014-03-05 11:48:00
Tag Avg(ms) Min Max Std Dev Count
AUTHENTICATE 0.0 0 0 0.0 1
CREATE_TICKET_GRANTING_TICKET 0.0 0 0 0.0 1
DESTROY_TICKET_GRANTING_TICKET 1.3 0 4 1.9 3

Performance Statistics 2014-03-05 11:48:00 - 2014-03-05 11:49:00
Tag Avg(ms) Min Max Std Dev Count
AUTHENTICATE 0.0 0 0 0.0 1
CREATE_TICKET_GRANTING_TICKET 0.0 0 0 0.0 1
DESTROY_TICKET_GRANTING_TICKET 14.0 14 14 0.0 1

Performance Statistics 2014-03-05 11:49:00 - 2014-03-05 11:50:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:50:00 - 2014-03-05 11:51:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:51:00 - 2014-03-05 11:52:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:52:00 - 2014-03-05 11:53:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:53:00 - 2014-03-05 11:54:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:54:00 - 2014-03-05 11:55:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:55:00 - 2014-03-05 11:56:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:56:00 - 2014-03-05 11:57:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:57:00 - 2014-03-05 11:58:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:58:00 - 2014-03-05 11:59:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 11:59:00 - 2014-03-05 12:00:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:00:00 - 2014-03-05 12:01:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:01:00 - 2014-03-05 12:02:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:02:00 - 2014-03-05 12:03:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:03:00 - 2014-03-05 12:04:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:04:00 - 2014-03-05 12:05:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:05:00 - 2014-03-05 12:06:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:06:00 - 2014-03-05 12:07:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:07:00 - 2014-03-05 12:08:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:08:00 - 2014-03-05 12:09:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:09:00 - 2014-03-05 12:10:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:10:00 - 2014-03-05 12:11:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:11:00 - 2014-03-05 12:12:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:12:00 - 2014-03-05 12:13:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:13:00 - 2014-03-05 12:14:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:14:00 - 2014-03-05 12:15:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:15:00 - 2014-03-05 12:16:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:16:00 - 2014-03-05 12:17:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:17:00 - 2014-03-05 12:18:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:18:00 - 2014-03-05 12:19:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:19:00 - 2014-03-05 12:20:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:20:00 - 2014-03-05 12:21:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:21:00 - 2014-03-05 12:22:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:22:00 - 2014-03-05 12:23:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:23:00 - 2014-03-05 12:24:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:24:00 - 2014-03-05 12:25:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:25:00 - 2014-03-05 12:26:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:26:00 - 2014-03-05 12:27:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:27:00 - 2014-03-05 12:28:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:28:00 - 2014-03-05 12:29:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:29:00 - 2014-03-05 12:30:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:30:00 - 2014-03-05 12:31:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:31:00 - 2014-03-05 12:32:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:32:00 - 2014-03-05 12:33:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:33:00 - 2014-03-05 12:34:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:34:00 - 2014-03-05 12:35:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:35:00 - 2014-03-05 12:36:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:36:00 - 2014-03-05 12:37:00
Tag Avg(ms) Min Max Std Dev Count

Performance Statistics 2014-03-05 12:37:00 - 2014-03-05 12:38:00
Tag Avg(ms) Min Max Std Dev Count

Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<property name="users">
<map>
<entry key="casuser" value="Mellon"/>
<entry key="zhang" value="123"/>
<entry key="wang" value="123"/>
</map>
</property>
</bean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.github.zhangkaitao.shiro.chapter16.dao.UserDao;
import com.github.zhangkaitao.shiro.chapter16.entity.User;

import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.*;
Expand Down Expand Up @@ -70,7 +72,9 @@ public List<User> findAll() {
* @param username
* @return
*/
//@Cacheable(value={"testCache"})
public User findByUsername(String username) {
System.out.println("--=--findByUsername");
return userDao.findByUsername(username);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public boolean supportsParameter(MethodParameter parameter) {
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
CurrentUser currentUserAnnotation = parameter.getParameterAnnotation(CurrentUser.class);
System.out.println("==================currentUserAnnotation.value()");
System.out.println(currentUserAnnotation.value());
return webRequest.getAttribute(currentUserAnnotation.value(), NativeWebRequest.SCOPE_REQUEST);
}
}
19 changes: 19 additions & 0 deletions shiro-example-chapter16/src/main/resources/ehcache/ehcache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@

<diskStore path="java.io.tmpdir"/>

<defaultCache
maxElementsInMemory="3000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="100"
memoryStoreEvictionPolicy="LRU"
/>
<cache name="testCache"
maxElementsInMemory="3000"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="36000"
timeToLiveSeconds="36000"
memoryStoreEvictionPolicy="LFU"
/>

<!-- 登录记录缓存 锁定10分钟 -->
<cache name="passwordRetryCache"
maxEntriesLocalHeap="2000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#dataSource configure
connection.url=jdbc:mysql://localhost:3306/shiro2
connection.url=jdbc:mysql://localhost:3306/shiro
connection.username=root
connection.password=
connection.password=111111

#druid datasource
#²Î¿¼ https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_DruidDataSource%E5%8F%82%E8%80%83%E9%85%8D%E7%BD%AE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">

<bean id="springCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcacheManager"/>
Expand All @@ -11,6 +14,5 @@
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache/ehcache.xml"/>
</bean>


<cache:annotation-driven cache-manager="springCacheManager" />
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<!-- 凭证匹配器 -->
<bean id="credentialsMatcher" class="com.github.zhangkaitao.shiro.chapter16.credentials.RetryLimitHashedCredentialsMatcher">
<constructor-arg ref="cacheManager"/>
<property name="hashAlgorithmName" value="md5"/>
<property name="hashIterations" value="2"/>
<property name="hashAlgorithmName" value="${password.algorithmName}"/>
<property name="hashIterations" value="${password.hashIterations}"/>
<property name="storedCredentialsHexEncoded" value="true"/>
</bean>

Expand Down
Loading

0 comments on commit 109d541

Please sign in to comment.