All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.transferwise.tasks.utils.ClientIdUtils Maven / Gradle / Ivy

There is a newer version: 1.43.0
Show newest version
package com.transferwise.tasks.utils;

import com.transferwise.common.baseutils.ExceptionUtils;
import java.net.InetAddress;
import org.apache.commons.lang3.StringUtils;

public final class ClientIdUtils {

  private ClientIdUtils() {
    throw new AssertionError();
  }

  public static String clientIdFromHostname() {
    String hostName = ExceptionUtils.doUnchecked(() -> InetAddress.getLocalHost().getHostName());
    String clientId = hostName.replaceAll("[^\\p{Alpha}\\p{Digit}]", "");
    if (StringUtils.isEmpty(clientId)) {
      throw new IllegalStateException("Could not get clientId from hostname '" + hostName + "'.");
    }
    return clientId;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy