之前没在shiroConfig里加public FilterRegistrationBean singleSignOutFilter() ;可以实现单点登录,登出有问题,家里这个方法后,启动报错:

java.lang.IllegalArgumentException: casServerUrlPrefix cannot be null.

at org.jasig.cas.client.util.CommonUtils.assertNotNull(CommonUtils.java:87)

at org.jasig.cas.client.session.SingleSignOutHandler.init(SingleSignOutHandler.java:130)

at org.jasig.cas.client.session.SingleSignOutFilter.init(SingleSignOutFilter.java:54)

…………………………………

package com.audaque.gm.config;

import com.audaque.gm.modules.sys.shiro.ShiroPermsFilterFactoryBean;

import com.audaque.gm.modules.sys.shiro.UserFilter;

import com.audaque.gm.modules.sys.shiro.UserPermFilter;

import com.audaque.gm.modules.sys.sso.CallbackFilter;

import com.audaque.gm.modules.sys.sso.CasRealm;

import com.audaque.gm.support.shiro.listener.UserSessionListener;

import com.audaque.gm.support.shiro.session.UserSessionDAO;

import com.audaque.gm.support.shiro.session.UserSessionFactory;

import io.buji.pac4j.filter.LogoutFilter;

import io.buji.pac4j.filter.SecurityFilter;

import io.buji.pac4j.subject.Pac4jSubjectFactory;

import org.apache.shiro.mgt.SecurityManager;

import org.apache.shiro.session.SessionListener;

import org.apache.shiro.session.mgt.SessionManager;

import org.apache.shiro.session.mgt.eis.MemorySessionDAO;

import org.apache.shiro.session.mgt.eis.SessionDAO;

import org.apache.shiro.spring.LifecycleBeanPostProcessor;

import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;

import org.apache.shiro.spring.web.ShiroFilterFactoryBean;

import org.apache.shiro.web.mgt.DefaultWebSecurityManager;

import org.apache.shiro.web.servlet.SimpleCookie;

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import org.jasig.cas.client.session.SingleSignOutFilter;

import org.jasig.cas.client.session.SingleSignOutHttpSessionListener;

import org.pac4j.core.config.Config;

import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.boot.web.servlet.FilterRegistrationBean;

import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.DependsOn;

import org.springframework.core.Ordered;

import org.springframework.core.annotation.Order;

import org.springframework.stereotype.Component;

import org.springframework.web.filter.DelegatingFilterProxy;

import javax.servlet.DispatcherType;

import javax.servlet.Filter;

import java.util.*;

import java.util.Map.Entry;

/**

shiro配置

*/

@DependsOn(“springContextUtils”)

@Configuration

public class ShiroConfig {

/** 项目工程路径 */

@Value("${cas.project.url}")

private String projectUrl;

/** 项目cas服务路径 */

@Value("${cas.server.url}")

private String casServerUrl;

/** 客户端名称 */

@Value("${cas.client-name}")

private String clientName;

/**

安全管理器

@param sessionManager

@return

*/

@Bean

public SecurityManager securityManager(SessionManager sessionManager) {

DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();

securityManager.setSessionManager(sessionManager);

securityManager.setSubjectFactory(subjectFactory());

securityManager.setRealm(this.userRealm());

return securityManager;

}

/**

用户realm

@return

*/

@Bean

public CasRealm userRealm(){

CasRealm userRealm = new CasRealm();

//——新加代码开始——-

// 使用自定义的realm

userRealm.setClientName(clientName);

userRealm.setCachingEnabled(false);

//暂时不使用缓存

userRealm.setAuthenticationCachingEnabled(false);

userRealm.setAuthorizationCachingEnabled(false);

//———-新加代码结束———-

return userRealm;

}

/**

使用 pac4j 的 subjectFactory

@return

*/

@Bean

public Pac4jSubjectFactory subjectFactory(){

return new Pac4jSubjectFactory();

}

@Bean

public FilterRegistrationBean filterReg