1 /*
2 * Copyright 2002-2011 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.springframework.security.oauth2.client.resource;
17
18 import java.util.List;
19 import java.util.Map;
20
21 /**
22 * Exception indicating that user approval is required, with some indication of how to signal the approval.
23 *
24 * @author Dave Syer
25 *
26 */
27 @SuppressWarnings("serial")
28 public class UserApprovalRequiredException extends RuntimeException {
29
30 private final String approvalUri;
31
32 private final Map<String, String> parameters;
33
34 private final String clientId;
35
36 private final List<String> scope;
37
38 public UserApprovalRequiredException(String approvalUri, Map<String, String> parameters, String clientId, List<String> scope) {
39 this.approvalUri = approvalUri;
40 this.parameters = parameters;
41 this.clientId = clientId;
42 this.scope = scope;
43 }
44
45 /**
46 * @return the approvalUri the uri to which the user should submit for approval
47 */
48 public String getApprovalUri() {
49 return approvalUri;
50 }
51
52 /**
53 * Description of the parameters required to be submitted for approval. Map from the name of the parameter to its
54 * description.
55 *
56 * @return the parameters the parameters required for approval
57 */
58 public Map<String, String> getParameters() {
59 return parameters;
60 }
61
62 /**
63 * @return the clientId the client that is requesting approval
64 */
65 public String getClientId() {
66 return clientId;
67 }
68
69 /**
70 * @return the scope the scope that has been requested for the token grant
71 */
72 public List<String> getScope() {
73 return scope;
74 }
75
76 }