List of usage examples for java.net UnknownHostException getMessage
public String getMessage()
From source file:io.kamax.mxisd.lookup.strategy.RecursivePriorityLookupStrategy.java
private boolean isAllowedForRecursive(String source) { boolean canRecurse = false; try {/*from w w w .j av a2 s. c o m*/ if (cfg.isEnabled()) { log.debug("Checking {} CIDRs for recursion", allowedCidr.size()); for (CIDRUtils cidr : allowedCidr) { if (cidr.isInRange(source)) { log.debug("{} is in range {}, allowing recursion", source, cidr.getNetworkAddress()); canRecurse = true; break; } else { log.debug("{} is not in range {}", source, cidr.getNetworkAddress()); } } } } catch (UnknownHostException e) { // this should never happened as we should have only IP ranges! log.error("Unexpected {} exception: {}", e.getClass().getSimpleName(), e.getMessage()); } return canRecurse; }
From source file:org.openhab.binding.modbus.internal.pooling.ModbusSlaveConnectionFactoryImpl.java
private InetAddress getInetAddress(ModbusIPSlaveEndpoint key) { try {//w ww. ja v a2s . com return InetAddress.getByName(key.getAddress()); } catch (UnknownHostException e) { logger.error("KeyedPooledModbusSlaveConnectionFactory: Unknown host: {}. Connection creation failed.", e.getMessage()); return null; } }
From source file:org.asimba.engine.cluster.JGroupsCluster.java
/** * Return the JChannel instance configured for this JGroupsCluster<br/> * Note: the JChannel is connected to upon first instantiation *//*from w w w . j a v a2 s . c om*/ @Override public Object getChannel() { if (_jChannel == null) { String sNodeId = null; // initialize channel from initialcontext try { InitialContext ic = new InitialContext(); sNodeId = (String) ic.lookup("java:comp/env/" + PROP_ASIMBA_NODE_ID); _oLogger.debug("Trying to read the node id from initial context"); } catch (NamingException e) { _oLogger.warn("Getting initialcontext failed! " + e.getMessage()); } if (StringUtils.isEmpty(sNodeId)) { // Initialize the channel, based on configuration sNodeId = System.getProperty(PROP_ASIMBA_NODE_ID); } if (StringUtils.isEmpty(sNodeId)) { try { // Initialize the channel, based on hostname sNodeId = getHostName(); } catch (UnknownHostException ex) { _oLogger.error("Getting hostname failed! " + ex.getMessage()); } } try { if (sNodeId != null) { // Apply custom options: Map<String, String> mOptions = _mCustomOptions.get(sNodeId); _oLogger.info("System property " + PROP_ASIMBA_NODE_ID + " specified; applying" + "custom properties JGroupsCluster '" + _sID + "', node '" + sNodeId + "'"); for (Entry<String, String> prop : mOptions.entrySet()) { System.setProperty(prop.getKey(), prop.getValue()); } } else { _oLogger.info("No " + PROP_ASIMBA_NODE_ID + " system property specified, so no " + "custom properties applied for JGroupsCluster '" + _sID + "'"); } _jChannel = new JChannel(_sConfigLocation); if (_sID != null) _jChannel.setName(_sID); _oLogger.info("Connecting to cluster " + _sID + " with name " + _sClusterName); _jChannel.connect(_sClusterName); } catch (Exception e) { _oLogger.error("Could not create JChannel: " + e.getMessage(), e); return null; } } return _jChannel; }
From source file:com.yodlee.sampleapps.helper.OpenSamlHelper.java
/** * This function generates the response. * * @param subjects// ww w . ja v a 2 s . c o m * @return SAMLResponse object * @throws SAMLException * @throws Exception */ public SAMLResponse generateResponse(String[] subjects, String issuer) throws SAMLException { // Get Host Information InetAddress address = null; try { address = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } String IPAddress = address.getHostAddress(); String DNSAddress = address.getHostName(); Collection statements = new ArrayList(); // Create the SAML subject for (int i = 0; i < subjects.length; i++) { String subject = subjects[i]; SAMLNameIdentifier nameIdentifier = new SAMLNameIdentifier(subject, null, SAMLNameIdentifier.FORMAT_X509); List confirmationMethodList = new ArrayList(); confirmationMethodList.add(SAMLSubject.CONF_BEARER); SAMLSubject samlSubject = new SAMLSubject(nameIdentifier, confirmationMethodList, null, null); // Create the SAML Authentication Statement SAMLAuthenticationStatement sas = new SAMLAuthenticationStatement //(subject,"auth",new Date(),IPAddress,DNSAddress,null); (samlSubject, "password", new Date(), IPAddress, DNSAddress, null); statements.add(sas); } // Create the SAML Assertion SAMLAssertion assertion = new SAMLAssertion //(issuer,new Date(),new Date(),null,null,statements); (issuer, null, null, null, null, statements); Collection assertions = new ArrayList(); assertions.add(assertion); // Create the SAML Response SAMLResponse response = null; response = new SAMLResponse("artifact", subjects[0], assertions, null); Collection dsa_certs = new ArrayList(); for (int i = 0; i < OpenSamlHelper.certs.length; i++) dsa_certs.add(OpenSamlHelper.certs[i]); // Sign the Response try { response.sign(XMLSignature.ALGO_ID_SIGNATURE_RSA, OpenSamlHelper.privateKey, dsa_certs); } catch (SAMLException e) { System.out.println("SAMLException. Error signing the response."); e.printStackTrace(); } //response.toStream( System.out); return response; }
From source file:org.openhab.binding.heos.internal.resources.Telnet.java
/** * Connects to a host with the specified IP address and port * * @param ip IP Address of the host/*from www. jav a 2s .c o m*/ * @param port where to be connected * @return True if connection was successful * @throws SocketException * @throws IOException */ public boolean connect(String ip, int port) throws SocketException, IOException { this.ip = ip; this.port = port; try { address = InetAddress.getByName(ip); } catch (UnknownHostException e) { logger.debug("Unknown Host Exception - Message: {}", e.getMessage()); } return openConnection(); }
From source file:org.archive.modules.fetcher.FetchDNS.java
protected boolean isQuadAddress(final CrawlURI curi, final String dnsName, final CrawlHost targetHost) { boolean result = false; Matcher matcher = InetAddressUtil.IPV4_QUADS.matcher(dnsName); // If it's an ip no need to do a lookup if (matcher == null || !matcher.matches()) { return result; }//from w w w. j av a 2 s. co m result = true; // Ideally this branch would never be reached: no CrawlURI // would be created for numerical IPs if (logger.isLoggable(Level.WARNING)) { logger.warning("Unnecessary DNS CrawlURI created: " + curi); } try { targetHost.setIP( InetAddress.getByAddress(dnsName, new byte[] { (byte) (new Integer(matcher.group(1)).intValue()), (byte) (new Integer(matcher.group(2)).intValue()), (byte) (new Integer(matcher.group(3)).intValue()), (byte) (new Integer(matcher.group(4)).intValue()) }), CrawlHost.IP_NEVER_EXPIRES); // Never expire numeric IPs curi.setFetchStatus(S_DNS_SUCCESS); } catch (UnknownHostException e) { logger.log(Level.SEVERE, "Should never be " + e.getMessage(), e); setUnresolvable(curi, targetHost); } return result; }
From source file:org.exist.management.client.JMXServlet.java
/** * Register all known IP-addresses for localhost. *//*from w w w . ja va2 s . c o m*/ void registerLocalHostAddresses() { // The external IP address of the server try { localhostAddresses.add(InetAddress.getLocalHost().getHostAddress()); } catch (UnknownHostException ex) { LOG.warn(String.format("Unable to get HostAddress for localhost: %s", ex.getMessage())); } // The configured Localhost addresses try { for (InetAddress address : InetAddress.getAllByName("localhost")) { localhostAddresses.add(address.getHostAddress()); } } catch (UnknownHostException ex) { LOG.warn(String.format("Unable to retrieve ipaddresses for localhost: %s", ex.getMessage())); } if (localhostAddresses.isEmpty()) { LOG.error("Unable to determine addresses for localhost, jmx servlet might be disfunctional."); } }
From source file:org.apache.flink.runtime.taskmanager.TaskManager.java
public static TaskManager createTaskManager(ExecutionMode mode) throws Exception { // IMPORTANT! At this point, the GlobalConfiguration must have been read! final InetSocketAddress jobManagerAddress; LOG.info("Reading location of job manager from configuration"); final String address = GlobalConfiguration.getString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, null); final int port = GlobalConfiguration.getInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, ConfigConstants.DEFAULT_JOB_MANAGER_IPC_PORT); if (address == null) { throw new Exception("Job manager address not configured in the GlobalConfiguration."); }/* www . j a v a 2s . co m*/ // Try to convert configured address to {@link InetAddress} try { final InetAddress tmpAddress = InetAddress.getByName(address); jobManagerAddress = new InetSocketAddress(tmpAddress, port); } catch (UnknownHostException e) { LOG.error("Could not resolve JobManager host name."); throw new Exception("Could not resolve JobManager host name: " + e.getMessage(), e); } return createTaskManager(mode, jobManagerAddress); }
From source file:com.pushinginertia.commons.net.client.AbstractHttpPostClient.java
/** * Opens the TCP connection to the remote host and sends the given payload. * * @param con instantiated connection/*from w w w . ja v a2 s .c o m*/ * @param payload data to send * @throws HttpConnectException if there is a communication problem with the remote host */ protected void connectAndSend(final URLConnection con, final String payload) throws HttpConnectException { try { final OutputStream os = new BufferedOutputStream(con.getOutputStream()); os.write(payload.getBytes()); os.flush(); } catch (UnknownHostException e) { // thrown when the host name cannot be resolved final String msg = "Cannot resolve host [" + getHostName() + "]: " + e.getMessage(); LOG.error(getClass().getSimpleName(), msg, e); throw new HttpConnectException(msg, e); } catch (SocketTimeoutException e) { final String msg = "Timed out waiting for connection to [" + getUrl() + "]: " + e.getMessage(); LOG.error(getClass().getSimpleName(), msg, e); throw new HttpConnectException(msg, e); } catch (SocketException e) { final String msg = "Failed to connect to [" + getUrl() + "]: " + e.getMessage(); LOG.error(getClass().getSimpleName(), msg, e); throw new HttpConnectException(msg, e); } catch (Exception e) { final String msg = "A communication error occurred while trying to send payload to [" + getUrl() + "]: " + e.getMessage(); LOG.error(getClass().getSimpleName(), msg, e); throw new HttpConnectException(msg, e); } }
From source file:org.parosproxy.paros.core.proxy.ProxyParam.java
@Override protected void parse() { proxyIp = getConfig().getString(PROXY_IP, "localhost"); determineProxyIpAnyLocalAddress();/*from w ww. j av a 2s .com*/ try { proxyPort = getConfig().getInt(PROXY_PORT, 8080); } catch (Exception e) { } try { proxySSLPort = 8443; //getConfig().getInt(PROXY_SSL_PORT, 8443); } catch (Exception e) { } reverseProxyIp = getConfig().getString(REVERSE_PROXY_IP); if (reverseProxyIp.equalsIgnoreCase("localhost") || reverseProxyIp.equalsIgnoreCase("127.0.0.1")) { try { reverseProxyIp = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e1) { logger.error(e1.getMessage(), e1); } } reverseProxyHttpPort = getConfig().getInt(REVERSE_PROXY_HTTP_PORT, 80); reverseProxyHttpsPort = getConfig().getInt(REVERSE_PROXY_HTTPS_PORT, 443); useReverseProxy = getConfig().getInt(USE_REVERSE_PROXY, 0); modifyAcceptEncodingHeader = getConfig().getBoolean(MODIFY_ACCEPT_ENCODING_HEADER, true); alwaysDecodeGzip = getConfig().getBoolean(ALWAYS_DECODE_GZIP, true); loadSecurityProtocolsEnabled(); }