1 /*
2 * Copyright 2006-2011 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5 * the License. You may obtain a copy of the License at
6 *
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11 * specific language governing permissions and limitations under the License.
12 */
13 package org.springframework.security.oauth2.client;
14
15 import org.springframework.security.oauth2.client.token.AccessTokenRequest;
16 import org.springframework.security.oauth2.common.OAuth2AccessToken;
17
18 /**
19 * @author Dave Syer
20 *
21 */
22 public interface OAuth2ClientContext {
23
24 /**
25 * @return the current access token if any (may be null or empty)
26 */
27 OAuth2AccessToken getAccessToken();
28
29 /**
30 * @param accessToken the current access token
31 */
32 void setAccessToken(OAuth2AccessToken accessToken);
33
34 /**
35 * @return the current request if any (may be null or empty)
36 */
37 AccessTokenRequest getAccessTokenRequest();
38
39 /**
40 * Convenience method for saving state in the {@link OAuth2ClientContext}.
41 *
42 * @param stateKey the key to use to save the state
43 * @param preservedState the state to be saved
44 */
45 void setPreservedState(String stateKey, Object preservedState);
46
47 /**
48 * @param stateKey the state key to lookup
49 * @return the state preserved with this key (if any)
50 */
51 Object removePreservedState(String stateKey);
52
53 }