Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
online-edu-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Redmine
Redmine
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
online-edu
online-edu-backend
Commits
7dc47c16
Commit
7dc47c16
authored
Jun 01, 2021
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed auth faild code
parent
41d9479d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
AuthorizationResponseEnum.java
...va/com/qkdata/common/oauth/AuthorizationResponseEnum.java
+10
-10
OAuthFilter.java
src/main/java/com/qkdata/common/oauth/OAuthFilter.java
+2
-2
OAuthRealm.java
src/main/java/com/qkdata/common/oauth/OAuthRealm.java
+1
-1
No files found.
src/main/java/com/qkdata/common/oauth/AuthorizationResponseEnum.java
View file @
7dc47c16
...
@@ -3,23 +3,23 @@ package com.qkdata.common.oauth;
...
@@ -3,23 +3,23 @@ package com.qkdata.common.oauth;
public
enum
AuthorizationResponseEnum
{
public
enum
AuthorizationResponseEnum
{
MISSING_TOKEN
(
"403"
,
"HEADER中不存在TOKEN"
),
MISSING_TOKEN
(
403
,
"HEADER中不存在TOKEN"
),
INVALID_TOKEN
(
"403"
,
"校验TOKEN失败"
),
INVALID_TOKEN
(
403
,
"校验TOKEN失败"
),
EXPIRED_TOKEN
(
"403"
,
"TOKEN已过期"
),
EXPIRED_TOKEN
(
403
,
"TOKEN已过期"
),
MISSING_CLAIMS
(
"403"
,
"不合法的TOKEN, 信息可能被篡改"
),
MISSING_CLAIMS
(
403
,
"不合法的TOKEN, 信息可能被篡改"
),
INVALID_CLAIM
(
"403"
,
"不合法的TOKEN, 系统中不存在资源"
);
INVALID_CLAIM
(
403
,
"不合法的TOKEN, 系统中不存在资源"
);
private
String
valu
e
;
private
Integer
cod
e
;
private
String
text
;
private
String
text
;
AuthorizationResponseEnum
(
String
valu
e
,
String
text
)
{
AuthorizationResponseEnum
(
Integer
cod
e
,
String
text
)
{
this
.
value
=
valu
e
;
this
.
code
=
cod
e
;
this
.
text
=
text
;
this
.
text
=
text
;
}
}
public
String
valu
e
()
{
public
Integer
cod
e
()
{
return
this
.
valu
e
;
return
this
.
cod
e
;
}
}
public
String
text
()
{
public
String
text
()
{
...
...
src/main/java/com/qkdata/common/oauth/OAuthFilter.java
View file @
7dc47c16
...
@@ -52,7 +52,7 @@ public class OAuthFilter extends AuthenticatingFilter {
...
@@ -52,7 +52,7 @@ public class OAuthFilter extends AuthenticatingFilter {
httpResponse
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
httpResponse
.
setHeader
(
"Access-Control-Allow-Origin"
,
HttpContextUtils
.
getOrigin
());
httpResponse
.
setHeader
(
"Access-Control-Allow-Origin"
,
HttpContextUtils
.
getOrigin
());
Result
responseData
=
Result
.
failed
(
AuthorizationResponseEnum
.
MISSING_TOKEN
.
text
());
Result
responseData
=
Result
.
of
(
""
,
AuthorizationResponseEnum
.
MISSING_TOKEN
.
code
(),
AuthorizationResponseEnum
.
MISSING_TOKEN
.
text
());
String
json
=
mapper
.
writeValueAsString
(
responseData
);
String
json
=
mapper
.
writeValueAsString
(
responseData
);
httpResponse
.
getWriter
().
print
(
json
);
httpResponse
.
getWriter
().
print
(
json
);
...
@@ -72,7 +72,7 @@ public class OAuthFilter extends AuthenticatingFilter {
...
@@ -72,7 +72,7 @@ public class OAuthFilter extends AuthenticatingFilter {
try
{
try
{
//处理登录失败的异常
//处理登录失败的异常
Throwable
throwable
=
e
.
getCause
()
==
null
?
e
:
e
.
getCause
();
Throwable
throwable
=
e
.
getCause
()
==
null
?
e
:
e
.
getCause
();
Result
rd
=
Result
.
failed
(
AuthorizationResponseEnum
.
INVALID_TOKEN
.
valu
e
(),
e
.
getMessage
());
Result
rd
=
Result
.
of
(
""
,
AuthorizationResponseEnum
.
MISSING_TOKEN
.
cod
e
(),
e
.
getMessage
());
String
json
=
mapper
.
writeValueAsString
(
rd
);
String
json
=
mapper
.
writeValueAsString
(
rd
);
httpResponse
.
getWriter
().
print
(
json
);
httpResponse
.
getWriter
().
print
(
json
);
}
catch
(
IOException
e1
)
{
}
catch
(
IOException
e1
)
{
...
...
src/main/java/com/qkdata/common/oauth/OAuthRealm.java
View file @
7dc47c16
...
@@ -81,7 +81,7 @@ public class OAuthRealm extends AuthorizingRealm {
...
@@ -81,7 +81,7 @@ public class OAuthRealm extends AuthorizingRealm {
throw
new
AuthenticationException
(
AuthorizationResponseEnum
.
INVALID_CLAIM
.
text
());
throw
new
AuthenticationException
(
AuthorizationResponseEnum
.
INVALID_CLAIM
.
text
());
}
}
if
(
user
.
getStatus
()
==
AccountStatusEnum
.
DISABLE
){
if
(
user
.
getStatus
()
==
AccountStatusEnum
.
DISABLE
){
throw
new
AuthenticationException
(
"您
已退出团队,不能登陆
"
);
throw
new
AuthenticationException
(
"您
的帐号已被禁用
"
);
}
}
SimpleAuthenticationInfo
info
=
new
SimpleAuthenticationInfo
(
user
,
accessToken
,
getName
());
SimpleAuthenticationInfo
info
=
new
SimpleAuthenticationInfo
(
user
,
accessToken
,
getName
());
return
info
;
return
info
;
...
...
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