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.uma.service;
018
019import java.util.Set;
020
021import org.mitre.uma.model.PermissionTicket;
022import org.mitre.uma.model.ResourceSet;
023import org.springframework.security.oauth2.common.exceptions.InsufficientScopeException;
024
025
026/**
027 * @author jricher
028 *
029 */
030public interface PermissionService {
031
032        /**
033         * @param resourceSet the resource set to create the permission on
034         * @param scopes the set of scopes that this permission is for
035         * @return the created (and stored) permission object, with ticket
036         * @throws InsufficientScopeException if the scopes in scopes don't match those in resourceSet.getScopes
037         */
038        public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes);
039
040        /**
041         *
042         * Read the permission associated with the given ticket.
043         *
044         * @param the ticket value to search on
045         * @return the permission object, or null if none is found
046         */
047        public PermissionTicket getByTicket(String ticket);
048
049        /**
050         * Save the updated permission ticket to the database. Does not create a new ticket.
051         *
052         * @param ticket
053         * @return
054         */
055        public PermissionTicket updateTicket(PermissionTicket ticket);
056
057}