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.service;
019
020import java.util.List;
021import java.util.Set;
022
023import org.mitre.oauth2.model.ClientDetailsEntity;
024import org.mitre.oauth2.model.OAuth2AccessTokenEntity;
025import org.mitre.oauth2.model.OAuth2RefreshTokenEntity;
026import org.springframework.security.oauth2.provider.OAuth2Authentication;
027import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
028import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
029
030public interface OAuth2TokenEntityService extends AuthorizationServerTokenServices, ResourceServerTokenServices {
031
032        @Override
033        public OAuth2AccessTokenEntity readAccessToken(String accessTokenValue);
034
035        public OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue);
036
037        public void revokeRefreshToken(OAuth2RefreshTokenEntity refreshToken);
038
039        public void revokeAccessToken(OAuth2AccessTokenEntity accessToken);
040
041        public List<OAuth2AccessTokenEntity> getAccessTokensForClient(ClientDetailsEntity client);
042
043        public List<OAuth2RefreshTokenEntity> getRefreshTokensForClient(ClientDetailsEntity client);
044
045        public void clearExpiredTokens();
046
047        public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity accessToken);
048
049        public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken);
050
051        @Override
052        public OAuth2AccessTokenEntity getAccessToken(OAuth2Authentication authentication);
053
054        public OAuth2AccessTokenEntity getAccessTokenById(Long id);
055
056        public OAuth2RefreshTokenEntity getRefreshTokenById(Long id);
057
058        public Set<OAuth2AccessTokenEntity> getAllAccessTokensForUser(String name);
059
060        public Set<OAuth2RefreshTokenEntity> getAllRefreshTokensForUser(String name);
061
062        public OAuth2AccessTokenEntity getRegistrationAccessTokenForClient(ClientDetailsEntity client);
063}