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