Example usage for java.net InetAddress getByName

List of usage examples for java.net InetAddress getByName

Introduction

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

Prototype

public static InetAddress getByName(String host) throws UnknownHostException 

Source Link

Document

Determines the IP address of a host, given the host's name.

Usage

From source file:com.munichtrading.tracking.camera.APIIPCamera.java

public APIIPCamera(String _device) throws Exception {
    SimpleLayout layout = new SimpleLayout();
    ConsoleAppender consoleAppender = new ConsoleAppender(layout);
    logger.addAppender(consoleAppender);
    logger.setLevel(Level.INFO);//from w  w  w.ja va 2s  .  c om
    this.device = InetAddress.getByName(_device);
    this.getSettings();
}

From source file:com.opensoc.enrichment.adapters.geo.AbstractGeoAdapter.java

/**
 * Check if we can reach the IP where geo data is storred
 * /* w w  w. ja v a 2  s . c o m*/
 * @param ip
 *            - ip of geo database
 * @param timeout
 *            - timeout for a connection attempt
 * @return - True if can connect, False if cannot
 * @throws Exception
 */
public boolean checkIfReachable(String ip, int timeout) throws Exception {
    boolean reachable = InetAddress.getByName(ip).isReachable(timeout);

    if (!reachable)
        return false;

    return true;

}

From source file:net.jradius.radsec.SimpleProxyHandler.java

public void afterPropertiesSet() throws Exception {
    radiusClient = new RadiusClient(InetAddress.getByName(radiusServer), sharedSecret, authPort, acctPort, 60);
    if (radiusClient == null)
        throw new RuntimeException("could not create RadSec proxy radius client");
}

From source file:com.eviware.soapui.impl.support.HttpUtils.java

public static boolean ping(String host, int timeout) {
    pingErrorMessage = "No Error";
    try {//w  w  w .  j  a  v a 2s  .  com
        InetAddress address = InetAddress.getByName(host);
        return address.isReachable(timeout);
    } catch (Exception e) {
        pingErrorMessage = e.getMessage();
        return false;
    }
}

From source file:com.jforex.dzplugin.task.NTPTimeSynchTask.java

private void init() {
    timeClient.setDefaultTimeout(Configuration.NTP_TIMEOUT);
    try {//from ww  w  .ja  v  a  2  s . c  om
        inetAddress = InetAddress.getByName(pluginConfig.NTP_TIME_SERVER_URL());
    } catch (UnknownHostException e) {
        logger.error("NTP server url " + pluginConfig.NTP_TIME_SERVER_URL() + " is not reachable!");
    }
}

From source file:com.couchbase.client.core.config.DefaultCouchbaseBucketConfigTest.java

@Test
public void shouldHavePrimaryPartitionsOnNode() throws Exception {
    String raw = Resources.read("config_with_mixed_partitions.json", getClass());
    CouchbaseBucketConfig config = JSON_MAPPER.readValue(raw, CouchbaseBucketConfig.class);

    assertTrue(config.hasPrimaryPartitionsOnNode(InetAddress.getByName("1.2.3.4")));
    assertFalse(config.hasPrimaryPartitionsOnNode(InetAddress.getByName("2.3.4.5")));
}

From source file:co.cask.common.security.server.ExternalAuthenticationServerSSLTest.java

@BeforeClass
public static void beforeClass() throws Exception {
    URL certUrl = ExternalAuthenticationServerSSLTest.class.getClassLoader().getResource("cert.jks");
    Assert.assertNotNull(certUrl);/*from   ww w. ja  v a  2  s. c o m*/

    String authHandlerConfigBase = Constants.AUTH_HANDLER_CONFIG_BASE;

    SecurityConfiguration cConf = SecurityConfiguration.create();
    cConf.set(Constants.SSL_ENABLED, "true");
    cConf.set(authHandlerConfigBase.concat("useLdaps"), "true");
    cConf.set(authHandlerConfigBase.concat("ldapsVerifyCertificate"), "false");
    cConf.set(Constants.AuthenticationServer.SSL_KEYSTORE_PATH, certUrl.getPath());
    configuration = cConf;

    String keystorePassword = cConf.get(Constants.AuthenticationServer.SSL_KEYSTORE_PASSWORD);
    KeyStoreKeyManager keyManager = new KeyStoreKeyManager(certUrl.getFile(), keystorePassword.toCharArray());
    SSLUtil sslUtil = new SSLUtil(keyManager, new TrustAllTrustManager());
    ldapListenerConfig = InMemoryListenerConfig.createLDAPSConfig("LDAP", InetAddress.getByName("127.0.0.1"),
            ldapPort, sslUtil.createSSLServerSocketFactory(), sslUtil.createSSLSocketFactory());

    setup();
}

From source file:org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory.java

@Override
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
    return fireOffThread(InetAddress.getByName(host), port, null, -1);
}

From source file:com.jim.im.login.config.GatewayConfig.java

/**
 * geteway UserManagerService bean/*from www.  j ava 2 s .  c o  m*/
 * @return
 * @throws UnknownHostException
 */
@Bean
public UserManagerService UserManagerService() throws UnknownHostException {
    /*   ProtocolRegister.registerProcotol(
        CommandIDs.vlsp_maUserManagerService.loginbymobileMethod,
        null,
        new UserManagerService_loginbymobileRequest(),
        new UserManagerService_loginbymobileResponse());
            
       ProtocolRegister.registerProcotol(
      CommandIDs.vlsp_maUserManagerService.updatetokenMethod,
        null,
        new UserManagerService_updatetokenRequest(),
        new UserManagerService_updatetokenResponse());
    */
    UserManagerService service = new UserManagerService(InetAddress.getByName(gateway_ip), gateway_port);

    return service;
}

From source file:com.nesscomputing.jmx.starter.guice.JmxExporterConfigProvider.java

@Inject(optional = true)
void injectGalaxyConfig(final GalaxyConfig galaxyConfig) throws IOException {
    this.galaxyPort = galaxyConfig.getPrivate().getPortJmx() == 0 ? null
            : galaxyConfig.getPrivate().getPortJmx();
    final String host = galaxyConfig.getInternalIp().getIp();
    if (host != null) {
        this.galaxyHost = InetAddress.getByName(host);
    }// www  . ja va  2  s  .c o m
}