@Test public void testReadKeyFromFileExpectCanReadPublicKey() throws Exception { KeyFilesOperationsPgpImpl fixture = buildFixture(); Key key = fixture.readKeyFromFile(TestTools.getFileNameForResource("keys/Paul.asc")); assertNotNull(key); assertNotNull(key.getKeyInfo()); assertEquals("Paul <paul@email.com>", key.getKeyInfo().getUser()); }
@Override public Key readKeyFromFile(String fileName) { try { List<Key> ret = readKeysFromFile(new File(fileName)); Preconditions.checkArgument(ret.size() == 1, "Exactly one key is expected"); return ret.get(0); } catch (Throwable t) { throw new RuntimeException("Failed to read key", t); } }
KeyFilesOperationsPgpImpl implements KeyFilesOperations { @Override public Key readKeyFromFile(String fileName) { try { List<Key> ret = readKeysFromFile(new File(fileName)); Preconditions.checkArgument(ret.size() == 1, "Exactly one key is expected"); return ret.get(0); } catch (Throwable t) { throw new RuntimeException("Failed to read key", t); } } }
KeyFilesOperationsPgpImpl implements KeyFilesOperations { @Override public Key readKeyFromFile(String fileName) { try { List<Key> ret = readKeysFromFile(new File(fileName)); Preconditions.checkArgument(ret.size() == 1, "Exactly one key is expected"); return ret.get(0); } catch (Throwable t) { throw new RuntimeException("Failed to read key", t); } }  }
KeyFilesOperationsPgpImpl implements KeyFilesOperations { @Override public Key readKeyFromFile(String fileName) { try { List<Key> ret = readKeysFromFile(new File(fileName)); Preconditions.checkArgument(ret.size() == 1, "Exactly one key is expected"); return ret.get(0); } catch (Throwable t) { throw new RuntimeException("Failed to read key", t); } }  @Override List<Key> readKeysFromFile(File file); @Override List<Key> readKeysFromText(String text); @Override void exportPublicKey(Key key, String targetFilePathname); @Override String getPublicKeyArmoredRepresentation(Key key); @Override void exportPrivateKey(Key key, String targetFilePathname); @Override void validateDecryptionKeyPassword(String requestedKeyId, Key key, String password); @Override Key readKeyFromFile(String fileName); }
KeyFilesOperationsPgpImpl implements KeyFilesOperations { @Override public Key readKeyFromFile(String fileName) { try { List<Key> ret = readKeysFromFile(new File(fileName)); Preconditions.checkArgument(ret.size() == 1, "Exactly one key is expected"); return ret.get(0); } catch (Throwable t) { throw new RuntimeException("Failed to read key", t); } }  @Override List<Key> readKeysFromFile(File file); @Override List<Key> readKeysFromText(String text); @Override void exportPublicKey(Key key, String targetFilePathname); @Override String getPublicKeyArmoredRepresentation(Key key); @Override void exportPrivateKey(Key key, String targetFilePathname); @Override void validateDecryptionKeyPassword(String requestedKeyId, Key key, String password); @Override Key readKeyFromFile(String fileName);  }