use of rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractor method extractUserDetails.
private CoffeeNetUserDetails extractUserDetails(Map<String, Object> map) {
HumanCoffeeNetUser humanCoffeeUser;
if (map.containsKey(PRINCIPAL_KEY) && map.get(PRINCIPAL_KEY) instanceof Map) {
Map principal = (Map) map.get(PRINCIPAL_KEY);
humanCoffeeUser = new HumanCoffeeNetUser(extractUsername(principal), extractMail(principal), this.authoritiesExtractor.extractAuthorities(map));
} else {
humanCoffeeUser = new HumanCoffeeNetUser(UNKNOWN_VALUE, UNKNOWN_VALUE, authoritiesExtractor.extractAuthorities(map));
LOGGER.warn(ERROR_MSG_TEMPLATE, PRINCIPAL_KEY, humanCoffeeUser);
}
return humanCoffeeUser;
}
use of rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetNavigationDataExtractorTest method extractUser.
@Test
public void extractUser() {
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.USER_SERVICE, coffeeNetCurrentUserServiceMock);
Optional<CoffeeNetUserDetails> user = of(new HumanCoffeeNetUser("username", "email", emptyList()));
when(coffeeNetCurrentUserServiceMock.get()).thenReturn(user);
Optional<CurrentCoffeeNetUser> coffeeNetWebUser = sut.extractUser();
assertThat(coffeeNetWebUser.get().getEmail()).isSameAs("email");
assertThat(coffeeNetWebUser.get().getUsername()).isSameAs("username");
}
use of rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsHumanCoffeeUserWithUnknownMailIfMailIsNotOfTypeString.
@Test
public void extractPrincipalReturnsHumanCoffeeUserWithUnknownMailIfMailIsNotOfTypeString() {
testPrincipal.put("mail", true);
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getUsername(), is("coffy"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
use of rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsUnknownHumanCoffeeUserIfPrincipalIsNotOfTypeMap.
@Test
public void extractPrincipalReturnsUnknownHumanCoffeeUserIfPrincipalIsNotOfTypeMap() {
userInfoHashMap.put("principal", "someThingElse");
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getUsername(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
use of rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnHumanCoffeeUser.
@Test
public void extractPrincipalReturnHumanCoffeeUser() {
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("coffy@coffeenet"));
assertThat(humanCoffeeUser.getUsername(), is("coffy"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
Aggregations