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.repository;
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;
026
027public interface OAuth2TokenRepository {
028
029        public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity token);
030
031        public OAuth2RefreshTokenEntity getRefreshTokenByValue(String refreshTokenValue);
032
033        public OAuth2RefreshTokenEntity getRefreshTokenById(Long Id);
034
035        public void clearAccessTokensForRefreshToken(OAuth2RefreshTokenEntity refreshToken);
036
037        public void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken);
038
039        public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken);
040
041        public OAuth2AccessTokenEntity getAccessTokenByValue(String accessTokenValue);
042
043        public OAuth2AccessTokenEntity getAccessTokenById(Long id);
044
045        public void removeAccessToken(OAuth2AccessTokenEntity accessToken);
046
047        public void clearTokensForClient(ClientDetailsEntity client);
048
049        public List<OAuth2AccessTokenEntity> getAccessTokensForClient(ClientDetailsEntity client);
050
051        public List<OAuth2RefreshTokenEntity> getRefreshTokensForClient(ClientDetailsEntity client);
052
053        public OAuth2AccessTokenEntity getByAuthentication(OAuth2Authentication auth);
054
055        public OAuth2AccessTokenEntity getAccessTokenForIdToken(OAuth2AccessTokenEntity idToken);
056
057        public Set<OAuth2AccessTokenEntity> getAllAccessTokens();
058
059        public Set<OAuth2RefreshTokenEntity> getAllRefreshTokens();
060
061        public Set<OAuth2AccessTokenEntity> getAllExpiredAccessTokens();
062
063        public Set<OAuth2RefreshTokenEntity> getAllExpiredRefreshTokens();
064
065}