@Test public void testGetKey_JCEKS_DES() { URL url = getClass().getResource(KS1_JCEKS); assertNotNull(url); Map<String, String> props = new HashMap<>(); props.put(CryptoConstants.KEYSTORE_URL, url.toExternalForm()); props.put(CryptoConstants.ENCRYPTION_KEY_ALIAS, "k2"); Map<String, char[]> creds = new HashMap<>(); creds.put(CryptoConstants.KEY_PASSWORD, TEST_KEY_PASS); JceksKeySource ks = new JceksKeySource(props, creds); assertNull(ks.getKey("no-such-key")); Key k1 = ks.getKey("k1"); assertNotNull(k1); assertEquals("DES", k1.getAlgorithm()); Key k2 = ks.getKey("k2"); assertNotNull(k2); assertEquals("DES", k2.getAlgorithm()); Key k3 = ks.getKey("k3"); assertNotNull(k3); assertEquals("AES", k3.getAlgorithm()); }
@Override public Key getKey(String alias) { Key key = keyCache.get(alias); if (key == null) { Key newKey = createKey(alias); Key oldKey = keyCache.putIfAbsent(alias, newKey); key = oldKey != null ? oldKey : newKey; } return key == NULL_KEY ? null : key; }
JceksKeySource implements KeySource { @Override public Key getKey(String alias) { Key key = keyCache.get(alias); if (key == null) { Key newKey = createKey(alias); Key oldKey = keyCache.putIfAbsent(alias, newKey); key = oldKey != null ? oldKey : newKey; } return key == NULL_KEY ? null : key; } }
JceksKeySource implements KeySource { @Override public Key getKey(String alias) { Key key = keyCache.get(alias); if (key == null) { Key newKey = createKey(alias); Key oldKey = keyCache.putIfAbsent(alias, newKey); key = oldKey != null ? oldKey : newKey; } return key == NULL_KEY ? null : key; } JceksKeySource(@Inject(CryptoConstants.PROPERTIES_MAP) Map<String, String> properties,
			@Inject(CryptoConstants.CREDENTIALS_MAP) Map<String, char[]> credentials); }
JceksKeySource implements KeySource { @Override public Key getKey(String alias) { Key key = keyCache.get(alias); if (key == null) { Key newKey = createKey(alias); Key oldKey = keyCache.putIfAbsent(alias, newKey); key = oldKey != null ? oldKey : newKey; } return key == NULL_KEY ? null : key; } JceksKeySource(@Inject(CryptoConstants.PROPERTIES_MAP) Map<String, String> properties,
			@Inject(CryptoConstants.CREDENTIALS_MAP) Map<String, char[]> credentials); @Override Key getKey(String alias); @Override String getDefaultKeyAlias(); }
JceksKeySource implements KeySource { @Override public Key getKey(String alias) { Key key = keyCache.get(alias); if (key == null) { Key newKey = createKey(alias); Key oldKey = keyCache.putIfAbsent(alias, newKey); key = oldKey != null ? oldKey : newKey; } return key == NULL_KEY ? null : key; } JceksKeySource(@Inject(CryptoConstants.PROPERTIES_MAP) Map<String, String> properties,
			@Inject(CryptoConstants.CREDENTIALS_MAP) Map<String, char[]> credentials); @Override Key getKey(String alias); @Override String getDefaultKeyAlias();  }