private static Region parseRegionElement( final Element regionElement, final boolean endpointVerification) { String name = getChildElementValue(REGION_ID_TAG, regionElement); String domain = getChildElementValue(DOMAIN_TAG, regionElement); InMemoryRegionImpl regionImpl = new InMemoryRegionImpl(name, domain); NodeList endpointNodes = regionElement.getElementsByTagName(ENDPOINT_TAG); for (int i = 0; i < endpointNodes.getLength(); i++) { addRegionEndpoint(regionImpl, (Element) endpointNodes.item(i), endpointVerification); } return new Region(regionImpl); }
/** * Parses the specified input stream and returns a list of the regions * declared in it. By default, verification on the region endpoints is * disabled. * * @param input * The stream containing the region metadata to parse. * * @return The list of parsed regions. * @deprecated in favor of {@link #parse(InputStream)} */ @Deprecated public List<Region> parseRegionMetadata(InputStream input) throws IOException { return internalParse(input, false); }
if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element)node; regions.add(parseRegionElement(element, endpointVerification));
private static void addRegionEndpoint( final InMemoryRegionImpl region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if ( endpointVerification && !verifyLegacyEndpoint(hostname) ) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.addEndpoint(serviceName, hostname); if (Boolean.valueOf(http)) { region.addHttp(serviceName); } if (Boolean.valueOf(https)) { region.addHttps(serviceName); } }
/** * Tries to initialize the regions list from the stream given. * * @param regionsFile The input stream pointing to the retrieved region * file. */ private static void initRegions(InputStream regionsFile) { try { RegionMetadataParser parser = new RegionMetadataParser(); regions = parser.parseRegionMetadata(regionsFile); } catch (Exception e) { log.warn("Failed to parse regional endpoints", e); } }
/** * Loads a set of region metadata from an arbitrary {@code InputStream} * containing an XML file. * * @param stream the stream to load from * @return the loaded region metadata * @throws IOException on error reading from the stream */ public static RegionMetadata load (final InputStream stream) throws IOException { return RegionMetadataParser.parse(stream); }
private static void addRegionEndpoint( final Region region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if (endpointVerification && !verifyLegacyEndpoint(hostname)) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.getServiceEndpoints().put(serviceName, hostname); region.getHttpSupport().put(serviceName, "true".equals(http)); region.getHttpsSupport().put(serviceName, "true".equals(https)); }
/** * Tries to initialize the regions list from the stream given. * * @param regionsFile The input stream pointing to the retrieved region * file. */ private static void initRegions(InputStream regionsFile) { try { RegionMetadataParser parser = new RegionMetadataParser(); regions = parser.parseRegionMetadata(regionsFile); } catch (Exception e) { log.warn("Failed to parse regional endpoints", e); } }
/** * Loads a set of region metadata by parsing the given file. * * @param file the region metadata to load from * @throws IOException any error while reading from file. */ public static RegionMetadata load (final File file) throws IOException { return RegionMetadataParser.parse(new BufferedInputStream(new FileInputStream(file))); }
private static Region parseRegionElement( final Element regionElement, final boolean endpointVerification) { String name = getChildElementValue(REGION_ID_TAG, regionElement); String domain = getChildElementValue(DOMAIN_TAG, regionElement); Region region = new Region(name, domain); NodeList endpointNodes = regionElement.getElementsByTagName(ENDPOINT_TAG); for (int i = 0; i < endpointNodes.getLength(); i++) { addRegionEndpoint(region, (Element) endpointNodes.item(i), endpointVerification); } return region; }
private static void addRegionEndpoint( final InMemoryRegionImpl region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if ( endpointVerification && !verifyLegacyEndpoint(hostname) ) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.addEndpoint(serviceName, hostname); if (Boolean.valueOf(http)) { region.addHttp(serviceName); } if (Boolean.valueOf(https)) { region.addHttps(serviceName); } }
/** * Parses the specified input stream and optionally verifies that all of * the endpoints end in ".amazonaws.com". This method is deprecated, since * not all valid AWS endpoints end in ".amazonaws.com" any more. * * @param input * The stream containing the region metadata to parse. * @param endpointVerification * Whether to verify each region endpoint * * @return The list of parsed regions. * @deprecated in favor of {@link #parse(InputStream)} */ @Deprecated public List<Region> parseRegionMetadata(final InputStream input, final boolean endpointVerification) throws IOException { return internalParse(input, endpointVerification); }
if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; regions.add(parseRegionElement(element, endpointVerification));
/** * Tries to initialize the regions list from the stream given. * * @param regionsFile The input stream pointing to the retrieved region * file. */ private static void initRegions(InputStream regionsFile) { try { RegionMetadataParser parser = new RegionMetadataParser(); regions = parser.parseRegionMetadata(regionsFile); } catch (Exception e) { log.warn("Failed to parse regional endpoints", e); } }
/** * Loads a set of region metadata by downloading an XML file from the * given URI and parsing it. * * @param uri the uri of the XML file to parse * @param config configuration for the HTTP client to use to fetch the file * @throws IOException any error while reading data. */ public static RegionMetadata load (final URI uri, final ClientConfiguration config) throws IOException { return RegionMetadataParser.parse( RuntimeHttpUtils.fetchFile(uri, config)); }
private static Region parseRegionElement( final Element regionElement, final boolean endpointVerification) { String name = getChildElementValue(REGION_ID_TAG, regionElement); String domain = getChildElementValue(DOMAIN_TAG, regionElement); InMemoryRegionImpl regionImpl = new InMemoryRegionImpl(name, domain); NodeList endpointNodes = regionElement.getElementsByTagName(ENDPOINT_TAG); for (int i = 0; i < endpointNodes.getLength(); i++) { addRegionEndpoint(regionImpl, (Element) endpointNodes.item(i), endpointVerification); } return new Region(regionImpl); }
private static void addRegionEndpoint( final Region region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if (endpointVerification && !verifyLegacyEndpoint(hostname)) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.getServiceEndpoints().put(serviceName, hostname); region.getHttpSupport().put(serviceName, "true".equals(http)); region.getHttpsSupport().put(serviceName, "true".equals(https)); }
/** * Parses the specified input stream and returns a {@code RegionMetadata} * object. * * @param input the input stream to parse * @return the parsed region metadata * @throws IOException on error */ public static RegionMetadata parse(final InputStream input) throws IOException { return new RegionMetadata(internalParse(input, false)); }
if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element)node; regions.add(parseRegionElement(element, endpointVerification));
/** * Loads a set of region metadata from an arbitrary {@code InputStream} * containing an XML file. * * @param stream the stream to load from * @return the loaded region metadata * @throws IOException on error reading from the stream */ public static RegionMetadata load (final InputStream stream) throws IOException { return RegionMetadataParser.parse(stream); }