Last change
on this file since a64f926 was b8dc761, checked in by NikolaCenevski <cenevskinikola@…>, 3 years ago |
part 2
|
-
Property mode
set to
100644
|
File size:
934 bytes
|
Line | |
---|
1 | package it.finki.charitable.security;
|
---|
2 |
|
---|
3 | import org.springframework.security.core.GrantedAuthority;
|
---|
4 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
---|
5 | import org.springframework.security.oauth2.core.user.OAuth2User;
|
---|
6 |
|
---|
7 | import java.util.Collection;
|
---|
8 | import java.util.Collections;
|
---|
9 | import java.util.Map;
|
---|
10 |
|
---|
11 | public class UserO2Auth implements OAuth2User {
|
---|
12 |
|
---|
13 | private OAuth2User oAuth2User;
|
---|
14 |
|
---|
15 | public UserO2Auth(OAuth2User oAuth2User) {
|
---|
16 | this.oAuth2User = oAuth2User;
|
---|
17 | }
|
---|
18 |
|
---|
19 | @Override
|
---|
20 | public Map<String, Object> getAttributes() {
|
---|
21 | return oAuth2User.getAttributes();
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public Collection<? extends GrantedAuthority> getAuthorities() {
|
---|
26 | SimpleGrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
---|
27 | return Collections.singletonList(authority);
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public String getName() {
|
---|
32 | return oAuth2User.getAttribute("email");
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.