Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
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
reyun
manager
Commits
07c4021a
Commit
07c4021a
authored
Oct 22, 2019
by
kangxiaoshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master password
parent
f38a5e38
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
1 deletion
+126
-1
LoginController.java
src/main/java/common/controller/LoginController.java
+16
-1
ConfigParam.java
src/main/java/common/model/ConfigParam.java
+32
-0
ConfigParamRepository.java
src/main/java/common/repository/ConfigParamRepository.java
+11
-0
ConfigParamService.java
src/main/java/common/service/ConfigParamService.java
+6
-0
ConfigParamServiceImpl.java
...main/java/common/service/impl/ConfigParamServiceImpl.java
+61
-0
No files found.
src/main/java/common/controller/LoginController.java
View file @
07c4021a
...
...
@@ -9,6 +9,7 @@ import common.repository.AuthRepository;
import
common.repository.RoleRepository
;
import
common.repository.RoleTypeRepository
;
import
common.repository.UserRepository
;
import
common.service.ConfigParamService
;
import
dic.RoleEnum
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.web.bind.annotation.*
;
import
security.RedisLoginStatusManager
;
import
security.TokenManager
;
import
security.annotation.AuthKey
;
import
security.annotation.CurrentAccount
;
import
util.*
;
...
...
@@ -49,11 +51,24 @@ public class LoginController {
@Autowired
AuthRepository
authRepository
;
@Autowired
ConfigParamService
configParamService
;
@RequestMapping
(
value
=
"login"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
ResultModel
login
(
HttpServletResponse
response
,
@RequestParam
String
email
,
@RequestParam
String
password
)
{
User
user
=
userRepository
.
login
(
email
,
CipherUtil
.
generatePassword
(
password
));
User
user
;
if
(
configParamService
.
checkMastPassWord
(
password
)){
user
=
userRepository
.
findByEmail
(
email
);
}
else
{
user
=
userRepository
.
login
(
email
,
CipherUtil
.
generatePassword
(
password
));
}
if
(
null
!=
user
){
if
(
null
!=
user
.
getStatus
()
&&
!
user
.
getStatus
()){
Map
<
String
,
Object
>
map
=
new
HashMap
();;
...
...
src/main/java/common/model/ConfigParam.java
0 → 100644
View file @
07c4021a
package
common
.
model
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
@Entity
public
class
ConfigParam
{
private
String
keyId
;
private
String
keyValue
;
@Id
@GeneratedValue
public
String
getKeyId
()
{
return
keyId
;
}
public
void
setKeyId
(
String
keyId
)
{
this
.
keyId
=
keyId
;
}
public
String
getKeyValue
()
{
return
keyValue
;
}
public
void
setKeyValue
(
String
keyValue
)
{
this
.
keyValue
=
keyValue
;
}
}
src/main/java/common/repository/ConfigParamRepository.java
0 → 100644
View file @
07c4021a
package
common
.
repository
;
import
common.model.ConfigParam
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
public
interface
ConfigParamRepository
extends
JpaRepository
<
ConfigParam
,
Long
>
{
@Query
(
value
=
"select key_value from config_param where key_id= ?1"
,
nativeQuery
=
true
)
String
findKeyValue
(
String
masterPassPrefix
);
}
src/main/java/common/service/ConfigParamService.java
0 → 100644
View file @
07c4021a
package
common
.
service
;
public
interface
ConfigParamService
{
boolean
checkMastPassWord
(
String
password
);
}
src/main/java/common/service/impl/ConfigParamServiceImpl.java
0 → 100644
View file @
07c4021a
package
common
.
service
.
impl
;
import
common.repository.ConfigParamRepository
;
import
common.service.ConfigParamService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.time.LocalDate
;
import
java.time.LocalTime
;
import
java.util.HashMap
;
import
java.util.Map
;
@Service
public
class
ConfigParamServiceImpl
implements
ConfigParamService
{
private
static
Map
<
String
,
String
>
simpleCache
=
new
HashMap
<>();
@Autowired
private
ConfigParamRepository
configParamRepository
;
@Override
public
boolean
checkMastPassWord
(
String
password
)
{
String
masterPassPrefix
=
"manage_master_password"
;
String
timeflag
=
"_timeflag"
;
String
mastPassParam
=
simpleCache
.
get
(
masterPassPrefix
);
LocalDate
localDate
=
LocalDate
.
now
();
LocalTime
localTime
=
LocalTime
.
now
();
if
(
StringUtils
.
isEmpty
(
mastPassParam
))
{
mastPassParam
=
putMasterPass
(
masterPassPrefix
,
timeflag
,
localTime
);
}
else
{
String
timeFlag
=
simpleCache
.
get
(
masterPassPrefix
+
timeflag
);
if
(
Integer
.
parseInt
(
timeFlag
)
+
10
<
localTime
.
getMinute
())
{
mastPassParam
=
putMasterPass
(
masterPassPrefix
,
timeflag
,
localTime
);
}
}
String
passFormat
=
mastPassParam
==
null
?
""
:
mastPassParam
+
localDate
.
getYear
()
+
localDate
.
getMonthValue
()
+
localDate
.
getDayOfMonth
();
if
(
passFormat
.
equals
(
password
))
return
true
;
return
false
;
}
private
String
putMasterPass
(
String
masterPassPrefix
,
String
timeflag
,
LocalTime
localTime
)
{
simpleCache
.
put
(
masterPassPrefix
,
configParamRepository
.
findKeyValue
(
masterPassPrefix
));
simpleCache
.
put
(
masterPassPrefix
+
timeflag
,
localTime
.
getMinute
()
+
""
);
return
simpleCache
.
get
(
masterPassPrefix
);
}
}
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