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.common; 14 15 import java.util.Date; 16 import java.util.Map; 17 import java.util.Set; 18 19 /** 20 * @author Dave Syer 21 * 22 */ 23 @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = OAuth2AccessTokenJackson2Serializer.class) 24 @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = OAuth2AccessTokenJackson2Deserializer.class) 25 public interface OAuth2AccessToken { 26 27 public static String BEARER_TYPE = "Bearer"; 28 29 public static String OAUTH2_TYPE = "OAuth2"; 30 31 /** 32 * The access token issued by the authorization server. This value is REQUIRED. 33 */ 34 public static String ACCESS_TOKEN = "access_token"; 35 36 /** 37 * The type of the token issued as described in <a 38 * href="https://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-7.1">Section 7.1</a>. Value is case insensitive. 39 * This value is REQUIRED. 40 */ 41 public static String TOKEN_TYPE = "token_type"; 42 43 /** 44 * The lifetime in seconds of the access token. For example, the value "3600" denotes that the access token will 45 * expire in one hour from the time the response was generated. This value is OPTIONAL. 46 */ 47 public static String EXPIRES_IN = "expires_in"; 48 49 /** 50 * The refresh token which can be used to obtain new access tokens using the same authorization grant as described 51 * in <a href="https://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-6">Section 6</a>. This value is OPTIONAL. 52 */ 53 public static String REFRESH_TOKEN = "refresh_token"; 54 55 /** 56 * The scope of the access token as described by <a 57 * href="https://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.3">Section 3.3</a> 58 */ 59 public static String SCOPE = "scope"; 60 61 /** 62 * The additionalInformation map is used by the token serializers to export any fields used by extensions of OAuth. 63 * @return a map from the field name in the serialized token to the value to be exported. The default serializers 64 * make use of Jackson's automatic JSON mapping for Java objects (for the Token Endpoint flows) or implicitly call 65 * .toString() on the "value" object (for the implicit flow) as part of the serialization process. 66 */ 67 Map<String, Object> getAdditionalInformation(); 68 69 Set<String> getScope(); 70 71 OAuth2RefreshToken getRefreshToken(); 72 73 String getTokenType(); 74 75 boolean isExpired(); 76 77 Date getExpiration(); 78 79 int getExpiresIn(); 80 81 String getValue(); 82 83 }