Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
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
DEMO
spring-boot
Commits
adb42ed9
Commit
adb42ed9
authored
Apr 05, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
15cbef3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
FixedAuthoritiesExtractor.java
...e/security/oauth2/resource/FixedAuthoritiesExtractor.java
+15
-16
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/FixedAuthoritiesExtractor.java
View file @
adb42ed9
...
...
@@ -38,6 +38,8 @@ public class FixedAuthoritiesExtractor implements AuthoritiesExtractor {
private
static
final
String
AUTHORITIES
=
"authorities"
;
private
static
final
String
[]
AUTHORITY_KEYS
=
{
"authority"
,
"role"
,
"value"
};
@Override
public
List
<
GrantedAuthority
>
extractAuthorities
(
Map
<
String
,
Object
>
map
)
{
String
authorities
=
"ROLE_USER"
;
...
...
@@ -60,22 +62,7 @@ public class FixedAuthoritiesExtractor implements AuthoritiesExtractor {
authorities
.
add
(
value
);
}
else
if
(
value
instanceof
Map
)
{
Map
<?,
?>
map
=
(
Map
<?,
?>)
value
;
if
(
map
.
size
()
==
1
)
{
authorities
.
add
(
map
.
values
().
iterator
().
next
());
}
else
if
(
map
.
containsKey
(
"authority"
))
{
authorities
.
add
(
map
.
get
(
"authority"
));
}
else
if
(
map
.
containsKey
(
"role"
))
{
authorities
.
add
(
map
.
get
(
"role"
));
}
else
if
(
map
.
containsKey
(
"value"
))
{
authorities
.
add
(
map
.
get
(
"value"
));
}
else
{
authorities
.
add
(
map
);
}
authorities
.
add
(
asAuthority
((
Map
<?,
?>)
value
));
}
else
{
authorities
.
add
(
value
);
...
...
@@ -86,4 +73,16 @@ public class FixedAuthoritiesExtractor implements AuthoritiesExtractor {
return
object
.
toString
();
}
private
Object
asAuthority
(
Map
<?,
?>
map
)
{
if
(
map
.
size
()
==
1
)
{
return
map
.
values
().
iterator
().
next
();
}
for
(
String
key
:
AUTHORITY_KEYS
)
{
if
(
map
.
containsKey
(
key
))
{
return
map
.
get
(
map
);
}
}
return
map
;
}
}
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