mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-03 15:15:54 +00:00
Merge branch 'security-stable-2.138' into security-stable-2.150
This commit is contained in:
commit
85cc922e85
25 files changed
+2105
-24
No files matched your search
@@ -94,6 +94,8 @@ import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
/**
|
||||
* Various utility methods that don't have more proper home.
|
||||
@@ -1729,6 +1731,19 @@ public class Util {
|
||||
return Math.max(0, daysBetween(date, new Date()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the specific ancestor, or throw an exception.
|
||||
* Useful for an ancestor we know is inside the URL to ease readability
|
||||
*/
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static @Nonnull <T> T getNearestAncestorOfTypeOrThrow(@Nonnull StaplerRequest request, @Nonnull Class<T> clazz) {
|
||||
T t = request.findAncestorObject(clazz);
|
||||
if (t == null) {
|
||||
throw new IllegalArgumentException("No ancestor of type " + clazz.getName() + " in the request");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static final FastDateFormat XS_DATETIME_FORMATTER = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss'Z'",new SimpleTimeZone(0,"GMT"));
|
||||
|
||||
// Note: RFC822 dates must not be localized!
|
||||
|
||||
Reference in new issue
Block a user