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
14
15 package org.springframework.security.oauth2.client.token;
16
17 import org.springframework.security.core.Authentication;
18 import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
19 import org.springframework.security.oauth2.common.OAuth2AccessToken;
20
21 /**
22 * @author Dave Syer
23 *
24 */
25 public interface ClientTokenServices {
26
27 /**
28 * Retrieve the access token for a given resource and user authentication (my be null).
29 *
30 * @param resource the resource to be accessed
31 * @param authentication the current user authentication (or null if there is none)
32 * @return an access token if one has been stored, null otherwise
33 */
34 OAuth2AccessToken getAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication);
35
36 /**
37 * Save or update the access token for this resource and authentication (may be null).
38 *
39 * @param resource the resource to be accessed
40 * @param authentication the current user authentication (or null if there is none)
41 * @param accessToken an access token to be stored
42 */
43 void saveAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication,
44 OAuth2AccessToken accessToken);
45
46 /**
47 * Remove the token (if any) that is stored with the provided resource and authentication. If there is no such token
48 * do nothing.
49 *
50 * @param resource the resource to be accessed
51 * @param authentication the current user authentication (or null if there is none)
52 */
53 void removeAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication);
54
55 }