use of com.nexblocks.authguard.service.model.TokenRestrictionsBO in project AuthGuard by AuthGuard.
the class AuthorizationCodeToAccessToken method generateToken.
private Either<Exception, AuthResponseBO> generateToken(final AccountTokenDO accountToken) {
final TokenOptionsBO options = TokenOptionsBO.builder().source("aut_code").build();
final TokenRestrictionsBO restrictions = getRestrictions(accountToken);
return accountsServiceAdapter.getAccount(accountToken.getAssociatedAccountId()).map(account -> accessTokenProvider.generateToken(account, restrictions, options));
}
use of com.nexblocks.authguard.service.model.TokenRestrictionsBO in project AuthGuard by AuthGuard.
the class JwtPermissionsMapperTest method map.
@Test
void map() {
final AccountBO account = AccountBO.builder().permissions(Arrays.asList(PermissionBO.builder().group("test").name("read").build(), PermissionBO.builder().group("test").name("write").build(), PermissionBO.builder().group("test").name("nothing").build())).build();
final TokenRestrictionsBO restrictions = TokenRestrictionsBO.builder().addPermissions("test:read", "test:nothing").build();
final String[] expected = new String[] { "test:read", "test:nothing" };
final String[] actual = JwtPermissionsMapper.map(account, restrictions);
assertThat(Arrays.asList(actual)).isEqualTo(Arrays.asList(expected));
}
use of com.nexblocks.authguard.service.model.TokenRestrictionsBO in project AuthGuard by AuthGuard.
the class JwtPermissionsMapperTest method mapNoPermissionRestrictions.
@Test
void mapNoPermissionRestrictions() {
final AccountBO account = AccountBO.builder().permissions(Arrays.asList(PermissionBO.builder().group("test").name("read").build(), PermissionBO.builder().group("test").name("write").build(), PermissionBO.builder().group("test").name("nothing").build())).build();
final TokenRestrictionsBO restrictions = TokenRestrictionsBO.builder().build();
final String[] expected = new String[] { "test:read", "test:write", "test:nothing" };
final String[] actual = JwtPermissionsMapper.map(account, restrictions);
assertThat(Arrays.asList(actual)).isEqualTo(Arrays.asList(expected));
}
Aggregations