Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xxl-job
Project
Project
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
刘晓滨
xxl-job
Commits
ac20a400
Commit
ac20a400
authored
Oct 18, 2021
by
刘晓滨
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master_zcc_adminfix' into 'master'
fix(xxl-job):登录用户名密码由数据库查询认证 See merge request
!10
parents
150c9c7d
de411ea1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
32 deletions
+107
-32
PermissionInterceptor.java
...b/admin/controller/interceptor/PermissionInterceptor.java
+14
-10
XxlJobAdminConfig.java
...n/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java
+6
-18
XxlJobAdmin.java
...c/main/java/com/xxl/job/admin/core/model/XxlJobAdmin.java
+39
-0
XxlJobAdminDao.java
...n/src/main/java/com/xxl/job/admin/dao/XxlJobAdminDao.java
+15
-0
application.properties
xxl-job-admin/src/main/resources/application.properties
+2
-2
XxlJobAdminMapper.xml
...n/src/main/resources/mybatis-mapper/XxlJobAdminMapper.xml
+25
-0
JobInfoControllerTest.java
...a/com/xxl/job/admin/controller/JobInfoControllerTest.java
+6
-2
No files found.
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java
View file @
ac20a400
...
@@ -2,7 +2,9 @@ package com.xxl.job.admin.controller.interceptor;
...
@@ -2,7 +2,9 @@ package com.xxl.job.admin.controller.interceptor;
import
com.xxl.job.admin.controller.annotation.PermessionLimit
;
import
com.xxl.job.admin.controller.annotation.PermessionLimit
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.model.XxlJobAdmin
;
import
com.xxl.job.admin.core.util.CookieUtil
;
import
com.xxl.job.admin.core.util.CookieUtil
;
import
com.xxl.job.admin.dao.XxlJobAdminDao
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.method.HandlerMethod
;
...
@@ -23,22 +25,24 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
...
@@ -23,22 +25,24 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
public
static
final
String
LOGIN_IDENTITY_KEY
=
"XXL_JOB_LOGIN_IDENTITY"
;
public
static
final
String
LOGIN_IDENTITY_KEY
=
"XXL_JOB_LOGIN_IDENTITY"
;
private
static
String
LOGIN_IDENTITY_TOKEN
;
private
static
String
LOGIN_IDENTITY_TOKEN
;
public
static
String
getLoginIdentityToken
()
{
public
static
String
getLoginIdentityToken
()
{
if
(
LOGIN_IDENTITY_TOKEN
==
null
)
{
XxlJobAdminDao
xxlJobAdminDao
=
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobAdminDao
();
String
username
=
XxlJobAdminConfig
.
getAdminConfig
().
getLoginUsername
();
XxlJobAdmin
admin
=
xxlJobAdminDao
.
findOne
();
String
password
=
XxlJobAdminConfig
.
getAdminConfig
().
getLoginPassword
();
if
(
admin
==
null
)
{
return
LOGIN_IDENTITY_TOKEN
;
}
String
username
=
admin
.
getUsername
();
String
password
=
admin
.
getPassword
();
// login token
// login token
String
tokenTmp
=
DigestUtils
.
md5DigestAsHex
(
String
.
valueOf
(
username
+
"_"
+
password
).
getBytes
());
//.getBytes("UTF-8")
String
tokenTmp
=
DigestUtils
.
md5DigestAsHex
(
String
.
valueOf
(
username
+
"_"
+
password
).
getBytes
());
//.getBytes("UTF-8")
tokenTmp
=
new
BigInteger
(
1
,
tokenTmp
.
getBytes
()).
toString
(
16
);
tokenTmp
=
new
BigInteger
(
1
,
tokenTmp
.
getBytes
()).
toString
(
16
);
LOGIN_IDENTITY_TOKEN
=
tokenTmp
;
return
tokenTmp
;
}
return
LOGIN_IDENTITY_TOKEN
;
}
}
public
static
boolean
login
(
HttpServletResponse
response
,
String
username
,
String
password
,
boolean
ifRemember
){
public
static
boolean
login
(
HttpServletResponse
response
,
String
username
,
String
password
,
boolean
ifRemember
){
// login token
// login token
String
tokenTmp
=
DigestUtils
.
md5DigestAsHex
(
String
.
valueOf
(
username
+
"_"
+
password
).
getBytes
());
String
tokenTmp
=
DigestUtils
.
md5DigestAsHex
(
String
.
valueOf
(
username
+
"_"
+
password
).
getBytes
());
tokenTmp
=
new
BigInteger
(
1
,
tokenTmp
.
getBytes
()).
toString
(
16
);
tokenTmp
=
new
BigInteger
(
1
,
tokenTmp
.
getBytes
()).
toString
(
16
);
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/conf/XxlJobAdminConfig.java
View file @
ac20a400
package
com
.
xxl
.
job
.
admin
.
core
.
conf
;
package
com
.
xxl
.
job
.
admin
.
core
.
conf
;
import
com.xxl.job.admin.dao.XxlJobGroupDao
;
import
com.xxl.job.admin.dao.*
;
import
com.xxl.job.admin.dao.XxlJobInfoDao
;
import
com.xxl.job.admin.dao.XxlJobLogDao
;
import
com.xxl.job.admin.dao.XxlJobRegistryDao
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.AdminBiz
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -48,12 +45,6 @@ public class XxlJobAdminConfig implements InitializingBean{
...
@@ -48,12 +45,6 @@ public class XxlJobAdminConfig implements InitializingBean{
@Value
(
"${xxl.job.mail.sendNick}"
)
@Value
(
"${xxl.job.mail.sendNick}"
)
private
String
mailSendNick
;
private
String
mailSendNick
;
@Value
(
"${xxl.job.login.username}"
)
private
String
loginUsername
;
@Value
(
"${xxl.job.login.password}"
)
private
String
loginPassword
;
@Value
(
"${xxl.job.i18n}"
)
@Value
(
"${xxl.job.i18n}"
)
private
String
i18n
;
private
String
i18n
;
...
@@ -72,7 +63,12 @@ public class XxlJobAdminConfig implements InitializingBean{
...
@@ -72,7 +63,12 @@ public class XxlJobAdminConfig implements InitializingBean{
public
XxlJobGroupDao
xxlJobGroupDao
;
public
XxlJobGroupDao
xxlJobGroupDao
;
@Resource
@Resource
public
AdminBiz
adminBiz
;
public
AdminBiz
adminBiz
;
@Resource
public
XxlJobAdminDao
xxlJobAdminDao
;
public
XxlJobAdminDao
getXxlJobAdminDao
()
{
return
xxlJobAdminDao
;
}
public
String
getMailHost
()
{
public
String
getMailHost
()
{
return
mailHost
;
return
mailHost
;
...
@@ -98,14 +94,6 @@ public class XxlJobAdminConfig implements InitializingBean{
...
@@ -98,14 +94,6 @@ public class XxlJobAdminConfig implements InitializingBean{
return
mailSendNick
;
return
mailSendNick
;
}
}
public
String
getLoginUsername
()
{
return
loginUsername
;
}
public
String
getLoginPassword
()
{
return
loginPassword
;
}
public
String
getI18n
()
{
public
String
getI18n
()
{
return
i18n
;
return
i18n
;
}
}
...
...
xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobAdmin.java
0 → 100644
View file @
ac20a400
package
com
.
xxl
.
job
.
admin
.
core
.
model
;
/**
* Created by xuxueli on 16/9/30.
*/
public
class
XxlJobAdmin
{
private
int
id
;
private
String
username
;
private
String
password
;
public
XxlJobAdmin
()
{
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/XxlJobAdminDao.java
0 → 100644
View file @
ac20a400
package
com
.
xxl
.
job
.
admin
.
dao
;
import
com.xxl.job.admin.core.model.XxlJobAdmin
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* Created by xuxueli on 16/9/30.
*/
@Mapper
public
interface
XxlJobAdminDao
{
public
XxlJobAdmin
findOne
();
}
xxl-job-admin/src/main/resources/application.properties
View file @
ac20a400
...
@@ -36,8 +36,8 @@ xxl.job.mail.password=Chyezaq1234
...
@@ -36,8 +36,8 @@ xxl.job.mail.password=Chyezaq1234
xxl.job.mail.sendNick
=
XXL-JOB
xxl.job.mail.sendNick
=
XXL-JOB
### xxl-job login
### xxl-job login
xxl.job.login.username
=
admin
#
xxl.job.login.username=admin
xxl.job.login.password
=
123456
#
xxl.job.login.password=123456
### xxl-job, access token
### xxl-job, access token
xxl.job.accessToken
=
xxl.job.accessToken
=
...
...
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobAdminMapper.xml
0 → 100644
View file @
ac20a400
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.xxl.job.admin.dao.XxlJobAdminDao"
>
<resultMap
id=
"XxlJobAdmin"
type=
"com.xxl.job.admin.core.model.XxlJobAdmin"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"username"
property=
"username"
/>
<result
column=
"password"
property=
"password"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
t.id,
t.username,
t.password
</sql>
<select
id=
"findOne"
resultMap=
"XxlJobAdmin"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM XXL_JOB_QRTZ_ADMIN AS t
ORDER BY t.id ASC LIMIT 1
</select>
</mapper>
\ No newline at end of file
xxl-job-admin/src/test/java/com/xxl/job/admin/controller/JobInfoControllerTest.java
View file @
ac20a400
...
@@ -2,6 +2,8 @@ package com.xxl.job.admin.controller;
...
@@ -2,6 +2,8 @@ package com.xxl.job.admin.controller;
import
com.xxl.job.admin.controller.interceptor.PermissionInterceptor
;
import
com.xxl.job.admin.controller.interceptor.PermissionInterceptor
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.model.XxlJobAdmin
;
import
com.xxl.job.admin.dao.XxlJobAdminDao
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
...
@@ -19,11 +21,13 @@ public class JobInfoControllerTest extends AbstractSpringMvcTest {
...
@@ -19,11 +21,13 @@ public class JobInfoControllerTest extends AbstractSpringMvcTest {
@Before
@Before
public
void
login
()
throws
Exception
{
public
void
login
()
throws
Exception
{
XxlJobAdminDao
xxlJobAdminDao
=
XxlJobAdminConfig
.
getAdminConfig
().
getXxlJobAdminDao
();
XxlJobAdmin
admin
=
xxlJobAdminDao
.
findOne
();
MvcResult
ret
=
mockMvc
.
perform
(
MvcResult
ret
=
mockMvc
.
perform
(
post
(
"/login"
)
post
(
"/login"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
param
(
"userName"
,
XxlJobAdminConfig
.
getAdminConfig
().
getLogin
Username
())
.
param
(
"userName"
,
admin
.
get
Username
())
.
param
(
"password"
,
XxlJobAdminConfig
.
getAdminConfig
().
getLogin
Password
())
.
param
(
"password"
,
admin
.
get
Password
())
).
andReturn
();
).
andReturn
();
cookie
=
ret
.
getResponse
().
getCookie
(
PermissionInterceptor
.
LOGIN_IDENTITY_KEY
);
cookie
=
ret
.
getResponse
().
getCookie
(
PermissionInterceptor
.
LOGIN_IDENTITY_KEY
);
}
}
...
...
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