Commit 5b6f71c9 authored by 周毅's avatar 周毅

适配framework改动

parent d36d86fb
......@@ -7,7 +7,6 @@ import javax.servlet.Filter;
import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.cache.MemoryConstrainedCacheManager;
import org.apache.shiro.cas.CasSubjectFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator;
import org.apache.shiro.session.mgt.eis.SessionIdGenerator;
......@@ -29,10 +28,6 @@ import com.gavel.common.Constants;
import com.gavel.common.utils.StringUtils;
import com.gavel.framework.filter.GavelCommonLogoutFilter;
import com.gavel.framework.filter.ShiroAuthFilter;
import com.gavel.kzzx.auth.cas.GavelAuthenticationFilter;
import com.gavel.kzzx.auth.cas.GavelCasFilter;
import com.gavel.kzzx.auth.cas.GavelCasRealm;
import com.gavel.kzzx.auth.cas.GavelLogoutFilter;
import com.gavel.kzzx.auth.shiro.GavelAuthResource;
import com.gavel.kzzx.auth.shiro.GavelAuthorizationAttributeSourceAdvisor;
import com.gavel.kzzx.auth.shiro.GavelAuthorizingRealm;
......@@ -43,14 +38,6 @@ import com.gavel.kzzx.auth.shiro.GavelSessionManager;
@Configuration
public class ShiroConfig {
private static final String CAS_FILTER_URL = "/shiro-cas";
@Value("${sso.enable:false}")
private boolean ssoEnable;
@Value("${sso.server:}")
private String casServerUrl;
@Value("${shiro.cache:}")
private String cacheType;
......@@ -79,49 +66,22 @@ public class ShiroConfig {
// 登录成功后要跳转的链接
shiroFilterFactoryBean.setSuccessUrl("/index");
if ( ssoEnable ) {
Map<String, Filter> filters = new LinkedHashMap<>();
shiroFilterFactoryBean.setFilters(filters);
filters.put("casFilter", new GavelCasFilter(casServerUrl));
filters.put("logout", new GavelLogoutFilter(casServerUrl, ssoEnable));
filters.put("authFilter", new GavelAuthenticationFilter(casServerUrl, ssoEnable));
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put(CAS_FILTER_URL, "casFilter");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/file/**", "anon");
filterChainDefinitionMap.put("/api/**", "anon");
filterChainDefinitionMap.put("/video.html", "anon");
filterChainDefinitionMap.put("/static/**", "anon");
filterChainDefinitionMap.put("/api/**", "anon");
filterChainDefinitionMap.put("/css/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/images/**", "anon");
filterChainDefinitionMap.put("/lib/**", "anon");
filterChainDefinitionMap.put("/fonts/**", "anon");
filterChainDefinitionMap.put("/mock/**", "anon");
filterChainDefinitionMap.put("/**", "authFilter");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
}
else {
// 设置login URL
shiroFilterFactoryBean.setLoginUrl("/login_view");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
shiroFilterFactoryBean.setSuccessUrl("/index");
Map<String, Filter> filters = new LinkedHashMap<>();
filters.put("permFilter", new ShiroAuthFilter());
filters.put("logout", new GavelCommonLogoutFilter());
shiroFilterFactoryBean.setFilters(filters);
Map<String, String> filterChainDefinitionMap = GavelAuthResource.init();
filterChainDefinitionMap.put("/kmes/gpfk/login", "anon");
filterChainDefinitionMap.put("/kmes/gpfk/testFeedBack", "anon");
filterChainDefinitionMap.put("/loginscan_view", "anon");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/**", "permFilter");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
// 设置login URL
shiroFilterFactoryBean.setLoginUrl("/login_view");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
shiroFilterFactoryBean.setSuccessUrl("/index");
}
Map<String, Filter> filters = new LinkedHashMap<>();
filters.put("permFilter", new ShiroAuthFilter());
filters.put("logout", new GavelCommonLogoutFilter());
shiroFilterFactoryBean.setFilters(filters);
Map<String, String> filterChainDefinitionMap = GavelAuthResource.init();
filterChainDefinitionMap.put("/kmes/gpfk/login", "anon");
filterChainDefinitionMap.put("/kmes/gpfk/testFeedBack", "anon");
filterChainDefinitionMap.put("/loginscan_view", "anon");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/**", "permFilter");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
......@@ -144,35 +104,11 @@ public class ShiroConfig {
return shiroRealm;
}
@Bean(name = "casRealm")
public GavelCasRealm casRealm() {
GavelCasRealm casRealm = new GavelCasRealm();
// 认证通过后的默认角色
casRealm.setDefaultRoles("ROLE_USER");
// cas 服务端地址前缀
casRealm.setCasServerUrlPrefix(casServerUrl);
// 应用服务地址,用来接收cas服务端票证
// casRealm.setCasService(appServerUrl + CAS_FILTER_URL);
return casRealm;
}
@Bean("securityManager")
public SecurityManager securityManager(GavelCasRealm casRealm) {
public SecurityManager securityManager() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
// 注入自定义的realm;
if ( ssoEnable ) {
// 设置授权策略,此步骤必须在设置realm的前面,不然会报错realm未配置
//securityManager.setAuthenticator(authenticator);
securityManager.setSubjectFactory(new CasSubjectFactory());
// 设置自定义验证策略
securityManager.setRealm(casRealm);
} else {
securityManager.setRealm(shiroRealm());
}
securityManager.setRealm(shiroRealm());
// 注入缓存管理器;
if (StringUtils.equals(cacheType, "redis")){
securityManager.setCacheManager(redisCacheManager());
......
......@@ -22,7 +22,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.SystemOperation;
import com.gavel.common.annotation.ResourcePermissions;
import com.gavel.common.attachment.persistent.Attachment;
import com.gavel.common.base.controller.BaseController;
import com.gavel.common.utils.ThreadContext;
import com.gavel.gygl.service.BzgxService;
......@@ -40,7 +39,7 @@ public class BzgxFjController extends BaseController {
@RequestMapping(value = "attachment/list", method = RequestMethod.POST)
@ResponseBody
public Object attachmentListSub(@RequestBody JSONObject param) {
return buildReturnData(getAttachmentListSub(ATTACHMENT_FOLDER, param), Attachment.class);
return buildReturnData(getAttachmentListSub(ATTACHMENT_FOLDER, param));
}
@ResourcePermissions({SystemOperation.BottonResource.ADD, SystemOperation.BottonResource.EDIT})
......
......@@ -22,7 +22,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.SystemOperation;
import com.gavel.common.annotation.ResourcePermissions;
import com.gavel.common.attachment.persistent.Attachment;
import com.gavel.common.base.controller.BaseController;
import com.gavel.common.utils.ThreadContext;
import com.gavel.gygl.service.GylxService;
......@@ -40,7 +39,7 @@ public class GylxFjController extends BaseController {
@RequestMapping(value = "attachment/list", method = RequestMethod.POST)
@ResponseBody
public Object attachmentListSub(@RequestBody JSONObject param) {
return buildReturnData(getAttachmentListSub(ATTACHMENT_FOLDER, param), Attachment.class);
return buildReturnData(getAttachmentListSub(ATTACHMENT_FOLDER, param));
}
@ResourcePermissions({SystemOperation.BottonResource.ADD, SystemOperation.BottonResource.EDIT})
......
package com.gavel.kwell.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
......@@ -8,17 +7,15 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.gavel.common.Constants;
import com.gavel.common.attachment.persistent.Attachment;
import com.gavel.common.attachment.service.AttachmentService;
import com.gavel.common.attachment.vo.AttachmentVO;
import com.gavel.common.base.entity.BaseEntity;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.business.service.CommonService;
......@@ -33,7 +30,6 @@ import com.gavel.common.utils.StringUtils;
import com.gavel.common.utils.ThreadContext;
import com.gavel.common.utils.UserInfoUtil;
import com.gavel.framework.service.FrameService;
import com.gavel.framework.utils.JwtUtil;
import com.gavel.gygl.persistent.Bzgx;
import com.gavel.gygl.service.BzgxService;
import com.gavel.gygl.utils.GyglParamEnum;
......@@ -53,7 +49,6 @@ import com.gavel.kwell.service.GpfkService;
import com.gavel.kwell.service.GpfkjgService;
import com.gavel.kwell.service.GphyService;
import com.gavel.kwell.utils.GpfkFklxEnum;
import com.gavel.kwell.utils.GpfkHgEnum;
import com.gavel.kwell.utils.HzGylxEnum;
import com.gavel.kwell.utils.SmCodeEnum;
import com.gavel.kwell.utils.SmCodeModel;
......@@ -74,6 +69,7 @@ import com.gavel.kzzx.dao.UserDao;
import com.gavel.kzzx.persistent.User;
import com.gavel.kzzx.service.UserRoleService;
import com.gavel.kzzx.service.YymkService;
import com.gavel.kzzx.utils.JwtUtil;
import com.gavel.kzzx.vo.UserRoleCondition;
import com.gavel.kzzx.vo.UserRoleVO;
import com.gavel.kzzx.vo.YymkCondition;
......@@ -786,7 +782,7 @@ public class GpfkServiceImpl extends BaseEditServiceImpl implements GpfkService
public Attachment queryWoGylxFj(String woid,String bzlx) {
GylxVO gylx = queryKwellWoStandGylx(woid, bzlx);
if(gylx!=null) {
List<Attachment> list =attachmentService.getAttachmentAndSubFolder(gylx.getId(), "gylx");
List<AttachmentVO> list =attachmentService.getAttachmentAndSubFolder(gylx.getId(), "gylx");
if(list!=null&&list.size()>0) {
return list.get(0);
}
......@@ -846,7 +842,7 @@ public class GpfkServiceImpl extends BaseEditServiceImpl implements GpfkService
addReturnData("appName", commonService.getApplicationName());
addReturnData(Constants.UserInfo.TOKEN, token);
addReturnData("roles", roles);
UserInfoUtil.tokenUserMap.put(token, userInfo);
// UserInfoUtil.tokenUserMap.put(token, userInfo);
frameService.login(user.getUserid(), user.getPassword());
// UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(StringUtils.upperCase(user.getUserid()), user.getPassword());
// SecurityUtils.getSubject().login(usernamePasswordToken);
......
......@@ -12,9 +12,8 @@ import com.gavel.common.attachment.persistent.Attachment;
import com.gavel.common.attachment.persistent.Folder;
import com.gavel.common.attachment.service.AttachmentFolderService;
import com.gavel.common.attachment.service.AttachmentService;
import com.gavel.common.attachment.vo.AttachmentVO;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.gygl.dao.BzgxDao;
import com.gavel.gygl.persistent.Bzgx;
import com.gavel.gygl.vo.GylxVO;
import com.gavel.kwell.dao.GpfkDao;
import com.gavel.kwell.service.GpfkfjService;
......@@ -52,19 +51,19 @@ public class GpfkfjServiceImpl extends BaseEditServiceImpl implements GpfkfjServ
// Bzgx bzgxVo = bzgxDao.queryById(Bzgx.class, bzgxid);
if(gylxVO!=null&&StringUtils.isNotEmpty(type)) {
if(type.equals(ZDS1_BZ)) {
List<Attachment> list =attachmentService.getAttachmentAndSubFolder(gylxVO.getId(), ZDS1_FLODER);
List<AttachmentVO> list =attachmentService.getAttachmentAndSubFolder(gylxVO.getId(), ZDS1_FLODER);
if(list!=null&&list.size()>0) {
return list.get(0);
}
}
else if(type.equals(ZDS2_BZ)) {
List<Attachment> list =attachmentService.getAttachmentAndSubFolder(gylxVO.getId(), ZDS2_FLODER);
List<AttachmentVO> list =attachmentService.getAttachmentAndSubFolder(gylxVO.getId(), ZDS2_FLODER);
if(list!=null&&list.size()>0) {
return list.get(0);
}
}
else if(type.equals(SP_BZ)) {
List<Attachment> list =attachmentService.getAttachmentAndSubFolder(gylxVO.getId(), SP_FLODER);
List<AttachmentVO> list =attachmentService.getAttachmentAndSubFolder(gylxVO.getId(), SP_FLODER);
if(list!=null&&list.size()>0) {
return list.get(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment