本文整理匯總了Java中javax.ws.rs.core.SecurityContext類的典型用法代碼示例。如果您正苦於以下問題:Java SecurityContext類的具體用法?Java SecurityContext怎麽用?Java SecurityContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SecurityContext類屬於javax.ws.rs.core包,在下文中一共展示了SecurityContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOrganisations
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例2: postJobEnable
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例3: checkIsUserInRole
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
/**
* 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;
}
示例4: postViewConfig
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例5: getPipelineQueue
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例6: toolsPost
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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();
}
示例7: addCouponToInvoice
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例8: getJobLastBuild
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
示例9: getJobConfig
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
示例10: deletePipelineQueueItem
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例11: searchClasses
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例12: checkSecurityProviderRegistered
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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"));
}
示例13: postJobConfig
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
示例14: getPipelines
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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);
}
示例15: fetchJobStdoutById
import javax.ws.rs.core.SecurityContext; //導入依賴的package包/類
@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));
}