use of org.kohsuke.stapler.WebMethod in project blueocean-plugin by jenkinsci.
the class BitbucketServerEndpoint method doDelete.
@WebMethod(name = "")
@DELETE
public void doDelete(StaplerResponse resp) {
final BitbucketEndpointConfiguration config = BitbucketEndpointConfiguration.get();
config.removeEndpoint(getApiUrl());
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
use of org.kohsuke.stapler.WebMethod in project blueocean-plugin by jenkinsci.
the class SigningPublicKey method asJSON.
/**
* Renders the key as JSON in the JWK format.
*/
@WebMethod(name = "")
public JSONObject asJSON() {
JSONObject jwk = new JSONObject();
jwk.put("kty", "RSA");
jwk.put("alg", "RS256");
jwk.put("kid", kid);
jwk.put("use", "sig");
jwk.put("key_ops", Collections.singleton("verify"));
jwk.put("n", Base64.getUrlEncoder().withoutPadding().encodeToString(key.getModulus().toByteArray()));
jwk.put("e", Base64.getUrlEncoder().withoutPadding().encodeToString(key.getPublicExponent().toByteArray()));
return jwk;
}
use of org.kohsuke.stapler.WebMethod in project blueocean-plugin by jenkinsci.
the class CredentialApi method create.
@POST
@WebMethod(name = "")
public CreateResponse create(@JsonBody JSONObject body, StaplerRequest request) throws IOException {
User authenticatedUser = User.current();
if (authenticatedUser == null) {
throw new ServiceException.UnauthorizedException("No authenticated user found");
}
JSONObject jsonObject = body.getJSONObject("credentials");
final IdCredentials credentials = request.bindJSON(IdCredentials.class, jsonObject);
String domainName = DOMAIN_NAME;
if (jsonObject.get("domain") != null && jsonObject.get("domain") instanceof String) {
domainName = (String) jsonObject.get("domain");
}
CredentialsUtils.createCredentialsInUserStore(credentials, authenticatedUser, domainName, Collections.singletonList(new BlueOceanDomainSpecification()));
CredentialsStoreAction.DomainWrapper domainWrapper = credentialStoreAction.getDomain(domainName);
if (domainWrapper != null) {
CredentialsStoreAction.CredentialsWrapper credentialsWrapper = domainWrapper.getCredential(credentials.getId());
if (credentialsWrapper != null) {
return new CreateResponse(new CredentialApi.Credential(credentialsWrapper, getLink().rel("domains").rel(domainName).rel("credentials")));
}
}
// this should never happen
throw new ServiceException.UnexpectedErrorException("Unexpected error, failed to create credential");
}
use of org.kohsuke.stapler.WebMethod in project workflow-cps-plugin by jenkinsci.
the class CpsThreadDumpAction method doProgramDotXml.
@WebMethod(name = "program.xml")
public void doProgramDotXml(StaplerRequest req, StaplerResponse rsp) throws Exception {
Jenkins.get().checkPermission(Jenkins.RUN_SCRIPTS);
CompletableFuture<String> f = new CompletableFuture<>();
execution.runInCpsVmThread(new FutureCallback<CpsThreadGroup>() {
@Override
public void onSuccess(CpsThreadGroup g) {
try {
f.complete(g.asXml());
} catch (Throwable t) {
f.completeExceptionally(t);
}
}
@Override
public void onFailure(Throwable t) {
f.completeExceptionally(t);
}
});
String xml;
try {
xml = f.get(1, TimeUnit.MINUTES);
} catch (Exception x) {
HttpResponses.error(x).generateResponse(req, rsp, this);
return;
}
rsp.setContentType("text/xml;charset=UTF-8");
PrintWriter pw = rsp.getWriter();
pw.print(xml);
pw.flush();
}
Aggregations