001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.shiro.spring.config.web.autoconfigure; 020 021import java.util.List; 022 023import org.apache.shiro.authc.Authenticator; 024import org.apache.shiro.authc.pam.AuthenticationStrategy; 025import org.apache.shiro.authz.Authorizer; 026import org.apache.shiro.mgt.RememberMeManager; 027import org.apache.shiro.mgt.SessionStorageEvaluator; 028import org.apache.shiro.mgt.SessionsSecurityManager; 029import org.apache.shiro.mgt.SubjectDAO; 030import org.apache.shiro.mgt.SubjectFactory; 031import org.apache.shiro.realm.Realm; 032import org.apache.shiro.session.mgt.SessionFactory; 033import org.apache.shiro.session.mgt.SessionManager; 034import org.apache.shiro.session.mgt.eis.SessionDAO; 035import org.apache.shiro.spring.boot.autoconfigure.ShiroAutoConfiguration; 036import org.apache.shiro.spring.web.ShiroUrlPathHelper; 037import org.apache.shiro.spring.web.config.AbstractShiroWebConfiguration; 038import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; 039import org.apache.shiro.web.servlet.Cookie; 040import org.springframework.boot.autoconfigure.AutoConfigureAfter; 041import org.springframework.boot.autoconfigure.AutoConfigureBefore; 042import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 043import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 044import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; 045import org.springframework.context.annotation.Bean; 046import org.springframework.context.annotation.Configuration; 047 048/** 049 * @since 1.4.0 050 */ 051@Configuration 052@AutoConfigureBefore(ShiroAutoConfiguration.class) 053@AutoConfigureAfter(ShiroWebMvcAutoConfiguration.class) 054@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) 055@ConditionalOnProperty(name = "shiro.web.enabled", matchIfMissing = true) 056public class ShiroWebAutoConfiguration extends AbstractShiroWebConfiguration { 057 058 @Bean 059 @ConditionalOnMissingBean 060 @Override 061 protected AuthenticationStrategy authenticationStrategy() { 062 return super.authenticationStrategy(); 063 } 064 065 @Bean 066 @ConditionalOnMissingBean 067 @Override 068 protected Authenticator authenticator() { 069 return super.authenticator(); 070 } 071 072 @Bean 073 @ConditionalOnMissingBean 074 @Override 075 protected Authorizer authorizer() { 076 return super.authorizer(); 077 } 078 079 @Bean 080 @ConditionalOnMissingBean 081 @Override 082 protected SubjectDAO subjectDAO() { 083 return super.subjectDAO(); 084 } 085 086 @Bean 087 @ConditionalOnMissingBean 088 @Override 089 protected SessionStorageEvaluator sessionStorageEvaluator() { 090 return super.sessionStorageEvaluator(); 091 } 092 093 @Bean 094 @ConditionalOnMissingBean 095 @Override 096 protected SubjectFactory subjectFactory() { 097 return super.subjectFactory(); 098 } 099 100 @Bean 101 @ConditionalOnMissingBean 102 @Override 103 protected SessionFactory sessionFactory() { 104 return super.sessionFactory(); 105 } 106 107 @Bean 108 @ConditionalOnMissingBean 109 @Override 110 protected SessionDAO sessionDAO() { 111 return super.sessionDAO(); 112 } 113 114 @Bean 115 @ConditionalOnMissingBean 116 @Override 117 protected SessionManager sessionManager() { 118 return super.sessionManager(); 119 } 120 121 @Bean 122 @ConditionalOnMissingBean 123 @Override 124 protected SessionsSecurityManager securityManager(List<Realm> realms) { 125 return super.securityManager(realms); 126 } 127 128 @Bean 129 @ConditionalOnMissingBean(name = "sessionCookieTemplate") 130 @Override 131 protected Cookie sessionCookieTemplate() { 132 return super.sessionCookieTemplate(); 133 } 134 135 @Bean 136 @ConditionalOnMissingBean 137 @Override 138 protected RememberMeManager rememberMeManager() { 139 return super.rememberMeManager(); 140 } 141 142 @Bean 143 @ConditionalOnMissingBean(name = "rememberMeCookieTemplate") 144 @Override 145 protected Cookie rememberMeCookieTemplate() { 146 return super.rememberMeCookieTemplate(); 147 } 148 149 @Bean 150 @ConditionalOnMissingBean 151 @Override 152 protected ShiroFilterChainDefinition shiroFilterChainDefinition() { 153 return super.shiroFilterChainDefinition(); 154 } 155 156 @Bean 157 @ConditionalOnMissingBean 158 @Override 159 protected ShiroUrlPathHelper shiroUrlPathHelper() { 160 return super.shiroUrlPathHelper(); 161 } 162}