Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hg-smart
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
platform
hg-smart
Commits
855f3503
Commit
855f3503
authored
Oct 18, 2024
by
宋祥
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-sx' of
http://129.211.46.84:8800/platform/hg-smart
into dev
parents
deed2114
be1b826f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
0 deletions
+119
-0
ServiceXS0105.java
...java/com/baosight/xservices/xs/service/ServiceXS0105.java
+119
-0
No files found.
src/main/java/com/baosight/xservices/xs/service/ServiceXS0105.java
0 → 100644
View file @
855f3503
package
com
.
baosight
.
xservices
.
xs
.
service
;
import
com.baosight.iplat4j.core.cache.CacheManager
;
import
com.baosight.iplat4j.core.ei.EiConstant
;
import
com.baosight.iplat4j.core.ei.EiInfo
;
import
com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext
;
import
com.baosight.iplat4j.core.log.xeye.entity.XEyeEntity
;
import
com.baosight.iplat4j.core.service.impl.ServiceEPBase
;
import
com.baosight.iplat4j.core.util.DateUtils
;
import
com.baosight.xservices.xs.authentication.SecurityBridgeFactory
;
import
com.baosight.xservices.xs.util.UserSession
;
import
java.util.GregorianCalendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
/**
*
* @author:songx
* @date:2024/10/18,17:45
*/
public
class
ServiceXS0105
extends
ServiceEPBase
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
ServiceXS0105
.
class
);
private
static
String
defaultPasswordSwitch
=
StringUtils
.
defaultIfEmpty
(
PlatApplicationContext
.
getProperty
(
"xservices.security.default.password.switch"
),
"on"
);
private
static
final
String
loginFailCountCache
=
"iplat:security:loginFailCountCache"
;
private
Map
<
String
,
Integer
>
failCountCache
=
CacheManager
.
getCache
(
"iplat:security:loginFailCountCache"
);
public
ServiceXS0105
()
{
}
public
EiInfo
query
(
EiInfo
inInfo
)
{
String
loginName
=
inInfo
.
get
(
"loginName"
).
toString
();
Map
map
=
new
HashMap
();
map
.
put
(
"loginName"
,
loginName
);
List
resultList
=
this
.
dao
.
query
(
"XS0105.query"
,
map
);
if
(
null
!=
resultList
&&
resultList
.
size
()
==
1
)
{
inInfo
.
setStatus
(
EiConstant
.
STATUS_SUCCESS
);
Map
result
=
(
Map
)
resultList
.
get
(
0
);
inInfo
.
set
(
"loginName"
,
result
.
get
(
"loginName"
));
inInfo
.
set
(
"userName"
,
result
.
get
(
"userName"
));
inInfo
.
set
(
"mobile"
,
result
.
get
(
"mobile"
));
inInfo
.
set
(
"email"
,
result
.
get
(
"email"
));
}
else
{
inInfo
.
setStatus
(
EiConstant
.
STATUS_FAILURE
);
inInfo
.
setMsg
(
"请输入正确的登录账号!"
);
}
return
inInfo
;
}
public
EiInfo
resetPassword
(
EiInfo
inInfo
)
{
String
msg
=
""
;
int
status
=
-
1
;
String
revisor
=
UserSession
.
getUser
().
getUsername
();
String
loginName
=
inInfo
.
get
(
"loginName"
).
toString
();
try
{
Map
map
=
new
HashMap
();
map
.
put
(
"loginName"
,
loginName
);
List
resultList
=
this
.
dao
.
query
(
"XS0104.query"
,
map
);
if
(
resultList
!=
null
&&
resultList
.
size
()
>
0
)
{
Map
result
=
(
Map
)
resultList
.
get
(
0
);
String
newPassword
=
""
;
String
defaultPassword
;
if
(
"on"
.
equals
(
defaultPasswordSwitch
))
{
defaultPassword
=
StringUtils
.
defaultIfEmpty
(
PlatApplicationContext
.
getProperty
(
"xservices.security.default.password"
),
"admin123!@#"
);
if
(
StringUtils
.
isBlank
(
defaultPassword
))
{
defaultPassword
=
loginName
;
}
newPassword
=
SecurityBridgeFactory
.
getSecurityPasswordEncrypt
().
encode
(
loginName
);
}
else
{
newPassword
=
SecurityBridgeFactory
.
getSecurityPasswordEncrypt
().
encode
(
loginName
);
}
map
.
put
(
"password"
,
newPassword
);
map
.
put
(
"status"
,
"1"
);
map
.
put
(
"isLocked"
,
"1"
);
map
.
put
(
"recRevisor"
,
revisor
);
map
.
put
(
"recReviseTime"
,
DateUtils
.
curDateTimeStr14
());
map
.
put
(
"pwdRevisor"
,
revisor
);
map
.
put
(
"pwdReviseDate"
,
DateUtils
.
curDateTimeStr14
());
map
.
put
(
"userId"
,
result
.
get
(
"userId"
));
defaultPassword
=
StringUtils
.
defaultIfEmpty
(
PlatApplicationContext
.
getProperty
(
"xservices.security.accountExpireDays"
),
"90"
);
String
pwdExpireDays
=
StringUtils
.
defaultIfEmpty
(
PlatApplicationContext
.
getProperty
(
"xservices.security.pwdExpireDays"
),
"90"
);
GregorianCalendar
gc
=
new
GregorianCalendar
();
gc
.
setTime
(
DateUtils
.
toDate8
(
DateUtils
.
curDateStr8
()));
gc
.
add
(
5
,
Integer
.
parseInt
(
pwdExpireDays
));
map
.
put
(
"pwdExpireDate"
,
DateUtils
.
toDateStr8
(
gc
.
getTime
()));
gc
.
setTime
(
DateUtils
.
toDate8
(
DateUtils
.
curDateStr8
()));
gc
.
add
(
5
,
Integer
.
parseInt
(
defaultPassword
));
map
.
put
(
"accountExpireDate"
,
DateUtils
.
toDateStr8
(
gc
.
getTime
()));
this
.
dao
.
update
(
"XS0104.update"
,
map
);
this
.
failCountCache
.
remove
(
loginName
);
msg
=
"重置密码成功!"
;
status
=
1
;
XEyeEntity
xEyeEntity
=
new
XEyeEntity
();
xEyeEntity
.
setLogId
(
"1004"
);
xEyeEntity
.
setLogName
(
"重置密码"
);
xEyeEntity
.
setInvokeInfo
(
UserSession
.
getUser
().
getUsername
()
+
"在"
+
DateUtils
.
curDateStr
(
"yyyy-MM-dd HH:mm:ss"
)
+
"重置了登录名为:"
+
result
.
get
(
"loginName"
)
+
"的用户的密码"
);
xEyeEntity
.
setStatus
(
inInfo
.
getStatus
()
+
""
);
xEyeEntity
.
set
(
"x_xs_id"
,
result
.
get
(
"userId"
));
xEyeEntity
.
set
(
"x_xs_on"
,
UserSession
.
getUser
().
getUsername
());
xEyeEntity
.
set
(
"x_xs_ln"
,
result
.
get
(
"loginName"
));
this
.
log
(
xEyeEntity
);
}
}
catch
(
Exception
var14
)
{
msg
=
var14
.
getMessage
();
logger
.
error
(
var14
.
getCause
().
getMessage
());
}
inInfo
.
setMsg
(
msg
);
inInfo
.
setStatus
(
status
);
return
inInfo
;
}
}
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