/** * Returns canonical host name from which the request is made; used for doAs validation */ private static String getRequestingHost(String requestingUser, HttpServletRequest request) { final String unkHost = "???"; if(request == null) { LOG.warn("request is null; cannot determine hostname"); return unkHost; } try { String address = request.getRemoteAddr();//returns IP addr if(address == null) { LOG.warn(MessageFormat.format("Request remote address is NULL for user [{0}]", requestingUser)); return unkHost; } //Inet4Address/Inet6Address String hostName = InetAddress.getByName(address).getCanonicalHostName(); if(LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Resolved remote hostname: [{0}]", hostName)); } return hostName; } catch (UnknownHostException ex) { LOG.warn(MessageFormat.format("Request remote address could not be resolved, {0}", ex.toString(), ex)); return unkHost; } }
throw new IllegalArgumentException( String.format("%s value %s must be a valid host name. %s", name, value, ex.toString()));
conf.getString("dfs.datanode.dns.nameserver", "default")); } catch (UnknownHostException uhe) { LOG.error(uhe.toString()); hostName = "UNKNOWN.example.com";
public CIDR(String ip, int prefix) { try { this.address = InetAddress.getByName(ip); this.prefix = prefix; } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
private static boolean comeFromSameHost(String host) { try { String ipStr = Inet4Address.getLocalHost().getHostAddress(); return ipStr.equals(host); } catch (UnknownHostException e) { logger.error("unknown host exception : " + e.toString()); throw new RuntimeException("unknown host exception : " + e.toString()); } }
/** * Returns the highest v4 or v6 InetAddress * * @param v6 true for IPv6, false for Ipv4 * @return The highest IPv4 or IPv6 address */ public static InetAddress gethighestIP(boolean v6) { try { return (v6) ? InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") : InetAddress .getByName("255.255.255.255"); } catch(UnknownHostException e) { LOG.error("Exception received in gethighestIP", e.toString()); return null; } }
public void setHost(String host) { try { InetAddress hostAddress = InetAddress.getByName(host); if (!hostAddress.isAnyLocalAddress()) { this.host = hostAddress; } } catch (UnknownHostException e) { throw new RuntimeException(e.toString()); } }
@Override public void beginWindow(long windowId) { try { mongoClient = new MongoClient(hostName); db = mongoClient.getDB(dataBase); if (userName != null && passWord != null) { db.authenticate(userName, passWord.toCharArray()); } } catch (UnknownHostException ex) { logger.debug(ex.toString()); } }
@Override public void beginWindow(long windowId) { try { mongoClient = new MongoClient(hostName); db = mongoClient.getDB(dataBase); if (userName != null && passWord != null) { db.authenticate(userName, passWord.toCharArray()); } } catch (UnknownHostException ex) { logger.debug(ex.toString()); } }
private void handleBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel) throws OperationFailedException { context.removeService(SOCKET_BINDING.append(bindingName)); try { BindingAddHandler.installBindingService(context, bindingModel, bindingName, null); } catch (UnknownHostException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
/** * Constructor */ public JCollector(String probeId, JasmineIndicator def, int period) { this.indicator = def; this.period = period; this.probeId = probeId; try { this.hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { logger.warn("Cannot get host name for indicator {0} ({1})", def.getName(), e.toString()); } }
private void handleBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel) throws OperationFailedException { context.removeService(SOCKET_BINDING.append(bindingName)); try { BindingAddHandler.installBindingService(context, bindingModel, bindingName, null); } catch (UnknownHostException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
/** * IDs generate by this method are 10 byte long and have the highest bit of * their first byte set to zero. * This property may be used to generate other types of IDs. */ private static void startType0() throws ClusterException { try { InetAddress a = InetAddress.getLocalHost(); byte aa[] = a.getAddress(); startTypeIp(a); } catch (UnknownHostException e) { throw new ClusterException("Error in getLocalHost() : " + e.toString()); } }
public enum PortAvailability { illegalNumber, noPermission, inUse, unknown, OK };
public enum PortAvailability { illegalNumber, noPermission, inUse, unknown, OK };
/** * {@inheritDoc} */ @Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined() && value.getType() != ModelType.EXPRESSION) { String str = value.asString(); try { InetAddress.getByName(str); } catch (UnknownHostException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } } }
private void handleBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel, ServiceName serviceName) throws OperationFailedException { context.removeService(serviceName); try { BindingAddHandler.installBindingService(context, bindingModel, bindingName); } catch (UnknownHostException e) { throw new OperationFailedException(e.toString()); } }
private void handleBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel, ServiceName serviceName) throws OperationFailedException { context.removeService(serviceName); try { BindingAddHandler.installBindingService(context, bindingModel, bindingName); } catch (UnknownHostException e) { throw new OperationFailedException(e.toString()); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); String name = address.getLastElement().getValue(); try { installBindingService(context, model, name); } catch (UnknownHostException e) { throw new OperationFailedException(e.toString()); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); String name = address.getLastElement().getValue(); try { installBindingService(context, model, name); } catch (UnknownHostException e) { throw new OperationFailedException(e.toString()); } }