Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-28 16:31:26 +08:00
commit 22cb72b0bf
5 changed files with 105 additions and 9 deletions

View File

@ -50,6 +50,7 @@ import okhttp3.*;
import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@ -1063,9 +1064,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
ArrayList cameraList = new ArrayList();
applicationEntities.forEach(index -> {
List<CameraChannelDto1> channelDto1s = cameraChannelMapper.selectByChannelCode(index.getCameraList().replaceAll("\"", ""));
if (!channelDto1s.isEmpty()) {
cameraList.add(channelDto1s.get(0));
//List<CameraChannelDto1> channelDto1s = cameraChannelMapper.selectByChannelCode(index.getCameraList().replaceAll("\"", ""));
CameraChannelDto1 channelDto1s = JSON.toJavaObject(JSON.parseObject(index.getCameraList()), CameraChannelDto1.class);
if (ObjectUtils.allNotNull(channelDto1s)) {
cameraList.add(channelDto1s);
}
});
return cameraList;

View File

@ -2,6 +2,7 @@ package io.renren.modules.security.config;
import io.renren.modules.security.oauth2.Oauth2Filter;
import io.renren.modules.security.oauth2.Oauth2Realm;
import io.renren.modules.security.oauth2.ShiroSessionManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
@ -9,6 +10,7 @@ import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSource
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -26,13 +28,21 @@ public class ShiroConfig {
// @Autowired
// private Oauth2Filter oauth2Filter;
//@Autowired
//private ShiroSessionManager shiroSessionManager;
//@Bean
//public DefaultWebSessionManager sessionManager() {
// DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
// sessionManager.setSessionValidationSchedulerEnabled(false);
// sessionManager.setSessionIdUrlRewritingEnabled(false);
// sessionManager.setGlobalSessionTimeout(-1000l);
// return sessionManager;
//}
@Bean
public DefaultWebSessionManager sessionManager() {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionValidationSchedulerEnabled(false);
sessionManager.setSessionIdUrlRewritingEnabled(false);
sessionManager.setGlobalSessionTimeout(-1000l);
return sessionManager;
return new ShiroSessionManager();
}
@Bean("securityManager")
@ -77,6 +87,9 @@ public class ShiroConfig {
filterMap.put("/bsabilityrecord/**", "anon");
filterMap.put("/act/his/getInstImage", "anon");
filterMap.put("/resource/getApplyCameraList/**", "anon");
filterMap.put("/resource/hls/getHls", "anon");
/**
* 资源上传
*/

View File

@ -1,6 +1,5 @@
package io.renren.modules.security.oauth2;
import cn.hutool.core.util.URLUtil;
import org.apache.commons.lang3.StringUtils;
import org.jasig.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.TicketValidationException;

View File

@ -0,0 +1,81 @@
package io.renren.modules.security.oauth2;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.SessionContext;
import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.apache.shiro.web.util.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
//@Component
public class ShiroSessionManager extends DefaultWebSessionManager {
/**
* 返回客户端的
*/
public final String TOKEN_NAME = "token";
/**
* 这个是客户端请求给服务端带的header
*/
public final static String HEADER_TOKEN_NAME = "token";
public final static Logger log = LoggerFactory.getLogger(ShiroSessionManager.class);
private static final String REFERENCED_SESSION_ID_SOURCE = "Stateless request";
/**
* 重写getSessionId,分析请求头中的指定参数做用户凭证sessionId
*/
@Override
protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
String sessionId = WebUtils.toHttp(request).getHeader(HEADER_TOKEN_NAME);
log.info("获取的sessionId为" + sessionId);
if (StringUtils.isEmpty(sessionId)) {
return super.getSessionId(request, response);
} else {
//如果请求头中有 token 则其值为sessionId
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, REFERENCED_SESSION_ID_SOURCE);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, sessionId);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
return sessionId;
}
}
/*@Override
protected void onStart(Session session, SessionContext context) {
log.info("执行onStart");
if (!WebUtils.isHttp(context)) {
log.debug("SessionContext argument is not HTTP compatible or does not have an HTTP request/response pair. No session ID cookie will be set.");
} else {
HttpServletRequest request = WebUtils.getHttpRequest(context);
HttpServletResponse response = WebUtils.getHttpResponse(context);
Serializable sessionId = session.getId();
this.storeSessionId(sessionId, request, response);
request.removeAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_IS_NEW, Boolean.TRUE);
}
}
*//**
* 把sessionId 放入 response header
* onStart时调用
* 没有sessionid时 会产生sessionid 并放入 response header中
*//*
private void storeSessionId(Serializable currentId, HttpServletRequest ignored, HttpServletResponse response) {
if (currentId == null) {
String msg = "sessionId cannot be null when persisting for subsequent requests.";
throw new IllegalArgumentException(msg);
} else {
String idString = currentId.toString();
response.setHeader(this.TOKEN_NAME, idString);
log.info("Set session ID header for session with id {}", idString);
log.trace("Set session ID header for session with id {}", idString);
}
}*/
}

View File

@ -0,0 +1 @@
REPLACE INTO `tb_data_resource`(`id`, `type`, `name`, `description`, `link`, `api_method_type`, `api_url`, `group_id`, `dept_id`, `dept_contacts`, `dept_phone`, `share_type`, `share_mode`, `share_condition`, `district_id`, `visits`, `del_flag`, `creator`, `create_date`, `updater`, `update_date`, `note1`, `note2`, `note3`, `note4`, `note5`, `enclosure`, `undercarriage_reason`, `undercarriage_user_name`, `info_list`, `total`, `visitor`, `apply_number`, `undercarriage_enclosure`) VALUES (8888888880000000001, '基础设施', '申请摄像头', NULL, '', NULL, NULL, NULL, 1067246875800000066, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, '2022-07-04 18:23:47', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', 13, 5, NULL, NULL);