You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.6 KiB
94 lines
2.6 KiB
3 years ago
|
/*
|
||
|
* Copyright (C), 2018-2021
|
||
|
* Project: starter
|
||
|
* FileName: SSOFilter
|
||
|
* Author: xx
|
||
|
* Date: 2021/12/16 15:01
|
||
|
*/
|
||
|
package com.fr.plugin.fbpa.request;
|
||
|
|
||
|
import com.fanruan.api.i18n.I18nKit;
|
||
|
import com.fanruan.api.log.LogKit;
|
||
|
import com.fr.base.ServerConfig;
|
||
|
import com.fr.decision.fun.GlobalRequestFilterProvider;
|
||
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.plugin.fbpa.config.FbpaConfig;
|
||
|
import org.jetbrains.annotations.NotNull;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/**
|
||
|
* <Function Description><br>
|
||
|
* <SSOFilter>
|
||
|
*
|
||
|
* @author xx
|
||
|
* @since 1.0.0
|
||
|
*/
|
||
|
public class SSOFilter extends AbstractGlobalRequestFilterProvider {
|
||
|
|
||
|
public static final String LOGIN_URL = "edu.yale.its.tp.cas.client.filter.loginUrl";
|
||
|
public static final String VALIDATE_URL = "edu.yale.its.tp.cas.client.filter.validateUrl";
|
||
|
public static final String SERVER_NAME = "edu.yale.its.tp.cas.client.filter.serverName";
|
||
|
|
||
|
/**
|
||
|
* 过滤器名称
|
||
|
*
|
||
|
* @return
|
||
|
*/
|
||
|
@Override
|
||
|
public String filterName() {
|
||
|
return "B_SSOFilter";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 过滤规则
|
||
|
*
|
||
|
* @return
|
||
|
*/
|
||
|
@Override
|
||
|
public String[] urlPatterns() {
|
||
|
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) {
|
||
|
LogKit.error(I18nKit.getLocText("Plugin-fbpa_Licence_Expired"));
|
||
|
return new String[]{};
|
||
|
}
|
||
|
return new String[]{"/" + ServerConfig.getInstance().getServletName()};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 外部的过滤器类名,需要把相应的jar包放到web服务器的classpath中
|
||
|
*
|
||
|
* @return 类名
|
||
|
*/
|
||
|
@Override
|
||
|
public String externalFilterClassName() {
|
||
|
return "edu.yale.its.tp.cas.client.filter.CASFilter";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 过滤器的初始化参数
|
||
|
*
|
||
|
* @return 参数集合
|
||
|
*/
|
||
|
@Override
|
||
|
public Map<String, String> initializationParameters() {
|
||
|
Map<String, String> params = new HashMap<>();
|
||
|
FbpaConfig config = FbpaConfig.getInstance();
|
||
|
params.put(LOGIN_URL, config.getLoginUrl());
|
||
|
params.put(VALIDATE_URL, config.getValidateUrl());
|
||
|
params.put(SERVER_NAME, config.getServerName());
|
||
|
return params;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 可选实现的多个filter排序(执行顺序)的方法
|
||
|
*
|
||
|
* @param other
|
||
|
* @return 0 相等,大于0是自身优先 小于0 是other优先
|
||
|
*/
|
||
|
@Override
|
||
|
public int compareTo(@NotNull GlobalRequestFilterProvider other) {
|
||
|
return super.compareTo(other);
|
||
|
}
|
||
|
}
|