source: src/main/java/it/finki/charitable/security/UserO2Auth.java

Last change on this file was b8dc761, checked in by NikolaCenevski <cenevskinikola@…>, 3 years ago

part 2

  • Property mode set to 100644
File size: 934 bytes
Line 
1package it.finki.charitable.security;
2
3import org.springframework.security.core.GrantedAuthority;
4import org.springframework.security.core.authority.SimpleGrantedAuthority;
5import org.springframework.security.oauth2.core.user.OAuth2User;
6
7import java.util.Collection;
8import java.util.Collections;
9import java.util.Map;
10
11public 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.