org.kohsuke.stapler.HttpRedirect Java Examples

The following examples show how to use org.kohsuke.stapler.HttpRedirect. 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 vote down vote up
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: OicSession.java    From oic-auth-plugin with MIT License 5 votes vote down vote up
/**
 * Starts the login session.
 * @return an {@link HttpResponse}
 */
@SuppressFBWarnings("J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION")
public HttpResponse doCommenceLogin() {
    // remember this in the session
    Stapler.getCurrentRequest().getSession().setAttribute(SESSION_NAME, this);
    AuthorizationCodeRequestUrl authorizationCodeRequestUrl = flow.newAuthorizationUrl().setState(state).setRedirectUri(redirectUrl);
    return new HttpRedirect(authorizationCodeRequestUrl.toString());
}
 
Example #3
Source File: TemplateDrivenMultiBranchProject.java    From multi-branch-project-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings(UNUSED)
@CLIMethod(name = "disable-job")
@RequirePOST
public HttpResponse doDisable() throws IOException, ServletException { // NOSONAR
    checkPermission(CONFIGURE);
    makeDisabled(true);
    return new HttpRedirect(".");
}
 
Example #4
Source File: TemplateDrivenMultiBranchProject.java    From multi-branch-project-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings(UNUSED)
@CLIMethod(name = "enable-job")
@RequirePOST
public HttpResponse doEnable() throws IOException, ServletException { // NOSONAR
    checkPermission(CONFIGURE);
    makeDisabled(false);
    return new HttpRedirect(".");
}