@GET @Path("/rest/organizations/") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve all organizations details", response = Organisations.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved pipelines details", response = Organisations.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Organisations.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Organisations.class) }) public Response getOrganisations(@Context SecurityContext securityContext) throws NotFoundException { return delegate.getOrganisations(securityContext); }
@POST @Path("/{name}/enable") @io.swagger.annotations.ApiOperation(value = "", notes = "Enable a job", response = void.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "remoteAccess", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully enabled the job", response = void.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = void.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = void.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = void.class) }) public Response postJobEnable(@ApiParam(value = "Name of the job",required=true) @PathParam("name") String name ,@ApiParam(value = "CSRF protection token" )@HeaderParam("Jenkins-Crumb") String jenkinsCrumb ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.postJobEnable(name,jenkinsCrumb,securityContext); }
/** * This endpoint requires a Tester role, and also validates that the caller has the role Echoer by calling * {@linkplain SecurityContext#isUserInRole(String)}. * * @return principal name or FORBIDDEN error */ @GET @Path("/checkIsUserInRole") @RolesAllowed("Tester") public Response checkIsUserInRole(@Context SecurityContext sec) { Principal user = sec.getUserPrincipal(); Response response; if(!sec.isUserInRole("Echoer")) { response = Response.status(new Response.StatusType() { @Override public int getStatusCode() { return Response.Status.FORBIDDEN.getStatusCode(); } @Override public Response.Status.Family getFamily() { return Response.Status.FORBIDDEN.getFamily(); } @Override public String getReasonPhrase() { return "SecurityContext.isUserInRole(Echoer) was false"; } }).build(); } else { response = Response.ok(user.getName(), MediaType.TEXT_PLAIN).build(); } return response; }
@Override public Response getInvoiceTransfers(UUID invoiceId, SecurityContext securityContext) throws NotFoundException { Response resp; Error err = new Error(); err.setMessage("success"); try { List<AddressValuePair> transfers = Bitcoin.getInstance().getInvoiceTransfers(invoiceId); resp = Response.ok().entity(transfers).build(); } catch (NullPointerException e) { // likely no invoice found for provided invoiceID err.setMessage("no invoice found for id " + invoiceId); resp = Response.status(404).entity(err).build(); } logger.info(String.format("%s (%03d) getInvoiceTransfers: %s", invoiceId, resp.getStatus(), err.getMessage())); return resp; }
@POST @Path("/{name}/config.xml") @io.swagger.annotations.ApiOperation(value = "", notes = "Update view configuration", response = Void.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "remoteAccess", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully updated view configuration", response = Void.class), @io.swagger.annotations.ApiResponse(code = 400, message = "An error has occurred - error message is embedded inside the HTML response", response = Void.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Void.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Void.class), @io.swagger.annotations.ApiResponse(code = 404, message = "View cannot be found on Jenkins instance", response = Void.class) }) public Response postViewConfig( @PathParam("name") String name,@ApiParam(value = "View configuration in config.xml format" ,required=true) String body,@ApiParam(value = "CSRF protection token" )@HeaderParam("Jenkins-Crumb") String jenkinsCrumb,@Context SecurityContext securityContext) throws NotFoundException { return delegate.postViewConfig(name,body,jenkinsCrumb,securityContext); }
@GET @Path("/rest/organizations/{organization}/pipelines/{pipeline}/queue") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve queue details for an organization pipeline", response = PipelineQueue.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved queue details", response = PipelineQueue.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = PipelineQueue.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = PipelineQueue.class) }) public Response getPipelineQueue(@ApiParam(value = "Name of the organization",required=true) @PathParam("organization") String organization ,@ApiParam(value = "Name of the pipeline",required=true) @PathParam("pipeline") String pipeline ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getPipelineQueue(organization,pipeline,securityContext); }
@Transaction @Override public Response toolsPost(Tool body, SecurityContext securityContext) throws NotFoundException { // try creating a repo on github for this, this should probably be made into a transaction if (!gitHubBuilder.repoExists(body.getOrganization(), body.getToolname())) { LOG.info("Repo does not exist"); boolean repo = gitHubBuilder.createRepo(body.getOrganization(), body.getToolname()); if (!repo) { return Response.notModified("Could not create github repo").build(); } } try { toolDAO.insert(body.getId()); } catch (UnableToExecuteStatementException e) { LOG.info("Tool already exists in database"); } String gitUrl = gitHubBuilder.getGitUrl(body.getOrganization(), body.getToolname()); body.setUrl(gitUrl); toolDAO.update(body); Tool byId = toolDAO.findById(body.getId()); if (byId != null) { return Response.ok().entity(byId).build(); } return Response.notModified().build(); }
@POST @Path("/{invoiceId}/coupons") @Consumes({ "application/json" }) @Produces({ "application/json", "text/plain" }) @io.swagger.annotations.ApiOperation(value = "Adds one coupon to the invoice.", notes = "", response = AddressValuePair.class, tags={ }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 201, message = "returns the balance of the new coupon", response = AddressValuePair.class), @io.swagger.annotations.ApiResponse(code = 404, message = "invoice id not found", response = AddressValuePair.class), @io.swagger.annotations.ApiResponse(code = 409, message = "invoice already closed", response = AddressValuePair.class), @io.swagger.annotations.ApiResponse(code = 422, message = "coupon code is invalid", response = AddressValuePair.class), @io.swagger.annotations.ApiResponse(code = 503, message = "balance of coupon could not be retrieved", response = AddressValuePair.class) }) public Response addCouponToInvoice(@ApiParam(value = "the id of the invoice the coupon is for",required=true) @PathParam("invoiceId") UUID invoiceId ,@ApiParam(value = "coupon code" ,required=true) Coupon coupon ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.addCouponToInvoice(invoiceId,coupon,securityContext); }
@GET @Path("/{name}/lastBuild/api/json") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve job's last build details", response = FreeStyleBuild.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "remoteAccess", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved job's last build details", response = FreeStyleBuild.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = FreeStyleBuild.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = FreeStyleBuild.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = FreeStyleBuild.class) }) public Response getJobLastBuild( @PathParam("name") String name,@Context SecurityContext securityContext);
@GET @Path("/{name}/config.xml") @Produces({ "text/xml" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve job configuration", response = String.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "remoteAccess", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved job configuration in config.xml format", response = String.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = String.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = String.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = String.class) }) public Response getJobConfig( @PathParam("name") String name,@Context SecurityContext securityContext);
@DELETE @Path("/rest/organizations/{organization}/pipelines/{pipeline}/queue/{queue}") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Delete queue item from an organization pipeline queue", response = Void.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully deleted queue item", response = Void.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Void.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Void.class) }) public Response deletePipelineQueueItem( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline, @PathParam("queue") String queue,@Context SecurityContext securityContext) throws NotFoundException { return delegate.deletePipelineQueueItem(organization,pipeline,queue,securityContext); }
@GET @Path("/rest/classes/") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Get classes details", response = String.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved search result", response = String.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = String.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = String.class) }) public Response searchClasses( @NotNull @QueryParam("q") String q,@Context SecurityContext securityContext) throws NotFoundException { return delegate.searchClasses(q,securityContext); }
@Test public void checkSecurityProviderRegistered() { SecurityContext securityContext = Mockito.mock(SecurityContext.class); JaxrsModule module = new JaxrsModule(securityContext); CrnkBoot boot = new CrnkBoot(); boot.addModule(module); boot.boot(); SecurityProvider securityProvider = boot.getModuleRegistry().getSecurityProvider(); Assert.assertNotNull(securityProvider); Mockito.when(securityContext.isUserInRole("admin")).thenReturn(true); Assert.assertTrue(securityProvider.isUserInRole("admin")); Assert.assertFalse(securityProvider.isUserInRole("other")); }
@POST @Path("/{name}/config.xml") @Produces({ "text/xml" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Update job configuration", response = Void.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "remoteAccess", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved job configuration in config.xml format", response = Void.class), @io.swagger.annotations.ApiResponse(code = 400, message = "An error has occurred - error message is embedded inside the HTML response", response = Void.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Void.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Void.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = Void.class) }) public Response postJobConfig( @PathParam("name") String name,@ApiParam(value = "Job configuration in config.xml format" ,required=true) String body,@ApiParam(value = "CSRF protection token" )@HeaderParam("Jenkins-Crumb") String jenkinsCrumb,@Context SecurityContext securityContext);
@GET @Path("/rest/organizations/{organization}/pipelines/") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve all pipelines details for an organization", response = Pipelines.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved pipelines details", response = Pipelines.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Pipelines.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Pipelines.class) }) public Response getPipelines(@ApiParam(value = "Name of the organization",required=true) @PathParam("organization") String organization ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getPipelines(organization,securityContext); }
@GET @Path("/{job-id}/stdout") @ApiOperation( value = "Get a job's standard output", notes = "Get a job's standard output, if available. A job that has not yet started will not have a standard output and, " + "therefore, this method will return a 404. There is no guarantee that all running/finished jobs will have standard output " + "data. This is because administrative and cleanup routines may dequeue a job's output in order to save space on the server. ") @Produces(DEFAULT_BINARY_MIME_TYPE) @PermitAll public Response fetchJobStdoutById( @Context SecurityContext context, @ApiParam(value = "ID of the job to get stdout for") @PathParam("job-id") @NotNull JobId jobId) { if (jobId == null) throw new WebApplicationException("Job ID cannot be null", 400); return generateBinaryDataResponse(jobId, jobDAO.getStdout(jobId)); }
@GET @Path("/rest/organizations/{organization}/pipelines/{pipeline}") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve pipeline details for an organization", response = Pipeline.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved pipeline details", response = Pipeline.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Pipeline.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Pipeline.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Pipeline cannot be found on Jenkins instance", response = Pipeline.class) }) public Response getPipeline( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline,@Context SecurityContext securityContext);
@Override public Response getInvoiceState(UUID invoiceId, SecurityContext securityContext) throws NotFoundException { Response resp; Error err = new Error(); err.setMessage("success"); try { State state = Bitcoin.getInstance().getInvoiceState(invoiceId); resp = Response.ok().entity(state).build(); } catch (NullPointerException e) { // likely no invoice found for provided invoiceID err.setMessage("no invoice found for id " + invoiceId); resp = Response.status(404).entity(err).build(); } logger.info(String.format("%s (%03d) getInvoiceState: %s", invoiceId, resp.getStatus(), err.getMessage())); return resp; }
@Inject public JobResource( JobsService jobsService, DatasetVersionMutator datasetService, @Context SecurityContext securityContext ) { this.jobsService = jobsService; this.datasetService = datasetService; this.securityContext = securityContext; }
@GET @Path("/rest/organizations/{organization}/scm/{scm}/organizations") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve SCM organizations details for an organization", response = ScmOrganisations.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved SCM organizations details", response = ScmOrganisations.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = ScmOrganisations.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = ScmOrganisations.class) }) public Response getSCMOrganisations( @PathParam("organization") String organization, @PathParam("scm") String scm, @QueryParam("credentialId") String credentialId,@Context SecurityContext securityContext);
@Override public Response getJob(UUID jobUUID, SecurityContext securityContext) throws NotFoundException { try { JobDefinition job = ctx.jobManager().getJob(jobUUID); if (job == null) { return Response.status(Response.Status.NOT_FOUND).build(); } else { return Response.ok(job).build(); } } catch (IOException e) { throw new NotFoundException(INVALID_REQUEST, e.getMessage()); } }
@Override public Response removeJob(UUID jobUUID, SecurityContext securityContext) throws NotFoundException { try { ctx.jobManager().removeJob(jobUUID); } catch (IOException e) { throw new NotFoundException(INVALID_REQUEST, e.getMessage()); } return Response.ok().build(); }
@Override public Response getMtaOperationLogs(String operationId, SecurityContext securityContext, String spaceGuid) { try { Operation operation = dao.find(operationId); if (operation == null) { return Response.status(Status.NOT_FOUND).entity("Operation with id " + operationId + " not found").build(); } List<String> logIds = logsService.getLogNames(spaceGuid, operationId); List<Log> logs = logIds.stream().map(id -> new Log().id(id)).collect(Collectors.toList()); return Response.ok().entity(logs).build(); } catch (FileStorageException e) { throw new ContentException(e); } }
@GET @Path("/rest/users/{user}/favorites") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve user favorites details for an organization", response = UserFavorites.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved users favorites details", response = UserFavorites.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = UserFavorites.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = UserFavorites.class) }) public Response getUserFavorites( @PathParam("user") String user,@Context SecurityContext securityContext);
@DELETE @Path("/rest/organizations/{organization}/pipelines/{pipeline}/queue/{queue}") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Delete queue item from an organization pipeline queue", response = Void.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully deleted queue item", response = Void.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Void.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Void.class) }) public Response deletePipelineQueueItem( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline, @PathParam("queue") String queue,@Context SecurityContext securityContext);
@Override public Response toolClassesGet(SecurityContext securityContext) throws NotFoundException { ToolClass toolClass = new ToolClass(); toolClass.setDescription("CommandLineTool"); toolClass.setId("0"); toolClass.setName("CommandLineTool"); return Response.ok().entity(toolClass).build(); }
@Transaction @Override public Response toolsIdVersionsVersionIdTypeDescriptorRelativePathPost(String type, String id, String versionId, String relativePath, ToolDescriptor body, SecurityContext securityContext) throws NotFoundException { // hook up to github return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
@GET @Path("/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes/{node}") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve run node details for an organization pipeline", response = PipelineRunNode.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved run node details", response = PipelineRunNode.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = PipelineRunNode.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = PipelineRunNode.class) }) public Response getPipelineRunNode( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline, @PathParam("run") String run, @PathParam("node") String node,@Context SecurityContext securityContext);
@GET @Path("/rest/organizations/{organization}/pipelines/{pipeline}/runs/{run}/nodes/{node}/steps") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve run node steps details for an organization pipeline", response = PipelineRunNodeSteps.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved run node steps details", response = PipelineRunNodeSteps.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = PipelineRunNodeSteps.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = PipelineRunNodeSteps.class) }) public Response getPipelineRunNodeSteps( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline, @PathParam("run") String run, @PathParam("node") String node,@Context SecurityContext securityContext);
@Inject public DatasetsResource( NamespaceService namespaceService, DatasetVersionMutator datasetService, JobsService jobsService, QueryExecutor executor, @Context SecurityContext securityContext) { this(namespaceService, datasetService, new DatasetTool(datasetService, jobsService, executor, securityContext)); }
@POST @Path("/rest/organizations/{organization}/pipelines/{pipeline}/runs") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Start a build for an organization pipeline", response = QueueItemImpl.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully started a build", response = QueueItemImpl.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = QueueItemImpl.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = QueueItemImpl.class) }) public Response postPipelineRuns( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline,@Context SecurityContext securityContext);
@DELETE @Path("/{agentId}") @Consumes({ "application/json" }) @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "Delete a agent", notes = "A client delete a agent", response = void.class, tags={ }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Agent successfully deleted", response = void.class), @io.swagger.annotations.ApiResponse(code = 200, message = "Unexpected error", response = void.class) }) public Response deleteAgent(@ApiParam(value = "Id of agent to delete",required=true) @PathParam("agentId") String agentId ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.deleteAgent(agentId,securityContext); }
@GET @Path("/rest/organizations/{organization}/pipelines/{folder}/") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve pipeline folder for an organization", response = PipelineFolderImpl.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "blueOcean", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved folder details", response = PipelineFolderImpl.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = PipelineFolderImpl.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = PipelineFolderImpl.class) }) public Response getPipelineFolder( @PathParam("organization") String organization, @PathParam("folder") String folder,@Context SecurityContext securityContext);
@GET @Path("/{invoiceId}") @Consumes({ "application/json" }) @Produces({ "application/json", "text/plain" }) @io.swagger.annotations.ApiOperation(value = "Returns information about the invoice to the provided id.", notes = "", response = Invoice.class, tags={ }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "returns the information about the invoice", response = Invoice.class), @io.swagger.annotations.ApiResponse(code = 404, message = "invoice not found", response = Invoice.class) }) public Response getInvoiceById(@ApiParam(value = "the invoice id to get the information for",required=true) @PathParam("invoiceId") UUID invoiceId ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getInvoiceById(invoiceId,securityContext); }
@Override public void filter(final ContainerRequestContext ctx) throws IOException { if (nonNull(ctx.getHeaders().getFirst(HttpHeaders.AUTHORIZATION))) { throw new WebApplicationException(unauthorizedHandler.buildResponse(prefix, realm)); } final SecurityContext securityContext = ctx.getSecurityContext(); final boolean secure = securityContext != null && securityContext.isSecure(); ctx.setSecurityContext(new SecurityContext() { @Override public Principal getUserPrincipal() { return new PrincipalImpl(Trellis.AnonymousAgent.getIRIString()); } @Override public boolean isUserInRole(final String role) { return false; } @Override public boolean isSecure() { return secure; } @Override public String getAuthenticationScheme() { return "NONE"; } }); }
@GET @Path("/api/json") @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve computer details", response = ComputerSet.class, authorizations = { @io.swagger.annotations.Authorization(value = "jenkins_auth") }, tags={ "remoteAccess", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved computer details", response = ComputerSet.class), @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = ComputerSet.class), @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = ComputerSet.class) }) public Response getComputer( @NotNull @QueryParam("depth") Integer depth,@Context SecurityContext securityContext);
@GET @Produces({ "application/json" }) @io.swagger.annotations.ApiOperation(value = "retrieve list of sessions", notes = "list sessions", response = Session.class, responseContainer = "List", tags={ "sessions", }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "session objects", response = Session.class, responseContainer = "List") }) public Response listSessions( @Context SecurityContext securityContext) throws NotFoundException { return delegate.listSessions(securityContext); }
@GET @Path("/{invoiceId}/state") @Consumes({ "application/json" }) @Produces({ "application/json", "text/plain" }) @io.swagger.annotations.ApiOperation(value = "Returns a confidence object that describes the state of the incoming tx.", notes = "", response = State.class, tags={ }) @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "returns the state object of the incoming tx", response = State.class), @io.swagger.annotations.ApiResponse(code = 404, message = "invoice not found", response = State.class) }) public Response getInvoiceState(@ApiParam(value = "the invoice id to get the state for",required=true) @PathParam("invoiceId") UUID invoiceId ,@Context SecurityContext securityContext) throws NotFoundException { return delegate.getInvoiceState(invoiceId,securityContext); }
@Override public String getAuthenticationScheme() { if (session == null) { // Not authenticated return null; } if (session.getId() == null) { // API key return SecurityContext.BASIC_AUTH; } return SecurityContext.FORM_AUTH; }
@Inject public QueryExecutor(JobsService jobsService, SchemaTreeProvider schemaProvider, SecurityContext context) { super(); this.jobsService = jobsService; this.schemaProvider = schemaProvider; this.context = context; }