static String userAgent() {

    String ua = InternalConfig.Factory.getInternalConfig().getUserAgentTemplate();

    if (ua == null) {
      return "aws-sdk-java";
    }

    ua =
        ua.replace("{platform}", getPlatform().toLowerCase())
            .replace("{version}", getVersion())
            .replace("{os.name}", replaceSpaces(System.getProperty("os.name")))
            .replace("{os.version}", replaceSpaces(System.getProperty("os.version")))
            .replace("{java.vm.name}", replaceSpaces(System.getProperty("java.vm.name")))
            .replace("{java.vm.version}", replaceSpaces(System.getProperty("java.vm.version")))
            .replace("{java.version}", replaceSpaces(System.getProperty("java.version")));

    String language = System.getProperty("user.language");
    String region = System.getProperty("user.region");

    String languageAndRegion = "";
    if (language != null && region != null) {
      languageAndRegion = " " + replaceSpaces(language) + "_" + replaceSpaces(region);
    }
    ua = ua.replace("{language.and.region}", languageAndRegion);

    return ua;
  }
Ejemplo n.º 2
0
 /**
  * Returns a non-null signer for the specified service and region.
  *
  * @throws UnsupportedOperationException if the internal signer type configured is not currently
  *     supported.
  */
 static String getServiceName(String httpClientName) {
   InternalConfig config = InternalConfig.Factory.getInternalConfig();
   HttpClientConfig clientConfig = config.getHttpClientConfig(httpClientName);
   return clientConfig == null ? null : clientConfig.getServiceName();
 }