package it.finki.charitable.security; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.oauth2.core.user.OAuth2User; import java.util.Collection; import java.util.Collections; import java.util.Map; public class UserO2Auth implements OAuth2User { private OAuth2User oAuth2User; public UserO2Auth(OAuth2User oAuth2User) { this.oAuth2User = oAuth2User; } @Override public Map getAttributes() { return oAuth2User.getAttributes(); } @Override public Collection getAuthorities() { SimpleGrantedAuthority authority = new SimpleGrantedAuthority("USER"); return Collections.singletonList(authority); } @Override public String getName() { return oAuth2User.getAttribute("email"); } }