InstanceZTSProvider implements InstanceProvider { boolean validateSanUri(final String sanUri, final String hostname) { LOGGER.debug("Validating sanUri: {}, hostname: {}", sanUri, hostname); if (sanUri == null || sanUri.isEmpty()) { LOGGER.info("Request contains no sanURI to verify"); return true; } for (String uri: sanUri.split(",")) { int idx = uri.indexOf(URI_HOSTNAME_PREFIX); if (idx != -1) { if (!uri.substring(idx + URI_HOSTNAME_PREFIX.length()).equals(hostname)) { LOGGER.error("SanURI: {} does not contain hostname: {}", sanUri, hostname); return false; } } } return true; }  @Override Scheme getProviderScheme(); @Override void initialize(String provider, String providerEndpoint, SSLContext sslContext,
            KeyStore keyStore); @Override void setHostnameResolver(HostnameResolver hostnameResolver); @Override InstanceConfirmation confirmInstance(InstanceConfirmation confirmation); @Override InstanceConfirmation refreshInstance(InstanceConfirmation confirmation); boolean validatePublicKeys(final String athenzPublicKey, final String csrPublicKey);  }
@Test public void testValidateSanUri() { InstanceZTSProvider provider = new InstanceZTSProvider(); provider.initialize("provider", "com.yahoo.athenz.instance.provider.impl.InstanceZTSProvider", null, null); assertTrue(provider.validateSanUri("athenz: assertTrue(provider.validateSanUri("spiffe: assertTrue(provider.validateSanUri("spiffe: assertTrue(provider.validateSanUri("spiffe: assertTrue(provider.validateSanUri("", "abc.athenz.com")); assertTrue(provider.validateSanUri(null, "abc.athenz.com")); assertFalse(provider.validateSanUri("athenz: assertFalse(provider.validateSanUri("spiffe: assertFalse(provider.validateSanUri("spiffe: provider.close(); }