CredentialProvider { protected CredentialStore getKeystoreService() { return keystoreService; } CredentialProvider(String masterKey, File masterKeyLocation,
                            boolean isMasterKeyPersisted, File masterKeyStoreLocation); char[] getPasswordForAlias(String alias); void generateAliasWithPassword(String alias); void addAliasToCredentialStore(String alias, String passwordString); static boolean isAliasString(String aliasStr); static void main(String args[]); static final Pattern PASSWORD_ALIAS_PATTERN; }
@Test public void testInitialization() throws Exception { CredentialProvider cr; File msFile = tmpFolder.newFile(Configuration.MASTER_KEY_FILENAME_DEFAULT); File mksFile = tmpFolder.newFile(Configuration.MASTER_KEYSTORE_FILENAME_DEFAULT); try { new CredentialProvider(null, null, true, null); Assert.fail("Expected an exception"); } catch (Throwable t) { Assert.assertTrue(t instanceof IllegalArgumentException); } cr = new CredentialProvider("blahblah!", msFile, false, mksFile); Assert.assertNotNull(cr); Assert.assertNotNull(cr.getKeystoreService()); msFile.delete(); mksFile.delete(); createMasterKey(); cr = new CredentialProvider(null, msFile, true, mksFile); Assert.assertNotNull(cr); Assert.assertNotNull(cr.getKeystoreService()); }