KerberosOperationHandler { protected Set<EncryptionType> translateEncryptionTypes(String names, String delimiter) { Set<EncryptionType> encryptionTypes = new HashSet<EncryptionType>(); if (!StringUtils.isEmpty(names)) { for (String name : names.split((delimiter == null) ? "\\s+" : delimiter)) { encryptionTypes.addAll(translateEncryptionType(name.trim())); } } return encryptionTypes; }  abstract void open(PrincipalKeyCredential administratorCredential, String defaultRealm, Map<String, String> kerberosConfiguration); abstract void close(); abstract boolean principalExists(String principal); abstract Integer createPrincipal(String principal, String password, boolean service); abstract Integer setPrincipalPassword(String principal, String password); abstract boolean removePrincipal(String principal); boolean testAdministratorCredentials(); boolean createKeytabFile(Keytab keytab, File destinationKeytabFile); PrincipalKeyCredential getAdministratorCredential(); void setAdministratorCredential(PrincipalKeyCredential administratorCredential); String getDefaultRealm(); void setDefaultRealm(String defaultRealm); Set<EncryptionType> getKeyEncryptionTypes(); void setKeyEncryptionTypes(Set<EncryptionType> keyEncryptionTypes); String[] getExecutableSearchPaths(); void setExecutableSearchPaths(String[] executableSearchPaths); void setExecutableSearchPaths(String delimitedExecutableSearchPaths); boolean isOpen(); void setOpen(boolean open); final static String KERBEROS_ENV_LDAP_URL; final static String KERBEROS_ENV_PRINCIPAL_CONTAINER_DN; final static String KERBEROS_ENV_USER_PRINCIPAL_GROUP; final static String KERBEROS_ENV_PASSWORD_CHAT_TIMEOUT; final static int DEFAULT_PASSWORD_CHAT_TIMEOUT; final static String KERBEROS_ENV_SET_PASSWORD_EXPIRY; final static String KERBEROS_ENV_AD_CREATE_ATTRIBUTES_TEMPLATE; final static String KERBEROS_ENV_KDC_CREATE_ATTRIBUTES; final static String KERBEROS_ENV_ENCRYPTION_TYPES; final static String KERBEROS_ENV_KDC_HOSTS; final static String KERBEROS_ENV_ADMIN_SERVER_HOST; final static String KERBEROS_ENV_EXECUTABLE_SEARCH_PATHS; }
@Test public void testTranslateEncryptionTypes() throws Exception { KerberosOperationHandler handler = createHandler(); Assert.assertEquals( new HashSet<EncryptionType>() {{ add(EncryptionType.AES256_CTS_HMAC_SHA1_96); add(EncryptionType.AES128_CTS_HMAC_SHA1_96); add(EncryptionType.DES3_CBC_SHA1_KD); add(EncryptionType.DES_CBC_MD5); add(EncryptionType.DES_CBC_MD4); add(EncryptionType.DES_CBC_CRC); add(EncryptionType.UNKNOWN); }}, handler.translateEncryptionTypes("aes256-cts-hmac-sha1-96\n aes128-cts-hmac-sha1-96\tdes3-cbc-sha1 arcfour-hmac-md5 " + "camellia256-cts-cmac camellia128-cts-cmac des-cbc-crc des-cbc-md5 des-cbc-md4", "\\s+") ); Assert.assertEquals( new HashSet<EncryptionType>() {{ add(EncryptionType.AES256_CTS_HMAC_SHA1_96); add(EncryptionType.AES128_CTS_HMAC_SHA1_96); }}, handler.translateEncryptionTypes("aes", " ") ); Assert.assertEquals( new HashSet<EncryptionType>() {{ add(EncryptionType.AES256_CTS_HMAC_SHA1_96); }}, handler.translateEncryptionTypes("aes-256", " ") ); Assert.assertEquals( new HashSet<EncryptionType>() {{ add(EncryptionType.DES3_CBC_SHA1_KD); }}, handler.translateEncryptionTypes("des3", " ") ); }