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.Collection;
021
022import org.mitre.data.PageCriteria;
023import org.mitre.oauth2.model.AuthorizationCodeEntity;
024
025/**
026 * Interface for saving and consuming OAuth2 authorization codes as AuthorizationCodeEntitys.
027 *
028 * @author aanganes
029 *
030 */
031public interface AuthorizationCodeRepository {
032
033        /**
034         * Save an AuthorizationCodeEntity to the repository
035         *
036         * @param authorizationCode the AuthorizationCodeEntity to save
037         * @return                                      the saved AuthorizationCodeEntity
038         */
039        public AuthorizationCodeEntity save(AuthorizationCodeEntity authorizationCode);
040
041        /**
042         * Get an authorization code from the repository by value.
043         *
044         * @param code                                          the authorization code value
045         * @return                                                      the authentication associated with the code
046         */
047        public AuthorizationCodeEntity getByCode(String code);
048
049        /**
050         * Remove an authorization code from the repository
051         *
052         * @param authorizationCodeEntity
053         */
054        public void remove(AuthorizationCodeEntity authorizationCodeEntity);
055
056        /**
057         * @return A collection of all expired codes.
058         */
059        public Collection<AuthorizationCodeEntity> getExpiredCodes();
060
061        /**
062         * @return A collection of all expired codes, limited by the given
063         * PageCriteria.
064         */
065        public Collection<AuthorizationCodeEntity> getExpiredCodes(PageCriteria pageCriteria);
066
067}