Example usage for java.net InetAddress getLocalHost

List of usage examples for java.net InetAddress getLocalHost

Introduction

In this page you can find the example usage for java.net InetAddress getLocalHost.

Prototype

public static InetAddress getLocalHost() throws UnknownHostException 

Source Link

Document

Returns the address of the local host.

Usage

From source file:com.adaptris.hpcc.DesprayFromThor.java

String destIpAddress() throws IOException {
    return getDestIpAddress() != null ? getDestIpAddress() : InetAddress.getLocalHost().getHostAddress();
}

From source file:com.facebook.infrastructure.utils.FBUtilities.java

public static InetAddress getLocalAddress() throws UnknownHostException {
    if (localInetAddress_ == null)
        localInetAddress_ = InetAddress.getLocalHost();
    return localInetAddress_;
}

From source file:com.netscape.cmstools.OCSPClient.java

public static void printHelp() throws Exception {
    System.out.println("Usage: OCSPClient [OPTIONS]");
    System.out.println();//w  w  w  . j ava2s .  com
    System.out.println("Options:");
    System.out.println("  -d <database>        Security database location (default: current directory)");
    System.out.println("  -h <hostname>        OCSP server hostname (default: "
            + InetAddress.getLocalHost().getCanonicalHostName() + ")");
    System.out.println("  -p <port>            OCSP server port number (default: 8080)");
    System.out.println("  -t <path>            OCSP service path (default: /ocsp/ee/ocsp)");
    System.out.println("  -c <nickname>        CA certificate nickname (defaut: CA Signing Certificate)");
    System.out.println("  -n <times>           Number of submissions (default: 1)");
    System.out.println();
    System.out.println("  --serial <serial>    Serial number of certificate to be checked");
    System.out.println("  --input <input>      Input file containing DER-encoded OCSP request");
    System.out.println("  --output <output>    Output file to store DER-encoded OCSP response");
    System.out.println();
    System.out.println("  -v, --verbose        Run in verbose mode.");
    System.out.println("      --help           Show help message.");
}

From source file:org.camunda.bpm.ext.sdk.CamundaClientBuilder.java

protected void initClientId() {
    if (clientId == null) {
        String hostName;/*from   ww  w  .  j a  va 2 s.  c  o m*/
        try {
            hostName = InetAddress.getLocalHost().getHostName() + " - " + UUID.randomUUID().toString();
            clientId = hostName;
        } catch (UnknownHostException e) {
            throw new CamundaClientException("Cannot get hostname", e);
        }
    }
}

From source file:org.auraframework.integration.test.configuration.JettyTestServletConfig.java

private String getHost() throws UnknownHostException {
    if (SauceUtil.areTestsRunningOnSauce()) {
        return InetAddress.getLocalHost().getCanonicalHostName();
    }//from w  w w.j  a  v  a  2s  .c  o  m
    return "localhost";
}

From source file:com.vmware.photon.controller.common.auth.AuthOIDCRegistrar.java

public void register(String registrationAddress, String username, String password, String mgmtUiRegPath,
        String swaggerUiRegPath) throws AuthException {
    try {/*  ww w.java  2 s .c o m*/
        AuthOIDCClient client = new AuthOIDCClient(domainInfo.getDomainController(), domainInfo.getPort(),
                domainInfo.getDomain());
        AuthClientHandler handler = client.getClientHandler(username, password);

        String hostname = registrationAddress;

        if (hostname == null || hostname.isEmpty()) {
            hostname = InetAddress.getLocalHost().getCanonicalHostName();
        }

        AuthClientHandler.ImplicitClient managementUI = handler.registerImplicitClient(
                new URI(String.format(MGMT_UI_LOGIN_REDIRECT_URL_TEMPLATE, hostname)),
                new URI(String.format(MGMT_UI_LOGOUT_REDIRECT_URL_TEMPLATE, hostname)));

        AuthClientHandler.ImplicitClient swaggerUI = handler.registerImplicitClient(
                new URI(String.format(SWAGGER_UI_LOGIN_REDIRECT_URL_TEMPLATE, hostname)),
                new URI(String.format(SWAGGER_UI_LOGOUT_REDIRECT_URL_TEMPLATE, hostname)));

        if (mgmtUiRegPath == null || mgmtUiRegPath.isEmpty()) {
            mgmtUiRegPath = MGMT_UI_REG_PATH_DEFAULT;
        }

        writeToFile(managementUI, mgmtUiRegPath);

        if (swaggerUiRegPath == null || swaggerUiRegPath.isEmpty()) {
            swaggerUiRegPath = SWAGGER_UI_REG_PATH_DEFAULT;
        }

        writeToFile(swaggerUI, swaggerUiRegPath);
    } catch (UnknownHostException e) {
        throw new AuthException(e);
    } catch (URISyntaxException e) {
        throw new AuthException(e);
    } catch (IOException e) {
        throw new AuthException(e);
    }
}

From source file:in.gov.uidai.auth.aua.httpclient.OtpClient.java

public OtpResponseDetails generateOtp(Otp otp) {
    try {/*from   w  w w  .j  a v  a  2  s.com*/
        String signedXML = generateSignedOtpXML(otp);
        System.out.println(signedXML);

        String uriString = otpServerURI.toString() + (otpServerURI.toString().endsWith("/") ? "" : "/")
                + otp.getAc() + "/" + otp.getUid().charAt(0) + "/" + otp.getUid().charAt(1);

        if (StringUtils.isNotBlank(asaLicenseKey)) {
            uriString = uriString + "/" + asaLicenseKey;
        }

        URI otpURI = new URI(uriString);

        WebResource webResource = Client.create(HttpClientHelper.getClientConfig(otpServerURI.getScheme()))
                .resource(otpURI);

        String responseXML = webResource.header("REMOTE_ADDR", InetAddress.getLocalHost().getHostAddress())
                .post(String.class, signedXML);

        return new OtpResponseDetails(responseXML, parseOtpResponseXML(responseXML));

    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Exception during OTP generation " + e.getMessage(), e);
    }

}

From source file:com.nridge.core.base.std.Platform.java

/**
 * Convenience method that returns the host IP address of the current machine.
 *
 * @return Host IP address.//from   w  w  w  .j  a v  a 2  s . com
 */
public static String getHostIPAddress() {
    String hostAddress;

    try {
        InetAddress inetAddress = InetAddress.getLocalHost();
        hostAddress = inetAddress.getHostAddress();
    } catch (UnknownHostException e) {
        hostAddress = "127.0.0.1";
    }

    return hostAddress;
}

From source file:uk.ac.sanger.cgp.wwdocker.beans.WorkerResources.java

private void base_init(OperatingSystemMXBean osmxb) {
    String[] bits = ManagementFactory.getRuntimeMXBean().getName().split("@");
    pid = Long.getLong(bits[0]);/*  www .  j  ava  2s  .  co m*/
    totalMemBytes = osmxb.getTotalPhysicalMemorySize();
    availableProcessors = Runtime.getRuntime().availableProcessors();
    hostName = System.getenv("HOSTNAME");
    if (hostName == null) {
        try {
            hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            throw new RuntimeException("Unable to determine hostname", e);
        }
    }
}

From source file:in.bbat.license.LicenseInfo.java

private String getHostname() {
    String str = null;/*from  ww  w . j av a 2 s.  c o  m*/
    try {
        str = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException localUnknownHostException) {
    }
    if (str == null)
        str = "<unknown>";
    return str;
}