forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccessDeniedException2.java
More file actions
59 lines (50 loc) · 2.04 KB
/
AccessDeniedException2.java
File metadata and controls
59 lines (50 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package hudson.security;
import io.jenkins.servlet.http.HttpServletResponseWrapper;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.acegisecurity.AccessDeniedException;
import org.acegisecurity.Authentication;
/**
* {@link AccessDeniedException} with more information.
* @author Kohsuke Kawaguchi
* @deprecated use {@link AccessDeniedException3}
*/
@Deprecated
public class AccessDeniedException2 extends AccessDeniedException {
/**
* This object represents the user being authenticated.
*/
public final Authentication authentication;
/**
* This object represents the permission that the user needed.
*/
public final Permission permission;
public AccessDeniedException2(Authentication authentication, Permission permission) {
this(null, authentication, permission);
}
public AccessDeniedException2(Throwable t, Authentication authentication, Permission permission) {
super(Messages.AccessDeniedException2_MissingPermission(authentication.getName(),
permission.group.title + "/" + permission.name), t);
this.authentication = authentication;
this.permission = permission;
}
/**
* Reports the details of the access failure in HTTP headers to assist diagnosis.
*/
public void reportAsHeaders(HttpServletResponse rsp) {
toSpring().reportAsHeaders(HttpServletResponseWrapper.toJakartaHttpServletResponse(rsp));
}
/**
* Reports the details of the access failure.
* This method is similar to {@link #reportAsHeaders(HttpServletResponse)} for the intention
* but instead of using HTTP headers, this version is meant to go inside the payload.
*/
public void report(PrintWriter w) {
toSpring().report(w);
}
@Override
public AccessDeniedException3 toSpring() {
Throwable t = getCause();
return t != null ? new AccessDeniedException3(t, authentication.toSpring(), permission) : new AccessDeniedException3(authentication.toSpring(), permission);
}
}