Collects some user credentials and sends them over the network.

@throws java.net.UnknownHostException if the local host name could not be resolved into an address
327826
protected void sendUserCredentials() throws UnknownHostException {
    this.getTracePrintStream().printf("user = %s, host = %s, name = %s%n", System.getProperty("user.name"), InetAddress.getLocalHost().getHostName(), super.getName());
  }
765482
public InetAddress getInetAddress(){
      if(localIP == null){
	 try{
	   localIP = InetAddress.getByName(localHost);
	 }catch(UnknownHostException e){
	   return null;
	 }
      }
      return localIP;
   }
1107199
public void connect() throws IOException {
        SmbTransport trans;
        SmbSession ssn;
        UniAddress addr;

        if( isConnected() ) {
            return;
        }

        getUncPath0();
        getFirstAddress();
        for ( ;; ) {
            try {
                doConnect();
                return;
            } catch(SmbAuthException sae) {
                throw sae; // Prevents account lockout on servers with multiple IPs
            } catch(SmbException se) {
                if (getNextAddress() == null) 
                    throw se;
                if (log.level >= 3)
                    se.printStackTrace(log);
            }
        }
    }
448751
protected void connect(String host, int port)
        throws UnknownHostException, IOException
    {
        boolean connected = false;
        try {
            InetAddress address = InetAddress.getByName(host);
            this.port = port;
            this.address = address;

            connectToAddress(address, port, timeout);
            connected = true;
        } finally {
            if (!connected) {
                try {
                    close();
                } catch (IOException ioe) {
                    /* Do nothing. If connect threw an exception then
                       it will be passed up the call stack */
                }
            }
        }
    }
76763
public static InetAddress anonymize(final InetAddress inetAddress) throws UnknownHostException {
        if (inetAddress.isAnyLocalAddress() || inetAddress.isLoopbackAddress()) {
            return inetAddress;
        }

        final int mask = inetAddress instanceof Inet4Address ? 24 : 48;
        return truncate(inetAddress, mask);
    }
913338
public void onUnknownHost(String host, SshPublicKey pk) {
		try {
			System.out.println("The host " + host
					+ " is currently unknown to the system");
			System.out.println("The MD5 host key " + "(" + pk.getAlgorithm()
					+ ") fingerprint is: " + pk.getFingerprint());
			System.out.println("The SHA1 host key "
					+ "("
					+ pk.getAlgorithm()
					+ ") fingerprint is: "
					+ SshKeyFingerprint.getFingerprint(pk.getEncoded(),
							SshKeyFingerprint.SHA1_FINGERPRINT));
			try {
				System.out.println("The SHA256 host key "
						+ "("
						+ pk.getAlgorithm()
						+ ") fingerprint is: "
						+ SshKeyFingerprint.getFingerprint(pk.getEncoded(),
								SshKeyFingerprint.SHA256_FINGERPRINT));
			} catch (Exception ex) {
			}

			getResponse(host, pk);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
850445
public static String dumpLocalNetworkInfo() throws UnknownHostException, SocketException {
        StringBuffer buffer = new StringBuffer();
        InetAddress addr = InetAddress.getLocalHost();
        buffer.append("Localhost: " + getAddrInfo(addr) + "\n");
        Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
        buffer.append("Network interfaces:\n");
        while (nifs.hasMoreElements()) {
            NetworkInterface nif = nifs.nextElement();
            buffer.append("  - " + getNetworkInterfaceInfo(nif) + "\n");
            Enumeration<InetAddress> addresses = nif.getInetAddresses();
            while (addresses.hasMoreElements()) {
                addr = addresses.nextElement();
                buffer.append("    " + getAddrInfo(addr) + "\n");
            }
        }
        return buffer.toString();
    }
621127
public static void sendMail(String host, String personal, String to, String title, String content,
                                final String from, final String key) throws Exception {
        setHost(host);
        setPersonal(personal);
        sendMail(to, title, content, from, key);
    }
133646
public InetAddress
getAddress() {
	try {
		if (name == null)
			return InetAddress.getByAddress(address);
		else
			return InetAddress.getByAddress(name.toString(),
							address);
	} catch (UnknownHostException e) {
		return null;
	}
}
260219
private void initializeLocalhostNI() {
    InetAddress localhost;
    try {
      localhost = InetAddress.getLocalHost();
      NetworkInterface ni = NetworkInterface.getByInetAddress(localhost);

      if (ni != null)
        getNIList().add(ni.getName());

    } catch (UnknownHostException | SocketException e) {
      Console.severe("Cannot get the Network Interface for localhost");
      Console.severe(e.getMessage());
    }

  }
1082985
public static void sendMail(MailHost mailHost, String personal, String to, String title, String content,
                                final String from, final String key) throws Exception {
        setHost(mailHost);
        setPersonal(personal);
        sendMail(to, title, content, from, key);
    }
1277751
@Override
    public InetAddress[] resolve(String host) throws UnknownHostException {

        if (ipStringToBytes(host) != null) {
            return new InetAddress[] { InetAddress.getByAddress(ipStringToBytes(host)) };
        }

        List<InetAddress> inetAddresses = new ArrayList<>();
        try {
            resolve(host, inetAddresses);
        } catch (NamingException e) {
            throw new UnknownHostException(String.format("Cannot resolve %s to a hostname because of %s", host, e));
        }

        if (inetAddresses.isEmpty()) {
            throw new UnknownHostException(String.format("Cannot resolve %s to a hostname", host));
        }

        return inetAddresses.toArray(new InetAddress[inetAddresses.size()]);
    }
1184042
@Override
    public void populateCredentials(Map<String, String> credentials, Map topologyConfiguration) {
        populateCredentials(credentials, topologyConfiguration, null);
    }
1290305
public static void main(String[] args) throws Exception {
    if (args.length < 2)
      throw new IllegalArgumentException("must supply a path and set of host:port tuples");

    // Parse the address to which to bind the server.
    String[] mainParts = args[1].split(":");
    Address address = new Address(mainParts[0], Integer.valueOf(mainParts[1]));

    // Build a list of all member addresses to which to connect.
    List<Address> members = new ArrayList<>();
    for (int i = 1; i < args.length; i++) {
      String[] parts = args[i].split(":");
      members.add(new Address(parts[0], Integer.valueOf(parts[1])));
    }

    CopycatServer server = CopycatServer.builder(address)
      .withStateMachine(ValueStateMachine::new)
      .withTransport(new NettyTransport())
      .withStorage(Storage.builder()
        .withDirectory(args[0])
        .withMaxSegmentSize(1024 * 1024 * 32)
        .withMinorCompactionInterval(Duration.ofMinutes(1))
        .withMajorCompactionInterval(Duration.ofMinutes(15))
        .build())
      .build();

    server.serializer().register(SetCommand.class, 1);
    server.serializer().register(GetQuery.class, 2);
    server.serializer().register(DeleteCommand.class, 3);

    server.bootstrap(members).join();

    while (server.isRunning()) {
      Thread.sleep(1000);
    }
  }
261252
public static void configureExample(String host, int port, String user, String password, Authentication authType)
    throws IOException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException
  {
    // create the client
    DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);

    installResourceExtension(client);

    configureQueryOptions(client);

    setUpExample(client);

    // release the client
    client.release();
  }
706541
@SuppressWarnings("rawtypes")
    private List<InetAddress> resolve(String hostname, String attrName) throws NamingException, UnknownHostException {

        Attributes attrs = context.getAttributes(hostname, new String[] { attrName });

        List<InetAddress> inetAddresses = new ArrayList<>();
        Attribute attr = attrs.get(attrName);

        if (attr != null && attr.size() > 0) {
            NamingEnumeration e = attr.getAll();

            while (e.hasMore()) {
                InetAddress inetAddress = InetAddress.getByName("" + e.next());
                inetAddresses.add(InetAddress.getByAddress(hostname, inetAddress.getAddress()));
            }
        }

        return inetAddresses;
    }
1349824
public void connect(Object address) throws Exception {

        this.targetAddress = (HttpAddress) address;
        // if we're connecting on an existing SC, then clear it if need be
        // we do not want to clear when the reconnect flag is false because
        // that means we're in the middle of a reconnect (we called this method
        // and not an external user)
        if (null != this.myInterface && isReconnectAllowed()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Clearing existing OSC on connect");
            }
            this.myInterface.clear();
        }
        super.connect(address);
    }