vault-credentialstore-lib/src/main/java/com/streamsets/datacollector/vault/Vault.java
static String calculateUserId(String csId) {
    try {
      // Try to hash based on default interface
      InetAddress ip = InetAddress.getLocalHost();
      NetworkInterface netIf = NetworkInterface.getByInetAddress(ip);
      byte[] mac = netIf.getHardwareAddress();

      if (mac == null) {
        // In some cases the default interface may be a tap/tun device which has no MAC
        // instead pick the first available interface.
        Enumeration<NetworkInterface> netIfs = NetworkInterface.getNetworkInterfaces();
        while (netIfs.hasMoreElements() && mac == null) {
          netIf = netIfs.nextElement();
          mac = netIf.getHardwareAddress();
        }
      }

      if (mac == null) {
        throw new IllegalStateException("Could not find network interface with MAC address.");
      }

      Hasher hasher = HASH_FUNCTION.newHasher(6); // MAC is 6 bytes.
      return hasher.putBytes(mac).hash().toString();
    } catch (IOException e) {
      LOG.error("CredentialStore '{}' Vault, could not compute Vault user-id: '{}'", csId, e);
      throw new VaultRuntimeException("Could not compute Vault user-id: " + e.toString());
    }
  }
static String calculateUserId(String csId) {
    try {
      // Try to hash based on default interface
      InetAddress ip = InetAddress.getLocalHost();
      NetworkInterface netIf = NetworkInterface.getByInetAddress(ip);
      byte[] mac = netIf.getHardwareAddress();

      if (mac == null) {
        // In some cases the default interface may be a tap/tun device which has no MAC
        // instead pick the first available interface.
        Enumeration<NetworkInterface> netIfs = NetworkInterface.getNetworkInterfaces();
        while (netIfs.hasMoreElements() && mac == null) {
          netIf = netIfs.nextElement();
          mac = netIf.getHardwareAddress();
        }
      }

      if (mac == null) {
        throw new IllegalStateException("Could not find network interface with MAC address.");
      }

      Hasher hasher = HASH_FUNCTION.newHasher(6); // MAC is 6 bytes.
      return hasher.putBytes(mac).hash().toString();
    } catch (IOException e) {
      LOG.error("CredentialStore '{}' Vault, could not compute Vault user-id: '{}'", csId, e);
      throw new VaultRuntimeException("Could not compute Vault user-id: " + e.toString());
    }
  }
static String calculateUserId ( String csId ) { try { // Try to hash based on default interface InetAddress ip = InetAddress . getLocalHost ( ) ; NetworkInterface netIf = NetworkInterface . getByInetAddress ( ip ) ; byte [ ] mac = netIf . getHardwareAddress ( ) ; if ( mac == null ) { // In some cases the default interface may be a tap/tun device which has no MAC // instead pick the first available interface. Enumeration < NetworkInterface > netIfs = NetworkInterface . getNetworkInterfaces ( ) ; while ( netIfs . hasMoreElements ( ) && mac == null ) { netIf = netIfs . nextElement ( ) ; mac = netIf . getHardwareAddress ( ) ; } } if ( mac == null ) { throw new IllegalStateException ( "Could not find network interface with MAC address." ) ; } Hasher hasher = HASH_FUNCTION . newHasher ( 6 ) ; // MAC is 6 bytes. return hasher . putBytes ( mac ) . hash ( ) . toString ( ) ; } catch ( IOException e ) { LOG . error ( "CredentialStore '{}' Vault, could not compute Vault user-id: '{}'" , csId , e ) ; throw new VaultRuntimeException ( "Could not compute Vault user-id: " + e . toString ( ) ) ; } }
The user-id portion of Vault's app-auth should be machine specific and at least
somewhat obfuscated to make it more difficult to derive. We use the sha256 hash of
the MAC address of the first interface found by InetAddress.getLocalHost().

This provides a way for administrators to compute the value itself during/after
deployment and authorize the app-id, user-id pair out of band.

@return String representation of the user-id portion of an auth token.
The user - id portion of Vault s app - auth should be machine specific and at least somewhat obfuscated to make it more difficult to derive . We use the sha256 hash of the MAC address of the first interface found by InetAddress . getLocalHost () .