use of io.gravitee.am.identityprovider.api.User in project gravitee-access-management by gravitee-io.
the class ApplicationsResource method createApplication.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create an application", notes = "User must have APPLICATION[CREATE] permission on the specified domain " + "or APPLICATION[CREATE] permission on the specified environment " + "or APPLICATION[CREATE] permission on the specified organization")
@ApiResponses({ @ApiResponse(code = 201, message = "Application successfully created"), @ApiResponse(code = 500, message = "Internal server error") })
public void createApplication(@PathParam("organizationId") String organizationId, @PathParam("environmentId") String environmentId, @PathParam("domain") String domain, @ApiParam(name = "application", required = true) @Valid @NotNull final NewApplication newApplication, @Suspended final AsyncResponse response) {
final User authenticatedUser = getAuthenticatedUser();
checkAnyPermission(organizationId, environmentId, domain, Permission.APPLICATION, Acl.CREATE).andThen(domainService.findById(domain).switchIfEmpty(Maybe.error(new DomainNotFoundException(domain))).flatMapSingle(__ -> applicationService.create(domain, newApplication, authenticatedUser).map(application -> Response.created(URI.create("/organizations/" + organizationId + "/environments/" + environmentId + "/domains/" + domain + "/applications/" + application.getId())).entity(application).build()))).subscribe(response::resume, response::resume);
}
use of io.gravitee.am.identityprovider.api.User in project gravitee-access-management by gravitee-io.
the class ApplicationsResource method list.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "List registered applications for a security domain", notes = "User must have the APPLICATION[LIST] permission on the specified domain, environment or organization " + "AND either APPLICATION[READ] permission on each domain's application " + "or APPLICATION[READ] permission on the specified domain " + "or APPLICATION[READ] permission on the specified environment " + "or APPLICATION[READ] permission on the specified organization. " + "Each returned application is filtered and contains only basic information such as id, name, description and isEnabled.")
@ApiResponses({ @ApiResponse(code = 200, message = "List registered applications for a security domain", response = Application.class, responseContainer = "List"), @ApiResponse(code = 500, message = "Internal server error") })
public void list(@PathParam("organizationId") String organizationId, @PathParam("environmentId") String environmentId, @PathParam("domain") String domain, @QueryParam("page") @DefaultValue("0") int page, @QueryParam("size") @DefaultValue(MAX_APPLICATIONS_SIZE_PER_PAGE_STRING) int size, @QueryParam("q") String query, @Suspended final AsyncResponse response) {
final User authenticatedUser = getAuthenticatedUser();
checkAnyPermission(organizationId, environmentId, domain, Permission.APPLICATION, Acl.LIST).andThen(domainService.findById(domain).switchIfEmpty(Maybe.error(new DomainNotFoundException(domain))).flatMapSingle(__ -> {
if (query != null) {
return applicationService.search(domain, query, 0, Integer.MAX_VALUE);
} else {
return applicationService.findByDomain(domain, 0, Integer.MAX_VALUE);
}
}).flatMap(pagedApplications -> Maybe.concat(pagedApplications.getData().stream().map(application -> hasAnyPermission(authenticatedUser, organizationId, environmentId, domain, application.getId(), Permission.APPLICATION, Acl.READ).filter(Boolean::booleanValue).map(__ -> filterApplicationInfos(application))).collect(Collectors.toList())).sorted((a1, a2) -> a2.getUpdatedAt().compareTo(a1.getUpdatedAt())).toList().map(applications -> new Page<>(applications.stream().skip(page * size).limit(size).collect(Collectors.toList()), page, applications.size())))).subscribe(response::resume, response::resume);
}
use of io.gravitee.am.identityprovider.api.User in project gravitee-access-management by gravitee-io.
the class AuthenticationDeviceNotifiersResource method create.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create an Authentication Device Notifier", notes = "User must have the DOMAIN_AUTHDEVICE_NOTIFIER[CREATE] permission on the specified domain " + "or DOMAIN_AUTHDEVICE_NOTIFIER[CREATE] permission on the specified environment " + "or DOMAIN_AUTHDEVICE_NOTIFIER[CREATE] permission on the specified organization")
@ApiResponses({ @ApiResponse(code = 201, message = "Authentication Device Notifier successfully created"), @ApiResponse(code = 500, message = "Internal server error") })
public void create(@PathParam("organizationId") String organizationId, @PathParam("environmentId") String environmentId, @PathParam("domain") String domain, @ApiParam(name = "notifier", required = true) @Valid @NotNull final NewAuthenticationDeviceNotifier newDeviceNotifier, @Suspended final AsyncResponse response) {
final User authenticatedUser = getAuthenticatedUser();
checkAnyPermission(organizationId, environmentId, domain, Permission.DOMAIN_AUTHDEVICE_NOTIFIER, Acl.CREATE).andThen(domainService.findById(domain).switchIfEmpty(Maybe.error(new DomainNotFoundException(domain))).flatMapSingle(__ -> authDeviceNotifierService.create(domain, newDeviceNotifier, authenticatedUser)).map(deviceNotifier -> Response.created(URI.create("/organizations/" + organizationId + "/environments/" + environmentId + "/domains/" + domain + "/auth-device-notifiers/" + deviceNotifier.getId())).entity(deviceNotifier).build())).subscribe(response::resume, response::resume);
}
use of io.gravitee.am.identityprovider.api.User in project gravitee-access-management by gravitee-io.
the class BotDetectionResource method delete.
@DELETE
@ApiOperation(value = "Delete a bot detection", notes = "User must have the DOMAIN_BOT_DETECTION[DELETE] permission on the specified domain " + "or DOMAIN_BOT_DETECTION[DELETE] permission on the specified environment " + "or DOMAIN_BOT_DETECTION[DELETE] permission on the specified organization")
@ApiResponses({ @ApiResponse(code = 204, message = "Bot detection successfully deleted"), @ApiResponse(code = 500, message = "Internal server error") })
public void delete(@PathParam("organizationId") String organizationId, @PathParam("environmentId") String environmentId, @PathParam("domain") String domain, @PathParam("botDetection") String botDetectionId, @Suspended final AsyncResponse response) {
final User authenticatedUser = getAuthenticatedUser();
checkAnyPermission(organizationId, environmentId, domain, Permission.DOMAIN_BOT_DETECTION, Acl.DELETE).andThen(botDetectionService.delete(domain, botDetectionId, authenticatedUser)).subscribe(() -> response.resume(Response.noContent().build()), response::resume);
}
use of io.gravitee.am.identityprovider.api.User in project gravitee-access-management by gravitee-io.
the class BotDetectionResource method update.
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update a bot detection", notes = "User must have the DOMAIN_BOT_DETECTION[UPDATE] permission on the specified domain " + "or DOMAIN_BOT_DETECTION[UPDATE] permission on the specified environment " + "or DOMAIN_BOT_DETECTION[UPDATE] permission on the specified organization")
@ApiResponses({ @ApiResponse(code = 201, message = "Bot detection successfully updated", response = BotDetection.class), @ApiResponse(code = 500, message = "Internal server error") })
public void update(@PathParam("organizationId") String organizationId, @PathParam("environmentId") String environmentId, @PathParam("domain") String domain, @PathParam("botDetection") String botDetection, @ApiParam(name = "identity", required = true) @Valid @NotNull UpdateBotDetection updateBotDetection, @Suspended final AsyncResponse response) {
final User authenticatedUser = getAuthenticatedUser();
checkAnyPermission(organizationId, environmentId, domain, Permission.DOMAIN_BOT_DETECTION, Acl.UPDATE).andThen(domainService.findById(domain).switchIfEmpty(Maybe.error(new DomainNotFoundException(domain))).flatMapSingle(__ -> botDetectionService.update(domain, botDetection, updateBotDetection, authenticatedUser))).subscribe(response::resume, response::resume);
}
Aggregations