Search in sources :

Example 61 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationRolesController method removeGroupRole.

/**
 * Remove a role from a user on a specific application
 *
 * @param applicationId The id of the application.
 * @param groupId The id of the group to update roles.
 * @param role The role to add to the user on the application.
 * @return A {@link Void} {@link RestResponse}.
 */
@ApiOperation(value = "Remove a role of a group on a specific application", notes = "Any user with application role APPLICATION_MANAGER can un-assign any role to a group. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(value = "/groups/{groupId}/{role}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> removeGroupRole(@PathVariable String applicationId, @PathVariable String groupId, @PathVariable String role) {
    Application application = applicationService.getOrFail(applicationId);
    AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
    resourceRoleService.removeGroupRole(application, groupId, role);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 62 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationRolesController method addGroupRole.

/**
 * Add a role to a group on a specific application
 *
 * @param applicationId The id of the application.
 * @param groupId The id of the group to update roles.
 * @param role The role to add to the group on the application.
 * @return A {@link Void} {@link RestResponse}.
 */
@ApiOperation(value = "Add a role to a group on a specific application", notes = "Any user with application role APPLICATION_MANAGER can assign any role to a group of users. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(value = "/groups/{groupId}/{role}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> addGroupRole(@PathVariable String applicationId, @PathVariable String groupId, @PathVariable String role) {
    Application application = applicationService.getOrFail(applicationId);
    AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
    resourceRoleService.addGroupRole(application, groupId, role);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 63 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationRolesController method removeUserRole.

/**
 * Remove a role from a user on a specific application
 *
 * @param applicationId The id of the application.
 * @param username The username of the user to update roles.
 * @param role The role to add to the user on the application.
 * @return A {@link Void} {@link RestResponse}.
 */
@ApiOperation(value = "Remove a role to a user on a specific application", notes = "Any user with application role APPLICATION_MANAGER can unassign any role to another user. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(value = "/users/{username}/{role}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> removeUserRole(@PathVariable String applicationId, @PathVariable String username, @PathVariable String role) {
    Application application = applicationService.getOrFail(applicationId);
    AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
    resourceRoleService.removeUserRole(application, username, role);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 64 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationTagsController method deleteTag.

/**
 * Delete a tag for the application.
 *
 * @param applicationId Id of the application for which to remove the tag.
 * @param tagId The key of the tag to remove.
 * @return An empty {@link RestResponse}.
 */
@ApiOperation(value = "Delete a tag for the application.", notes = "The logged-in user must have the application manager role for this application. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(value = "/{tagId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> deleteTag(@PathVariable String applicationId, @PathVariable String tagId) {
    Application application = applicationService.getOrFail(applicationId);
    AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
    tagService.removeTag(application, tagId);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 65 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationTagsController method upsertTag.

/**
 * Update or create a tag for a given application
 *
 * @param applicationId The id of the application for which to update/create a tag.
 * @param updateApplicationTagRequest The object that contains the tag's key and value.
 * @return An empty rest response.
 */
@ApiOperation(value = "Update/Create a tag for the application.", notes = "The logged-in user must have the application manager role for this application. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> upsertTag(@PathVariable String applicationId, @RequestBody UpdateTagRequest updateApplicationTagRequest) {
    Application application = applicationService.getOrFail(applicationId);
    AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
    tagService.upsertTag(application, updateApplicationTagRequest.getTagKey(), updateApplicationTagRequest.getTagValue());
    return RestResponseBuilder.<Void>builder().build();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Application (alien4cloud.model.application.Application)103 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)45 ApiOperation (io.swagger.annotations.ApiOperation)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)39 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)38 Audit (alien4cloud.audit.annotation.Audit)28 List (java.util.List)14 Topology (org.alien4cloud.tosca.model.templates.Topology)14 Set (java.util.Set)12 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)11 RestResponse (alien4cloud.rest.model.RestResponse)11 Collectors (java.util.stream.Collectors)11 Map (java.util.Map)10 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)9 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)9 Arrays (java.util.Arrays)9 When (cucumber.api.java.en.When)8 Deployment (alien4cloud.model.deployment.Deployment)7 RestResponseBuilder (alien4cloud.rest.model.RestResponseBuilder)7 ApplicationEnvironmentAuthorizationDTO (alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationDTO)7