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.openid.connect.service;
019
020import java.util.Collection;
021import java.util.Date;
022import java.util.List;
023import java.util.Set;
024
025import org.mitre.oauth2.model.OAuth2AccessTokenEntity;
026import org.mitre.openid.connect.model.ApprovedSite;
027import org.springframework.security.oauth2.provider.ClientDetails;
028
029/**
030 * Interface for ApprovedSite service
031 *
032 * @author Michael Joseph Walsh, aanganes
033 *
034 */
035public interface ApprovedSiteService {
036
037
038        public ApprovedSite createApprovedSite(String clientId, String userId, Date timeoutDate, Set<String> allowedScopes);
039
040        /**
041         * Return a collection of all ApprovedSites
042         *
043         * @return the ApprovedSite collection, or null
044         */
045        public Collection<ApprovedSite> getAll();
046
047        /**
048         * Return a collection of ApprovedSite managed by this repository matching the
049         * provided client ID and user ID
050         *
051         * @param clientId
052         * @param userId
053         * @return
054         */
055        public Collection<ApprovedSite> getByClientIdAndUserId(String clientId, String userId);
056
057        /**
058         * Save an ApprovedSite
059         *
060         * @param approvedSite
061         *            the ApprovedSite to be saved
062         */
063        public ApprovedSite save(ApprovedSite approvedSite);
064
065        /**
066         * Get ApprovedSite for id
067         *
068         * @param id
069         *            id for ApprovedSite
070         * @return ApprovedSite for id, or null
071         */
072        public ApprovedSite getById(Long id);
073
074        /**
075         * Remove the ApprovedSite
076         *
077         * @param approvedSite
078         *            the ApprovedSite to remove
079         */
080        public void remove(ApprovedSite approvedSite);
081
082        /**
083         * Get all sites approved by this user
084         * @param userId
085         * @return
086         */
087        public Collection<ApprovedSite> getByUserId(String userId);
088
089        /**
090         * Get all sites associated with this client
091         * @param clientId
092         * @return
093         */
094        public Collection<ApprovedSite> getByClientId(String clientId);
095
096        /**
097         * Clear out any approved sites for a given client.
098         * @param client
099         */
100        public void clearApprovedSitesForClient(ClientDetails client);
101
102        /**
103         * Remove all expired approved sites fromt he data store.
104         * @return
105         */
106        public void clearExpiredSites();
107
108        /**
109         * Return all approved access tokens for the site.
110         * @return
111         */
112        public List<OAuth2AccessTokenEntity> getApprovedAccessTokens(ApprovedSite approvedSite);
113
114}