public static AuthenticatedAccount of(Account account) { return new AuthenticatedAccount(account, new AccountUserDetails(account)); }
@Override public Account withACL(AuthenticatedAccount raw) { return raw.getAccount() // Global role .withGlobalRole( roleRepository.findGlobalRoleByAccount(raw.getAccount().id()).flatMap(rolesService::getGlobalRole) ) // Project roles .withProjectRoles( roleRepository.findProjectRoleAssociationsByAccount(raw.getAccount().id(), rolesService::getProjectRoleAssociation) ) // Groups from the repository .withGroups( accountGroupRepository.findByAccount(raw.getAccount().id()).stream() .map(this::groupWithACL) .collect(Collectors.toList()) ) // Group contributions .withGroups( accountGroupContributors.stream() .flatMap(accountGroupContributor -> accountGroupContributor.collectGroups(raw).stream()) .map(this::groupWithACL) .collect(Collectors.toList()) ) // OK .lock(); }
public static Collection<String> getLdapGroups(@NotNull AuthenticatedAccount authenticatedAccount) { UserDetails userDetails = authenticatedAccount.getUserDetails(); if (userDetails instanceof ExtendedLDAPUserDetails) { return ((ExtendedLDAPUserDetails) userDetails).getGroups(); } else { return Collections.emptyList(); } } }
new AuthenticatedAccount( accountService.create( new AccountInput( AuthenticatedAccount.of( Account.of( name, AuthenticatedAccount.of( Account.of( name, account -> new AuthenticatedAccount(account, userDetails) );
protected Account doCreateAccountWithGlobalRole(String role) throws Exception { Account account = doCreateAccount(); return asUser().with(AccountManagement.class).call(() -> { accountService.saveGlobalPermission( PermissionTargetType.ACCOUNT, account.id(), new PermissionInput(role) ); return accountService.withACL( AuthenticatedAccount.of(account) ); }); }
protected Account doCreateAccountWithProjectRole(Project project, String role) throws Exception { Account account = doCreateAccount(); return asUser().with(project, ProjectAuthorisationMgt.class).call(() -> { accountService.saveProjectPermission( project.getId(), PermissionTargetType.ACCOUNT, account.id(), new PermissionInput(role) ); return accountService.withACL( AuthenticatedAccount.of(account) ); }); }