001/******************************************************************************* 002 * Copyright 2014 The MITRE Corporation 003 * and the MIT Kerberos and Internet Trust Consortium 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 ******************************************************************************/ 017package org.mitre.oauth2.service; 018 019import java.util.List; 020import java.util.Set; 021 022import org.mitre.oauth2.model.ClientDetailsEntity; 023import org.mitre.oauth2.model.OAuth2AccessTokenEntity; 024import org.mitre.oauth2.model.OAuth2RefreshTokenEntity; 025import org.springframework.security.oauth2.provider.OAuth2Authentication; 026import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices; 027import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices; 028 029public interface OAuth2TokenEntityService extends AuthorizationServerTokenServices, ResourceServerTokenServices { 030 031 @Override 032 public OAuth2AccessTokenEntity readAccessToken(String accessTokenValue); 033 034 public OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue); 035 036 public void revokeRefreshToken(OAuth2RefreshTokenEntity refreshToken); 037 038 public void revokeAccessToken(OAuth2AccessTokenEntity accessToken); 039 040 public List<OAuth2AccessTokenEntity> getAccessTokensForClient(ClientDetailsEntity client); 041 042 public List<OAuth2RefreshTokenEntity> getRefreshTokensForClient(ClientDetailsEntity client); 043 044 public void clearExpiredTokens(); 045 046 public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity accessToken); 047 048 public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken); 049 050 @Override 051 public OAuth2AccessTokenEntity getAccessToken(OAuth2Authentication authentication); 052 053 /** 054 * @param incomingToken 055 * @return 056 */ 057 public OAuth2AccessTokenEntity getAccessTokenForIdToken(OAuth2AccessTokenEntity idToken); 058 059 public OAuth2AccessTokenEntity getAccessTokenById(Long id); 060 061 public OAuth2RefreshTokenEntity getRefreshTokenById(Long id); 062 063 public Set<OAuth2AccessTokenEntity> getAllAccessTokensForUser(String name); 064 065 public Set<OAuth2RefreshTokenEntity> getAllRefreshTokensForUser(String name); 066 067 public OAuth2AccessTokenEntity getRegistrationAccessTokenForClient(ClientDetailsEntity client); 068}