Here you can find the source of parseServiceName(URI endpoint)
@Deprecated public static String parseServiceName(URI endpoint)
//package com.java2s; /*/*w w w . j av a 2 s. c om*/ * Copyright 2015-2016 ksyun.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://ksyun.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ import java.net.URI; public class Main { /** * Parses the service name from an endpoint. Can only handle endpoints of * the form 'service.[region.].api.ksyun.com'. * * @Deprecated This method currently doesn't support BJS endpoints. This * method is used only in AWS4Signer to identify the service name from an * endpoint. This method is broken as it no longer returns the service * name to used for signing for all KSC services. This method will be * removed as part of next major version upgrade. */ @Deprecated public static String parseServiceName(URI endpoint) { String host = endpoint.getHost(); // If we don't recognize the domain, throw an exception. if (!host.endsWith(".api.ksyun.com")) { throw new IllegalArgumentException( "Cannot parse a service name from an unrecognized endpoint (" + host + ")."); } String serviceAndRegion = host.substring(0, host.indexOf(".api.ksyun.com")); char separator = '.'; // If we don't detect a separator between service name and region, then // assume that the region is not included in the hostname, and it's only // the service name (ex: "http://iam.ksyun.com"). if (serviceAndRegion.indexOf(separator) == -1) { return serviceAndRegion; } String service = serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator)); return service; } }