001/******************************************************************************* 002 * Copyright 2017 The MIT Internet Trust Consortium 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 *******************************************************************************/ 016package org.mitre.oauth2.service; 017 018import java.text.SimpleDateFormat; 019import java.util.Map; 020import java.util.Set; 021 022import javax.swing.text.DateFormatter; 023 024import org.mitre.oauth2.model.OAuth2AccessTokenEntity; 025import org.mitre.oauth2.model.OAuth2RefreshTokenEntity; 026import org.mitre.openid.connect.model.UserInfo; 027 028/** 029 * Strategy interface for assembling a token introspection result. 030 */ 031public interface IntrospectionResultAssembler { 032 033 public String TOKEN_TYPE = "token_type"; 034 public String CLIENT_ID = "client_id"; 035 public String USER_ID = "user_id"; 036 public String SUB = "sub"; 037 public String EXP = "exp"; 038 public String EXPIRES_AT = "expires_at"; 039 public String SCOPE_SEPARATOR = " "; 040 public String SCOPE = "scope"; 041 public String ACTIVE = "active"; 042 public DateFormatter dateFormat = new DateFormatter(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")); 043 044 /** 045 * Assemble a token introspection result from the given access token and user info. 046 * 047 * @param accessToken the access token 048 * @param userInfo the user info 049 * @param authScopes the scopes the client is authorized for 050 * @return the token introspection result 051 */ 052 Map<String, Object> assembleFrom(OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set<String> authScopes); 053 054 /** 055 * Assemble a token introspection result from the given refresh token and user info. 056 * 057 * @param refreshToken the refresh token 058 * @param userInfo the user info 059 * @param authScopes the scopes the client is authorized for 060 * @return the token introspection result 061 */ 062 Map<String, Object> assembleFrom(OAuth2RefreshTokenEntity refreshToken, UserInfo userInfo, Set<String> authScopes); 063 064}