List of usage examples for org.springframework.vault.authentication Sha256 toSha256
public static String toSha256(String content)
From source file:org.springframework.vault.authentication.MacAddressUserId.java
@Override public String createUserId() { try {// w w w . j a va2 s . c om NetworkInterface networkInterface = null; List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); if (StringUtils.hasText(networkInterfaceHint)) { try { networkInterface = getNetworkInterface(Integer.parseInt(networkInterfaceHint), interfaces); } catch (NumberFormatException e) { networkInterface = getNetworkInterface((networkInterfaceHint), interfaces); } } if (networkInterface == null) { if (StringUtils.hasText(networkInterfaceHint)) { log.warn(String.format("Did not find a NetworkInterface applying hint %s", networkInterfaceHint)); } InetAddress localHost = InetAddress.getLocalHost(); networkInterface = NetworkInterface.getByInetAddress(localHost); if (networkInterface == null) { throw new IllegalStateException( String.format("Cannot determine NetworkInterface for %s", localHost)); } } byte[] mac = networkInterface.getHardwareAddress(); if (mac == null) { throw new IllegalStateException( String.format("Network interface %s has no hardware address", networkInterface.getName())); } return Sha256.toSha256(Sha256.toHexString(mac)); } catch (IOException e) { throw new IllegalStateException(e); } }