001/*******************************************************************************
002 * Copyright 2017 The MIT Internet Trust Consortium
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *   http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *******************************************************************************/
016
017package org.mitre.oauth2.service;
018
019import java.util.Map;
020import java.util.Set;
021
022import org.mitre.oauth2.exception.DeviceCodeCreationException;
023import org.mitre.oauth2.model.ClientDetailsEntity;
024import org.mitre.oauth2.model.DeviceCode;
025import org.springframework.security.oauth2.provider.ClientDetails;
026import org.springframework.security.oauth2.provider.OAuth2Authentication;
027
028/**
029 * @author jricher
030 *
031 */
032public interface DeviceCodeService {
033
034        /**
035         * @param userCode
036         * @return
037         */
038        public DeviceCode lookUpByUserCode(String userCode);
039
040        /**
041         * @param dc
042         * @param o2Auth
043         */
044        public DeviceCode approveDeviceCode(DeviceCode dc, OAuth2Authentication o2Auth);
045
046        /**
047         * @param deviceCode
048         * @param client
049         * @return
050         */
051        public DeviceCode findDeviceCode(String deviceCode, ClientDetails client);
052
053
054        /**
055         * 
056         * @param deviceCode
057         * @param client
058         */
059        public void clearDeviceCode(String deviceCode, ClientDetails client);
060        
061        /**
062         * @param deviceCode
063         * @param userCode
064         * @param requestedScopes
065         * @param client
066         * @param parameters
067         * @return
068         */
069        public DeviceCode createNewDeviceCode(Set<String> requestedScopes, ClientDetailsEntity client, Map<String, String> parameters) throws DeviceCodeCreationException;
070
071
072        public void clearExpiredDeviceCodes();
073}