/** * Builder */ public static PermissionInput of(String role) { return new PermissionInput(role); }
@Override public Ack saveGlobalPermission(PermissionTargetType type, int id, PermissionInput input) { switch (type) { case ACCOUNT: securityService.checkGlobalFunction(AccountManagement.class); return roleRepository.saveGlobalRoleForAccount(id, input.getRole()); case GROUP: securityService.checkGlobalFunction(AccountGroupManagement.class); return roleRepository.saveGlobalRoleForGroup(id, input.getRole()); default: return Ack.NOK; } }
protected AccountGroup doCreateAccountGroupWithGlobalRole(String role) throws Exception { AccountGroup group = doCreateAccountGroup(); return asUser().with(AccountGroupManagement.class).call(() -> { accountService.saveGlobalPermission( PermissionTargetType.GROUP, group.id(), new PermissionInput(role) ); return group; }); }
@Override public Ack saveProjectPermission(ID projectId, PermissionTargetType type, int id, PermissionInput input) { securityService.checkProjectFunction(projectId.getValue(), ProjectAuthorisationMgt.class); switch (type) { case ACCOUNT: return roleRepository.saveProjectRoleForAccount(projectId.getValue(), id, input.getRole()); case GROUP: return roleRepository.saveProjectRoleForGroup(projectId.getValue(), id, input.getRole()); default: return Ack.NOK; } }
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) ); }); }