001/******************************************************************************* 002 * Copyright 2017 The MIT Internet Trust Consortium 003 * 004 * Portions copyright 2011-2013 The MITRE Corporation 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 *******************************************************************************/ 018package org.mitre.oauth2.repository; 019 020import java.util.List; 021import java.util.Set; 022 023import org.mitre.data.PageCriteria; 024import org.mitre.oauth2.model.ClientDetailsEntity; 025import org.mitre.oauth2.model.OAuth2AccessTokenEntity; 026import org.mitre.oauth2.model.OAuth2RefreshTokenEntity; 027import org.mitre.openid.connect.model.ApprovedSite; 028import org.mitre.uma.model.ResourceSet; 029 030public interface OAuth2TokenRepository { 031 032 public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity token); 033 034 public OAuth2RefreshTokenEntity getRefreshTokenByValue(String refreshTokenValue); 035 036 public OAuth2RefreshTokenEntity getRefreshTokenById(Long Id); 037 038 public void clearAccessTokensForRefreshToken(OAuth2RefreshTokenEntity refreshToken); 039 040 public void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken); 041 042 public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken); 043 044 public OAuth2AccessTokenEntity getAccessTokenByValue(String accessTokenValue); 045 046 public OAuth2AccessTokenEntity getAccessTokenById(Long id); 047 048 public void removeAccessToken(OAuth2AccessTokenEntity accessToken); 049 050 public void clearTokensForClient(ClientDetailsEntity client); 051 052 public List<OAuth2AccessTokenEntity> getAccessTokensForClient(ClientDetailsEntity client); 053 054 public List<OAuth2RefreshTokenEntity> getRefreshTokensForClient(ClientDetailsEntity client); 055 056 public Set<OAuth2AccessTokenEntity> getAllAccessTokens(); 057 058 public Set<OAuth2RefreshTokenEntity> getAllRefreshTokens(); 059 060 public Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens(); 061 062 public Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens(PageCriteria pageCriteria); 063 064 public Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens(); 065 066 public Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens(PageCriteria pageCriteria); 067 068 public Set<OAuth2AccessTokenEntity> getAccessTokensForResourceSet(ResourceSet rs); 069 070 /** 071 * removes duplicate access tokens. 072 * 073 * @deprecated this method was added to return the remove duplicate access tokens values 074 * so that {code removeAccessToken(OAuth2AccessTokenEntity o)} would not to fail. the 075 * removeAccessToken method has been updated so as it will not fail in the event that an 076 * accessToken has been duplicated, so this method is unnecessary. 077 * 078 */ 079 @Deprecated 080 public void clearDuplicateAccessTokens(); 081 082 /** 083 * removes duplicate refresh tokens. 084 * 085 * @deprecated this method was added to return the remove duplicate refresh token value 086 * so that {code removeRefreshToken(OAuth2RefreshTokenEntity o)} would not to fail. the 087 * removeRefreshToken method has been updated so as it will not fail in the event that 088 * refreshToken has been duplicated, so this method is unnecessary. 089 * 090 */ 091 @Deprecated 092 public void clearDuplicateRefreshTokens(); 093 094 public List<OAuth2AccessTokenEntity> getAccessTokensForApprovedSite(ApprovedSite approvedSite); 095 096}