/** * Exposes {@link CredentialsStore#isDomainsModifiable()} for Jelly. * * @return {@link CredentialsStore#isDomainsModifiable()}. */ public boolean isDomainsModifiable() { return getStore().isDomainsModifiable(); }
/** * Exposes {@link CredentialsStore#isDomainsModifiable()} for Jelly. * * @return {@link CredentialsStore#isDomainsModifiable()}. */ public boolean isDomainsModifiable() { return getStore().isDomainsModifiable(); }
return; if (req.getMethod().equals("POST") && getStore().isDomainsModifiable()) { if (req.getMethod().equals("DELETE") && getStore().isDomainsModifiable()) { if (getStore().removeDomain(domain)) { return;
if (store.isDomainsModifiable()) { Matcher matcher = Pattern.compile("\\s*<([^>]+)>.*").matcher(legacyRealm); if (matcher.matches()) {
return; if (req.getMethod().equals("POST") && getStore().isDomainsModifiable()) { if (req.getMethod().equals("DELETE") && getStore().isDomainsModifiable()) { if (getStore().removeDomain(domain)) { return;
public HttpResponse doCreateDomain(StaplerRequest req) throws ServletException, IOException { getStore().checkPermission(MANAGE_DOMAINS); if (!getStore().isDomainsModifiable()) { return HttpResponses.status(HttpServletResponse.SC_BAD_REQUEST);
return HttpResponses.status(400); if (!destinationStore.isDomainsModifiable()) { return HttpResponses.status(400);
public HttpResponse doCreateDomain(StaplerRequest req) throws ServletException, IOException { getStore().checkPermission(MANAGE_DOMAINS); if (!getStore().isDomainsModifiable()) { return HttpResponses.status(HttpServletResponse.SC_BAD_REQUEST);
return HttpResponses.status(400); if (!destinationStore.isDomainsModifiable()) { return HttpResponses.status(400);
/** * Creates the context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); if (getStore().isDomainsModifiable() && getStore().hasPermission(MANAGE_DOMAINS)) { menu.add(ContextMenuIconUtils.buildUrl(prefix, "newDomain"), getMenuItemIconUrlByClassSpec("icon-credentials-new-domain icon-md"), Messages.CredentialsStoreAction_AddDomainAction() ); } for (Action action : getActions()) { ContextMenuIconUtils.addMenuItem(menu, prefix, action); } return menu.items.isEmpty() ? null : menu; }
/** * Creates the context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); if (getStore().isDomainsModifiable() && getStore().hasPermission(MANAGE_DOMAINS)) { menu.add(ContextMenuIconUtils.buildUrl(prefix, "newDomain"), getMenuItemIconUrlByClassSpec("icon-credentials-new-domain icon-md"), Messages.CredentialsStoreAction_AddDomainAction() ); } for (Action action : getActions()) { ContextMenuIconUtils.addMenuItem(menu, prefix, action); } return menu.items.isEmpty() ? null : menu; }
/** * Deletes a domain. * * @param req the request. * @return the response. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doDoDelete(StaplerRequest req) throws IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); if (getStore().removeDomain(domain)) { return HttpResponses.redirectTo("../.."); } return HttpResponses.redirectToDot(); }
/** * Stapler web binding for adding credentials to the domain. * * @param req the request. * @param rsp the response. * @throws IOException if something goes wrong. * @throws ServletException if something goes wrong. */ @RequirePOST public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if (!store.isDomainsModifiable()) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Domain is read-only')").generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); JSONObject data = req.getSubmittedForm(); String domainName = data.getString("domain"); CredentialsStoreAction.DomainWrapper wrapper = getWrappers().get(domainName); if (!store.getDomains().contains(wrapper.getDomain())) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Store does not have selected domain')") .generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials")); store.addCredentials(wrapper.getDomain(), credentials); FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null); }
/** * Deletes a domain. * * @param req the request. * @return the response. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doDoDelete(StaplerRequest req) throws IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); if (getStore().removeDomain(domain)) { return HttpResponses.redirectTo("../.."); } return HttpResponses.redirectToDot(); }
/** * Stapler web binding for adding credentials to the domain. * * @param req the request. * @param rsp the response. * @throws IOException if something goes wrong. * @throws ServletException if something goes wrong. */ @RequirePOST public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if (!store.isDomainsModifiable()) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Domain is read-only')").generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); JSONObject data = req.getSubmittedForm(); String domainName = data.getString("domain"); CredentialsStoreAction.DomainWrapper wrapper = getWrappers().get(domainName); if (!store.getDomains().contains(wrapper.getDomain())) { hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null); FormApply.applyResponse("window.alert('Store does not have selected domain')") .generateResponse(req, rsp, null); } store.checkPermission(CredentialsStoreAction.CREATE); Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials")); store.addCredentials(wrapper.getDomain(), credentials); FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null); }
/** * Updates the domain configuration. * * @param req the request. * @return the response. * @throws ServletException if something goes wrong. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doConfigSubmit(StaplerRequest req) throws ServletException, IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); JSONObject data = req.getSubmittedForm(); Domain domain = req.bindJSON(Domain.class, data); String domainName = domain.getName(); if (domainName != null && getStore().updateDomain(this.domain, domain)) { return HttpResponses.redirectTo("../../domain/" + Util.rawEncode(domainName)); } return HttpResponses.redirectToDot(); }
/** * Updates the domain configuration. * * @param req the request. * @return the response. * @throws ServletException if something goes wrong. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doConfigSubmit(StaplerRequest req) throws ServletException, IOException { if (!getStore().isDomainsModifiable()) { return HttpResponses.status(400); } getStore().checkPermission(MANAGE_DOMAINS); JSONObject data = req.getSubmittedForm(); Domain domain = req.bindJSON(Domain.class, data); String domainName = domain.getName(); if (domainName != null && getStore().updateDomain(this.domain, domain)) { return HttpResponses.redirectTo("../../domain/" + Util.rawEncode(domainName)); } return HttpResponses.redirectToDot(); }