Codota Logo
OpenPgpV4Fingerprint
Code IndexAdd Codota to your IDE (free)

How to use
OpenPgpV4Fingerprint
in
org.pgpainless.key

Best Java code snippets using org.pgpainless.key.OpenPgpV4Fingerprint (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: igniterealtime/Smack

@Override
public PGPSecretKeyRing getSecretKeyRing(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException, PGPException {
  PGPSecretKeyRingCollection secretKeyRings = getSecretKeysOf(owner);
  if (secretKeyRings != null) {
    return secretKeyRings.getSecretKeyRing(fingerprint.getKeyId());
  }
  return null;
}
origin: igniterealtime/Smack

  @Override
  public boolean accept(Map<OpenPgpV4Fingerprint, Date> announcedKeys, PGPPublicKeyRing publicKeys) {
    return announcedKeys.keySet().contains(new OpenPgpV4Fingerprint(publicKeys));
  }
}
origin: igniterealtime/Smack

@Override
public int hashCode() {
  return getV4Fingerprint().hashCode() + 3 * getDate().hashCode();
}
origin: igniterealtime/Smack

@Test
public void t07_multipleKeysTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, IOException, MissingUserIdOnKeyException {
  PGPKeyRing one = openPgpStoreInstance1.generateKeyRing(alice);
  PGPKeyRing two = openPgpStoreInstance1.generateKeyRing(alice);
  OpenPgpV4Fingerprint fingerprint1 = new OpenPgpV4Fingerprint(one.getSecretKeys());
  OpenPgpV4Fingerprint fingerprint2 = new OpenPgpV4Fingerprint(two.getSecretKeys());
  openPgpStoreInstance1.importSecretKey(alice, one.getSecretKeys());
  openPgpStoreInstance1.importSecretKey(alice, two.getSecretKeys());
  openPgpStoreInstance1.importPublicKey(alice, one.getPublicKeys());
  openPgpStoreInstance1.importPublicKey(alice, two.getPublicKeys());
  assertTrue(Arrays.equals(one.getSecretKeys().getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint1).getEncoded()));
  assertTrue(Arrays.equals(two.getSecretKeys().getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint2).getEncoded()));
  assertTrue(Arrays.equals(one.getSecretKeys().getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getSecretKeyRing(fingerprint1.getKeyId()).getEncoded()));
  assertTrue(Arrays.equals(one.getPublicKeys().getEncoded(),
      openPgpStoreInstance1.getPublicKeyRing(alice, fingerprint1).getEncoded()));
  // Cleanup
  openPgpStoreInstance1.deletePublicKeyRing(alice, fingerprint1);
  openPgpStoreInstance1.deletePublicKeyRing(alice, fingerprint2);
  openPgpStoreInstance1.deleteSecretKeyRing(alice, fingerprint1);
  openPgpStoreInstance1.deleteSecretKeyRing(alice, fingerprint2);
}
origin: igniterealtime/Smack

/**
 * Create a new {@link MissingOpenPgpKeyException}.
 *
 * @param owner {@link BareJid} of the keys owner.
 * @param fingerprint {@link OpenPgpV4Fingerprint} of the missing key.
 */
public MissingOpenPgpKeyException(BareJid owner, OpenPgpV4Fingerprint fingerprint) {
  super("Missing key " + fingerprint.toString() + " for owner " + owner + ".");
  this.owner = owner;
  this.fingerprint = fingerprint;
}
origin: igniterealtime/Smack

public PubkeyMetadataElement(OpenPgpV4Fingerprint v4_fingerprint, Date date) {
  this.v4_fingerprint = Objects.requireNonNull(v4_fingerprint);
  this.date = Objects.requireNonNull(date);
  if (v4_fingerprint.length() != 40) {
    throw new IllegalArgumentException("OpenPGP v4 fingerprint must be 40 characters long.");
  }
}
origin: igniterealtime/Smack

  @Override
  public boolean equals(Object o) {
    if (o == null) {
      return false;
    }
    if (!(o instanceof PubkeyMetadataElement)) {
      return false;
    }
    if (o == this) {
      return true;
    }
    PubkeyMetadataElement otherPubkeyMetadataElement = (PubkeyMetadataElement) o;
    return this.getV4Fingerprint().equals(otherPubkeyMetadataElement.getV4Fingerprint()) &&
      this.getDate().equals(otherPubkeyMetadataElement.getDate());
  }
}
origin: igniterealtime/Smack

PGPKeyRing bobKeys = bobStore.generateKeyRing(bob);
OpenPgpV4Fingerprint aliceFingerprint = new OpenPgpV4Fingerprint(aliceKeys.getPublicKeys());
OpenPgpV4Fingerprint bobFingerprint = new OpenPgpV4Fingerprint(bobKeys.getPublicKeys());
aliceStore.setAnnouncedFingerprintsOf(alice, Collections.singletonMap(new OpenPgpV4Fingerprint(aliceKeys.getPublicKeys()), new Date()));
bobStore.setAnnouncedFingerprintsOf(bob, Collections.singletonMap(new OpenPgpV4Fingerprint(bobKeys.getPublicKeys()), new Date()));
bobStore.importPublicKey(alice, aliceKeys.getPublicKeys());
aliceStore.setAnnouncedFingerprintsOf(bob, Collections.singletonMap(new OpenPgpV4Fingerprint(bobKeys.getPublicKeys()), new Date()));
bobStore.setAnnouncedFingerprintsOf(alice, Collections.singletonMap(new OpenPgpV4Fingerprint(aliceKeys.getPublicKeys()), new Date()));
assertTrue(bobSelf.getSecretKeys().contains(decryptionFingerprint.getKeyId()));
assertTrue(decrypted.getMetadata().getVerifiedSignaturesFingerprints().contains(aliceFingerprint));
assertTrue(bobSelf.getSecretKeys().contains(decryptionFingerprint.getKeyId()));
assertTrue(decrypted.getMetadata().getVerifiedSignaturesFingerprints().isEmpty());
origin: igniterealtime/Smack

public MissingOpenPgpKeyException(BareJid owner, OpenPgpV4Fingerprint fingerprint, Throwable e) {
  super("Missing key " + fingerprint.toString() + " for owner " + owner + ".", e);
  this.owner = owner;
  this.fingerprint = fingerprint;
}
origin: igniterealtime/Smack

  @Override
  public boolean accept(Map<OpenPgpV4Fingerprint, Date> announcedKeys, PGPSecretKeyRing secretKeys) {
    return announcedKeys.keySet().contains(new OpenPgpV4Fingerprint(secretKeys));
  }
}
origin: igniterealtime/Smack

@Override
public PGPPublicKeyRing getPublicKeyRing(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException, PGPException {
  PGPPublicKeyRingCollection publicKeyRings = getPublicKeysOf(owner);
  if (publicKeyRings != null) {
    return publicKeyRings.getPublicKeyRing(fingerprint.getKeyId());
  }
  return null;
}
origin: igniterealtime/Smack

public static String TRUST_RECORD(OpenPgpV4Fingerprint fingerprint) {
  return fingerprint.toString() + ".trust";
}
origin: igniterealtime/Smack

/**
 * Return a {@link Set} of {@link OpenPgpV4Fingerprint}s of all keys in {@code publicKeys}, which are marked with the
 * {@link OpenPgpTrustStore.Trust} of {@code trust}.
 *
 * @param publicKeys {@link PGPPublicKeyRingCollection} of keys which are iterated.
 * @param trust {@link OpenPgpTrustStore.Trust} state.
 * @return {@link Set} of fingerprints
 *
 * @throws IOException IO error
 */
public Set<OpenPgpV4Fingerprint> getFingerprintsOfKeysWithState(PGPPublicKeyRingCollection publicKeys,
                                OpenPgpTrustStore.Trust trust)
    throws IOException {
  PGPPublicKeyRingCollection keys = getPublicKeysOfTrustState(publicKeys, trust);
  Set<OpenPgpV4Fingerprint> fingerprints = new HashSet<>();
  if (keys == null) {
    return fingerprints;
  }
  for (PGPPublicKeyRing ring : keys) {
    fingerprints.add(new OpenPgpV4Fingerprint(ring));
  }
  return fingerprints;
}
origin: igniterealtime/Smack

@Override
public void deletePublicKeyRing(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException, PGPException {
  PGPPublicKeyRingCollection publicKeyRings = getPublicKeysOf(owner);
  if (publicKeyRings.contains(fingerprint.getKeyId())) {
    publicKeyRings = PGPPublicKeyRingCollection.removePublicKeyRing(publicKeyRings, publicKeyRings.getPublicKeyRing(fingerprint.getKeyId()));
    if (!publicKeyRings.iterator().hasNext()) {
      publicKeyRings = null;
    }
    this.publicKeyRingCollections.put(owner, publicKeyRings);
    writePublicKeysOf(owner, publicKeyRings);
  }
}
origin: igniterealtime/Smack

  public MissingUserIdOnKeyException(BareJid owner, OpenPgpV4Fingerprint fingerprint) {
    super("Key " + fingerprint.toString() + " does not have a user-id of \"xmpp:" + owner.toString() + "\".");
  }
}
origin: igniterealtime/Smack

/**
 * Return the {@link OpenPgpV4Fingerprint} of our signing key.
 * @return fingerprint of signing key
 * @throws IOException IO is dangerous
 * @throws PGPException PGP is brittle
 */
public OpenPgpV4Fingerprint getSigningKeyFingerprint() throws IOException, PGPException {
  PGPSecretKeyRing signingKeyRing = getSigningKeyRing();
  return signingKeyRing != null ? new OpenPgpV4Fingerprint(signingKeyRing.getPublicKey()) : null;
}
origin: igniterealtime/Smack

@Override
public void deleteSecretKeyRing(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException, PGPException {
  PGPSecretKeyRingCollection secretKeyRings = getSecretKeysOf(owner);
  if (secretKeyRings.contains(fingerprint.getKeyId())) {
    secretKeyRings = PGPSecretKeyRingCollection.removeSecretKeyRing(secretKeyRings, secretKeyRings.getSecretKeyRing(fingerprint.getKeyId()));
    if (!secretKeyRings.iterator().hasNext()) {
      secretKeyRings = null;
    }
    this.secretKeyRingCollections.put(owner, secretKeyRings);
    writeSecretKeysOf(owner, secretKeyRings);
  }
}
origin: igniterealtime/Smack

static void writeFingerprintsAndDates(Map<OpenPgpV4Fingerprint, Date> data, File destination)
    throws IOException {
  if (data == null || data.isEmpty()) {
    FileUtils.maybeDeleteFileOrThrow(destination);
    return;
  }
  FileUtils.maybeCreateFileWithParentDirectories(destination);
  BufferedWriter writer = null;
  try {
    OutputStream outputStream = FileUtils.prepareFileOutputStream(destination);
    OutputStreamWriter osw = new OutputStreamWriter(outputStream, Util.UTF8);
    writer = new BufferedWriter(osw);
    for (OpenPgpV4Fingerprint fingerprint : data.keySet()) {
      Date date = data.get(fingerprint);
      String line = fingerprint.toString() + " " +
          (date != null ? XmppDateTime.formatXEP0082Date(date) : XmppDateTime.formatXEP0082Date(new Date()));
      writer.write(line);
      writer.newLine();
    }
  } finally {
    CloseableUtil.maybeClose(writer, LOGGER);
  }
}
origin: igniterealtime/Smack

OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(split[0]);
Date date = XmppDateTime.parseXEP0082Date(split[1]);
fingerprintDateMap.put(fingerprint, date);
origin: igniterealtime/Smack

Date fetchDate = fetchDates.get(fingerprint);
if (fetchDate != null && fingerprintsAndDates.get(fingerprint) != null && fetchDate.after(fingerprintsAndDates.get(fingerprint))) {
  LOGGER.log(Level.FINE, "Skip key " + Long.toHexString(fingerprint.getKeyId()) + " as we already have the most recent version. " +
      "Last announced: " + fingerprintsAndDates.get(fingerprint).toString() + " Last fetched: " + fetchDate.toString());
  continue;
  fetchDates.put(fingerprint, new Date());
  if (key == null) {
    LOGGER.log(Level.WARNING, "Public key " + Long.toHexString(fingerprint.getKeyId()) +
        " can not be imported: Is null");
    unfetchableKeys.put(fingerprint, new NullPointerException("Public key is null."));
} catch (PubSubException.NotAPubSubNodeException | PubSubException.NotALeafNodeException |
    XMPPException.XMPPErrorException e) {
  LOGGER.log(Level.WARNING, "Error fetching public key " + Long.toHexString(fingerprint.getKeyId()), e);
  unfetchableKeys.put(fingerprint, e);
} catch (PGPException | IOException e) {
  LOGGER.log(Level.WARNING, "Public key " + Long.toHexString(fingerprint.getKeyId()) +
      " can not be imported.", e);
  unfetchableKeys.put(fingerprint, e);
} catch (MissingUserIdOnKeyException e) {
  LOGGER.log(Level.WARNING, "Public key " + Long.toHexString(fingerprint.getKeyId()) +
      " is missing the user-id \"xmpp:" + getJid() + "\". Refuse to import it.", e);
  unfetchableKeys.put(fingerprint, e);
org.pgpainless.keyOpenPgpV4Fingerprint

Most used methods

  • getKeyId
  • <init>
  • equals
  • hashCode
  • length
  • toString

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • addToBackStack (FragmentTransaction)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now