Commit 13f6616c authored by beilang's avatar beilang

2023-11-24

parent d07ec9f4
package com.ces.framework.config;
import com.ces.framework.shiro.filter.CustomShiroFilterFactoryBean;
import com.ces.framework.shiro.realm.UserRealm;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
......@@ -74,7 +75,7 @@ public class ShiroConfig {
@Bean
public ShiroFilterFactoryBean shiroFilter() {
ShiroFilterFactoryBean shiroFilterFactory = new ShiroFilterFactoryBean();
CustomShiroFilterFactoryBean shiroFilterFactory = new CustomShiroFilterFactoryBean();
shiroFilterFactory.setSecurityManager(securityManager());
shiroFilterFactory.setLoginUrl("/login");
// 设置访问过滤条件。
......
package com.ces.framework.shiro.filter;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.filter.InvalidRequestFilter;
import org.apache.shiro.web.filter.mgt.DefaultFilter;
import org.apache.shiro.web.filter.mgt.FilterChainManager;
import org.apache.shiro.web.filter.mgt.FilterChainResolver;
import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;
import org.apache.shiro.web.mgt.WebSecurityManager;
import org.apache.shiro.web.servlet.AbstractShiroFilter;
import org.apache.shiro.mgt.SecurityManager;
import org.springframework.beans.factory.BeanInitializationException;
import javax.servlet.Filter;
import java.util.Map;
/**
* 自定义ShiroFilterFactoryBean解决中文路径问题
* @author Tao
* @date 2023/11/24
*/
public class CustomShiroFilterFactoryBean extends ShiroFilterFactoryBean {
@Override
public Class<MySpringShiroFilter> getObjectType()
{
return MySpringShiroFilter.class;
}
@Override
protected AbstractShiroFilter createInstance() throws Exception {
SecurityManager securityManager = getSecurityManager();
if (securityManager == null)
{
String msg = "SecurityManager property must be set.";
throw new BeanInitializationException(msg);
}
if (!(securityManager instanceof WebSecurityManager))
{
String msg = "The security manager does not implement the WebSecurityManager interface.";
throw new BeanInitializationException(msg);
}
FilterChainManager manager = createFilterChainManager();
// Expose the constructed FilterChainManager by first wrapping it in a
// FilterChainResolver implementation. The AbstractShiroFilter implementations
// do not know about FilterChainManagers - only resolvers:
PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
chainResolver.setFilterChainManager(manager);
Map<String, Filter> filterMap = manager.getFilters();
Filter invalidRequestFilter = filterMap.get(DefaultFilter.invalidRequest.name());
if (invalidRequestFilter instanceof InvalidRequestFilter)
{
// 此处是关键,设置false跳过URL携带中文400,servletPath中文校验bug
((InvalidRequestFilter) invalidRequestFilter).setBlockNonAscii(false);
}
// Now create a concrete ShiroFilter instance and apply the acquired SecurityManager and built
// FilterChainResolver. It doesn't matter that the instance is an anonymous inner class
// here - we're just using it because it is a concrete AbstractShiroFilter instance that accepts
// injection of the SecurityManager and FilterChainResolver:
return new MySpringShiroFilter((WebSecurityManager) securityManager, chainResolver);
}
private static final class MySpringShiroFilter extends AbstractShiroFilter {
protected MySpringShiroFilter(WebSecurityManager webSecurityManager, FilterChainResolver resolver)
{
if (webSecurityManager == null)
{
throw new IllegalArgumentException("WebSecurityManager property cannot be null.");
}
else
{
this.setSecurityManager(webSecurityManager);
if (resolver != null)
{
this.setFilterChainResolver(resolver);
}
}
}
}
}
......@@ -14,6 +14,8 @@ import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @author Tao
* @date 2023/11/20
......@@ -58,7 +60,11 @@ public class UserRealm extends AuthorizingRealm {
UserDTO userDTO = (UserDTO) principals.getPrimaryPrincipal();
simpleAuthorizationInfo.addRoles(userDTO.getRoleCodeList());
List<String> roleCodeList = userDTO.getRoleCodeList();
if (ObjectUtils.isNotEmpty(roleCodeList)) {
simpleAuthorizationInfo.addRoles(roleCodeList);
}
return simpleAuthorizationInfo;
}
......
......@@ -4,6 +4,7 @@ import com.ces.common.constant.Constant;
import com.ces.web.bs.service.IBsDeviceService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -21,19 +22,25 @@ public class BsController {
private final String prisonName = "沪-宝";
@GetMapping("areaPlanView")
@GetMapping
@RequiresRoles({Constant.RoleCode.BS})
public ModelAndView bsAreaPlanView () {
return new ModelAndView("bs/bsAreaPlan");
}
@GetMapping
@GetMapping("/jqone")
public ModelAndView jqoneIndex() {
return new ModelAndView("bs/jqone");
}
/*@GetMapping
@RequiresRoles({Constant.RoleCode.BS})
public ModelAndView bsView (String buildAreaName) {
ModelAndView modelAndView = new ModelAndView("bs/bs");
modelAndView.addObject("buildAreaName", buildAreaName);
return modelAndView;
}
}*/
@GetMapping("getBuildAreaAllCount")
@RequiresRoles({Constant.RoleCode.BS})
......
......@@ -6,6 +6,7 @@ import com.ces.common.utils.ObjectUtils;
import com.ces.framework.authsystem.AuthSystemUtils;
import com.ces.framework.shiro.token.UserToken;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -42,7 +43,10 @@ public class LoginController {
subject.login(new UserToken(loginName, password, AuthSystemUtils.getTenantId()));
return Result.success();
} catch (IncorrectCredentialsException e) {
return Result.error("账号或密码错误!");
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
if (StrUtil.isBlank(msg)) {
msg = "服务器错误,登录失败!";
......
......@@ -3,6 +3,7 @@ package com.ces.web.login.service;
import com.ces.common.constant.Constant;
import com.ces.common.exception.AccountErrorException;
import com.ces.common.exception.NoLoginPremException;
import com.ces.common.utils.ObjectUtils;
import com.ces.framework.authsystem.AuthSystemUtils;
import com.ces.framework.shiro.dto.UserDTO;
import com.cesgroup.authen4.ws.entity.Account;
......@@ -36,10 +37,6 @@ public class LoginService {
// 用户角色
List<String> roleCodeList = AuthSystemUtils.getUserRoleCodeList(account.getId());
if (!roleCodeList.contains(Constant.RoleCode.MONITOR)) {
throw new NoLoginPremException("您没有登录权限!");
}
return new UserDTO(account.getId(), account.getName(), account.getLoginName(), tenantId, roleCodeList);
}
}
......@@ -65,7 +65,7 @@
<ul>
<shiro:hasRole name="${role_code_bs}">
<li class="index_01">
<a href="${ctx}/bs/areaPlanView">
<a href="${ctx}/bs">
<div class="box_map bot">
<div class="box_title">
<img src="${ctx}/static/images/dalou2-mianxing.png" alt="">
......
......@@ -16,9 +16,6 @@
pageContext.setAttribute("role_code_xsf", Constant.RoleCode.XSF);
pageContext.setAttribute("role_code_zyy", Constant.RoleCode.ZYY);
pageContext.setAttribute("role_code_zp", Constant.RoleCode.ZP);
UserDTO userDTO = (UserDTO) SecurityUtils.getSubject().getPrincipal();
pageContext.setAttribute("username", userDTO.getName());
%>
<script>
let ctx = '${ctx}';
......@@ -31,54 +28,4 @@
<script src="${ctx}/static/js/popper.min.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/common.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/workshop.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/commonArea.css"/>
<style>
.login-info{
padding: 10px 0;
position: fixed;
top: 30px;
right: 15px;
background-color: rgba(255, 255, 255, 30%);
width: 150px;
border-radius: 15px;
display: flex;
flex-direction: column;
align-items: center;
z-index: 99;
}
.login-info a{
margin-top: 8px;
color: #fff;
font-size: 14px;
text-decoration: none!important;
}
.login-info a:hover{
color: #fff;
}
.login-name{
cursor: text;
}
.username{
font-size: 14px;
}
</style>
<!-- 登入人员信息 -->
<div class="login-info">
<img src="${ctx}/static/images/icon_tx.png" width="50" height="50">
<a class="login-name" href="javascript:;">
当前用户:<span class="username">${username}</span>
</a>
<a class="logout" href="javascript:;">
退出系统
</a>
</div>
<script type="text/javascript">
$(function () {
$(".logout").click(function () {
window.open(ctx + '/login', '_self');
})
})
</script>
\ No newline at end of file
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/commonArea.css"/>
\ No newline at end of file
......@@ -20,6 +20,9 @@
.area-box li {
cursor: pointer;
}
.area-right .area-box li a{
color: #fff;
}
</style>
</head>
<body>
......@@ -34,13 +37,15 @@
<div class="left-menu">
<ul>
<li>
<div class="menu-mc">
<span>一监区</span>
</div>
<div class="menu-num">
<span>监控点</span>
<span style="background-color: #43e04e;">0</span>
</div>
<a href="${ctx}/bs/jqone">
<div class="menu-mc">
<span>一监区</span>
</div>
<div class="menu-num">
<span>监控点</span>
<span style="background-color: #43e04e;">0</span>
</div>
</a>
</li>
<li>
<div class="menu-mc">
......@@ -112,8 +117,10 @@
<div class="area-box">
<ul>
<li class="a_floor">
<a href="javascript:void(0);"> <img src="${ctx}/static/images/A_floor.png"/></a>
<span>一监区</span>
<a href="${ctx}/bs/jqone">
<img src="${ctx}/static/images/A_floor.png"/>
<span>一监区</span>
</a>
</li>
<li class="bg1_floor">
<a href="javascript:void(0);"> <img src="${ctx}/static/images/bgq_floor.png"/></a>
......@@ -172,12 +179,6 @@
});
},
initPage: function(){
$('div.area-box li').on('click', function(){
var buildAreaName = $(this).find('span').html();
if (buildAreaName) {
window.open(ctx + '/bs?buildAreaName=' + encodeURIComponent(buildAreaName), '_self');
}
});
$('.area-content .left-menu li').on('click', function () {
var buildAreaName = $(this).find('.menu-mc>span').html();
if (buildAreaName) {
......
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../base.jsp"%>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>一监区</title>
</head>
<style type="text/css">
.content {
background: url('${ctx}/static/images/bg.jpg') center center no-repeat;
width: 100%;
height: 100%;
/* background-position-x: center; */
background-size: cover;
}
</style>
<body>
<div class="content">
<div class="content_top"></div>
<div class=" padding_box2 clearfix">
<div class="menu_box">
<div class="menu_title_box"><a class="menu_name" href="${ctx}/bs">一监区</a></div>
<div class="tab_list">
<ul>
<li class="current">
<div class="flex-box">
<p class="tabName">东部</p>
<p class="monitor">监控点<span>42</span></p>
</div>
</li>
<li>
<div class="flex-box">
<p class="tabName">西部</p>
<p class="monitor">监控点<span>40</span></p>
</div>
</li>
</ul>
</div>
</div>
<div class="content_box">
<div class="room_box">
</div>
</div>
</div>
</div>
<script>
let dataList = {
'arr1': [
{
top: '20%',
left: '1.5%',
gbid: '31011700001320000783'
}, {
top: '13%',
left: '9%',
gbid: '31011700001320001187'
}, {
top: '28%',
left: '9%',
gbid: '31011700001320001188'
}, {
top: '57%',
left: '9%',
gbid: '31011700001320001190'
}, {
top: '43%',
left: '9%',
gbid: '31011700001320001189'
}, {
top: '73%',
left: '9%',
gbid: '31011700001320001191'
}, {
top: '87%',
left: '9%',
gbid: '31011700001320001192'
}, {
top: '1.2rem',
left: '4.8rem',
gbid: '31011700001320001193'
}, {
top: '9%',
left: '5.6rem',
gbid: '31011700001320001194'
}, {
top: '9%',
left: '6.9rem',
gbid: '31011700001320001195'
}, {
top: '12%',
left: '10.3rem',
gbid: '31011700001320001196'
}, {
top: '1rem',
left: '11.5rem',
gbid: '31011700001320001197'
}, {
top: '48%',
left: '3.5rem',
gbid: '31011700001320000957'
}, {
top: '48%',
left: '5rem',
gbid: '31011700001320000965'
}, {
top: '48%',
left: '6.45rem',
gbid: '31011700001320000966'
}, {
top: '48%',
left: '7.9rem',
gbid: '31011700001320000967'
}, {
top: '48%',
left: '9.5rem',
gbid: '31011700001320000968'
}, {
top: '48%',
left: '10.95rem',
gbid: '31011700001320000969'
}, {
top: '69%',
left: '3.5rem',
gbid: '31011700001320000970'
}, {
top: '69%',
left: '5rem',
gbid: '31011700001320000971'
}, {
top: '69%',
left: '6.45rem',
gbid: '31011700001320000972'
}, {
top: '69%',
left: '7.9rem',
gbid: '31011700001320000958'
}, {
top: '69%',
left: "9.5rem",
gbid: '31011700001320000959'
}, {
top: '69%',
left: "10.95rem",
gbid: '31011700001320000960'
}, {
top: '92%',
left: "5rem",
gbid: '31011700001320000961'
}, {
top: '92%',
left: "6.45rem",
gbid: '31011700001320000962'
}, {
top: '92%',
left: "7.9rem",
gbid: '31011700001320000963'
}, {
top: '92%',
left: "9.5rem",
gbid: '31011700001320000964'
}],
'arr2': [
{
top: '1.4rem',
left: '0.15rem',
gbid: '31011700001320000785'
}, {
top: '2.1rem',
left: '1.4rem',
gbid: '31011700001320001179'
}, {
top: '2.1rem',
left: '3.4rem',
gbid: '31011700001320001180'
}, {
top: '3.9rem',
left: '1.4rem',
gbid: '31011700001320001181'
}, {
top: '3.9rem',
left: '3.4rem',
gbid: '31011700001320001182'
}, {
top: '92.5%',
left: '1.4rem',
gbid: '31011700001320001169'
}, {
top: '92.5%',
left: '3.4rem',
gbid: '31011700001320001170'
}, {
top: '70%',
left: '1.4rem',
gbid: '31011700001320001183'
}, {
top: '70%',
left: '3.4rem',
gbid: '31011700001320001184'
}, {
top: '3.3rem',
left: '5.3rem',
gbid: '31011700001320001186'
}, {
top: '58%',
left: '6.6rem',
gbid: '31011700001320001178'
}, {
top: '58%',
left: '5.3rem',
gbid: '31011700001320001185'
}, {
top: '3.3rem',
left: '6.6rem',
gbid: '31011700001320001177'
}, {
top: '2.1rem',
left: '8.5rem',
gbid: '31011700001320001171'
}, {
top: '2.1rem',
left: '10.5rem',
gbid: '31011700001320001172'
}, {
top: '3.9rem',
left: '8.5rem',
gbid: '31011700001320001173'
}, {
top: '3.9rem',
left: '10.5rem',
gbid: '31011700001320001174'
}, {
top: '70%',
left: '8.5rem',
gbid: '31011700001320001175'
}, {
top: '70%',
left: '10.5rem',
gbid: '31011700001320001176'
}, {
top: '92.5%',
left: '8.5rem',
gbid: '31011700001320001167'
}, {
top: '92.5%',
left: '10.5rem',
gbid: '31011700001320001168'
}, {
top: "80%",
left: "96%",
gbid: '31011700001320000784'
}]
};
let thisIndex = 1;
$(function () {
// 1、点击上面的li,当前点击的li添加current类,其余兄弟移除类
$(".tab_list li").click(function () {
// 链式编程 当前li添加类,其余兄弟移除类
$(this).addClass('current').siblings().removeClass('current');
// 2、拿到当前点击的索引号
var index = $(this).index();
// 3、下面index对应的模块显示,其余的item隐藏
$(".tab_con .item").eq(index).show().siblings().hide();
updateData(index + 1);
})
updateData(1);
});
function updateData(index) {
thisIndex = index;
//循环数组 打摄像头位置
var divElement = document.querySelector('.room_box');
let htmlTxt = '<img class="bg_img" src="${ctx}/static/images/workshop' + index + '.png" alt="">'
for (let i = 0; i < dataList[`arr${"${index}"}`].length; i++) {
htmlTxt = htmlTxt + '<img class="camera" src="${ctx}/static/images/camera.png" ' + ' style="top:' + dataList[`arr${"${index}"}`][i].top + ";left:" + dataList[`arr${"${index}"}`][i].left + '" onclick="handleClick(' + i + ')"></img>'
}
divElement.innerHTML = htmlTxt;
}
function handleClick(i) {
let gbId = dataList['arr' + thisIndex][i].gbid;
VideoPlayer.show(gbId);
}
</script>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="../base.jsp"/>
<%@ include file="../base.jsp"%>
<html>
<head>
<meta charset="UTF-8">
......
......@@ -10,7 +10,7 @@
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/common.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/workshop.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/css/commonArea.css"/>
<title>上海市人民检察院</title>
<title>教育楼</title>
</head>
<style type="text/css">
.content {
......
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="base.jsp"/>
<%@ include file="base.jsp"%>
<html>
<head>
<meta charset="UTF-8">
......
......@@ -427,8 +427,8 @@ body {
align-items: center;
justify-content: center;
}
#payerhf{
padding: 5px 30px;
#payerhf,#ishf,#isLive{
padding: 3px 20px;
font-size: 16px;
text-align: center;
}
......
......@@ -11,7 +11,7 @@ let dom_temp = '<div class="modal fade" id="cameraModal" tabindex="-1" role="dia
' <div class="modal-dialog" role="document">\n' +
' <div class="modal-content">\n' +
' <div class="title"></div>\n' +
'<div class="tools">\n' +
'<div class="tools" style="display: none">\n' +
' <div class="timeSelect">\n' +
' <div class="time-box">\n' +
' 开始时间: <input type="text" id="startTime" placeholder="请选择开始时间"/>\n' +
......@@ -19,7 +19,8 @@ let dom_temp = '<div class="modal fade" id="cameraModal" tabindex="-1" role="dia
' <div class="time-box">\n' +
' 结束时间: <input type="text" id="endTime" placeholder="请选择结束时间"/>\n' +
' </div>\n' +
' <button type="button" class="btn btn-primary" id="payerhf">加载回放</button>\n' +
' <button type="button" class="btn btn-primary" id="ishf">确定</button>\n' +
'<button type="button" class="btn btn-primary" style="display: none" id="isLive">实时播放</button>' +
' </div>\n' +
' </div>' +
' <div class="modal-body">\n' +
......@@ -113,7 +114,7 @@ var VideoPlayer = {
this.gbid = data.curr.gbId;
var $modal = $('#cameraModal');
$('.modal-content .title').html(data.curr.place + '监控点情况');
$('.modal-content .title').html(data.curr.place + '监控点情况 <button type="button" class="btn btn-primary btn-sm" id="payerhf">加载回放</button>');
// 假设每个摄像头的视频源可能不同,可以设置为动态获取
this.renderList(data.list);
......@@ -159,6 +160,7 @@ var VideoPlayer = {
},
show: function (gbId) {
this.gbid = gbId;
$('#isLive').hide();
if (asyLock) {
return;
}
......@@ -232,8 +234,10 @@ var VideoPlayer = {
let gbId = this.gbid;
let startTime = $('#startTime').val();
let endTime = $('#endTime').val();
console.log(gbId, startTime, endTime);
if (!startTime || !endTime) {
return;
}
if (gbId) {
player.loadVideo({
src: {
......@@ -245,27 +249,43 @@ var VideoPlayer = {
transport: KMediaUni.MODE.WEBRTC,
autoplay: true
});
$("#isLive").show();
return;
}
alert('未找到播放源');
}
}
let toolsShow = false;
$(document).on('click', function (e) {
if ($(e.target).hasClass('modal')) {
$('#cameraModal').modal('hide');
// 时间清空
$('#startTime').val('');
$('#endTime').val('');
$('.tools').hide();
toolsShow = false;
$('#cameraModal').modal('hide');
}
})
$(document).on('click', '.modal-content li', function () {
let gbId = $(this).data('gbid');
$("#isLive").hide();
VideoPlayer.show(gbId);
})
$(document).on('click', '#payerhf', function () {
if (toolsShow) {
$('.tools').hide();
toolsShow = false;
} else {
$('.tools').show();
toolsShow = true;
}
})
$(document).on('click', '#ishf', function () {
//加载回放
VideoPlayer.loadVideo();
})
\ No newline at end of file
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