AthenzUtils { public static String extractRoleName(final String roleName) { int idx = roleName.indexOf(AuthorityConsts.ROLE_SEP); if (idx == -1 || idx == 0 || idx == roleName.length() - AuthorityConsts.ROLE_SEP.length()) { return null; } else { return roleName.substring(idx + AuthorityConsts.ROLE_SEP.length()); } } 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 testExtractRoleName() { assertEquals(AthenzUtils.extractRoleName("athenz:role.readers"), "readers"); assertEquals(AthenzUtils.extractRoleName("athenz.api:role.readers"), "readers"); assertEquals(AthenzUtils.extractRoleName("athenz.api.test:role.readers"), "readers"); assertNull(AthenzUtils.extractRoleName("athenz:roles.readers")); assertNull(AthenzUtils.extractRoleName("athenz.role.readers")); assertNull(AthenzUtils.extractRoleName("athenz:role.")); assertNull(AthenzUtils.extractRoleName(":role.readers")); assertNull(AthenzUtils.extractRoleName("athenz.readers")); }