1 package org.springframework.security.oauth2.client.resource;
2
3 import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
4
5
6
7
8
9
10
11
12 @SuppressWarnings("serial")
13 public class OAuth2AccessDeniedException extends OAuth2Exception {
14
15 private OAuth2ProtectedResourceDetails resource;
16
17 public OAuth2AccessDeniedException() {
18 super("OAuth2 access denied.");
19 }
20
21 public OAuth2AccessDeniedException(String msg) {
22 super(msg);
23 }
24
25 public OAuth2AccessDeniedException(OAuth2ProtectedResourceDetails resource) {
26 super("OAuth2 access denied.");
27 this.resource = resource;
28 }
29
30 public OAuth2AccessDeniedException(String msg, OAuth2ProtectedResourceDetails resource) {
31 super(msg);
32 this.resource = resource;
33 }
34
35 public OAuth2AccessDeniedException(String msg, OAuth2ProtectedResourceDetails resource, Throwable t) {
36 super(msg, t);
37 this.resource = resource;
38 }
39
40 public OAuth2ProtectedResourceDetails getResource() {
41 return resource;
42 }
43
44 public void setResource(OAuth2ProtectedResourceDetails resource) {
45 this.resource = resource;
46 }
47
48 @Override
49 public String getOAuth2ErrorCode() {
50 return "access_denied";
51 }
52
53 @Override
54 public int getHttpErrorCode() {
55 return 403;
56 }
57 }