BootstrappedKeyStoreProtectionManager implements KeyStoreProtectionManager { @Override public Map<String, Key> getAllKeys() throws CryptoException { final Map<String, Key> keys = new HashMap<String, Key>(); for (Map.Entry<String, Entry> keyEntry : this.keyEntries.entrySet()) if (keyEntry.getValue() instanceof SecretKeyEntry) keys.put(keyEntry.getKey(), ((SecretKeyEntry)keyEntry.getValue()).getSecretKey()); return keys; } BootstrappedKeyStoreProtectionManager();  BootstrappedKeyStoreProtectionManager(String keyStoreProtectionKey, String privateKeyProtectionKey);  BootstrappedKeyStoreProtectionManager(String keyStoreProtectionKey, String privateKeyProtectionKey,
			Map<String, Entry> entries); void setKeyStoreProtectionKey(byte[] keyStoreProtectionKey); void setKeyStoreProtectionKey(String keyStoreProtectionKey); void setPrivateKeyProtectionKey(byte[] privateKeyProtectionKey); void setPrivateKeyProtectionKey(String privateKeyProtectionKey); void setKeyEntries(Map<String, Entry> entries); @Override Key getPrivateKeyProtectionKey(); @Override Key getKeyStoreProtectionKey(); @Override Map<String, Key> getAllKeys(); @Override Key getKey(String keyName); @Override Map<String, Entry> getAllEntries(); @Override Entry getEntry(String entryName); final static String PrivKeyProtKey; final static String KeyStoreProtKey; }
@Test public void testGetAllKeys() throws Exception { BootstrappedKeyStoreProtectionManager mgr = new BootstrappedKeyStoreProtectionManager(); mgr.setKeyStoreProtectionKey("1234"); mgr.setPrivateKeyProtectionKey("5678"); final Map<String, Key> keys = mgr.getAllKeys(); assertEquals(2, keys.size()); Iterator<Entry<String, Key>> entryIter = keys.entrySet().iterator(); Key key = entryIter.next().getValue(); assertTrue(Arrays.equals("5678".getBytes(), key.getEncoded())); key = entryIter.next().getValue(); assertTrue(Arrays.equals("1234".getBytes(), key.getEncoded())); }