Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
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
gechengyang
nouiWithSpringMVC
Commits
01135a00
Commit
01135a00
authored
Aug 03, 2021
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加基于人行coas单点登录功能
parent
3c702010
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1594 additions
and
742 deletions
+1594
-742
DatabaseLoginContextForELCS.java
...com/brilliance/eibs/auth/DatabaseLoginContextForELCS.java
+648
-643
CoasHandleController.java
...ss/presentation/noui/controller/CoasHandleController.java
+169
-0
LoginController.java
...org/sss/presentation/noui/controller/LoginController.java
+44
-29
HttpClientUtil.java
...n/java/org/sss/presentation/noui/util/HttpClientUtil.java
+657
-0
coas.properties
src/main/resources/coas.properties
+4
-0
spring-mvc.xml
src/main/resources/spring-mvc.xml
+72
-70
No files found.
src/main/java/cn/com/brilliance/eibs/auth/DatabaseLoginContextForELCS.java
View file @
01135a00
package
cn
.
com
.
brilliance
.
eibs
.
auth
;
package
cn
.
com
.
brilliance
.
eibs
.
auth
;
import
log.Log
;
import
log.Log
;
import
log.LogFactory
;
import
log.LogFactory
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.dbutils.DbUtils
;
import
org.apache.commons.dbutils.DbUtils
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.Session
;
import
org.hibernate.Session
;
import
org.hibernate.Transaction
;
import
org.hibernate.Transaction
;
import
org.hibernate.engine.spi.SessionImplementor
;
import
org.hibernate.engine.spi.SessionImplementor
;
import
org.sss.common.impl.AbstractLoginContext
;
import
org.sss.common.impl.AbstractLoginContext
;
import
org.sss.common.impl.MenuItemImpl
;
import
org.sss.common.impl.MenuItemImpl
;
import
org.sss.common.model.IContext.DataType
;
import
org.sss.common.model.IContext.DataType
;
import
org.sss.common.model.IFilter
;
import
org.sss.common.model.IFilter
;
import
org.sss.common.model.IMenuItem
;
import
org.sss.common.model.IMenuItem
;
import
org.sss.module.hibernate.HibernateUtils
;
import
org.sss.module.hibernate.HibernateUtils
;
import
org.sss.module.pojo.DatabaseUtils
;
import
org.sss.module.pojo.DatabaseUtils
;
import
org.sss.presentation.noui.api.response.ErrorCode
;
import
org.sss.presentation.noui.api.response.ErrorCode
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.presentation.noui.util.NoUiUtils
;
import
org.sss.presentation.noui.util.StringUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
org.sss.util.ContainerUtils
;
import
org.sss.util.ContainerUtils
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
java.security.KeyFactory
;
import
java.security.KeyFactory
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.sql.*
;
import
java.sql.*
;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
* LoginModule实现示例
* LoginModule实现示例
*
*
* @author Jason.Hoo (latest modification by $Author: hujianxin $)
* @author Jason.Hoo (latest modification by $Author: hujianxin $)
* @version $Revision: 922 $ $Date: 2014-11-19 16:05:38 +0800 (Wed, 19 Nov 2014)
* @version $Revision: 922 $ $Date: 2014-11-19 16:05:38 +0800 (Wed, 19 Nov 2014)
* $
* $
*/
*/
public
class
DatabaseLoginContextForELCS
extends
AbstractLoginContext
{
public
class
DatabaseLoginContextForELCS
extends
AbstractLoginContext
{
public
static
final
String
ERROR
=
"error"
;
public
static
final
String
ERROR
=
"error"
;
final
static
Log
log
=
LogFactory
.
getLog
(
DatabaseLoginContextForELCS
.
class
);
final
static
Log
log
=
LogFactory
.
getLog
(
DatabaseLoginContextForELCS
.
class
);
final
static
String
ERROR_USERNAME_PASSWORD
=
"error.username.password"
;
final
static
String
ERROR_USERNAME_PASSWORD
=
"error.username.password"
;
final
static
String
ERROR_USER_LOCKED
=
"error.user.locked"
;
final
static
String
ERROR_USER_LOCKED
=
"error.user.locked"
;
final
static
String
ERROR_USER_EXPRIED
=
"error.user.expired"
;
final
static
String
ERROR_USER_EXPRIED
=
"error.user.expired"
;
final
static
String
ERROR_SYSTEM_FAULT
=
"error.system.fault"
;
final
static
String
ERROR_SYSTEM_FAULT
=
"error.system.fault"
;
final
static
String
STATUS_NORMAL
=
"0"
;
final
static
String
STATUS_NORMAL
=
"0"
;
final
static
String
STATUS_EXPIRED
=
"1"
;
final
static
String
STATUS_EXPIRED
=
"1"
;
final
static
String
STATUS_LOCKED
=
"2"
;
final
static
String
STATUS_LOCKED
=
"2"
;
final
static
String
TYPE_VISIBLE
=
"0"
;
final
static
String
TYPE_VISIBLE
=
"0"
;
final
static
String
TYPE_INVISIBLE
=
"1"
;
final
static
String
TYPE_INVISIBLE
=
"1"
;
final
static
String
TYPE_FREQUENT
=
"2"
;
final
static
String
TYPE_FREQUENT
=
"2"
;
final
static
String
FLAG_NORMAL
=
"0"
;
final
static
String
FLAG_NORMAL
=
"0"
;
final
static
String
FLAG_INDIRECT
=
"1"
;
final
static
String
FLAG_INDIRECT
=
"1"
;
final
static
String
FLAG_SKIP
=
"2"
;
final
static
String
FLAG_SKIP
=
"2"
;
final
static
String
MENU_FREQUENT_ITEM
=
"menu.frequent"
;
final
static
String
MENU_FREQUENT_ITEM
=
"menu.frequent"
;
final
static
int
INDEX_INR
=
1
;
final
static
int
INDEX_INR
=
1
;
final
static
int
INDEX_PNTINR
=
2
;
final
static
int
INDEX_PNTINR
=
2
;
final
static
int
INDEX_FRM
=
3
;
final
static
int
INDEX_FRM
=
3
;
final
static
int
INDEX_DSP
=
4
;
final
static
int
INDEX_DSP
=
4
;
final
static
int
INDEX_TYP
=
5
;
final
static
int
INDEX_TYP
=
5
;
final
static
int
INDEX_FLG
=
6
;
final
static
int
INDEX_FLG
=
6
;
final
static
int
INDEX_IMG
=
7
;
final
static
int
INDEX_IMG
=
7
;
final
static
int
INDEX_STL
=
8
;
final
static
int
INDEX_STL
=
8
;
final
static
int
INDEX_CLS
=
9
;
final
static
int
INDEX_CLS
=
9
;
final
static
String
PWDERROR
=
"ESFEERROR1"
;
final
static
String
PWDERROR
=
"ESFEERROR1"
;
final
static
String
VCODEERROR
=
"ESFEERROR2"
;
final
static
String
VCODEERROR
=
"ESFEERROR2"
;
final
static
String
REDISERROR
=
"ESFEERROR3"
;
final
static
String
REDISERROR
=
"ESFEERROR3"
;
final
static
String
INITERROR
=
"ESFEERROR4"
;
final
static
String
INITERROR
=
"ESFEERROR4"
;
private
static
final
String
loginCheck
=
"loginCheck.properties"
;
private
static
final
String
loginCheck
=
"loginCheck.properties"
;
private
static
final
String
privateKey
=
"MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALTHSCdzrBYyWReFrasVB+ehvfOg/34nTPPNSJsTlr0vqwvVohhqhnlBtIGE1g1//stMcAso8CevpCnN5/cOiwubzFhm1dRsyQmmkiMzH68sNx8+h87X/XeKpWIVSswc2Z3nMMV8zTDK8KhpPJwVRIQ5CqPdiYpQoDhBB5POiWPdAgMBAAECgYAxYCzI+cMK3P2QeyaQD9J05axoGpUt87YE8RDfql4Fljt1pAf9+zp3bAbNSWbdkRQamuoPYkMV09dWw7KTvBklwQe91llTF3eHXKXmI5M+NJtlfmk2aeJCwmb8LtFyIMb3ocgvni5es/jEd/UTzZvzZpbkR+aD5aiXEC/wFCNJUQJBANfQuCDO2d7MIfv36DKbGJ25oqX/e2B/GWDhNGb3F4BqN+3MkFw21MAP3OlW/nu0XgyRLVzw8pm6E6WlBR3GPGMCQQDWcHVWr7fIeQ9sLAKwhe+D4k/kPElaptxoqzMIWNcweG5fc2eMvJ5BHh081B0h4+KiLE6lgvitZU2c8aCm/TK/AkAuJ7U5TwPJYl7iRGKkcAcTtF/UoI8CVCxZS9CpNK8SB6VudhFpp1BYwwu7258RVcHHbkUFW4KG3gTVqDUv6PWBAkEAsuD6sMZB68Q4vkZ0M+Z2JzDI7h3wHuOkZtew6VyanT9I6uysy3SoGq/ROeXDK3samaeWL3DymkowFSRmnAYIpwJABliTTManT9rkQx+sahGwGKInAClxl3Po5XB8ST/75xkSobYAVaV8kgrxE4u4DJxbomBUWeT7oOOhX2vODMhuZg=="
;
private
static
final
String
privateKey
=
"MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALTHSCdzrBYyWReFrasVB+ehvfOg/34nTPPNSJsTlr0vqwvVohhqhnlBtIGE1g1//stMcAso8CevpCnN5/cOiwubzFhm1dRsyQmmkiMzH68sNx8+h87X/XeKpWIVSswc2Z3nMMV8zTDK8KhpPJwVRIQ5CqPdiYpQoDhBB5POiWPdAgMBAAECgYAxYCzI+cMK3P2QeyaQD9J05axoGpUt87YE8RDfql4Fljt1pAf9+zp3bAbNSWbdkRQamuoPYkMV09dWw7KTvBklwQe91llTF3eHXKXmI5M+NJtlfmk2aeJCwmb8LtFyIMb3ocgvni5es/jEd/UTzZvzZpbkR+aD5aiXEC/wFCNJUQJBANfQuCDO2d7MIfv36DKbGJ25oqX/e2B/GWDhNGb3F4BqN+3MkFw21MAP3OlW/nu0XgyRLVzw8pm6E6WlBR3GPGMCQQDWcHVWr7fIeQ9sLAKwhe+D4k/kPElaptxoqzMIWNcweG5fc2eMvJ5BHh081B0h4+KiLE6lgvitZU2c8aCm/TK/AkAuJ7U5TwPJYl7iRGKkcAcTtF/UoI8CVCxZS9CpNK8SB6VudhFpp1BYwwu7258RVcHHbkUFW4KG3gTVqDUv6PWBAkEAsuD6sMZB68Q4vkZ0M+Z2JzDI7h3wHuOkZtew6VyanT9I6uysy3SoGq/ROeXDK3samaeWL3DymkowFSRmnAYIpwJABliTTManT9rkQx+sahGwGKInAClxl3Po5XB8ST/75xkSobYAVaV8kgrxE4u4DJxbomBUWeT7oOOhX2vODMhuZg=="
;
public
static
int
defaultSessionTimeout
=
3600
;
public
static
int
defaultSessionTimeout
=
3600
;
public
static
String
defaultHomePageName
=
"/layout.zul"
;
public
static
String
defaultHomePageName
=
"/layout.zul"
;
public
static
String
defaultHomeTransaction
=
"office"
;
public
static
String
defaultHomeTransaction
=
"office"
;
public
static
boolean
guestAccountUsed
=
false
;
public
static
boolean
guestAccountUsed
=
false
;
public
static
boolean
loginOnlyOnce
=
true
;
public
static
boolean
loginOnlyOnce
=
true
;
public
static
String
imageNull
=
null
;
public
static
String
imageNull
=
null
;
public
static
String
imageFrequent
=
null
;
public
static
String
imageFrequent
=
null
;
static
int
ERROR_MAX_COUNT
=
5
;
static
int
ERROR_MAX_COUNT
=
5
;
//用户距离上次修改密码间隔
//用户距离上次修改密码间隔
private
static
Duration
pwdAmeInterval
=
Duration
.
ofDays
(
30
);
private
static
Duration
pwdAmeInterval
=
Duration
.
ofDays
(
30
);
//连续多次输入密码重置
//连续多次输入密码重置
private
static
int
maxfltcnt
=
5
;
private
static
int
maxfltcnt
=
5
;
static
{
static
{
init
();
init
();
}
}
protected
final
MenuItem
menu
=
new
MenuItem
();
protected
final
MenuItem
menu
=
new
MenuItem
();
private
String
userId
;
private
String
userId
;
private
String
userRol
;
private
String
userRol
;
private
String
userEty
;
private
String
userEty
;
private
Timestamp
pwdamedat
;
private
Timestamp
pwdamedat
;
private
String
ukey
;
private
String
ukey
;
private
String
homePageName
=
"/layout.zul"
;
private
String
homePageName
=
"/layout.zul"
;
private
String
homeTransaction
=
"office"
;
private
String
homeTransaction
=
"office"
;
private
int
sessionTimeout
=
3600
;
private
int
sessionTimeout
=
3600
;
private
static
void
init
()
{
private
static
void
init
()
{
try
{
try
{
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
// 加载配置文件
// 加载配置文件
props
.
load
(
DatabaseLoginContextForELCS
.
class
.
getClassLoader
().
getResourceAsStream
(
loginCheck
));
props
.
load
(
DatabaseLoginContextForELCS
.
class
.
getClassLoader
().
getResourceAsStream
(
loginCheck
));
pwdAmeInterval
=
Duration
.
ofDays
(
Integer
.
parseInt
(
props
.
getProperty
(
"pwdAmeInterval"
)));
pwdAmeInterval
=
Duration
.
ofDays
(
Integer
.
parseInt
(
props
.
getProperty
(
"pwdAmeInterval"
)));
maxfltcnt
=
Integer
.
parseInt
(
props
.
getProperty
(
"maxfltcnt"
));
maxfltcnt
=
Integer
.
parseInt
(
props
.
getProperty
(
"maxfltcnt"
));
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
log
.
warn
(
"初始化异常"
,
e
);
log
.
warn
(
"初始化异常"
,
e
);
recordException
(
INITERROR
,
"初始化异常:"
+
e
.
getMessage
(),
"ERROR"
);
recordException
(
INITERROR
,
"初始化异常:"
+
e
.
getMessage
(),
"ERROR"
);
}
}
}
}
public
static
void
recordException
(
String
srvcod
,
String
errormsg
,
String
lev
)
{
public
static
void
recordException
(
String
srvcod
,
String
errormsg
,
String
lev
)
{
Session
session
=
HibernateUtils
.
openSession
(
null
);
Session
session
=
HibernateUtils
.
openSession
(
null
);
long
count
=
DatabaseUtils
.
executeCounter
(((
SessionImplementor
)
session
).
connection
(),
"dealog"
);
long
count
=
DatabaseUtils
.
executeCounter
(((
SessionImplementor
)
session
).
connection
(),
"dealog"
);
String
inr
=
String
.
format
(
"%08d"
,
count
);
String
inr
=
String
.
format
(
"%08d"
,
count
);
Transaction
transaction
=
session
.
beginTransaction
();
Transaction
transaction
=
session
.
beginTransaction
();
SQLQuery
sqlQuery
=
session
.
createSQLQuery
(
"insert into dealog(INR,CREDATTIM,SRVCOD,SRVNAM,INIFRM,RTNMSG,LOGLEV) values(?,?,?,?,?,?,?)"
);
SQLQuery
sqlQuery
=
session
.
createSQLQuery
(
"insert into dealog(INR,CREDATTIM,SRVCOD,SRVNAM,INIFRM,RTNMSG,LOGLEV) values(?,?,?,?,?,?,?)"
);
sqlQuery
.
setString
((
Integer
)
0
,
inr
);
sqlQuery
.
setString
((
Integer
)
0
,
inr
);
sqlQuery
.
setTimestamp
(
1
,
new
Date
());
sqlQuery
.
setTimestamp
(
1
,
new
Date
());
sqlQuery
.
setString
(
2
,
srvcod
);
sqlQuery
.
setString
(
2
,
srvcod
);
sqlQuery
.
setString
(
3
,
srvcod
);
sqlQuery
.
setString
(
3
,
srvcod
);
sqlQuery
.
setString
(
4
,
"LOGIN"
);
sqlQuery
.
setString
(
4
,
"LOGIN"
);
sqlQuery
.
setString
(
5
,
errormsg
);
sqlQuery
.
setString
(
5
,
errormsg
);
sqlQuery
.
setString
(
6
,
lev
);
sqlQuery
.
setString
(
6
,
lev
);
sqlQuery
.
executeUpdate
();
sqlQuery
.
executeUpdate
();
transaction
.
commit
();
transaction
.
commit
();
session
.
close
();
session
.
close
();
log
.
debug
(
"完成登陆相关异常日志记录"
);
log
.
debug
(
"完成登陆相关异常日志记录"
);
}
}
/**
/**
* 用户原文密码解密,先传统base64解密,然后对解密后的字符串的首位字符串进行偏移【头4 尾7】
* 用户原文密码解密,先传统base64解密,然后对解密后的字符串的首位字符串进行偏移【头4 尾7】
*
*
* @param verifycode 验证码
* @param verifycode 验证码
* @param pwd 待解签串
* @param pwd 待解签串
* @return 解签后的字符串
* @return 解签后的字符串
*/
*/
public
static
String
pwdDecode
(
String
verifycode
,
String
pwd
)
{
public
static
String
pwdDecode
(
String
verifycode
,
String
pwd
)
{
if
(
StringUtil
.
isEmpty
(
pwd
))
{
if
(
StringUtil
.
isEmpty
(
pwd
))
{
return
""
;
return
""
;
}
}
try
{
try
{
// pwd = AESUtil.decryptAES(pwd,verifycode);
// pwd = AESUtil.decryptAES(pwd,verifycode);
pwd
=
decrypt
(
pwd
);
pwd
=
decrypt
(
pwd
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
log
.
warn
(
"密码解密异常:"
,
e
);
log
.
warn
(
"密码解密异常:"
,
e
);
recordException
(
PWDERROR
,
"密码解密异常:"
+
e
.
getMessage
(),
"FATAL"
);
recordException
(
PWDERROR
,
"密码解密异常:"
+
e
.
getMessage
(),
"FATAL"
);
}
}
return
pwd
;
return
pwd
;
}
}
public
static
String
decrypt
(
String
pwd
)
throws
Exception
{
public
static
String
decrypt
(
String
pwd
)
throws
Exception
{
pwd
=
pwd
.
replaceAll
(
"%2B"
,
"+"
);
pwd
=
pwd
.
replaceAll
(
"%2B"
,
"+"
);
//64位解码加密后的字符串
//64位解码加密后的字符串
byte
[]
inputByte
=
org
.
apache
.
commons
.
codec
.
binary
.
Base64
.
decodeBase64
(
pwd
.
getBytes
(
"UTF-8"
));
byte
[]
inputByte
=
org
.
apache
.
commons
.
codec
.
binary
.
Base64
.
decodeBase64
(
pwd
.
getBytes
(
"UTF-8"
));
//base64编码的私钥
//base64编码的私钥
byte
[]
decoded
=
Base64
.
decodeBase64
(
privateKey
);
byte
[]
decoded
=
Base64
.
decodeBase64
(
privateKey
);
RSAPrivateKey
priKey
=
(
RSAPrivateKey
)
KeyFactory
.
getInstance
(
"RSA"
).
generatePrivate
(
new
PKCS8EncodedKeySpec
(
decoded
));
RSAPrivateKey
priKey
=
(
RSAPrivateKey
)
KeyFactory
.
getInstance
(
"RSA"
).
generatePrivate
(
new
PKCS8EncodedKeySpec
(
decoded
));
//RSA解密
//RSA解密
Cipher
cipher
=
Cipher
.
getInstance
(
"RSA"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"RSA"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
priKey
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
priKey
);
String
outStr
=
new
String
(
cipher
.
doFinal
(
inputByte
),
"UTF-8"
);
String
outStr
=
new
String
(
cipher
.
doFinal
(
inputByte
),
"UTF-8"
);
return
outStr
;
return
outStr
;
}
}
//偏移 头4 尾7
//偏移 头4 尾7
private
static
String
convert
(
String
str
)
{
private
static
String
convert
(
String
str
)
{
if
(
str
.
length
()
==
1
)
{
if
(
str
.
length
()
==
1
)
{
return
change
(
str
.
charAt
(
0
),
4
);
return
change
(
str
.
charAt
(
0
),
4
);
}
else
if
(
str
.
length
()
==
2
)
{
}
else
if
(
str
.
length
()
==
2
)
{
return
change
(
str
.
charAt
(
0
),
4
)
+
change
(
str
.
charAt
(
1
),
7
);
return
change
(
str
.
charAt
(
0
),
4
)
+
change
(
str
.
charAt
(
1
),
7
);
}
else
{
}
else
{
String
btw_str
=
str
.
substring
(
1
,
str
.
length
()
-
1
);
String
btw_str
=
str
.
substring
(
1
,
str
.
length
()
-
1
);
String
head
=
change
(
str
.
charAt
(
0
),
4
);
String
head
=
change
(
str
.
charAt
(
0
),
4
);
String
tail
=
change
(
str
.
charAt
(
str
.
length
()
-
1
),
7
);
String
tail
=
change
(
str
.
charAt
(
str
.
length
()
-
1
),
7
);
return
head
+
btw_str
+
tail
;
return
head
+
btw_str
+
tail
;
}
}
}
}
//根据偏移量转换字符
//根据偏移量转换字符
private
static
String
change
(
char
ch
,
int
offset
)
{
private
static
String
change
(
char
ch
,
int
offset
)
{
int
before
=
ch
;
int
before
=
ch
;
int
after
;
int
after
;
//a-z
//a-z
if
(
ch
>=
97
&&
ch
<=
122
)
{
if
(
ch
>=
97
&&
ch
<=
122
)
{
if
(
before
+
offset
<=
122
)
{
if
(
before
+
offset
<=
122
)
{
after
=
before
+
offset
;
after
=
before
+
offset
;
}
else
{
}
else
{
after
=
(
before
+
offset
)
%
122
+
96
;
after
=
(
before
+
offset
)
%
122
+
96
;
}
}
return
String
.
valueOf
((
char
)
after
);
return
String
.
valueOf
((
char
)
after
);
}
}
//A-Z
//A-Z
else
if
(
ch
>=
65
&&
ch
<=
90
)
{
else
if
(
ch
>=
65
&&
ch
<=
90
)
{
if
(
before
+
offset
<=
90
)
{
if
(
before
+
offset
<=
90
)
{
after
=
before
+
offset
;
after
=
before
+
offset
;
}
else
{
}
else
{
after
=
(
before
+
offset
)
%
90
+
64
;
after
=
(
before
+
offset
)
%
90
+
64
;
}
}
return
String
.
valueOf
((
char
)
after
);
return
String
.
valueOf
((
char
)
after
);
}
}
//0-9
//0-9
else
if
(
ch
>=
48
&&
ch
<=
57
)
{
else
if
(
ch
>=
48
&&
ch
<=
57
)
{
if
(
before
+
offset
<=
57
)
{
if
(
before
+
offset
<=
57
)
{
after
=
before
+
offset
;
after
=
before
+
offset
;
}
else
{
}
else
{
after
=
(
before
+
offset
)
%
57
+
47
;
after
=
(
before
+
offset
)
%
57
+
47
;
}
}
return
String
.
valueOf
((
char
)
after
);
return
String
.
valueOf
((
char
)
after
);
}
}
return
String
.
valueOf
(
ch
);
return
String
.
valueOf
(
ch
);
}
}
protected
boolean
isVersion2
()
{
protected
boolean
isVersion2
()
{
return
false
;
return
false
;
}
}
private
String
getVersion2Sql
()
{
private
String
getVersion2Sql
()
{
return
isVersion2
()
?
",m.img,m.stl,m.stlcls"
:
""
;
return
isVersion2
()
?
",m.img,m.stl,m.stlcls"
:
""
;
}
}
private
String
getVersion2String
(
ResultSet
rs
,
int
index
)
throws
SQLException
{
private
String
getVersion2String
(
ResultSet
rs
,
int
index
)
throws
SQLException
{
return
isVersion2
()
?
rs
.
getString
(
index
)
:
null
;
return
isVersion2
()
?
rs
.
getString
(
index
)
:
null
;
}
}
private
String
getI18nValue
(
String
key
)
{
private
boolean
setLogon
(
boolean
flag
,
String
userName
,
String
type
,
String
logText
,
Statement
stmt
,
ResultSet
rs
)
{
return
ctx
.
getGui
().
getI18nValue
(
"eibs"
,
key
);
DbUtils
.
closeQuietly
(
rs
);
}
DbUtils
.
closeQuietly
(
stmt
);
if
(
flag
)
{
private
boolean
setLogon
(
boolean
flag
,
String
userName
,
String
type
,
String
logText
,
Statement
stmt
,
ResultSet
rs
)
{
if
(
loginOnlyOnce
)
DbUtils
.
closeQuietly
(
rs
);
ctx
.
logout
(
DataType
.
USER_NAME
,
userName
);
DbUtils
.
closeQuietly
(
stmt
);
this
.
_userName
=
userName
;
if
(
flag
)
{
}
if
(
loginOnlyOnce
)
if
(
log
.
isDebugEnabled
())
{
ctx
.
logout
(
DataType
.
USER_NAME
,
userName
);
log
.
debug
(
String
.
format
(
"%s,userName=[%s]"
,
logText
,
userName
));
this
.
_userName
=
userName
;
}
}
errorText
=
flag
?
""
:
getI18nValue
(
type
);
if
(
log
.
isDebugEnabled
()){
this
.
flag
=
flag
;
log
.
debug
(
String
.
format
(
"%s,userName=[%s]"
,
logText
,
userName
));
return
flag
;
}
}
errorText
=
flag
?
""
:
getI18nValue
(
type
);
this
.
flag
=
flag
;
private
String
getI18nValue
(
String
key
)
{
return
flag
;
return
ctx
.
getGui
().
getI18nValue
(
"eibs"
,
key
);
}
}
private
boolean
setAuth
(
boolean
flag
,
Statement
stmt1
,
ResultSet
rs1
,
Statement
stmt2
,
ResultSet
rs2
)
{
private
boolean
setAuth
(
boolean
flag
,
Statement
stmt1
,
ResultSet
rs1
,
Statement
stmt2
,
ResultSet
rs2
)
{
DbUtils
.
closeQuietly
(
rs1
);
DbUtils
.
closeQuietly
(
rs1
);
DbUtils
.
closeQuietly
(
stmt1
);
DbUtils
.
closeQuietly
(
stmt1
);
DbUtils
.
closeQuietly
(
rs2
);
DbUtils
.
closeQuietly
(
rs2
);
DbUtils
.
closeQuietly
(
stmt2
);
DbUtils
.
closeQuietly
(
stmt2
);
this
.
authed
=
flag
;
this
.
authed
=
flag
;
return
flag
;
return
flag
;
}
}
@Override
@Override
public
String
getHomePageName
()
{
public
String
getHomePageName
()
{
return
homePageName
;
return
homePageName
;
}
}
@Override
@Override
public
String
getHomeTransaction
()
{
public
String
getHomeTransaction
()
{
return
homeTransaction
;
return
homeTransaction
;
}
}
@Override
@Override
public
int
getSessionTimeout
()
{
public
int
getSessionTimeout
()
{
return
sessionTimeout
;
return
sessionTimeout
;
}
}
public
String
checkPassword
(
String
userName
,
String
verifycode
,
String
dbPassword
,
String
password
)
{
public
String
checkPassword
(
String
userName
,
String
verifycode
,
String
dbPassword
,
String
password
)
{
password
=
pwdDecode
(
verifycode
,
password
);
password
=
pwdDecode
(
verifycode
,
password
);
IFilter
passwordFilter
=
NoUiUtils
.
passwordFilter
;
IFilter
passwordFilter
=
NoUiUtils
.
passwordFilter
;
if
(
NoUiUtils
.
passwordFilter
==
null
)
{
if
(
NoUiUtils
.
passwordFilter
==
null
)
{
log
.
warn
(
"未在eibs.xml为NoUiUtils配置passwordFilter项"
);
log
.
warn
(
"未在eibs.xml为NoUiUtils配置passwordFilter项"
);
recordException
(
PWDERROR
,
"密码校验异常:未在eibs.xml为NoUiUtils配置passwordFilter项"
,
"FATAL"
);
recordException
(
PWDERROR
,
"密码校验异常:未在eibs.xml为NoUiUtils配置passwordFilter项"
,
"FATAL"
);
return
null
;
return
null
;
}
}
if
(
dbPassword
!=
null
)
{
if
(
dbPassword
!=
null
)
{
dbPassword
=
dbPassword
.
trim
();
dbPassword
=
dbPassword
.
trim
();
}
}
// String encodedPassword = ContainerUtils.encodeWithSalt ? passwordFilter.encode(password, userName).trim() : passwordFilter.encode(password).trim();
// String encodedPassword = ContainerUtils.encodeWithSalt ? passwordFilter.encode(password, userName).trim() : passwordFilter.encode(password).trim();
// log.info("password反转回来==="+password+",userName===="+userName);
// log.info("password反转回来==="+password+",userName===="+userName);
String
encodedPassword
=
passwordFilter
.
encode
(
password
,
userName
).
trim
();
String
encodedPassword
=
passwordFilter
.
encode
(
password
,
userName
).
trim
();
// log.info("password国密解析==="+encodedPassword);
// log.info("password国密解析==="+encodedPassword);
if
(
log
.
isDebugEnabled
()){
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"password(input/db)"
+
dbPassword
+
"\t"
+
encodedPassword
);
log
.
debug
(
"password(input/db)"
+
dbPassword
+
"\t"
+
encodedPassword
);
}
}
if
(!
encodedPassword
.
equals
(
dbPassword
))
if
(!
encodedPassword
.
equals
(
dbPassword
))
return
"[Database: NOT Match.]"
;
return
"[Database: NOT Match.]"
;
return
null
;
return
null
;
}
}
@Override
@Override
public
boolean
login
(
Connection
conn
,
Map
parameterMap
)
{
public
boolean
login
(
Connection
conn
,
Map
parameterMap
)
{
this
.
_userName
=
null
;
this
.
_userName
=
null
;
String
userName
=
getParameter
(
parameterMap
,
"j_username"
);
String
userName
=
getParameter
(
parameterMap
,
"j_username"
);
String
password
=
getParameter
(
parameterMap
,
"j_password"
);
String
password
=
getParameter
(
parameterMap
,
"j_password"
);
String
sendcode
=
getParameter
(
parameterMap
,
"j_sendcode"
);
String
sendcode
=
getParameter
(
parameterMap
,
"j_sendcode"
);
String
verifycode
=
getParameter
(
parameterMap
,
"j_verifycode"
);
String
verifycode
=
getParameter
(
parameterMap
,
"j_verifycode"
);
String
dncode
=
getParameter
(
parameterMap
,
"j_dncode"
);
String
dncode
=
getParameter
(
parameterMap
,
"j_dncode"
);
if
(
userName
==
null
||
password
==
null
||
dncode
==
null
)
{
String
channel
=
getParameter
(
parameterMap
,
"j_channel"
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PARAMETER_CHECK
);
if
(
userName
==
null
||
password
==
null
||
dncode
==
null
)
{
return
setLogon
(
false
,
userName
,
ERROR_USERNAME_PASSWORD
,
"用户名或密码为空."
,
null
,
null
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PARAMETER_CHECK
);
}
return
setLogon
(
false
,
userName
,
ERROR_USERNAME_PASSWORD
,
"用户名或密码为空."
,
null
,
null
);
}
ResultSet
rs
=
null
;
PreparedStatement
stmt
=
null
;
ResultSet
rs
=
null
;
try
{
PreparedStatement
stmt
=
null
;
if
(
sendcode
==
null
||
verifycode
==
null
||
!
sendcode
.
equalsIgnoreCase
(
verifycode
))
{
try
{
log
.
info
(
"验证码验证失败,待校验:"
+
sendcode
+
",原始:"
+
verifycode
);
if
(
sendcode
==
null
||
verifycode
==
null
||
!
sendcode
.
equalsIgnoreCase
(
verifycode
))
{
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_VERIFYCODE_ERROR
);
log
.
info
(
"验证码验证失败,待校验:"
+
sendcode
+
",原始:"
+
verifycode
);
return
setLogon
(
false
,
userName
,
ErrorCode
.
LOGIN_VERIFYCODE_ERROR
.
getCode
(),
ErrorCode
.
LOGIN_VERIFYCODE_ERROR
.
getMessage
(),
stmt
,
rs
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_VERIFYCODE_ERROR
);
}
return
setLogon
(
false
,
userName
,
ErrorCode
.
LOGIN_VERIFYCODE_ERROR
.
getCode
(),
ErrorCode
.
LOGIN_VERIFYCODE_ERROR
.
getMessage
(),
stmt
,
rs
);
String
sql
=
"SELECT inr,pwd,fltcnt,sta,etyextkey,usg,pwdamedat,ukey FROM usr WHERE nam=?"
;
}
stmt
=
conn
.
prepareStatement
(
sql
);
String
sql
=
"SELECT inr,pwd,fltcnt,sta,etyextkey,usg,pwdamedat,ukey FROM usr WHERE nam=?"
;
stmt
.
setString
(
1
,
userName
);
stmt
=
conn
.
prepareStatement
(
sql
);
rs
=
stmt
.
executeQuery
();
stmt
.
setString
(
1
,
userName
);
if
(!
rs
.
next
())
{
rs
=
stmt
.
executeQuery
();
if
(!
guestAccountUsed
)
{
if
(!
rs
.
next
())
{
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_NON_USR
);
if
(!
guestAccountUsed
)
{
return
setLogon
(
false
,
userName
,
ERROR_USERNAME_PASSWORD
,
"系统无此用户."
,
stmt
,
rs
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_NON_USR
);
}
return
setLogon
(
false
,
userName
,
ERROR_USERNAME_PASSWORD
,
"系统无此用户."
,
stmt
,
rs
);
userName
=
"guest"
;
}
homePageName
=
"/register.zul"
;
userName
=
"guest"
;
homeTransaction
=
"usrreg"
;
homePageName
=
"/register.zul"
;
sessionTimeout
=
-
1
;
homeTransaction
=
"usrreg"
;
return
setLogon
(
true
,
userName
,
null
,
"游客成功登录."
,
stmt
,
rs
);
sessionTimeout
=
-
1
;
}
return
setLogon
(
true
,
userName
,
null
,
"游客成功登录."
,
stmt
,
rs
);
userId
=
rs
.
getString
(
1
);
}
if
(
log
.
isDebugEnabled
()){
userId
=
rs
.
getString
(
1
);
log
.
debug
(
"userId="
+
userId
);
if
(
log
.
isDebugEnabled
())
{
}
log
.
debug
(
"userId="
+
userId
);
String
dbPassword
=
rs
.
getString
(
2
);
}
int
faultCount
=
rs
.
getInt
(
3
);
String
dbPassword
=
rs
.
getString
(
2
);
String
userState
=
rs
.
getString
(
4
);
// 0:正常;1:注销;2:锁定
int
faultCount
=
rs
.
getInt
(
3
);
userEty
=
rs
.
getString
(
5
);
String
userState
=
rs
.
getString
(
4
);
// 0:正常;1:注销;2:锁定
userRol
=
rs
.
getString
(
6
);
userEty
=
rs
.
getString
(
5
);
pwdamedat
=
rs
.
getTimestamp
(
7
);
userRol
=
rs
.
getString
(
6
);
ukey
=
rs
.
getString
(
8
);
pwdamedat
=
rs
.
getTimestamp
(
7
);
DbUtils
.
closeQuietly
(
stmt
);
ukey
=
rs
.
getString
(
8
);
DbUtils
.
closeQuietly
(
rs
);
DbUtils
.
closeQuietly
(
stmt
);
String
errorStr
=
checkPassword
(
userName
,
sendcode
,
dbPassword
,
password
);
DbUtils
.
closeQuietly
(
rs
);
if
(
STATUS_LOCKED
.
equals
(
userState
))
{
if
(
channel
==
null
)
{
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_LOCK_USR
);
String
errorStr
=
checkPassword
(
userName
,
sendcode
,
dbPassword
,
password
);
return
setLogon
(
false
,
userName
,
ERROR_USER_LOCKED
,
"用户已被锁定."
,
stmt
,
rs
);
if
(
STATUS_LOCKED
.
equals
(
userState
))
{
}
else
if
(
STATUS_EXPIRED
.
equals
(
userState
))
{
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_LOCK_USR
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_EXPRIED_USR
);
return
setLogon
(
false
,
userName
,
ERROR_USER_LOCKED
,
"用户已被锁定."
,
stmt
,
rs
);
return
setLogon
(
false
,
userName
,
ERROR_USER_EXPRIED
,
"用户已被注销."
,
stmt
,
rs
);
}
else
if
(
STATUS_EXPIRED
.
equals
(
userState
))
{
}
else
if
(!
STATUS_NORMAL
.
equals
(
userState
))
{
//非0:正常;1:注销;2:锁定,不可登录,
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_EXPRIED_USR
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_STATE_ABNORMAL_ERROR
);
return
setLogon
(
false
,
userName
,
ERROR_USER_EXPRIED
,
"用户已被注销."
,
stmt
,
rs
);
return
setLogon
(
false
,
userName
,
ErrorCode
.
LOGIN_STATE_ABNORMAL_ERROR
.
getCode
(),
ErrorCode
.
LOGIN_STATE_ABNORMAL_ERROR
.
getMessage
(),
stmt
,
rs
);
}
else
if
(!
STATUS_NORMAL
.
equals
(
userState
))
{
//非0:正常;1:注销;2:锁定,不可登录,
}
else
if
(!
Objects
.
equals
(
ukey
,
dncode
))
{
//dn码错误
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_STATE_ABNORMAL_ERROR
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_DN_ERROR
);
return
setLogon
(
false
,
userName
,
ErrorCode
.
LOGIN_STATE_ABNORMAL_ERROR
.
getCode
(),
ErrorCode
.
LOGIN_STATE_ABNORMAL_ERROR
.
getMessage
(),
stmt
,
rs
);
return
setLogon
(
false
,
userName
,
ErrorCode
.
LOGIN_DN_ERROR
.
getCode
(),
ErrorCode
.
LOGIN_DN_ERROR
.
getMessage
(),
stmt
,
rs
);
}
else
if
(!
Objects
.
equals
(
ukey
,
dncode
))
{
//dn码错误
}
else
if
(
Objects
.
nonNull
(
errorStr
))
{
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_DN_ERROR
);
// 校验密码
return
setLogon
(
false
,
userName
,
ErrorCode
.
LOGIN_DN_ERROR
.
getCode
(),
ErrorCode
.
LOGIN_DN_ERROR
.
getMessage
(),
stmt
,
rs
);
sql
=
"UPDATE usr SET fltcnt=?,sta=?,lstfltdattim=? WHERE inr=?"
;
}
else
if
(
Objects
.
nonNull
(
errorStr
))
{
stmt
=
conn
.
prepareStatement
(
sql
);
// 校验密码
faultCount
++;
sql
=
"UPDATE usr SET fltcnt=?,sta=?,lstfltdattim=? WHERE inr=?"
;
stmt
.
setInt
(
1
,
faultCount
);
stmt
=
conn
.
prepareStatement
(
sql
);
stmt
.
setString
(
2
,
faultCount
>=
maxfltcnt
?
STATUS_LOCKED
:
userState
);
faultCount
++;
stmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
stmt
.
setInt
(
1
,
faultCount
);
stmt
.
setString
(
4
,
userId
);
stmt
.
setString
(
2
,
faultCount
>=
maxfltcnt
?
STATUS_LOCKED
:
userState
);
stmt
.
execute
();
stmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
conn
.
commit
();
stmt
.
setString
(
4
,
userId
);
if
(
faultCount
>=
maxfltcnt
)
{
stmt
.
execute
();
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PWD_CHECK
);
conn
.
commit
();
}
else
{
if
(
faultCount
>=
maxfltcnt
)
{
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PWD_ERROR
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PWD_CHECK
);
}
}
else
{
return
setLogon
(
false
,
userName
,
ERROR_USERNAME_PASSWORD
,
String
.
format
(
"密码验证失败.%s."
,
errorStr
),
stmt
,
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PWD_ERROR
);
rs
);
}
}
else
if
(
Objects
.
isNull
(
pwdamedat
))
{
//初次登陆
return
setLogon
(
false
,
userName
,
ERROR_USERNAME_PASSWORD
,
String
.
format
(
"密码验证失败.%s."
,
errorStr
),
stmt
,
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_FIRST_LOGIN
);
rs
);
return
setLogon
(
true
,
userName
,
ErrorCode
.
LOGIN_FIRST_LOGIN
.
getCode
(),
ErrorCode
.
LOGIN_FIRST_LOGIN
.
getMessage
(),
stmt
,
rs
);
}
else
if
(
Objects
.
isNull
(
pwdamedat
))
{
//初次登陆
}
else
if
(
pwdamedat
.
toLocalDateTime
().
plus
(
pwdAmeInterval
).
isBefore
(
LocalDateTime
.
now
()))
{
//超过指定时间仍为修改密码
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_FIRST_LOGIN
);
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PWD_AME_INTERVAL
);
return
setLogon
(
true
,
userName
,
ErrorCode
.
LOGIN_FIRST_LOGIN
.
getCode
(),
ErrorCode
.
LOGIN_FIRST_LOGIN
.
getMessage
(),
stmt
,
rs
);
return
setLogon
(
true
,
userName
,
ErrorCode
.
LOGIN_PWD_AME_INTERVAL
.
getCode
(),
ErrorCode
.
LOGIN_PWD_AME_INTERVAL
.
getMessage
(),
stmt
,
rs
);
}
else
if
(
pwdamedat
.
toLocalDateTime
().
plus
(
pwdAmeInterval
).
isBefore
(
LocalDateTime
.
now
()))
{
//超过指定时间仍为修改密码
}
parameterMap
.
put
(
ERROR
,
ErrorCode
.
LOGIN_PWD_AME_INTERVAL
);
if
(
log
.
isDebugEnabled
()){
return
setLogon
(
true
,
userName
,
ErrorCode
.
LOGIN_PWD_AME_INTERVAL
.
getCode
(),
ErrorCode
.
LOGIN_PWD_AME_INTERVAL
.
getMessage
(),
stmt
,
rs
);
log
.
debug
(
"faultCount="
+
faultCount
);
}
}
if
(
log
.
isDebugEnabled
())
{
sql
=
"UPDATE usr SET fltcnt=?,sta=?,lstdattim=? WHERE inr=?"
;
log
.
debug
(
"faultCount="
+
faultCount
);
stmt
=
conn
.
prepareStatement
(
sql
);
}
stmt
.
setInt
(
1
,
0
);
}
stmt
.
setString
(
2
,
STATUS_NORMAL
);
stmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
sql
=
"UPDATE usr SET fltcnt=?,sta=?,lstdattim=? WHERE inr=?"
;
stmt
.
setString
(
4
,
userId
);
stmt
=
conn
.
prepareStatement
(
sql
);
stmt
.
execute
();
stmt
.
setInt
(
1
,
0
);
conn
.
commit
();
stmt
.
setString
(
2
,
STATUS_NORMAL
);
// 监控用户返回监控页面
stmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
if
(
"monitor"
.
equals
(
userName
))
{
stmt
.
setString
(
4
,
userId
);
homePageName
=
"/monitor.zul"
;
stmt
.
execute
();
homeTransaction
=
"monitor"
;
conn
.
commit
();
sessionTimeout
=
-
1
;
// 监控用户返回监控页面
return
setLogon
(
true
,
userName
,
null
,
"监控用户成功登录."
,
stmt
,
rs
);
if
(
"monitor"
.
equals
(
userName
))
{
}
homePageName
=
"/monitor.zul"
;
homePageName
=
defaultHomePageName
;
homeTransaction
=
"monitor"
;
homeTransaction
=
defaultHomeTransaction
;
sessionTimeout
=
-
1
;
sessionTimeout
=
defaultSessionTimeout
;
return
setLogon
(
true
,
userName
,
null
,
"监控用户成功登录."
,
stmt
,
rs
);
}
catch
(
Throwable
e
)
{
}
log
.
error
(
"系统登录内部错误"
,
e
);
homePageName
=
defaultHomePageName
;
parameterMap
.
put
(
ERROR
,
ErrorCode
.
SYSTEM_ERROR
);
homeTransaction
=
defaultHomeTransaction
;
return
setLogon
(
false
,
userName
,
ERROR_SYSTEM_FAULT
,
"系统内部错误."
,
stmt
,
rs
);
sessionTimeout
=
defaultSessionTimeout
;
}
}
catch
(
Throwable
e
)
{
return
setLogon
(
true
,
userName
,
null
,
"成功登录."
,
stmt
,
rs
);
log
.
error
(
"系统登录内部错误"
,
e
);
}
parameterMap
.
put
(
ERROR
,
ErrorCode
.
SYSTEM_ERROR
);
return
setLogon
(
false
,
userName
,
ERROR_SYSTEM_FAULT
,
"系统内部错误."
,
stmt
,
rs
);
@Override
}
public
boolean
auth
(
Connection
conn
,
Map
parameterMap
)
{
return
setLogon
(
true
,
userName
,
null
,
"成功登录."
,
stmt
,
rs
);
if
(
log
.
isDebugEnabled
()){
}
log
.
debug
(
"正在加载当前用户菜单."
);
}
@Override
String
sql
=
""
;
public
boolean
auth
(
Connection
conn
,
Map
parameterMap
)
{
ResultSet
rs
=
null
;
if
(
log
.
isDebugEnabled
())
{
PreparedStatement
stmt
=
null
;
log
.
debug
(
"正在加载当前用户菜单."
);
ResultSet
subRs
=
null
;
}
PreparedStatement
subStmt
=
null
;
String
sql
=
""
;
try
{
ResultSet
rs
=
null
;
// 进行菜单处理
PreparedStatement
stmt
=
null
;
Map
<
String
,
Menu
>
menuMap
=
new
HashMap
();
// 全部菜单
ResultSet
subRs
=
null
;
Map
<
String
,
Menu
>
frequentMap
=
new
HashMap
();
// 常用菜单
PreparedStatement
subStmt
=
null
;
// 加载所有默认可访问的交易
try
{
// sql = "SELECT inr,pntinr,frm,dsp,typ,flg" + getVersion2Sql() + " FROM frm m
// 进行菜单处理
// WHERE typ=? OR typ=?"
Map
<
String
,
Menu
>
menuMap
=
new
HashMap
();
// 全部菜单
sql
=
"select frm.inr,frm.pntinr,frm.frm,frm.dsp,frm.typ,frm.flg from frm,frr where frr.rol=? and frr.etyextkey=? and frr.frm=substr(frm.dsp,6)"
;
Map
<
String
,
Menu
>
frequentMap
=
new
HashMap
();
// 常用菜单
stmt
=
conn
.
prepareStatement
(
sql
);
// 加载所有默认可访问的交易
stmt
.
setString
(
1
,
userRol
);
// sql = "SELECT inr,pntinr,frm,dsp,typ,flg" + getVersion2Sql() + " FROM frm m
stmt
.
setString
(
2
,
userEty
);
// WHERE typ=? OR typ=?"
rs
=
stmt
.
executeQuery
();
sql
=
"select frm.inr,frm.pntinr,frm.frm,frm.dsp,frm.typ,frm.flg from frm,frr where frr.rol=? and frr.etyextkey=? and frr.frm=substr(frm.dsp,6)"
;
while
(
rs
.
next
())
{
stmt
=
conn
.
prepareStatement
(
sql
);
String
id
=
rs
.
getString
(
INDEX_INR
);
stmt
.
setString
(
1
,
userRol
);
Menu
menu
=
new
Menu
(
id
,
rs
.
getString
(
INDEX_PNTINR
),
rs
.
getString
(
INDEX_FRM
),
stmt
.
setString
(
2
,
userEty
);
getVersion2String
(
rs
,
INDEX_IMG
),
getVersion2String
(
rs
,
INDEX_STL
),
rs
=
stmt
.
executeQuery
();
getVersion2String
(
rs
,
INDEX_CLS
),
rs
.
getString
(
INDEX_DSP
),
rs
.
getString
(
INDEX_FLG
));
while
(
rs
.
next
())
{
if
(!
menuMap
.
containsKey
(
id
))
String
id
=
rs
.
getString
(
INDEX_INR
);
menuMap
.
put
(
id
,
menu
);
Menu
menu
=
new
Menu
(
id
,
rs
.
getString
(
INDEX_PNTINR
),
rs
.
getString
(
INDEX_FRM
),
if
(
TYPE_FREQUENT
.
equals
(
rs
.
getString
(
INDEX_TYP
)))
getVersion2String
(
rs
,
INDEX_IMG
),
getVersion2String
(
rs
,
INDEX_STL
),
if
(!
frequentMap
.
containsKey
(
id
))
getVersion2String
(
rs
,
INDEX_CLS
),
rs
.
getString
(
INDEX_DSP
),
rs
.
getString
(
INDEX_FLG
));
frequentMap
.
put
(
id
,
menu
);
if
(!
menuMap
.
containsKey
(
id
))
}
menuMap
.
put
(
id
,
menu
);
DbUtils
.
closeQuietly
(
stmt
);
if
(
TYPE_FREQUENT
.
equals
(
rs
.
getString
(
INDEX_TYP
)))
DbUtils
.
closeQuietly
(
rs
);
if
(!
frequentMap
.
containsKey
(
id
))
frequentMap
.
put
(
id
,
menu
);
// 进行排序
}
List
<
Menu
>
menus
=
new
ArrayList
(
menuMap
.
values
());
DbUtils
.
closeQuietly
(
stmt
);
Collections
.
sort
(
menus
);
DbUtils
.
closeQuietly
(
rs
);
List
<
Menu
>
frequents
=
new
ArrayList
(
frequentMap
.
values
());
Collections
.
sort
(
frequents
);
// 进行排序
// 通过addMenu查询并增加菜单(若未添加成功直接添加为根菜单),同时添加可访问交易
List
<
Menu
>
menus
=
new
ArrayList
(
menuMap
.
values
());
for
(
Menu
menu
:
menus
)
{
Collections
.
sort
(
menus
);
if
(!
ContainerUtils
.
isEmpty
(
menu
.
transactionName
))
List
<
Menu
>
frequents
=
new
ArrayList
(
frequentMap
.
values
());
this
.
trans
.
put
(
menu
.
transactionName
,
getI18nValue
(
menu
.
descriptionKey
));
Collections
.
sort
(
frequents
);
if
(!
FLAG_INDIRECT
.
equals
(
menu
.
flag
)
&&
!
addMenu
(
this
.
menu
,
menuMap
.
get
(
menu
.
parentId
),
menu
))
// 通过addMenu查询并增加菜单(若未添加成功直接添加为根菜单),同时添加可访问交易
this
.
menu
.
add
(
for
(
Menu
menu
:
menus
)
{
new
MenuItem
(
menu
.
id
,
getI18nValue
(
menu
.
descriptionKey
),
menu
.
transactionName
,
menu
.
image
));
if
(!
ContainerUtils
.
isEmpty
(
menu
.
transactionName
))
}
this
.
trans
.
put
(
menu
.
transactionName
,
getI18nValue
(
menu
.
descriptionKey
));
// 删除菜单中为空的父项
if
(!
FLAG_INDIRECT
.
equals
(
menu
.
flag
)
&&
!
addMenu
(
this
.
menu
,
menuMap
.
get
(
menu
.
parentId
),
menu
))
checkMenu
(
this
.
menu
);
this
.
menu
.
add
(
// 添加常用菜单
new
MenuItem
(
menu
.
id
,
getI18nValue
(
menu
.
descriptionKey
),
menu
.
transactionName
,
menu
.
image
));
MenuItem
frequentItem
=
new
MenuItem
(
null
,
getI18nValue
(
MENU_FREQUENT_ITEM
),
null
,
imageFrequent
);
}
for
(
Menu
frequent
:
frequents
)
// 删除菜单中为空的父项
if
(!
FLAG_INDIRECT
.
equals
(
frequent
.
flag
))
checkMenu
(
this
.
menu
);
frequentItem
.
add
(
new
MenuItem
(
frequent
.
id
,
getI18nValue
(
frequent
.
descriptionKey
),
// 添加常用菜单
frequent
.
transactionName
,
frequent
.
image
));
MenuItem
frequentItem
=
new
MenuItem
(
null
,
getI18nValue
(
MENU_FREQUENT_ITEM
),
null
,
imageFrequent
);
if
(!
frequentItem
.
isEmpty
())
for
(
Menu
frequent
:
frequents
)
this
.
menu
.
add
(
frequentItem
);
if
(!
FLAG_INDIRECT
.
equals
(
frequent
.
flag
))
}
catch
(
Exception
e
)
{
frequentItem
.
add
(
new
MenuItem
(
frequent
.
id
,
getI18nValue
(
frequent
.
descriptionKey
),
return
setAuth
(
false
,
stmt
,
rs
,
subStmt
,
subRs
);
frequent
.
transactionName
,
frequent
.
image
));
}
if
(!
frequentItem
.
isEmpty
())
return
setAuth
(
true
,
stmt
,
rs
,
subStmt
,
subRs
);
this
.
menu
.
add
(
frequentItem
);
}
}
catch
(
Exception
e
)
{
return
setAuth
(
false
,
stmt
,
rs
,
subStmt
,
subRs
);
public
IMenuItem
filterMenu
(
IMenuItem
menuItem
,
String
filter
)
{
}
for
(
IMenuItem
item
:
menuItem
)
{
return
setAuth
(
true
,
stmt
,
rs
,
subStmt
,
subRs
);
if
(
filter
.
equals
(((
MenuItem
)
item
).
id
))
}
return
item
;
IMenuItem
result
=
filterMenu
(
item
,
filter
);
public
IMenuItem
filterMenu
(
IMenuItem
menuItem
,
String
filter
)
{
if
(
result
!=
null
)
for
(
IMenuItem
item
:
menuItem
)
{
return
result
;
if
(
filter
.
equals
(((
MenuItem
)
item
).
id
))
}
return
item
;
return
null
;
IMenuItem
result
=
filterMenu
(
item
,
filter
);
}
if
(
result
!=
null
)
return
result
;
@Override
}
public
IMenuItem
getMenu
()
{
return
null
;
if
(
ContainerUtils
.
isEmpty
(
menuFilter
))
}
return
menu
;
return
filterMenu
(
menu
,
menuFilter
);
@Override
}
public
IMenuItem
getMenu
()
{
if
(
ContainerUtils
.
isEmpty
(
menuFilter
))
@Override
return
menu
;
protected
String
getParameter
(
Map
map
,
String
key
)
{
return
filterMenu
(
menu
,
menuFilter
);
if
(
map
==
null
)
}
return
null
;
Object
o
=
map
.
get
(
key
);
@Override
if
(
o
==
null
)
protected
String
getParameter
(
Map
map
,
String
key
)
{
return
null
;
if
(
map
==
null
)
else
if
(
o
instanceof
String
)
return
null
;
return
(
String
)
o
;
Object
o
=
map
.
get
(
key
);
else
if
(
o
instanceof
String
[])
if
(
o
==
null
)
return
((
String
[])
o
)[
0
];
return
null
;
else
else
if
(
o
instanceof
String
)
return
o
.
toString
();
return
(
String
)
o
;
}
else
if
(
o
instanceof
String
[])
return
((
String
[])
o
)[
0
];
@Override
else
public
Object
getValue
(
String
key
)
{
return
o
.
toString
();
if
(
"usrinr"
.
equals
(
key
))
}
return
userId
;
return
null
;
@Override
}
public
Object
getValue
(
String
key
)
{
if
(
"usrinr"
.
equals
(
key
))
@Override
return
userId
;
public
String
getCustomNumber
()
{
return
null
;
return
""
;
}
}
@Override
protected
void
checkMenu
(
IMenuItem
menu
)
{
public
String
getCustomNumber
()
{
for
(
int
i
=
menu
.
size
()
-
1
;
i
>=
0
;
i
--)
{
return
""
;
IMenuItem
item
=
menu
.
get
(
i
);
}
if
(
ContainerUtils
.
isEmpty
(
item
.
getValue
()))
{
if
(
item
.
isEmpty
())
protected
void
checkMenu
(
IMenuItem
menu
)
{
menu
.
remove
(
item
);
for
(
int
i
=
menu
.
size
()
-
1
;
i
>=
0
;
i
--)
{
else
IMenuItem
item
=
menu
.
get
(
i
);
checkMenu
(
item
);
if
(
ContainerUtils
.
isEmpty
(
item
.
getValue
()))
{
}
if
(
item
.
isEmpty
())
}
menu
.
remove
(
item
);
}
else
checkMenu
(
item
);
private
void
calculateMenu
(
ResultSet
rs
,
Map
<
String
,
Menu
>
menuList
,
Map
<
String
,
Menu
>
frequentList
,
}
List
<
String
>
removeMenuList
,
List
<
String
>
removeFrequentList
,
boolean
flag
)
throws
Exception
{
// 如果为用户信息或第一条角色信息时,直接操作待删除菜单和待删除常用菜单
}
// 注:多角色叠加菜单时以最大可显示的方式进行处理:可见/常用直接增加,不可见或不常用待全部角色都不可见或不常用时才处理(多角色在所有角色处理结束后再处理)
}
// 当flag为true时表示直接处理/直接处理待删除菜单和待删除常用菜单、false时表示需多次处理/本次不可见和不常用需要对原有待删除菜单和待删除常用菜单进行比较
List
<
String
>
_removeMenuList
=
flag
?
removeMenuList
:
new
ArrayList
();
private
void
calculateMenu
(
ResultSet
rs
,
Map
<
String
,
Menu
>
menuList
,
Map
<
String
,
Menu
>
frequentList
,
List
<
String
>
_removeFrequentList
=
flag
?
removeFrequentList
:
new
ArrayList
();
List
<
String
>
removeMenuList
,
List
<
String
>
removeFrequentList
,
boolean
flag
)
throws
Exception
{
// 如果为用户信息或第一条角色信息时,直接操作待删除菜单和待删除常用菜单
while
(
rs
.
next
())
{
// 注:多角色叠加菜单时以最大可显示的方式进行处理:可见/常用直接增加,不可见或不常用待全部角色都不可见或不常用时才处理(多角色在所有角色处理结束后再处理)
String
id
=
rs
.
getString
(
INDEX_INR
);
// 当flag为true时表示直接处理/直接处理待删除菜单和待删除常用菜单、false时表示需多次处理/本次不可见和不常用需要对原有待删除菜单和待删除常用菜单进行比较
String
parentId
=
rs
.
getString
(
INDEX_PNTINR
);
List
<
String
>
_removeMenuList
=
flag
?
removeMenuList
:
new
ArrayList
();
String
type
=
rs
.
getString
(
INDEX_TYP
);
List
<
String
>
_removeFrequentList
=
flag
?
removeFrequentList
:
new
ArrayList
();
if
(
TYPE_FREQUENT
.
equals
(
type
))
{
// 常用菜单直接增加至可见和常用
while
(
rs
.
next
())
{
Menu
menu
=
new
Menu
(
id
,
parentId
,
rs
.
getString
(
INDEX_FRM
),
getVersion2String
(
rs
,
INDEX_IMG
),
String
id
=
rs
.
getString
(
INDEX_INR
);
getVersion2String
(
rs
,
INDEX_STL
),
getVersion2String
(
rs
,
INDEX_CLS
),
rs
.
getString
(
INDEX_DSP
),
String
parentId
=
rs
.
getString
(
INDEX_PNTINR
);
rs
.
getString
(
INDEX_FLG
));
String
type
=
rs
.
getString
(
INDEX_TYP
);
if
(!
menuList
.
containsKey
(
id
))
if
(
TYPE_FREQUENT
.
equals
(
type
))
{
// 常用菜单直接增加至可见和常用
menuList
.
put
(
id
,
menu
);
Menu
menu
=
new
Menu
(
id
,
parentId
,
rs
.
getString
(
INDEX_FRM
),
getVersion2String
(
rs
,
INDEX_IMG
),
if
(!
frequentList
.
containsKey
(
id
))
getVersion2String
(
rs
,
INDEX_STL
),
getVersion2String
(
rs
,
INDEX_CLS
),
rs
.
getString
(
INDEX_DSP
),
frequentList
.
put
(
id
,
menu
);
rs
.
getString
(
INDEX_FLG
));
}
else
if
(
TYPE_VISIBLE
.
equals
(
type
))
{
// 可见菜单直接增加至可见,增加待删除常用
if
(!
menuList
.
containsKey
(
id
))
if
(!
menuList
.
containsKey
(
id
))
{
menuList
.
put
(
id
,
menu
);
Menu
menu
=
new
Menu
(
id
,
parentId
,
rs
.
getString
(
INDEX_FRM
),
getVersion2String
(
rs
,
INDEX_IMG
),
if
(!
frequentList
.
containsKey
(
id
))
getVersion2String
(
rs
,
INDEX_STL
),
getVersion2String
(
rs
,
INDEX_CLS
),
rs
.
getString
(
INDEX_DSP
),
frequentList
.
put
(
id
,
menu
);
rs
.
getString
(
INDEX_FLG
));
}
else
if
(
TYPE_VISIBLE
.
equals
(
type
))
{
// 可见菜单直接增加至可见,增加待删除常用
menuList
.
put
(
id
,
menu
);
if
(!
menuList
.
containsKey
(
id
))
{
}
Menu
menu
=
new
Menu
(
id
,
parentId
,
rs
.
getString
(
INDEX_FRM
),
getVersion2String
(
rs
,
INDEX_IMG
),
if
(!
_removeFrequentList
.
contains
(
id
))
getVersion2String
(
rs
,
INDEX_STL
),
getVersion2String
(
rs
,
INDEX_CLS
),
rs
.
getString
(
INDEX_DSP
),
_removeFrequentList
.
add
(
id
);
rs
.
getString
(
INDEX_FLG
));
}
else
if
(
TYPE_INVISIBLE
.
equals
(
type
))
{
// 不可见菜单,增加待删除和待删除常用
menuList
.
put
(
id
,
menu
);
if
(!
_removeMenuList
.
contains
(
id
))
}
_removeMenuList
.
add
(
id
);
if
(!
_removeFrequentList
.
contains
(
id
))
if
(!
_removeFrequentList
.
contains
(
id
))
_removeFrequentList
.
add
(
id
);
_removeFrequentList
.
add
(
id
);
}
else
if
(
TYPE_INVISIBLE
.
equals
(
type
))
{
// 不可见菜单,增加待删除和待删除常用
}
if
(!
_removeMenuList
.
contains
(
id
))
}
_removeMenuList
.
add
(
id
);
if
(!
flag
)
{
// 从第二条(含)角色信息开始
if
(!
_removeFrequentList
.
contains
(
id
))
// 如果之前为待删除,但在本次不为待删除则剔除;常用菜单处理亦然
_removeFrequentList
.
add
(
id
);
for
(
int
i
=
removeMenuList
.
size
()
-
1
;
i
>=
0
;
i
--)
}
if
(!
_removeMenuList
.
contains
(
removeMenuList
.
get
(
i
)))
}
removeMenuList
.
remove
(
i
);
if
(!
flag
)
{
// 从第二条(含)角色信息开始
for
(
int
i
=
removeFrequentList
.
size
()
-
1
;
i
>=
0
;
i
--)
// 如果之前为待删除,但在本次不为待删除则剔除;常用菜单处理亦然
if
(!
_removeFrequentList
.
contains
(
removeFrequentList
.
get
(
i
)))
for
(
int
i
=
removeMenuList
.
size
()
-
1
;
i
>=
0
;
i
--)
removeFrequentList
.
remove
(
i
);
if
(!
_removeMenuList
.
contains
(
removeMenuList
.
get
(
i
)))
}
removeMenuList
.
remove
(
i
);
}
for
(
int
i
=
removeFrequentList
.
size
()
-
1
;
i
>=
0
;
i
--)
if
(!
_removeFrequentList
.
contains
(
removeFrequentList
.
get
(
i
)))
private
boolean
addMenu
(
MenuItem
item
,
Menu
parentMenu
,
Menu
menu
)
{
removeFrequentList
.
remove
(
i
);
if
(
parentMenu
==
null
||
parentMenu
.
id
.
equals
(
item
.
id
))
{
}
item
.
add
(
new
MenuItem
(
menu
.
id
,
getI18nValue
(
menu
.
descriptionKey
),
menu
.
transactionName
,
menu
.
image
));
}
return
true
;
}
private
boolean
addMenu
(
MenuItem
item
,
Menu
parentMenu
,
Menu
menu
)
{
for
(
IMenuItem
subItem
:
item
)
if
(
parentMenu
==
null
||
parentMenu
.
id
.
equals
(
item
.
id
))
{
if
(
addMenu
((
MenuItem
)
subItem
,
parentMenu
,
menu
))
item
.
add
(
new
MenuItem
(
menu
.
id
,
getI18nValue
(
menu
.
descriptionKey
),
menu
.
transactionName
,
menu
.
image
));
return
true
;
return
true
;
return
false
;
}
}
for
(
IMenuItem
subItem
:
item
)
if
(
addMenu
((
MenuItem
)
subItem
,
parentMenu
,
menu
))
class
Menu
implements
Comparable
<
Menu
>
{
return
true
;
String
id
;
return
false
;
String
parentId
;
}
String
transactionName
;
String
image
;
class
Menu
implements
Comparable
<
Menu
>
{
String
style
;
String
id
;
String
styleClass
;
String
parentId
;
String
descriptionKey
;
String
transactionName
;
String
flag
;
String
image
;
String
style
;
public
Menu
(
String
id
,
String
parentId
,
String
transactionName
,
String
image
,
String
style
,
String
styleClass
,
String
styleClass
;
String
descriptionKey
,
String
flag
)
{
String
descriptionKey
;
this
.
id
=
id
;
String
flag
;
this
.
parentId
=
parentId
;
this
.
transactionName
=
transactionName
;
public
Menu
(
String
id
,
String
parentId
,
String
transactionName
,
String
image
,
String
style
,
String
styleClass
,
this
.
image
=
image
;
String
descriptionKey
,
String
flag
)
{
this
.
style
=
style
;
this
.
id
=
id
;
this
.
styleClass
=
styleClass
;
this
.
parentId
=
parentId
;
this
.
descriptionKey
=
descriptionKey
;
this
.
transactionName
=
transactionName
;
this
.
flag
=
flag
;
this
.
image
=
image
;
}
this
.
style
=
style
;
this
.
styleClass
=
styleClass
;
@Override
this
.
descriptionKey
=
descriptionKey
;
public
int
compareTo
(
Menu
menu
)
{
this
.
flag
=
flag
;
if
(
parentId
==
null
&&
menu
.
parentId
!=
null
)
}
return
-
1
;
else
if
(
parentId
!=
null
&&
menu
.
parentId
==
null
)
@Override
return
1
;
public
int
compareTo
(
Menu
menu
)
{
return
id
.
compareTo
(
menu
.
id
);
if
(
parentId
==
null
&&
menu
.
parentId
!=
null
)
}
return
-
1
;
else
if
(
parentId
!=
null
&&
menu
.
parentId
==
null
)
@Override
return
1
;
public
String
toString
()
{
return
id
.
compareTo
(
menu
.
id
);
if
(
parentId
==
null
)
}
return
"<NULL>"
+
id
+
transactionName
;
return
parentId
+
id
+
transactionName
;
@Override
}
public
String
toString
()
{
}
if
(
parentId
==
null
)
return
"<NULL>"
+
id
+
transactionName
;
class
MenuItem
extends
MenuItemImpl
{
return
parentId
+
id
+
transactionName
;
String
id
;
}
}
MenuItem
()
{
}
class
MenuItem
extends
MenuItemImpl
{
String
id
;
MenuItem
(
String
id
,
String
label
,
String
transactionName
,
String
image
)
{
super
(
label
,
transactionName
,
image
);
MenuItem
()
{
if
(
image
==
null
&&
imageNull
!=
null
)
}
this
.
image
=
imageNull
;
this
.
id
=
id
;
MenuItem
(
String
id
,
String
label
,
String
transactionName
,
String
image
)
{
}
super
(
label
,
transactionName
,
image
);
if
(
image
==
null
&&
imageNull
!=
null
)
@Override
this
.
image
=
imageNull
;
public
String
toString
()
{
this
.
id
=
id
;
return
String
.
format
(
"Id = %s,Label = %s,Value = %s"
,
id
,
label
,
value
);
}
}
}
@Override
public
String
toString
()
{
return
String
.
format
(
"Id = %s,Label = %s,Value = %s"
,
id
,
label
,
value
);
}
}
}
}
\ No newline at end of file
src/main/java/org/sss/presentation/noui/controller/CoasHandleController.java
0 → 100644
View file @
01135a00
package
org
.
sss
.
presentation
.
noui
.
controller
;
import
com.google.gson.Gson
;
import
log.Log
;
import
log.LogFactory
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.Session
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.view.RedirectView
;
import
org.sss.module.hibernate.HibernateUtils
;
import
org.sss.presentation.noui.util.DataSecurityUtil
;
import
org.sss.presentation.noui.util.HttpClientUtil
;
import
org.sss.presentation.noui.util.StringUtil
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Controller
@PropertySource
({
"classpath:coas.properties"
})
public
class
CoasHandleController
{
final
static
Log
log
=
LogFactory
.
getLog
(
CoasHandleController
.
class
);
@Value
(
"${client_id:ESFE}"
)
private
String
client_id
;
@Value
(
"${client_secret}"
)
private
String
client_secret
;
@Value
(
"${coas_server}"
)
private
String
coas_server
;
private
Gson
gson
=
new
Gson
();
@RequestMapping
(
value
=
"/oaut2/callback"
,
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
GET
})
public
ModelAndView
callback
(
@RequestParam
(
"type"
)
String
type
,
@RequestParam
(
"value"
)
String
value
,
@RequestHeader
(
value
=
"certdn"
,
required
=
false
)
String
certdn
,
ModelAndView
view
)
{
try
{
Map
<
String
,
String
>
body
=
new
HashMap
<>();
body
.
put
(
"client_id"
,
client_id
);
body
.
put
(
"client_secret"
,
client_secret
);
body
.
put
(
"code"
,
value
);
String
url
=
coas_server
+
"get_token?client_id={client_id}&client_secret={client_secret}&code={code}"
;
if
(!
StringUtil
.
isEmpty
(
certdn
))
{
body
.
put
(
"user_certdn"
,
certdn
);
url
+=
"&user_certdn={user_certdn}"
;
}
log
.
info
(
"准备请求:"
+
url
+
"请求参数:"
+
body
);
// ResponseEntity<String> res = HttpClientUtil.post(coas_server + "get_token", body, String.class);
ResponseEntity
<
String
>
res
=
HttpClientUtil
.
post
(
url
,
null
,
String
.
class
,
body
);
String
res_str
=
res
.
getBody
();
Map
<
String
,
Object
>
res_body
=
gson
.
fromJson
(
res_str
,
Map
.
class
);
log
.
info
(
"调用coas的get_token接口响应:"
+
res_body
);
checkRes
(
res
,
(
String
)
res_body
.
get
(
"msgCode"
),
(
String
)
res_body
.
get
(
"message"
),
"get_token"
);
String
access_token
=
(
String
)
res_body
.
get
(
"access_token"
);
String
token_type
=
(
String
)
res_body
.
get
(
"token_type"
);
// log.info(String.format("准备调用coas的get_info接口.access_token=[%s],token_type=[%s]", access_token, token_type));
body
=
new
HashMap
<>();
body
.
put
(
"access_token"
,
access_token
);
// res = HttpClientUtil.post(coas_server + "get_info", body, String.class);
url
=
coas_server
+
"get_info?access_token={access_token}"
;
log
.
info
(
"准备请求:"
+
url
+
"请求参数:"
+
body
);
res
=
HttpClientUtil
.
post
(
url
,
null
,
String
.
class
,
body
);
res_str
=
res
.
getBody
();
res_body
=
gson
.
fromJson
(
res_str
,
Map
.
class
);
log
.
info
(
"调用coas的get_info接口响应:"
+
res_body
);
checkRes
(
res
,
(
String
)
res_body
.
get
(
"msgCode"
),
(
String
)
res_body
.
get
(
"message"
),
"get_info"
);
Map
<
String
,
Object
>
info
=
(
Map
<
String
,
Object
>)
res_body
.
get
(
"info"
);
log
.
info
(
"获取到用户信息:"
+
info
);
String
userid
=
(
String
)
info
.
get
(
"loginid"
);
//验证该用户是否在我方存在
Session
session
=
HibernateUtils
.
openSession
(
null
);
SQLQuery
sqlQuery
=
session
.
createSQLQuery
(
"SELECT inr FROM usr WHERE nam='"
+
userid
+
"'"
);
List
list
=
sqlQuery
.
list
();
session
.
close
();
if
(
list
.
size
()
==
0
)
{
//我方没有当前用户
log
.
error
(
"单点登陆失败,电证前置系统没有该用户:"
+
userid
);
view
.
setView
(
new
RedirectView
(
"/esfe/#/login?channel=coas&errtyp=L6665"
,
false
));
return
view
;
}
//动态生成安全盐z
String
[]
pars
=
{
userid
};
String
enc
=
DataSecurityUtil
.
encrypt
(
pars
,
userid
);
//准备调我方主交易
StringBuilder
sb
=
new
StringBuilder
(
"/esfe/#/login?channel=coas&userId="
);
sb
.
append
(
userid
);
sb
.
append
(
"&enc="
);
sb
.
append
(
enc
);
view
.
setView
(
new
RedirectView
(
sb
.
toString
(),
false
));
return
view
;
}
catch
(
Exception
e
)
{
//失败后默认进入我方登陆页面,并给出错误信息
if
(
e
instanceof
CoasInfCallException
)
{
String
errtyp
=
((
CoasInfCallException
)
e
).
getErrorCode
();
view
.
setView
(
new
RedirectView
(
"/esfe/#/login?channel=coas&errtyp="
+
errtyp
,
false
));
}
else
{
log
.
error
(
e
.
getMessage
(),
e
);
view
.
setView
(
new
RedirectView
(
"/esfe/#/login?channel=coas&errtyp=L6666"
,
false
));
}
return
view
;
}
}
/**
* 模拟coas得get_token接口
*
* @return
*/
@ResponseBody
@RequestMapping
(
value
=
"/oaut2/get_token"
,
method
=
RequestMethod
.
POST
)
public
Object
getToken
()
{
Map
<
String
,
String
>
res
=
new
HashMap
<>();
res
.
put
(
"msgCode"
,
"0000"
);
res
.
put
(
"message"
,
"success"
);
res
.
put
(
"token_type"
,
"jwt"
);
res
.
put
(
"expires_in"
,
"3600"
);
res
.
put
(
"access_token"
,
"PExDSWQ+CiAgICAgICAgICAgICAgICA8SXNzQmtDZD4xMDIxMDAwOTk5OTY8L0lzc0JrQ2Q+CiAgICAgICAgICAgICAgICA8TENOYj4yMDE5MDczMTAwMzAwMDAxPC9MQ05iPgogICAgICAgICAgICA8L0xDSWQ+CiAgICAgICAgICAgIDxQcmVzbklkPgogICAgICAgICAgICAgICAgPFByZXNuQmtDb2RlPjEwNTEwMDAwMDAxNzwvUHJlc25Ca0NvZGU+CiAgICAgICAgICAgICAgICA8UHJlc25OYj4xMjM0NTY3ODkxMjM0NTY3ODkxMjwvUHJlc25OYj4KICAgICAgICAgICAgPC9QcmVzbklkPg=="
);
return
res
;
}
/**
* 模拟coas得get_token接口
*
* @return
*/
@ResponseBody
@RequestMapping
(
value
=
"/oaut2/get_info"
,
method
=
RequestMethod
.
POST
)
public
Object
getInfo
()
{
Map
<
String
,
Object
>
res
=
new
HashMap
<>();
res
.
put
(
"msgCode"
,
"0000"
);
res
.
put
(
"message"
,
"success"
);
Map
<
String
,
String
>
info
=
new
HashMap
<>();
info
.
put
(
"loginid"
,
"system02"
);
info
.
put
(
"uname"
,
"共享前置管理员"
);
res
.
put
(
"info"
,
info
);
return
res
;
}
private
void
checkRes
(
ResponseEntity
<
String
>
res
,
String
code
,
String
msg
,
String
inf
)
{
int
status
=
res
.
getStatusCodeValue
();
if
(
200
==
status
)
{
if
(!
"0000"
.
equals
(
code
))
{
log
.
error
(
"调用"
+
inf
+
"接口失败:"
+
code
+
",具体处理信息:"
+
msg
);
throw
new
CoasInfCallException
(
code
);
}
}
else
{
throw
new
IllegalStateException
(
"单点登陆失败,调用coas接口失败,http返回的状态码:"
+
status
);
}
}
class
CoasInfCallException
extends
RuntimeException
{
private
String
errorCode
;
public
CoasInfCallException
(
String
errorCode
)
{
super
(
errorCode
);
this
.
errorCode
=
errorCode
;
}
public
String
getErrorCode
()
{
return
errorCode
;
}
}
}
src/main/java/org/sss/presentation/noui/controller/LoginController.java
View file @
01135a00
...
@@ -40,34 +40,50 @@ public class LoginController {
...
@@ -40,34 +40,50 @@ public class LoginController {
@ResponseBody
@ResponseBody
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
)
public
Object
login
(
@RequestBody
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpSession
session
)
{
public
Object
login
(
@RequestBody
Map
<
String
,
Object
>
dataMap
,
HttpServletRequest
request
,
HttpSession
session
)
{
NoUiContext
context
=
null
;
NoUiContext
context
=
null
;
try
{
try
{
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
dataMap
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
dataMap
);
TxInfo
.
putTxInfo
(
"login"
,
"/login"
,
"login"
);
TxInfo
.
putTxInfo
(
"login"
,
"/login"
,
"login"
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//此map会存储返回错误码
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//此map会存储返回错误码
String
userId
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
USERNAME
).
toString
();
String
userId
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
USERNAME
).
toString
();
String
password
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
PASSWORD
).
toString
();
String
password
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
PASSWORD
).
toString
();
String
dncode
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
DNCODE
)
==
null
?
null
:
noUiRequest
.
getDataMap
().
get
(
Constants
.
DNCODE
).
toString
();
String
channel
=
noUiRequest
.
getDataMap
().
get
(
"channel"
)
==
null
?
null
:
noUiRequest
.
getDataMap
().
get
(
"channel"
).
toString
();
String
sendcode
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
SENDCODE
)
==
null
?
null
:
noUiRequest
.
getDataMap
().
get
(
Constants
.
SENDCODE
).
toString
();
if
(
channel
!=
null
&&
"coas"
.
equals
(
channel
))
{
//coas单点登陆逻辑
//验证enc合法性
String
[]
pars
=
{
userId
};
String
errmsg
=
DataSecurityUtil
.
checkIllegalData
(
password
,
pars
,
userId
);
if
(
errmsg
!=
null
)
{
return
ResultUtil
.
result
(
"L6664"
,
errmsg
,
null
,
noUiVersion
.
getVersion
());
}
map
.
put
(
"j_username"
,
userId
);
map
.
put
(
"j_password"
,
password
);
map
.
put
(
"j_dncode"
,
channel
);
map
.
put
(
"j_sendcode"
,
channel
);
map
.
put
(
"j_verifycode"
,
channel
);
map
.
put
(
"j_channel"
,
channel
);
}
else
{
//常规登陆逻辑
String
dncode
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
DNCODE
)
==
null
?
null
:
noUiRequest
.
getDataMap
().
get
(
Constants
.
DNCODE
).
toString
();
String
sendcode
=
noUiRequest
.
getDataMap
().
get
(
Constants
.
SENDCODE
)
==
null
?
null
:
noUiRequest
.
getDataMap
().
get
(
Constants
.
SENDCODE
).
toString
();
// String verifycode = request.getSession().getAttribute(Constants.VERIFYCODE)==null?null:request.getSession().getAttribute(Constants.VERIFYCODE).toString();
// String verifycode = request.getSession().getAttribute(Constants.VERIFYCODE)==null?null:request.getSession().getAttribute(Constants.VERIFYCODE).toString();
StringBuilder
key
=
new
StringBuilder
(
sendcode
);
StringBuilder
key
=
new
StringBuilder
(
sendcode
);
if
(!
StringUtil
.
isEmpty
(
request
.
getRemoteAddr
())){
if
(!
StringUtil
.
isEmpty
(
request
.
getRemoteAddr
()))
{
key
.
append
(
request
.
getRemoteAddr
());
key
.
append
(
request
.
getRemoteAddr
());
}
String
kb
=
key
.
toString
().
toLowerCase
();
log
.
info
(
"key==="
+
kb
);
Object
verifycodeobj
=
RedisUtil
.
get
(
kb
);
String
verifycode
=
verifycodeobj
==
null
?
null
:
verifycodeobj
.
toString
();
map
.
put
(
"j_username"
,
userId
);
map
.
put
(
"j_password"
,
password
);
map
.
put
(
"j_dncode"
,
dncode
);
map
.
put
(
"j_sendcode"
,
sendcode
);
map
.
put
(
"j_verifycode"
,
verifycode
);
RedisUtil
.
delete
(
kb
);
}
}
String
kb
=
key
.
toString
().
toLowerCase
();
log
.
info
(
"key==="
+
kb
);
Object
verifycodeobj
=
RedisUtil
.
get
(
kb
);
String
verifycode
=
verifycodeobj
==
null
?
null
:
verifycodeobj
.
toString
();
map
.
put
(
"j_username"
,
userId
);
map
.
put
(
"j_password"
,
password
);
map
.
put
(
"j_dncode"
,
dncode
);
map
.
put
(
"j_sendcode"
,
sendcode
);
map
.
put
(
"j_verifycode"
,
verifycode
);
RedisUtil
.
delete
(
kb
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
context
=
NoUiContextManager
.
createNoUiContext
(
noUiRequest
);
if
(
context
.
getSession
().
login
(
map
))
{
if
(
context
.
getSession
().
login
(
map
))
{
JwtLogin
login
=
new
JwtLogin
();
JwtLogin
login
=
new
JwtLogin
();
login
.
setUserId
(
userId
);
login
.
setUserId
(
userId
);
login
.
setPassword
(
password
);
login
.
setPassword
(
password
);
...
@@ -92,17 +108,17 @@ public class LoginController {
...
@@ -92,17 +108,17 @@ public class LoginController {
context
.
getSession
().
chain
(
true
,
"office"
);
context
.
getSession
().
chain
(
true
,
"office"
);
byte
[]
sysmodBytes
=
NoUiPresentationUtil
.
sysmodToBytes
(
context
);
byte
[]
sysmodBytes
=
NoUiPresentationUtil
.
sysmodToBytes
(
context
);
// redis中存储用户相关信息
// redis中存储用户相关信息
IDatafield
inridf
=
(
IDatafield
)
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
"sysmod\\usr\\inr"
);
IDatafield
inridf
=
(
IDatafield
)
context
.
getSession
().
getBaseObject
(
context
.
getRoot
(),
"sysmod\\usr\\inr"
);
RedisLoginInfo
redisLoginInfo
=
new
RedisLoginInfo
(
userId
,
token
,
NumericUtil
.
sessionTimeOut
(),
sysmodBytes
,
noUiRequest
.
getTerminalType
());
RedisLoginInfo
redisLoginInfo
=
new
RedisLoginInfo
(
userId
,
token
,
NumericUtil
.
sessionTimeOut
(),
sysmodBytes
,
noUiRequest
.
getTerminalType
());
redisLoginInfo
.
setUserInr
((
String
)
inridf
.
getValue
());
//设置当前用户主键
redisLoginInfo
.
setUserInr
((
String
)
inridf
.
getValue
());
//设置当前用户主键
request
.
getSession
().
setAttribute
(
"token"
,
token
);
request
.
getSession
().
setAttribute
(
"token"
,
token
);
NoUiUtils
.
logout
(
userId
,
"*"
);
//清理可能存在的历史缓存
NoUiUtils
.
logout
(
userId
,
"*"
);
//清理可能存在的历史缓存
RedisUtil
.
set
(
StringUtil
.
userUniqueId
(
noUiRequest
),
redisLoginInfo
);
RedisUtil
.
set
(
StringUtil
.
userUniqueId
(
noUiRequest
),
redisLoginInfo
);
RedisUtil
.
set
(
StringUtil
.
getCacheSessionId
(
noUiRequest
.
getUserId
()),
request
.
getSession
().
getId
());
RedisUtil
.
set
(
StringUtil
.
getCacheSessionId
(
noUiRequest
.
getUserId
()),
request
.
getSession
().
getId
());
//解决初次登陆,超期限登陆
//解决初次登陆,超期限登陆
final
Object
o
=
map
.
get
(
ERROR
);
final
Object
o
=
map
.
get
(
ERROR
);
...
@@ -165,13 +181,12 @@ public class LoginController {
...
@@ -165,13 +181,12 @@ public class LoginController {
try
{
try
{
request
.
getSession
().
removeAttribute
(
"token"
);
request
.
getSession
().
removeAttribute
(
"token"
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
null
);
NoUiRequest
noUiRequest
=
new
NoUiRequest
(
request
,
""
,
null
);
NoUiUtils
.
logout
(
noUiRequest
.
getUserId
(),
"*"
);
//清理可能存在的历史缓存
NoUiUtils
.
logout
(
noUiRequest
.
getUserId
(),
"*"
);
//清理可能存在的历史缓存
return
ResultUtil
.
result
(
ErrorCodes
.
SUCCESS
,
"退出成功"
,
null
);
return
ResultUtil
.
result
(
ErrorCodes
.
SUCCESS
,
"退出成功"
,
null
);
}
catch
(
Exception
e
)
}
catch
(
Exception
e
)
{
{
}
}
return
ResultUtil
.
result
(
ErrorCodes
.
ERROR
,
"退出失败"
,
null
);
return
ResultUtil
.
result
(
ErrorCodes
.
ERROR
,
"退出失败"
,
null
);
}
}
}
}
src/main/java/org/sss/presentation/noui/util/HttpClientUtil.java
0 → 100644
View file @
01135a00
package
org
.
sss
.
presentation
.
noui
.
util
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Map
;
public
class
HttpClientUtil
{
static
RestTemplate
restTemplate
;
static
{
SimpleClientHttpRequestFactory
factory
=
new
SimpleClientHttpRequestFactory
();
factory
.
setConnectTimeout
(
15000
);
factory
.
setReadTimeout
(
30000
);
restTemplate
=
new
RestTemplate
(
factory
);
restTemplate
.
getMessageConverters
().
set
(
1
,
new
StringHttpMessageConverter
(
StandardCharsets
.
UTF_8
));
}
/**
* GET请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
Class
<
T
>
responseType
)
throws
RestClientException
{
return
restTemplate
.
getForEntity
(
url
,
responseType
);
}
/**
* GET请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
getForEntity
(
url
,
responseType
,
uriVariables
);
}
/**
* GET请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
getForEntity
(
url
,
responseType
,
uriVariables
);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
Map
<
String
,
String
>
headers
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
get
(
url
,
httpHeaders
,
responseType
,
uriVariables
);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
HttpHeaders
headers
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<?>
requestEntity
=
new
HttpEntity
<>(
headers
);
return
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
Map
<
String
,
String
>
headers
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
get
(
url
,
httpHeaders
,
responseType
,
uriVariables
);
}
/**
* 带请求头的GET请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
get
(
String
url
,
HttpHeaders
headers
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<?>
requestEntity
=
new
HttpEntity
<>(
headers
);
return
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
responseType
,
uriVariables
);
}
// ----------------------------------POST-------------------------------------------------------
/**
* POST请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @return
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
Class
<
T
>
responseType
)
throws
RestClientException
{
return
restTemplate
.
postForEntity
(
url
,
HttpEntity
.
EMPTY
,
responseType
);
}
/**
* POST请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
)
throws
RestClientException
{
return
restTemplate
.
postForEntity
(
url
,
requestBody
,
responseType
);
}
/**
* POST请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
postForEntity
(
url
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* POST请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
postForEntity
(
url
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
post
(
url
,
httpHeaders
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
HttpHeaders
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
,
headers
);
return
post
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
post
(
url
,
httpHeaders
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的POST请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
HttpHeaders
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
,
headers
);
return
post
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 自定义请求头和请求体的POST请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 自定义请求头和请求体的POST请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
post
(
String
url
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
responseType
,
uriVariables
);
}
// ----------------------------------PUT-------------------------------------------------------
/**
* PUT请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
put
(
url
,
HttpEntity
.
EMPTY
,
responseType
,
uriVariables
);
}
/**
* PUT请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
);
return
put
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* PUT请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
);
return
put
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
put
(
url
,
httpHeaders
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
HttpHeaders
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
,
headers
);
return
put
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
put
(
url
,
httpHeaders
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的PUT请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
HttpHeaders
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
,
headers
);
return
put
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 自定义请求头和请求体的PUT请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
PUT
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 自定义请求头和请求体的PUT请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
put
(
String
url
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
PUT
,
requestEntity
,
responseType
,
uriVariables
);
}
// ----------------------------------DELETE-------------------------------------------------------
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
delete
(
url
,
HttpEntity
.
EMPTY
,
responseType
,
uriVariables
);
}
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
delete
(
url
,
HttpEntity
.
EMPTY
,
responseType
,
uriVariables
);
}
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
);
return
delete
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* DELETE请求调用方式
*
* @param url 请求URL
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
);
return
delete
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Map
<
String
,
String
>
headers
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
delete
(
url
,
httpHeaders
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
HttpHeaders
headers
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
headers
);
return
delete
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Map
<
String
,
String
>
headers
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
delete
(
url
,
httpHeaders
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
HttpHeaders
headers
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
headers
);
return
delete
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
delete
(
url
,
httpHeaders
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
HttpHeaders
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
,
headers
);
return
delete
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
Map
<
String
,
String
>
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
setAll
(
headers
);
return
delete
(
url
,
httpHeaders
,
requestBody
,
responseType
,
uriVariables
);
}
/**
* 带请求头的DELETE请求调用方式
*
* @param url 请求URL
* @param headers 请求头参数
* @param requestBody 请求参数体
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
HttpHeaders
headers
,
Object
requestBody
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
HttpEntity
<
Object
>
requestEntity
=
new
HttpEntity
<
Object
>(
requestBody
,
headers
);
return
delete
(
url
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 自定义请求头和请求体的DELETE请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
DELETE
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 自定义请求头和请求体的DELETE请求调用方式
*
* @param url 请求URL
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
delete
(
String
url
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
DELETE
,
requestEntity
,
responseType
,
uriVariables
);
}
// ----------------------------------通用方法-------------------------------------------------------
/**
* 通用调用方式
*
* @param url 请求URL
* @param method 请求方法类型
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,按顺序依次对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
exchange
(
String
url
,
HttpMethod
method
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Object
...
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
method
,
requestEntity
,
responseType
,
uriVariables
);
}
/**
* 通用调用方式
*
* @param url 请求URL
* @param method 请求方法类型
* @param requestEntity 请求头和请求体封装对象
* @param responseType 返回对象类型
* @param uriVariables URL中的变量,与Map中的key对应
* @return ResponseEntity 响应对象封装类
*/
public
static
<
T
>
ResponseEntity
<
T
>
exchange
(
String
url
,
HttpMethod
method
,
HttpEntity
<?>
requestEntity
,
Class
<
T
>
responseType
,
Map
<
String
,
?>
uriVariables
)
throws
RestClientException
{
return
restTemplate
.
exchange
(
url
,
method
,
requestEntity
,
responseType
,
uriVariables
);
}
}
src/main/resources/coas.properties
0 → 100644
View file @
01135a00
client_id
=
ESFE
client_secret
=
666666
coas_server
=
http://111.1.12.211:8088/coas/oauth2/
\ No newline at end of file
src/main/resources/spring-mvc.xml
View file @
01135a00
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
>
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
>
<mvc:annotation-driven>
<mvc:annotation-driven>
<mvc:message-converters>
<mvc:message-converters>
<ref
bean=
"stringHttpMessageConverter"
/>
<ref
bean=
"stringHttpMessageConverter"
/>
<ref
bean=
"mappingJackson2HttpMessageConverter"
/>
<ref
bean=
"mappingJackson2HttpMessageConverter"
/>
</mvc:message-converters>
</mvc:message-converters>
</mvc:annotation-driven>
</mvc:annotation-driven>
<bean
id=
"stringHttpMessageConverter"
<bean
id=
"stringHttpMessageConverter"
class=
"org.springframework.http.converter.StringHttpMessageConverter"
/>
class=
"org.springframework.http.converter.StringHttpMessageConverter"
/>
<!--解决IE浏览器json文件下载和json数据中午乱码的问题-->
<!--解决IE浏览器json文件下载和json数据中午乱码的问题-->
<bean
id=
"mappingJackson2HttpMessageConverter"
<bean
id=
"mappingJackson2HttpMessageConverter"
class=
"org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"
>
class=
"org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"
>
<property
name=
"supportedMediaTypes"
>
<property
name=
"supportedMediaTypes"
>
<list>
<list>
<value>
text/html;charset=UTF-8
</value>
<value>
text/html;charset=UTF-8
</value>
</list>
</list>
</property>
</property>
</bean>
</bean>
<bean
id=
"multipartResolver"
class=
"org.springframework.web.multipart.commons.CommonsMultipartResolver"
>
<bean
id=
"multipartResolver"
class=
"org.springframework.web.multipart.commons.CommonsMultipartResolver"
>
<property
name=
"maxUploadSize"
value=
"200000"
/>
<property
name=
"maxUploadSize"
value=
"200000"
/>
<property
name=
"maxInMemorySize"
value=
"200000"
/>
<property
name=
"maxInMemorySize"
value=
"200000"
/>
</bean>
</bean>
<bean
id=
"nouiVersion"
class=
"org.sss.presentation.noui.api.response.NoUiVersion"
>
<bean
id=
"nouiVersion"
class=
"org.sss.presentation.noui.api.response.NoUiVersion"
>
<property
name=
"version"
value=
"202009091600"
/>
<property
name=
"version"
value=
"202009091600"
/>
<property
name=
"rootFilePath"
value=
""
/>
<property
name=
"rootFilePath"
value=
""
/>
</bean>
</bean>
<mvc:default-servlet-handler
/>
<mvc:default-servlet-handler
/>
<mvc:interceptors>
<mvc:interceptors>
<mvc:interceptor>
<mvc:interceptor>
<mvc:mapping
path=
"/**/*"
/>
<mvc:mapping
path=
"/**/*"
/>
<bean
class=
"org.sss.presentation.noui.filter.Cors"
/>
<bean
class=
"org.sss.presentation.noui.filter.Cors"
/>
</mvc:interceptor>
</mvc:interceptor>
<mvc:interceptor>
<mvc:interceptor>
<!-- 匹配的是url路径, 如果不配置或/**,将拦截所有的Controller -->
<!-- 匹配的是url路径, 如果不配置或/**,将拦截所有的Controller -->
<mvc:mapping
path=
"/**"
/>
<mvc:mapping
path=
"/**"
/>
<!--login 不需要拦截 -->
<!--login 不需要拦截 -->
<mvc:exclude-mapping
path=
"/login"
/>
<mvc:exclude-mapping
path=
"/login"
/>
<mvc:exclude-mapping
path=
"/getUserByDn"
/>
<mvc:exclude-mapping
path=
"/getUserByDn"
/>
<mvc:exclude-mapping
path=
"/login/**"
/>
<mvc:exclude-mapping
path=
"/login/**"
/>
<!--<mvc:exclude-mapping path="/fileBrowser/**" />-->
<mvc:exclude-mapping
path=
"/oaut2/**"
/>
<bean
class=
"org.sss.presentation.noui.jwt.TokenInterceptor"
></bean>
<!--<mvc:exclude-mapping path="/fileBrowser/**" />-->
</mvc:interceptor>
<bean
class=
"org.sss.presentation.noui.jwt.TokenInterceptor"
></bean>
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping
path=
"/**"
/>
<mvc:interceptor>
<bean
class=
"org.sss.presentation.noui.filter.FileTypeInterceptor"
>
<mvc:mapping
path=
"/**"
/>
<property
name=
"type_list"
value=
"bat,sh,js,sql,exe"
/>
<bean
class=
"org.sss.presentation.noui.filter.FileTypeInterceptor"
>
</bean>
<property
name=
"type_list"
value=
"bat,sh,js,sql,exe"
/>
</mvc:interceptor>
</bean>
</mvc:interceptors>
</mvc:interceptor>
</mvc:interceptors>
<!-- 配置自动扫描的包 -->
<context:component-scan
base-package=
"org.sss.presentation.noui.controller"
></context:component-scan>
<!-- 配置自动扫描的包 -->
<context:component-scan
base-package=
"org.sss.presentation.noui.controller"
></context:component-scan>
</beans>
</beans>
\ No newline at end of file
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