Search in sources :

Example 1 with RestrictedSince

use of hudson.RestrictedSince in project jenkins by jenkinsci.

the class ReverseProxySetupMonitor method doTest.

// WebOnly
@Restricted(DoNotUse.class)
@RestrictedSince("2.235")
public HttpResponse doTest(StaplerRequest request, @QueryParameter boolean testWithContext) {
    String referer = request.getReferer();
    Jenkins j = Jenkins.get();
    String redirect;
    // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all.
    if (testWithContext) {
        // Some of the possible values: "/jenkins" or ""
        String contextPath = request.getServletContext().getContextPath();
        if (contextPath.startsWith("/")) {
            // getRootUrl's contract is to end with /, we need to ensure the contextPath is not starting with one
            // and as only the empty string does not contain a leading slash, we have to also add one at the end
            contextPath = contextPath.substring(1) + "/";
        }
        redirect = j.getRootUrl() + contextPath + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
    } else {
        redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/";
    }
    LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] { referer, redirect });
    return new HttpRedirect(redirect);
}
Also used : Jenkins(jenkins.model.Jenkins) HttpRedirect(org.kohsuke.stapler.HttpRedirect) Restricted(org.kohsuke.accmod.Restricted) RestrictedSince(hudson.RestrictedSince)

Example 2 with RestrictedSince

use of hudson.RestrictedSince in project bitbucket-branch-source-plugin by jenkinsci.

the class BitbucketSCMSource method setBitbucketServerUrl.

@Deprecated
@Restricted(NoExternalUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBitbucketServerUrl(String url) {
    url = BitbucketEndpointConfiguration.normalizeServerUrl(url);
    AbstractBitbucketEndpoint endpoint = BitbucketEndpointConfiguration.get().findEndpoint(url);
    if (endpoint != null) {
        // we have a match
        setServerUrl(endpoint.getServerUrl());
        return;
    }
    LOGGER.log(Level.WARNING, "Call to legacy setBitbucketServerUrl({0}) method is configuring a url missing " + "from the global configuration.", url);
    setServerUrl(url);
}
Also used : AbstractBitbucketEndpoint(com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint) Restricted(org.kohsuke.accmod.Restricted) RestrictedSince(hudson.RestrictedSince) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Example 3 with RestrictedSince

use of hudson.RestrictedSince in project bitbucket-branch-source-plugin by jenkinsci.

the class BitbucketSCMNavigator method setBitbucketServerUrl.

@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBitbucketServerUrl(String url) {
    url = BitbucketEndpointConfiguration.normalizeServerUrl(url);
    AbstractBitbucketEndpoint endpoint = BitbucketEndpointConfiguration.get().findEndpoint(url);
    if (endpoint != null) {
        // we have a match
        setServerUrl(url);
        return;
    }
    LOGGER.log(Level.WARNING, "Call to legacy setBitbucketServerUrl({0}) method is configuring a url missing " + "from the global configuration.", url);
    setServerUrl(url);
}
Also used : AbstractBitbucketEndpoint(com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint) Restricted(org.kohsuke.accmod.Restricted) RestrictedSince(hudson.RestrictedSince) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Example 4 with RestrictedSince

use of hudson.RestrictedSince in project jenkins by jenkinsci.

the class ReverseProxySetupMonitor method getTestForReverseProxySetup.

// WebOnly
@Restricted(DoNotUse.class)
@RestrictedSince("2.235")
@StaplerDispatchable
public void getTestForReverseProxySetup(String rest) {
    Jenkins j = Jenkins.get();
    String inferred = j.getRootUrlFromRequest() + "manage";
    // TODO this could also verify that j.getRootUrl() has been properly configured, and send a different message if not
    if (rest.startsWith(inferred)) {
        // not using equals due to JENKINS-24014
        throw HttpResponses.ok();
    } else {
        LOGGER.log(Level.WARNING, "{0} vs. {1}", new Object[] { inferred, rest });
        throw HttpResponses.errorWithoutStack(404, inferred + " vs. " + rest);
    }
}
Also used : Jenkins(jenkins.model.Jenkins) Restricted(org.kohsuke.accmod.Restricted) RestrictedSince(hudson.RestrictedSince) StaplerDispatchable(jenkins.security.stapler.StaplerDispatchable)

Aggregations

RestrictedSince (hudson.RestrictedSince)4 Restricted (org.kohsuke.accmod.Restricted)4 AbstractBitbucketEndpoint (com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint)2 Jenkins (jenkins.model.Jenkins)2 DataBoundSetter (org.kohsuke.stapler.DataBoundSetter)2 StaplerDispatchable (jenkins.security.stapler.StaplerDispatchable)1 HttpRedirect (org.kohsuke.stapler.HttpRedirect)1