public boolean needsAdminLogin() { return !hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER); } }
public boolean needsAdminLogin() { return !hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER); }
public boolean needsAdminLogin() { return !hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER); }
@Override public boolean hasPermission(Permission permission) { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().hasPermission(permission); }
public HttpResponse doContinue() { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } initialSetup.getServletContext().setAttribute("app", initialSetup); return HttpResponses.ok(); } public boolean needsAdminLogin() {
@QueryParameter final String managerPassword) { if (!HudsonSecurityEntitiesHolder.getHudsonSecurityManager().hasPermission(Hudson.ADMINISTER) || StringUtils.isEmpty(server)) { return FormValidation.ok();
public HttpResponse doEnablePlugin(@QueryParameter String pluginName, @QueryParameter boolean enable) { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } InstalledPluginInfo plugin = installedPluginManager.getInstalledPlugin(pluginName); try { plugin.setEnable(enable); } catch (Exception ex) { return new ErrorHttpResponse("Plugin " + pluginName + " could not be enabled/disabled. " + ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doProxyConfigure( @QueryParameter("proxy.server") String server, @QueryParameter("proxy.port") String port, @QueryParameter("proxy.noProxyFor") String noProxyFor, @QueryParameter("proxy.userName") String userName, @QueryParameter("proxy.password") String password, @QueryParameter("proxy.authNeeded") String authNeeded) throws IOException { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } try { boolean proxySet = setProxy(server, port, noProxyFor, userName, password, authNeeded); if (proxySet) { proxyConfig.save(); } // Try opening a URL and see if the proxy works fine proxyConfig.openUrl(new URL("http://www.google.com")); } catch (IOException ex) { return new ErrorHttpResponse(ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doDowngradePlugin(@QueryParameter String pluginName) { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } InstalledPluginInfo plugin = installedPluginManager.getInstalledPlugin(pluginName); try { plugin.downgade(); } catch (Exception ex) { return new ErrorHttpResponse("Plugin " + pluginName + " could not be reverted to previous version. " + ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doUnpinPlugin(@QueryParameter String pluginName) { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } InstalledPluginInfo plugin = installedPluginManager.getInstalledPlugin(pluginName); try { plugin.unpin(); } catch (Exception ex) { return new ErrorHttpResponse("Plugin " + pluginName + " could not be unpinned. " + ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doDisablePlugin(@QueryParameter String pluginName) { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } InstalledPluginInfo plugin = installedPluginManager.getInstalledPlugin(pluginName); try { plugin.setEnable(false); } catch (Exception ex) { return new ErrorHttpResponse("Plugin " + pluginName + " could not be disabled. " + ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doProxyConfigure( @QueryParameter("proxy.server") String server, @QueryParameter("proxy.port") String port, @QueryParameter("proxy.noProxyFor") String noProxyFor, @QueryParameter("proxy.userName") String userName, @QueryParameter("proxy.password") String password, @QueryParameter("proxy.authNeeded") String authNeeded) throws IOException { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } try { boolean proxySet = setProxy(server, port, noProxyFor, userName, password, authNeeded); if (proxySet) { proxyConfig.save(); } // Try opening a URL and see if the proxy works fine proxyConfig.openUrl(new URL("http://www.hudson-ci.org/")); } catch (IOException ex) { return HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST, ex); } return HttpResponses.ok(); }
public HttpResponse doUploadPlugin(StaplerRequest request) throws IOException, ServletException { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } try { List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); for (FileItem fileItem : items) { if (fileItem.getFieldName().equals("file")) { String fileName = FilenameUtils.getName(fileItem.getName()); if ("".equals(fileName) || !fileName.endsWith(".hpi")) { return new ErrorHttpResponse("File " + fileName + " may not be a plugin"); } File uploadedPluginFile = new File(pluginsDir, fileName); fileItem.write(uploadedPluginFile); InstalledPluginInfo uploadedPluginInfo = new InstalledPluginInfo(uploadedPluginFile); for (Dependency dep : uploadedPluginInfo.getDependencies()) { doInstallPlugin(dep.getShortName()); } return HttpResponses.plainText("Plugin " + fileName + " successfully uploaded."); } } } catch (Exception exc) { return new ErrorHttpResponse(exc.getLocalizedMessage()); } return new ErrorHttpResponse("Failed to upload plugin"); }
public HttpResponse doAddSysAdmin(@QueryParameter String sysAdminSid) throws IOException { if (!HudsonSecurityEntitiesHolder.getHudsonSecurityManager().hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } if ((sysAdminSid == null) || "".equals(sysAdminSid.trim())) { return new TeamUtils.ErrorHttpResponse("Sys admin name required"); } TeamManager teamManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getTeamManager(); if (teamManager.getSysAdmins().contains(sysAdminSid)) { return new TeamUtils.ErrorHttpResponse(sysAdminSid + " is already a System Administrator."); } teamManager.addSysAdmin(sysAdminSid); return FormValidation.respond(FormValidation.Kind.OK, TeamUtils.getIcon(sysAdminSid)); }
public HttpResponse doRemoveSysAdmin(@QueryParameter String sysAdminSid) throws IOException { if (!HudsonSecurityEntitiesHolder.getHudsonSecurityManager().hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } if ((sysAdminSid == null) || "".equals(sysAdminSid.trim())) { return new TeamUtils.ErrorHttpResponse("Sys admin name required"); } TeamManager teamManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getTeamManager(); if (teamManager.getSysAdmins().contains(sysAdminSid)) { teamManager.removeSysAdmin(sysAdminSid); return HttpResponses.ok(); }else{ return new TeamUtils.ErrorHttpResponse(sysAdminSid + " is not a System Administrator."); } }
public HttpResponse doConfigureUpdateSite(@QueryParameter String siteUrl) throws IOException { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } try { updateSiteManager.verifyUpdateSite(siteUrl); updateSiteManager.setUpdateSiteUrl(siteUrl); // Ok a valid update site URL set it to the plugin manager. // For now let Plugin Manager periodically update the local cache. Hudson.getInstance().getPluginManager().doSiteConfigure(siteUrl); } catch (IOException ex) { return new ErrorHttpResponse("Update Site Could not be set. " + ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doRefreshUpdateCenter() throws IOException { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden(); } // Check if you are able to connect try { URL updateCenterRemoteUrl = new URL(updateSiteManager.getUpdateSiteUrl()); proxyConfig.openUrl(updateCenterRemoteUrl); } catch (Exception exc) { return new ErrorHttpResponse("Could not connect to " + updateSiteManager.getUpdateSiteUrl() + ". " + "If you are behind a firewall set HTTP proxy and try again."); } try { updateSiteManager.refreshFromUpdateSite(); } catch (IOException ex) { return new ErrorHttpResponse("Updates could not be refreshed. " + ex.getLocalizedMessage()); } return HttpResponses.ok(); }
public HttpResponse doinstallPlugin(@QueryParameter String pluginName) { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden();
public HttpResponse doInstallPlugin(@QueryParameter String pluginName) { if (!hudsonSecurityManager.hasPermission(Permission.HUDSON_ADMINISTER)) { return HttpResponses.forbidden();