Skip to content

Commit

Permalink
https://github.com/jenkinsci/jenkins/pull/9672#discussion_r1742082679
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Sep 3, 2024
1 parent de29558 commit 10f333f
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions core/src/main/java/hudson/util/FormFieldValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import hudson.model.Item;
import hudson.security.AccessControlled;
import hudson.security.Permission;
import jakarta.servlet.ServletException;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
Expand All @@ -44,10 +43,11 @@
import java.net.URL;
import java.net.URLConnection;
import java.util.Locale;
import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.springframework.security.access.AccessDeniedException;

/**
Expand All @@ -65,8 +65,8 @@
public abstract class FormFieldValidator {
public static final Permission CHECK = Jenkins.ADMINISTER;

protected final StaplerRequest2 request;
protected final StaplerResponse2 response;
protected final StaplerRequest request;
protected final StaplerResponse response;
/**
* Permission to check, or null if this check doesn't require any permission.
*/
Expand All @@ -84,17 +84,17 @@ public abstract class FormFieldValidator {
* for security reason, so that unauthenticated user cannot obtain sensitive
* information or run a process that may have side-effect.
*/
protected FormFieldValidator(StaplerRequest2 request, StaplerResponse2 response, boolean adminOnly) {
protected FormFieldValidator(StaplerRequest request, StaplerResponse response, boolean adminOnly) {
this(request, response, adminOnly ? Jenkins.get() : null, adminOnly ? CHECK : null);
}

/**
* @deprecated
* Use {@link #FormFieldValidator(Permission)} and remove {@link StaplerRequest2} and {@link StaplerResponse2}
* Use {@link #FormFieldValidator(Permission)} and remove {@link StaplerRequest} and {@link StaplerResponse}
* from your "doCheck..." method parameter
*/
@Deprecated
protected FormFieldValidator(StaplerRequest2 request, StaplerResponse2 response, Permission permission) {
protected FormFieldValidator(StaplerRequest request, StaplerResponse response, Permission permission) {
this(request, response, Jenkins.get(), permission);
}

Expand All @@ -103,24 +103,24 @@ protected FormFieldValidator(StaplerRequest2 request, StaplerResponse2 response,
* Permission needed to perform this validation, or null if no permission is necessary.
*/
protected FormFieldValidator(Permission permission) {
this(Stapler.getCurrentRequest2(), Stapler.getCurrentResponse2(), permission);
this(Stapler.getCurrentRequest(), Stapler.getCurrentResponse(), permission);
}

/**
* @deprecated
* Use {@link #FormFieldValidator(AccessControlled,Permission)} and remove {@link StaplerRequest2} and {@link StaplerResponse2}
* Use {@link #FormFieldValidator(AccessControlled,Permission)} and remove {@link StaplerRequest} and {@link StaplerResponse}
* from your "doCheck..." method parameter
*/
@Deprecated
protected FormFieldValidator(StaplerRequest2 request, StaplerResponse2 response, AccessControlled subject, Permission permission) {
protected FormFieldValidator(StaplerRequest request, StaplerResponse response, AccessControlled subject, Permission permission) {
this.request = request;
this.response = response;
this.subject = subject;
this.permission = permission;
}

protected FormFieldValidator(AccessControlled subject, Permission permission) {
this(Stapler.getCurrentRequest2(), Stapler.getCurrentResponse2(), subject, permission);
this(Stapler.getCurrentRequest(), Stapler.getCurrentResponse(), subject, permission);
}

/**
Expand Down Expand Up @@ -249,7 +249,7 @@ private void _errorWithMarkup(String message, String cssClass) throws IOExceptio
@Deprecated
public abstract static class URLCheck extends FormFieldValidator {

protected URLCheck(StaplerRequest2 request, StaplerResponse2 response) {
protected URLCheck(StaplerRequest request, StaplerResponse response) {
// can be used to check the existence of any file in file system
// or other HTTP URLs inside firewall, so limit this to the admin.
super(request, response, true);
Expand Down Expand Up @@ -320,7 +320,7 @@ private String getCharset(URLConnection con) {
* @since 1.192
*/
public static class HudsonURL extends URLCheck {
public HudsonURL(StaplerRequest2 request, StaplerResponse2 response) {
public HudsonURL(StaplerRequest request, StaplerResponse response) {
super(request, response);
}

Expand Down Expand Up @@ -366,11 +366,11 @@ private HttpURLConnection openConnection(URL url) throws IOException {
public static class WorkspaceFileMask extends FormFieldValidator {
private final boolean errorIfNotExist;

public WorkspaceFileMask(StaplerRequest2 request, StaplerResponse2 response) {
public WorkspaceFileMask(StaplerRequest request, StaplerResponse response) {
this(request, response, true);
}

public WorkspaceFileMask(StaplerRequest2 request, StaplerResponse2 response, boolean errorIfNotExist) {
public WorkspaceFileMask(StaplerRequest request, StaplerResponse response, boolean errorIfNotExist) {
// Require CONFIGURE permission on the job
super(request, response, request.findAncestorObject(AbstractProject.class), Item.CONFIGURE);
this.errorIfNotExist = errorIfNotExist;
Expand Down Expand Up @@ -419,11 +419,11 @@ protected FilePath getBaseDirectory(AbstractProject<?, ?> p) {
*/
@Deprecated
public static class WorkspaceDirectory extends WorkspaceFilePath {
public WorkspaceDirectory(StaplerRequest2 request, StaplerResponse2 response, boolean errorIfNotExist) {
public WorkspaceDirectory(StaplerRequest request, StaplerResponse response, boolean errorIfNotExist) {
super(request, response, errorIfNotExist, false);
}

public WorkspaceDirectory(StaplerRequest2 request, StaplerResponse2 response) {
public WorkspaceDirectory(StaplerRequest request, StaplerResponse response) {
this(request, response, true);
}
}
Expand All @@ -439,7 +439,7 @@ public static class WorkspaceFilePath extends FormFieldValidator {
private final boolean errorIfNotExist;
private final boolean expectingFile;

public WorkspaceFilePath(StaplerRequest2 request, StaplerResponse2 response, boolean errorIfNotExist, boolean expectingFile) {
public WorkspaceFilePath(StaplerRequest request, StaplerResponse response, boolean errorIfNotExist, boolean expectingFile) {
// Require CONFIGURE permission on this job
super(request, response, request.findAncestorObject(AbstractProject.class), Item.CONFIGURE);
this.errorIfNotExist = errorIfNotExist;
Expand Down Expand Up @@ -522,7 +522,7 @@ protected FilePath getBaseDirectory(AbstractProject<?, ?> p) {
@Deprecated
public static class Executable extends FormFieldValidator {

public Executable(StaplerRequest2 request, StaplerResponse2 response) {
public Executable(StaplerRequest request, StaplerResponse response) {
// Require admin permission
super(request, response, true);
}
Expand Down Expand Up @@ -599,7 +599,7 @@ public static class Base64 extends FormFieldValidator {
private final boolean allowEmpty;
private final String errorMessage;

public Base64(StaplerRequest2 request, StaplerResponse2 response, boolean allowWhitespace, boolean allowEmpty, String errorMessage) {
public Base64(StaplerRequest request, StaplerResponse response, boolean allowWhitespace, boolean allowEmpty, String errorMessage) {
super(request, response, false);
this.allowWhitespace = allowWhitespace;
this.allowEmpty = allowEmpty;
Expand Down

0 comments on commit 10f333f

Please sign in to comment.