| 1 | package edu.ucsb.cs156.courses.services; | |
| 2 | ||
| 3 | import java.util.Collection; | |
| 4 | ||
| 5 | import org.springframework.security.core.Authentication; | |
| 6 | import org.springframework.security.core.GrantedAuthority; | |
| 7 | import org.springframework.security.core.context.SecurityContext; | |
| 8 | import org.springframework.security.core.context.SecurityContextHolder; | |
| 9 | import org.springframework.stereotype.Service; | |
| 10 | ||
| 11 | import lombok.extern.slf4j.Slf4j; | |
| 12 | ||
| 13 | @Slf4j | |
| 14 | @Service("grantedAuthorities") | |
| 15 | public class GrantedAuthoritiesService { | |
| 16 | ||
| 17 | public Collection<? extends GrantedAuthority> getGrantedAuthorities() { | |
| 18 | SecurityContext securityContext = SecurityContextHolder.getContext(); | |
| 19 | Authentication authentication = securityContext.getAuthentication(); | |
| 20 | Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities(); | |
| 21 | log.info("authorities={}", authorities); | |
| 22 |
1
1. getGrantedAuthorities : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/services/GrantedAuthoritiesService::getGrantedAuthorities → KILLED |
return authorities; |
| 23 | } | |
| 24 | ||
| 25 | } | |
Mutations | ||
| 22 |
1.1 |