AthenzUtils { public static String[] splitPrincipalName(String name) { String principalName = name.toLowerCase(); int idx = principalName.lastIndexOf(AuthorityConsts.ATHENZ_PRINCIPAL_DELIMITER_CHAR); if (idx == -1 || idx == 0 || idx == principalName.length() - 1) { return null; } return new String[]{principalName.substring(0, idx), principalName.substring(idx + 1)}; } private  AthenzUtils(); static String extractServicePrincipal(X509Certificate x509Cert); static boolean isRoleCertificate(X509Certificate x509Cert); static String extractRoleName(final String roleName); static String extractRoleDomainName(final String roleName); static String extractPrincipalDomainName(final String principalName); static String extractPrincipalServiceName(final String principalName); static String[] splitPrincipalName(String name); static String getPrincipalName(String domain, String service); static List<String> splitCommaSeperatedSystemProperty(String property);  }
@Test public void testSplitPrincipalName() { assertEquals(AthenzUtils.splitPrincipalName("athenz.reader"), new String[]{"athenz", "reader"}); assertEquals(AthenzUtils.splitPrincipalName("Athenz.Reader"), new String[]{"athenz", "reader"}); assertEquals(AthenzUtils.splitPrincipalName("athenz.api.reader"), new String[]{"athenz.api", "reader"}); assertEquals(AthenzUtils.splitPrincipalName("athenz.api.test.reader"), new String[]{"athenz.api.test", "reader"}); assertNull(AthenzUtils.splitPrincipalName("athenz")); assertNull(AthenzUtils.splitPrincipalName("athenz.")); assertNull(AthenzUtils.splitPrincipalName(".athenz")); }