use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.
the class AccountAuthorizationServiceTest method testCheckPermissions.
@Test
public void testCheckPermissions() {
doNothing().when(commonPermissionCheckingUtils).checkPermissionForUser(any(), anyString());
CheckPermissionByAccount methodAnnotation = new CheckPermissionByAccount() {
@Override
public Class<? extends Annotation> annotationType() {
return CheckPermissionByAccount.class;
}
@Override
public AuthorizationResourceAction action() {
return AuthorizationResourceAction.ENVIRONMENT_WRITE;
}
};
underTest.authorize(methodAnnotation, USER_CRN);
verify(commonPermissionCheckingUtils).checkPermissionForUser(eq(AuthorizationResourceAction.ENVIRONMENT_WRITE), eq(USER_CRN));
}
use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.
the class EventV4Controller method download.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public Response download(String name, @AccountId String accountId) {
StructuredEventContainer events = legacyStructuredEventService.getStructuredEventsForStack(name, workspaceService.getForCurrentUser().getId());
StreamingOutput streamingOutput = output -> {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
zipOutputStream.write(JsonUtil.writeValueAsString(events).getBytes());
zipOutputStream.closeEntry();
}
};
return Response.ok(streamingOutput).header("content-disposition", "attachment; filename = struct-events.zip").build();
}
use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.
the class EventV4Controller method getCloudbreakEventsByStack.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public Page<CloudbreakEventV4Response> getCloudbreakEventsByStack(String name, Integer page, Integer size, @AccountId String accountId) {
PageRequest pageable = PageRequest.of(page, size, Sort.by("timestamp").descending());
StackView stackView = getStackViewByNameIfAvailable(name);
return cloudbreakEventsFacade.retrieveEventsByStack(stackView.getId(), stackView.getType(), pageable);
}
use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.
the class RecipesV4Controller method post.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_RECIPE)
public RecipeV4Response post(Long workspaceId, RecipeV4Request request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String creator = ThreadBasedUserCrnProvider.getUserCrn();
Recipe recipeToSave = recipeV4RequestToRecipeConverter.convert(request);
Recipe recipe = recipeService.createForLoggedInUser(recipeToSave, restRequestThreadLocalService.getRequestedWorkspaceId(), accountId, creator);
notify(ResourceEvent.RECIPE_CREATED);
return recipeToRecipeV4ResponseConverter.convert(recipe);
}
use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.
the class ClusterTemplateV4Controller method post.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CLUSTER_DEFINITION)
public ClusterTemplateV4Response post(Long workspaceId, @Valid ClusterTemplateV4Request request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String creator = ThreadBasedUserCrnProvider.getUserCrn();
ClusterTemplate clusterTemplate = clusterTemplateService.createForLoggedInUser(clusterTemplateV4RequestToClusterTemplateConverter.convert(request), threadLocalService.getRequestedWorkspaceId(), accountId, creator);
return getByName(threadLocalService.getRequestedWorkspaceId(), clusterTemplate.getName());
}
Aggregations