Я совсем новичок в весенней загрузке и пытаюсь написать тестовые примеры, но застрял полностью и не могу понять, как работает аутентификация.
Класс контроллера
@GetMapping(value = "/getAllConceptsNames")
public ConceptCO getAllConceptsNames(Authentication authentication) {
return conceptDelegate
.getAllConceptNames(PrincipalUtil.getConcepts(authentication));
}
PrincipalUtil. java
public final class PrincipalUtil {
public static Set<String> getConcepts(final Authentication authentication) {
UserPrincipal user =
(UserPrincipal) authentication.getPrincipal();
Set<String> allConcepts = new HashSet<String>();
user.getUserPrincipalAttributes().forEach(role -> allConcepts.addAll(role.getConcepts()));
return allConcepts;
}
UserPrincipalAttributes. java
public class UserPrincipalAttributes {
Set<String> columns;
Set<String> concepts;
String role;
// getter & setters
}
UserPrincipal. java
public class UserPrincipal implements AuthenticatedPrincipal {
private String name;
private Set<UserPrincipalAttributes> userPrincipalAttributes;
private String token;
// getter & setters
}