More informative error when refusing to copy.

This commit is contained in:
Jesse Glick committed 2016-04-29 08:18:13 -04:00
1 parent 3d65593818
commit aeefa6eb99
2 files changed
+4 -3

No files matched your search

@@ -27,7 +27,6 @@ import hudson.Util;
import hudson.XmlFile;
import hudson.model.listeners.ItemListener;
import hudson.security.AccessControlled;
import hudson.security.AccessDeniedException2;
import hudson.util.CopyOnWriteMap;
import hudson.util.Function1;
import hudson.util.Secret;
@@ -51,6 +50,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import jenkins.security.NotReallyRoleSensitiveCallable;
import org.acegisecurity.AccessDeniedException;
import org.xml.sax.SAXException;
/**
@@ -229,7 +229,8 @@ public abstract class ItemGroupMixIn {
Matcher matcher = AbstractItem.SECRET_PATTERN.matcher(srcConfigFile.asString());
while (matcher.find()) {
if (Secret.decrypt(matcher.group(1)) != null) {
throw new AccessDeniedException2(Jenkins.getAuthentication(), Item.CONFIGURE);
// AccessDeniedException2 does not permit a custom message, and anyway redirecting the user to the login screen is obviously pointless.
throw new AccessDeniedException(Messages.ItemGroupMixIn_may_not_copy_as_it_contains_secrets_and_(src.getFullName(), Jenkins.getAuthentication().getName(), Item.PERMISSIONS.title, Item.EXTENDED_READ.name, Item.CONFIGURE.name));
}
}
}
@@ -175,7 +175,7 @@ Item.CREATE.description=Create a new job.
Item.DELETE.description=Delete a job.
Item.CONFIGURE.description=Change the configuration of a job.
Item.READ.description=See a job. (You may deny this permission but allow Discover to force an anonymous user to log in to see the job.)
ItemGroupMixIn.may_not_copy_as_it_contains_secrets_and_=May not copy {0} as it contains secrets and {1} has {2}/{3} but not /{4}
Job.AllRecentBuildFailed=All recent builds failed.
Job.BuildStability=Build stability: {0}
Job.NOfMFailed={0} out of the last {1} builds failed.