@Override public boolean hasKey(ECKey key) { lock.lock(); try { return basicKeyChain.hasKey(key); } finally { lock.unlock(); } }
@Override public boolean hasKey(ECKey key) { lock.lock(); try { return basicKeyChain.hasKey(key); } finally { lock.unlock(); } }
@Override public boolean hasKey(ECKey key) { lock.lock(); try { return basicKeyChain.hasKey(key); } finally { lock.unlock(); } }
@Override public boolean hasKey(ECKey key) { lock.lock(); try { return basicKeyChain.hasKey(key); } finally { lock.unlock(); } }
public boolean hasKey(ECKey key) { if (basic.hasKey(key)) return true; for (DeterministicKeyChain chain : chains) if (chain.hasKey(key)) return true; return false; }
public boolean hasKey(ECKey key) { if (basic.hasKey(key)) return true; for (DeterministicKeyChain chain : chains) if (chain.hasKey(key)) return true; return false; }
public boolean hasKey(ECKey key) { if (basic.hasKey(key)) return true; for (DeterministicKeyChain chain : chains) if (chain.hasKey(key)) return true; return false; }
public boolean hasKey(ECKey key) { if (basic.hasKey(key)) return true; for (DeterministicKeyChain chain : chains) if (chain.hasKey(key)) return true; return false; }
/** * Imports a key to the key chain. If key is present in the key chain, ignore it. */ public void importKey(ECKey key) { lock.lock(); try { checkKeyEncryptionStateMatches(key); if (hasKey(key)) return; importKeyLocked(key); queueOnKeysAdded(ImmutableList.of(key)); } finally { lock.unlock(); } }
/** * Imports a key to the key chain. If key is present in the key chain, ignore it. */ public void importKey(ECKey key) { lock.lock(); try { checkKeyEncryptionStateMatches(key); if (hasKey(key)) return; importKeyLocked(key); queueOnKeysAdded(ImmutableList.of(key)); } finally { lock.unlock(); } }
/** * Imports a key to the key chain. If key is present in the key chain, ignore it. */ public void importKey(ECKey key) { lock.lock(); try { checkKeyEncryptionStateMatches(key); if (hasKey(key)) return; importKeyLocked(key); queueOnKeysAdded(ImmutableList.of(key)); } finally { lock.unlock(); } }
/** * Imports a key to the key chain. If key is present in the key chain, ignore it. */ public void importKey(ECKey key) { lock.lock(); try { checkKeyEncryptionStateMatches(key); if (hasKey(key)) return; importKeyLocked(key); queueOnKeysAdded(ImmutableList.of(key)); } finally { lock.unlock(); } }
public int importKeys(List<? extends ECKey> keys) { lock.lock(); try { // Check that if we're encrypted, the keys are all encrypted, and if we're not, that none are. // We are NOT checking that the actual password matches here because we don't have access to the password at // this point: if you screw up and import keys with mismatched passwords, you lose! So make sure the // password is checked first. for (ECKey key : keys) { checkKeyEncryptionStateMatches(key); } List<ECKey> actuallyAdded = new ArrayList<>(keys.size()); for (final ECKey key : keys) { if (hasKey(key)) continue; actuallyAdded.add(key); importKeyLocked(key); } if (actuallyAdded.size() > 0) queueOnKeysAdded(actuallyAdded); return actuallyAdded.size(); } finally { lock.unlock(); } }
public int importKeys(List<? extends ECKey> keys) { lock.lock(); try { // Check that if we're encrypted, the keys are all encrypted, and if we're not, that none are. // We are NOT checking that the actual password matches here because we don't have access to the password at // this point: if you screw up and import keys with mismatched passwords, you lose! So make sure the // password is checked first. for (ECKey key : keys) { checkKeyEncryptionStateMatches(key); } List<ECKey> actuallyAdded = new ArrayList<ECKey>(keys.size()); for (final ECKey key : keys) { if (hasKey(key)) continue; actuallyAdded.add(key); importKeyLocked(key); } if (actuallyAdded.size() > 0) queueOnKeysAdded(actuallyAdded); return actuallyAdded.size(); } finally { lock.unlock(); } }
public int importKeys(List<? extends ECKey> keys) { lock.lock(); try { // Check that if we're encrypted, the keys are all encrypted, and if we're not, that none are. // We are NOT checking that the actual password matches here because we don't have access to the password at // this point: if you screw up and import keys with mismatched passwords, you lose! So make sure the // password is checked first. for (ECKey key : keys) { checkKeyEncryptionStateMatches(key); } List<ECKey> actuallyAdded = new ArrayList<>(keys.size()); for (final ECKey key : keys) { if (hasKey(key)) continue; actuallyAdded.add(key); importKeyLocked(key); } if (actuallyAdded.size() > 0) queueOnKeysAdded(actuallyAdded); return actuallyAdded.size(); } finally { lock.unlock(); } }
public int importKeys(List<? extends ECKey> keys) { lock.lock(); try { // Check that if we're encrypted, the keys are all encrypted, and if we're not, that none are. // We are NOT checking that the actual password matches here because we don't have access to the password at // this point: if you screw up and import keys with mismatched passwords, you lose! So make sure the // password is checked first. for (ECKey key : keys) { checkKeyEncryptionStateMatches(key); } List<ECKey> actuallyAdded = new ArrayList<ECKey>(keys.size()); for (final ECKey key : keys) { if (hasKey(key)) continue; actuallyAdded.add(key); importKeyLocked(key); } if (actuallyAdded.size() > 0) queueOnKeysAdded(actuallyAdded); return actuallyAdded.size(); } finally { lock.unlock(); } }
@Test public void importKeys() { long now = Utils.currentTimeSeconds(); Utils.setMockClock(now); final ECKey key1 = new ECKey(); Utils.rollMockClock(86400); final ECKey key2 = new ECKey(); final ArrayList<ECKey> keys = Lists.newArrayList(key1, key2); // Import two keys, check the event is correct. assertEquals(2, chain.importKeys(keys)); assertEquals(2, chain.numKeys()); assertTrue(onKeysAddedRan.getAndSet(false)); assertArrayEquals(keys.toArray(), onKeysAdded.get().toArray()); assertEquals(now, chain.getEarliestKeyCreationTime()); // Check we ignore duplicates. final ECKey newKey = new ECKey(); keys.add(newKey); assertEquals(1, chain.importKeys(keys)); assertTrue(onKeysAddedRan.getAndSet(false)); assertEquals(newKey, onKeysAdded.getAndSet(null).get(0)); assertEquals(0, chain.importKeys(keys)); assertFalse(onKeysAddedRan.getAndSet(false)); assertNull(onKeysAdded.get()); assertTrue(chain.hasKey(key1)); assertTrue(chain.hasKey(key2)); assertEquals(key1, chain.findKeyFromPubHash(key1.getPubKeyHash())); assertEquals(key2, chain.findKeyFromPubKey(key2.getPubKey())); assertNull(chain.findKeyFromPubKey(key2.getPubKeyHash())); }