Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jfV5pc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
管理员
jfV5pc
Commits
ff6ae920
Commit
ff6ae920
authored
Jul 06, 2018
by
罗绍泽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新cas配置
parent
79fbacc1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
66 deletions
+108
-66
web.xml
WebContent/WEB-INF/web.xml
+19
-6
cas.jsp
WebContent/cas.jsp
+5
-60
struts-ext.xml
src/struts-ext.xml
+5
-0
CasAction.java
src_system/com/gaowj/system/login/CasAction.java
+79
-0
No files found.
WebContent/WEB-INF/web.xml
View file @
ff6ae920
...
...
@@ -69,17 +69,17 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j
<filter-class>
org.jasig.cas.client.authentication.AuthenticationFilter
</filter-class>
<init-param>
<param-name>
casServerLoginUrl
</param-name>
<param-value>
http://
localhost:8080/cas-test01
/login
</param-value>
<!-- cas 服务器登录 地址 http://IP:PORT/CasWebProName/login -->
<param-value>
http://
cas.jfbrother.com:9003/cas-jfsso
/login
</param-value>
<!-- cas 服务器登录 地址 http://IP:PORT/CasWebProName/login -->
</init-param>
<init-param>
<!-- 这里的server是服务端的IP -->
<param-name>
serverName
</param-name>
<param-value>
http://
localhost:8082
</param-value>
<!-- 客户端服务器地址 http://IP:PORT -->
<param-value>
http://
pc.jfbrother.com:9003
</param-value>
<!-- 客户端服务器地址 http://IP:PORT -->
</init-param>
</filter>
<filter-mapping>
<filter-name>
CASFilter
</filter-name>
<url-pattern>
/
cas.jsp
</url-pattern>
<url-pattern>
/
jfcas
</url-pattern>
<!-- <url-pattern>/*</url-pattern> -->
</filter-mapping>
...
...
@@ -89,16 +89,16 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j
<filter-class>
org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter
</filter-class>
<init-param>
<param-name>
casServerUrlPrefix
</param-name>
<param-value>
http://
localhost:8080/cas-test01
</param-value>
<!-- cas 服务器地址 http://IP:PORT/CasWebProName -->
<param-value>
http://
cas.jfbrother.com:9003/cas-jfsso
</param-value>
<!-- cas 服务器地址 http://IP:PORT/CasWebProName -->
</init-param>
<init-param>
<param-name>
serverName
</param-name>
<param-value>
http://
localhost:8082
</param-value>
<!-- 客户端服务器地址 http://IP:PORT -->
<param-value>
http://
pc.jfbrother.com:9003
</param-value>
<!-- 客户端服务器地址 http://IP:PORT -->
</init-param>
</filter>
<filter-mapping>
<filter-name>
CAS Validation Filter
</filter-name>
<url-pattern>
/
cas.jsp
</url-pattern>
<url-pattern>
/
jfcas
</url-pattern>
</filter-mapping>
<!-- 该过滤器负责实现HttpServletRequest请求的包裹,
...
...
@@ -112,6 +112,19 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j
<url-pattern>
/*
</url-pattern>
</filter-mapping>
<!-- 单点注销监听器 -->
<listener>
<listener-class>
org.jasig.cas.client.session.SingleSignOutHttpSessionListener
</listener-class>
</listener>
<!-- 单点注销过滤器 -->
<filter>
<filter-name>
caslogoutFilter
</filter-name>
<filter-class>
org.jasig.cas.client.session.SingleSignOutFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>
caslogoutFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
<filter>
<filter-name>
struts2
</filter-name>
<filter-class>
com.gaowj.business.filter.myStrutsPrepareAndExecuteFilter
</filter-class>
...
...
WebContent/cas.jsp
View file @
ff6ae920
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="org.jasig.cas.client.authentication.AttributePrincipal" %>
<%@ page import="org.jasig.cas.client.util.AssertionHolder"%>
<%@ page import="com.gaowj.business.comp.BusinessManager" %>
<%@ page import="com.gaowj.business.SystemOpeBusiness" %>
<%@ page import="com.gaowj.business.util.Java_tool" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.Map" %>
<%
//解决在IE的frame/iframe环境下,跨域单点登录后,无法重定向的问题
response.setHeader("P3P","CP=CAO PSA OUR");
%>
<%
AttributePrincipal principal = (AttributePrincipal)request.getUserPrincipal();
Map<String, Object> attributes = principal.getAttributes();
String userID = attributes.get("userid").toString();
String userName = attributes.get("USER_NAME").toString();
System.out.println("-----1"+userID);
System.out.println("-----2"+userName);
System.out.println("-----3"+attributes.get("UNIT_ID"));
if(userID!=null){
String username = userID;
Java_tool jt = new Java_tool();
SystemOpeBusiness systemOpeBusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
Map query = new HashMap();
query.put("EMID", username);
Map<String,Object> userInfoI = systemOpeBusiness.listLoginUserInfo(query).get(0);
Map<String,Object> sessionUser = new HashMap<String,Object>();
String u_all_m = systemOpeBusiness.getUserAllModule(userInfoI.get("CODE").toString());
sessionUser.put("CODE",userInfoI.get("CODE"));
sessionUser.put("EMID",userInfoI.get("EMID"));
sessionUser.put("EMSEX",userInfoI.get("EMSEX"));
sessionUser.put("EMDEPARTNAME",userInfoI.get("EMDEPARTNAME"));
sessionUser.put("EMDEPART",userInfoI.get("EMDEPART"));
sessionUser.put("EMNAME",userInfoI.get("EMNAME"));
sessionUser.put("BEFORETIME",userInfoI.get("BEFORETIME"));
sessionUser.put("SESSIONID", request.getSession().getId());
sessionUser.put("CURRENTTIME", jt.now_datetime());
sessionUser.put("LOGINIP", request.getRemoteAddr());
sessionUser.put("SERVERIP", request.getLocalAddr());
sessionUser.put("QUANXIAN",u_all_m);
request.getSession().setAttribute("userInfo", sessionUser);
//增加登陆日志
Map<String,Object> log = new HashMap<String,Object>();
log.put("CODE", sessionUser.get("CODE"));log.put("EMNAME", sessionUser.get("EMNAME"));log.put("EMIP", sessionUser.get("LOGINIP"));
log.put("OPENAME", "登陆");log.put("OPETIME", jt.String3date((String)sessionUser.get("CURRENTTIME")));log.put("TYPE", userInfoI.get("TYPE"));
log.put("OPETYPE", "B/S登陆");
systemOpeBusiness.insert_log(log);
}
String strRedirecturl = request.getParameter("redirectUrl");
if(strRedirecturl != null && strRedirecturl.length() > 0) {
response.sendRedirect(strRedirecturl);
}else{
response.sendRedirect("index.jsp");
}
response.getWriter().println("123");
%>
\ No newline at end of file
<script type="text/javascript">
var WebContextPath = '<%=request.getContextPath() %>';
window.location = WebContextPath + "/jfcas";
</script>
\ No newline at end of file
src/struts-ext.xml
View file @
ff6ae920
...
...
@@ -64,4 +64,9 @@
</result>
</action>
</package>
<package
name=
"caslogin"
extends=
"struts-default,json-default"
>
<action
name=
"jfcas"
class=
"com.gaowj.system.login.CasAction"
>
</action>
</package>
</struts>
src_system/com/gaowj/system/login/CasAction.java
0 → 100644
View file @
ff6ae920
package
com
.
gaowj
.
system
.
login
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.jasig.cas.client.authentication.AttributePrincipal
;
import
com.gaowj.business.SystemOpeBusiness
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.comp.BusinessManager
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.util.Java_tool
;
public
class
CasAction
extends
BasicAction
{
/**
*
*/
private
static
final
long
serialVersionUID
=
4192673206777760091L
;
public
String
execute
()
throws
BusinessException
{
response
.
setHeader
(
"P3P"
,
"CP=CAO PSA OUR"
);
AttributePrincipal
principal
=
(
AttributePrincipal
)
request
.
getUserPrincipal
();
Map
<
String
,
Object
>
attributes
=
principal
.
getAttributes
();
String
userID
=
attributes
.
get
(
"userid"
).
toString
();
String
userName
=
attributes
.
get
(
"USER_NAME"
).
toString
();
System
.
out
.
println
(
"-----1"
+
userID
);
System
.
out
.
println
(
"-----2"
+
userName
);
System
.
out
.
println
(
"-----3"
+
attributes
.
get
(
"UNIT_ID"
));
if
(
userID
!=
null
){
String
username
=
userID
;
Java_tool
jt
=
new
Java_tool
();
SystemOpeBusiness
systemOpeBusiness
=
BusinessManager
.
getBusiness
(
SystemOpeBusiness
.
class
);
Map
<
String
,
Object
>
query
=
new
HashMap
<
String
,
Object
>();
query
.
put
(
"EMID"
,
username
);
Map
<
String
,
Object
>
userInfoI
=
systemOpeBusiness
.
listLoginUserInfo
(
query
).
get
(
0
);
Map
<
String
,
Object
>
sessionUser
=
new
HashMap
<
String
,
Object
>();
String
u_all_m
=
systemOpeBusiness
.
getUserAllModule
(
userInfoI
.
get
(
"CODE"
).
toString
());
sessionUser
.
put
(
"CODE"
,
userInfoI
.
get
(
"CODE"
));
sessionUser
.
put
(
"EMID"
,
userInfoI
.
get
(
"EMID"
));
sessionUser
.
put
(
"EMSEX"
,
userInfoI
.
get
(
"EMSEX"
));
sessionUser
.
put
(
"EMDEPARTNAME"
,
userInfoI
.
get
(
"EMDEPARTNAME"
));
sessionUser
.
put
(
"EMDEPART"
,
userInfoI
.
get
(
"EMDEPART"
));
sessionUser
.
put
(
"EMNAME"
,
userInfoI
.
get
(
"EMNAME"
));
sessionUser
.
put
(
"BEFORETIME"
,
userInfoI
.
get
(
"BEFORETIME"
));
sessionUser
.
put
(
"SESSIONID"
,
request
.
getSession
().
getId
());
sessionUser
.
put
(
"CURRENTTIME"
,
jt
.
now_datetime
());
sessionUser
.
put
(
"LOGINIP"
,
request
.
getRemoteAddr
());
sessionUser
.
put
(
"SERVERIP"
,
request
.
getLocalAddr
());
sessionUser
.
put
(
"QUANXIAN"
,
u_all_m
);
request
.
getSession
().
setAttribute
(
"userInfo"
,
sessionUser
);
//增加登陆日志
Map
<
String
,
Object
>
log
=
new
HashMap
<
String
,
Object
>();
log
.
put
(
"CODE"
,
sessionUser
.
get
(
"CODE"
));
log
.
put
(
"EMNAME"
,
sessionUser
.
get
(
"EMNAME"
));
log
.
put
(
"EMIP"
,
sessionUser
.
get
(
"LOGINIP"
));
log
.
put
(
"OPENAME"
,
"登陆"
);
log
.
put
(
"OPETIME"
,
jt
.
String3date
((
String
)
sessionUser
.
get
(
"CURRENTTIME"
)));
log
.
put
(
"TYPE"
,
userInfoI
.
get
(
"TYPE"
));
log
.
put
(
"OPETYPE"
,
"B/S登陆"
);
systemOpeBusiness
.
insert_log
(
log
);
}
String
strRedirecturl
=
request
.
getParameter
(
"redirectUrl"
);
String
toUrl
=
""
;
if
(
strRedirecturl
!=
null
&&
strRedirecturl
.
length
()
>
0
)
{
toUrl
=
strRedirecturl
;
}
else
{
toUrl
=
"index.jsp"
;
}
try
{
response
.
sendRedirect
(
toUrl
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment