001/**
002 *
003 * Copyright 2018 Paul Schaub.
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.jivesoftware.smackx.ox.store.definition;
018
019import java.io.IOException;
020
021import org.jxmpp.jid.BareJid;
022import org.pgpainless.key.OpenPgpV4Fingerprint;
023
024public interface OpenPgpTrustStore {
025
026    /**
027     * Return the {@link Trust} state of {@code owner}s key with fingerprint {@code fingerprint}.
028     * The trust state describes, whether the user trusts a certain key of a contact.
029     * If no {@link Trust} record has been found, this method MUST return not null, nut {@link Trust#undecided}.
030     *
031     * @param owner owner of the key
032     * @param fingerprint fingerprint of the key
033     * @return trust state
034     *
035     * @throws IOException IO is dangerous
036     */
037    Trust getTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException;
038
039    /**
040     * Store the {@link Trust} state of {@code owner}s key with fingerprint {@code fingerprint}.
041     *
042     * @param owner owner of the key
043     * @param fingerprint fingerprint of the key
044     * @param trust trust record
045     *
046     * @throws IOException IO is dangerous
047     */
048    void setTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint, Trust trust) throws IOException;
049
050    enum Trust {
051        /**
052         * The user explicitly trusts the key.
053         */
054        trusted,
055        /**
056         * The user explicitly distrusts the key.
057         */
058        untrusted,
059        /**
060         * The user didn't yet describe, whether to trust the key or not.
061         */
062        undecided
063    }
064}