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.repository;
018
019import java.util.Collection;
020
021import org.mitre.uma.model.Permission;
022import org.mitre.uma.model.PermissionTicket;
023import org.mitre.uma.model.ResourceSet;
024
025/**
026 * @author jricher
027 *
028 */
029public interface PermissionRepository {
030
031        /**
032         *
033         * Save a permission ticket.
034         *
035         * @param p
036         * @return
037         */
038        public PermissionTicket save(PermissionTicket p);
039
040        /**
041         * Get the permission indicated by its ticket value.
042         *
043         * @param ticket
044         * @return
045         */
046        public PermissionTicket getByTicket(String ticket);
047
048        /**
049         * Get all the tickets in the system (used by the import/export API)
050         *
051         * @return
052         */
053        public Collection<PermissionTicket> getAll();
054
055        /**
056         * Save a permission object with no associated ticket (used by the import/export API)
057         *
058         * @param p
059         * @return
060         */
061        public Permission saveRawPermission(Permission p);
062
063        /**
064         * Get a permission object by its ID (used by the import/export API)
065         *
066         * @param permissionId
067         * @return
068         */
069        public Permission getById(Long permissionId);
070
071        /**
072         * Get all permission tickets issued against a resource set (called when RS is deleted)
073         *
074         * @param rs
075         * @return
076         */
077        public Collection<PermissionTicket> getPermissionTicketsForResourceSet(ResourceSet rs);
078
079        /**
080         * Remove the specified ticket.
081         *
082         * @param ticket
083         */
084        public void remove(PermissionTicket ticket);
085
086}