CredentialProvider { public static boolean isAliasString(String aliasStr) { if (aliasStr == null || aliasStr.isEmpty()) { return false; } Matcher matcher = PASSWORD_ALIAS_PATTERN.matcher(aliasStr); return matcher.matches(); } 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 testIsAliasString() { String test = "cassablanca"; Assert.assertFalse(CredentialProvider.isAliasString(test)); test = "${}"; Assert.assertFalse(CredentialProvider.isAliasString(test)); test = "{}"; Assert.assertFalse(CredentialProvider.isAliasString(test)); test = "{cassablanca}"; Assert.assertFalse(CredentialProvider.isAliasString(test)); test = "${cassablanca}"; Assert.assertFalse(CredentialProvider.isAliasString(test)); test = "${alias=cassablanca}"; Assert.assertTrue(CredentialProvider.isAliasString(test)); }