public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
/** * Generates a captcha image. */ public final void doCaptcha(StaplerRequest req, StaplerResponse rsp) throws IOException { if (captchaSupport != null) { String id = req.getSession().getId(); rsp.setContentType("image/png"); // source: https://stackoverflow.com/a/3414217 rsp.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); rsp.setHeader("Pragma", "no-cache"); rsp.setHeader("Expires", "0"); captchaSupport.generateImage(id, rsp.getOutputStream()); } }
public void doClearSecretToken(@AncestorInPath final Job<?, ?> project, StaplerResponse response) {; response.setHeader("script", "document.getElementById('secretToken').value=''"); } }
@Override protected void writeStatusBody(StaplerResponse response, Run<?, ?> build, BuildStatus status) { try { response.setHeader("Expires", "Fri, 01 Jan 1984 00:00:00 GMT"); response.setHeader("Cache-Control", "no-cache, private"); response.setHeader("Content-Type", "image/png"); IOUtils.copy(getStatusImage(status), response.getOutputStream()); response.flushBuffer(); } catch (Exception e) { throw HttpResponses.error(500, "Could not generate response."); } }
rsp.setHeader("Hudson-Duplex", "true"); // set the header so that the client would know
public long writeHtmlTo(long start, Writer w) throws IOException { ConsoleAnnotationOutputStream<T> caw = new ConsoleAnnotationOutputStream<>( w, createAnnotator(Stapler.getCurrentRequest()), context, charset); long r = super.writeLogTo(start,caw); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Cipher sym = PASSING_ANNOTATOR.encrypt(); ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(new GZIPOutputStream(new CipherOutputStream(baos,sym))); oos.writeLong(System.currentTimeMillis()); // send timestamp to prevent a replay attack oos.writeObject(caw.getConsoleAnnotator()); oos.close(); StaplerResponse rsp = Stapler.getCurrentResponse(); if (rsp!=null) rsp.setHeader("X-ConsoleAnnotator", new String(Base64.encode(baos.toByteArray()))); return r; }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType("text/html;charset=UTF-8"); rsp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rsp.setHeader("X-Jenkins-Select-Error", selectionCleared ? "clear" : "retain"); rsp.getWriter().print(renderHtml()); }
public void doGenerateSecretToken(@AncestorInPath final Job<?, ?> project, StaplerResponse response) { byte[] random = new byte[16]; // 16x8=128bit worth of randomness, since we use md5 digest as the API token RANDOM.nextBytes(random); String secretToken = Util.toHexString(random); response.setHeader("script", "document.getElementById('secretToken').value='" + secretToken + "'"); }
rsp.setHeader("n",nn);
/** * @deprecated use {@link #doGenerateNewToken(User, String)} instead */ @Deprecated @RequirePOST public HttpResponse doChangeToken(@AncestorInPath User u, StaplerResponse rsp) throws IOException { // you are the user or you have ADMINISTER permission u.checkPermission(Jenkins.ADMINISTER); LOGGER.log(Level.FINE, "Deprecated action /changeToken used, consider using /generateNewToken instead"); if(!mustDisplayLegacyApiToken(u)){ // user does not have legacy token and the capability to create one without an existing one is disabled return HttpResponses.html(Messages.ApiTokenProperty_ChangeToken_CapabilityNotAllowed()); } ApiTokenProperty p = u.getProperty(ApiTokenProperty.class); if (p == null) { p = forceNewInstance(u, true); p.setUser(u); u.addProperty(p); } else { // even if the user does not have legacy token, this method let some legacy system to regenerate one p.changeApiToken(); } rsp.setHeader("script","document.getElementById('apiToken').value='"+p.getApiToken()+"'"); return HttpResponses.html(p.hasPermissionToSeeToken() ? Messages.ApiTokenProperty_ChangeToken_Success() : Messages.ApiTokenProperty_ChangeToken_SuccessHidden()); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); //rsp.setHeader("Content-Disposition", "attachment; filename=" + file.getAbsolutePath()); rsp.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), file.getName()); in.close(); //The file has been read; the request will not be repeated this.close(); }
@Override public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { RSAPublicKey key = new InstanceIdentity().getPublic(); rsp.setStatus(HttpServletResponse.SC_OK); rsp.setHeader(X_INSTANCE_IDENTITY, new String(encodeBase64(key.getEncoded()), UTF_8)); } });
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType("text/html;charset=UTF-8"); rsp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rsp.setHeader("X-Jenkins-Select-Error", selectionCleared ? "clear" : "retain"); rsp.getWriter().print(renderHtml()); }