/** * Copyright (C) 2015-2017 Regents of the University of California. * @author: Jeff Thompson <jefft0@remap.ucla.edu> * @author: From ndn-group-encrypt src/consumer-db https://github.com/named-data/ndn-group-encrypt * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * A copy of the GNU Lesser General Public License is in the file COPYING. */ package net.named_data.jndn.encrypt; import net.named_data.jndn.Name; import net.named_data.jndn.util.Blob; /** * ConsumerDb is an abstract base class the storage of decryption keys for the * consumer. A subclass must implement the methods. For example, see * Sqlite3ConsumerDb. * @note This class is an experimental feature. The API may change. */ public abstract class ConsumerDb { /** * ConsumerDb.Error extends Exception for errors using ConsumerDb methods. * Note that even though this is called "Error" to be consistent with the * other libraries, it extends the Java Exception class, not Error. */ public static class Error extends Exception { public Error(String message) { super(message); } } /** * Get the key with keyName from the database. * @param keyName The key name. * @return A Blob with the encoded key, or an isNull Blob if cannot find the * key with keyName. * @throws ConsumerDb.Error for a database error. */ public abstract Blob getKey(Name keyName) throws ConsumerDb.Error; /** * Add the key with keyName and keyBlob to the database. * @param keyName The key name. * @param keyBlob The encoded key. * @throws ConsumerDb.Error if a key with the same keyName already exists in * the database, or other database error. */ public abstract void addKey(Name keyName, Blob keyBlob) throws ConsumerDb.Error; /** * Delete the key with keyName from the database. If there is no key with * keyName, do nothing. * @param keyName The key name. * @throws ConsumerDb.Error for a database error. */ public abstract void deleteKey(Name keyName) throws ConsumerDb.Error; }