View Javadoc
1   package org.springframework.security.oauth2.client.resource;
2   
3   import java.util.Map;
4   
5   /**
6    * Special exception thrown when a user redirect is required in order to obtain an OAuth2 access token.
7    * 
8    * @author Ryan Heaton
9    */
10  @SuppressWarnings("serial")
11  public class UserRedirectRequiredException extends RuntimeException {
12  
13  	private final String redirectUri;
14  
15  	private final Map<String, String> requestParams;
16  
17  	private String stateKey;
18  
19  	private Object stateToPreserve;
20  
21  	public UserRedirectRequiredException(String redirectUri, Map<String, String> requestParams) {
22  		super("A redirect is required to get the users approval");
23  		this.redirectUri = redirectUri;
24  		this.requestParams = requestParams;
25  	}
26  
27  	/**
28  	 * The uri to which the user is to be redirected.
29  	 * 
30  	 * @return The uri to which the user is to be redirected.
31  	 */
32  	public String getRedirectUri() {
33  		return redirectUri;
34  	}
35  
36  	/**
37  	 * The request parameters that are to be appended to the uri.
38  	 * 
39  	 * @return The request parameters that are to be appended to the uri.
40  	 */
41  	public Map<String, String> getRequestParams() {
42  		return requestParams;
43  	}
44  
45  	/**
46  	 * The key to the state to preserve.
47  	 * 
48  	 * @return The key to the state to preserve.
49  	 */
50  	public String getStateKey() {
51  		return stateKey;
52  	}
53  
54  	/**
55  	 * The key to the state to preserve.
56  	 * 
57  	 * @param stateKey The key to the state to preserve.
58  	 */
59  	public void setStateKey(String stateKey) {
60  		this.stateKey = stateKey;
61  	}
62  
63  	/**
64  	 * Some state that needs to be preserved and set up in the security context when the user returns.
65  	 * 
66  	 * @return The state that needs to be preserved.
67  	 */
68  	public Object getStateToPreserve() {
69  		return stateToPreserve;
70  	}
71  
72  	/**
73  	 * The state that needs to be preserved and set up in the security context when the user returns.
74  	 * 
75  	 * @param stateToPreserve The state.
76  	 */
77  	public void setStateToPreserve(Object stateToPreserve) {
78  		this.stateToPreserve = stateToPreserve;
79  	}
80  }