org.kohsuke.stapler.Header Java Examples
The following examples show how to use
org.kohsuke.stapler.Header.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitLabSecurityRealm.java From gitlab-oauth-plugin with MIT License | 6 votes |
public HttpResponse doCommenceLogin(StaplerRequest request, @QueryParameter String from, @Header("Referer") final String referer) throws IOException { // 2. Requesting authorization : // http://doc.gitlab.com/ce/api/oauth2.html String redirectOnFinish; if (from != null && Util.isSafeToRedirectTo(from)) { redirectOnFinish = from; } else if (referer != null && (referer.startsWith(Jenkins.getInstance().getRootUrl()) || Util.isSafeToRedirectTo(referer))) { redirectOnFinish = referer; } else { redirectOnFinish = Jenkins.getInstance().getRootUrl(); } List<NameValuePair> parameters = new ArrayList<>(); parameters.add(new BasicNameValuePair("redirect_uri", buildRedirectUrl(request, redirectOnFinish))); parameters.add(new BasicNameValuePair("response_type", "code")); parameters.add(new BasicNameValuePair("client_id", clientID)); return new HttpRedirect(gitlabWebUri + "/oauth/authorize?" + URLEncodedUtils.format(parameters, StandardCharsets.UTF_8)); }
Example #2
Source File: BranchHistoryWidget.java From DotCi with MIT License | 4 votes |
@Override public void doAjax(final StaplerRequest req, final StaplerResponse rsp, @Header("n") final String n) throws IOException, ServletException { if (n == null) { throw HttpResponses.error(SC_BAD_REQUEST, new IllegalArgumentException("Missing the 'n' HTTP header")); } rsp.setContentType("text/html;charset=UTF-8"); final List<T> items = new LinkedList<>(); String nn = null; // TODO refactor getBuildsAfter and database query to be getBuildsAfterAndEqual final Iterable<T> builds = this.model.getBuildsAfter(Integer.parseInt(n) - 1); for (final T t : builds) { if (this.adapter.compare(t, n) >= 0) { items.add(t); if (this.adapter.isBuilding(t)) { nn = this.adapter.getKey(t); } } else { break; } } if (nn == null) { if (items.isEmpty()) { nn = n; } else { nn = this.adapter.getNextKey(this.adapter.getKey(items.get(0))); } } this.baseList = items; GReflectionUtils.setField(HistoryWidget.class, "firstTransientBuildKey", this, nn); rsp.setHeader("n", nn); req.getView(this, "ajaxBuildHistory.jelly").forward(req, rsp); }