OpenPgpTrustStore.java

  1. /**
  2.  *
  3.  * Copyright 2018 Paul Schaub.
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.ox.store.definition;

  18. import java.io.IOException;

  19. import org.jxmpp.jid.BareJid;
  20. import org.pgpainless.key.OpenPgpV4Fingerprint;

  21. public interface OpenPgpTrustStore {

  22.     /**
  23.      * Return the {@link Trust} state of {@code owner}s key with fingerprint {@code fingerprint}.
  24.      * The trust state describes, whether the user trusts a certain key of a contact.
  25.      * If no {@link Trust} record has been found, this method MUST return not null, nut {@link Trust#undecided}.
  26.      *
  27.      * @param owner owner of the key
  28.      * @param fingerprint fingerprint of the key
  29.      * @return trust state
  30.      *
  31.      * @throws IOException IO is dangerous
  32.      */
  33.     Trust getTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException;

  34.     /**
  35.      * Store the {@link Trust} state of {@code owner}s key with fingerprint {@code fingerprint}.
  36.      *
  37.      * @param owner owner of the key
  38.      * @param fingerprint fingerprint of the key
  39.      * @param trust trust record
  40.      *
  41.      * @throws IOException IO is dangerous
  42.      */
  43.     void setTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint, Trust trust) throws IOException;

  44.     enum Trust {
  45.         /**
  46.          * The user explicitly trusts the key.
  47.          */
  48.         trusted,
  49.         /**
  50.          * The user explicitly distrusts the key.
  51.          */
  52.         untrusted,
  53.         /**
  54.          * The user didn't yet describe, whether to trust the key or not.
  55.          */
  56.         undecided
  57.     }
  58. }