Package java.net

Examples of java.net.NetworkInterface


        }

        List<Client.HostPort> addresses = Lists.newArrayList();
        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        while (networkInterfaces.hasMoreElements()) {
            NetworkInterface ifc = networkInterfaces.nextElement();
            if (!ifc.isLoopback()) {
                for (InterfaceAddress address : ifc.getInterfaceAddresses()) {
                    addresses.add(new Client.HostPort(address.getAddress().getHostAddress(), port));
                }
            }
        }
        ClusterState zkState = new ClusterState(zk_str, FRANZ_BASE, new Info(serverId, addresses));
View Full Code Here


        List<Client.HostPort> addresses = Lists.newArrayList();

        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        while (networkInterfaces.hasMoreElements()) {
            NetworkInterface ifc = networkInterfaces.nextElement();
            if (!ifc.isLoopback()) {
                for (InterfaceAddress address : ifc.getInterfaceAddresses()) {
                    addresses.add(new Client.HostPort(address.getAddress().getHostAddress(), port));
                }
            }
        }
        serverId = new SecureRandom().nextLong();
View Full Code Here

    public static boolean isLocalRequest(HttpServletRequest req){
      boolean isLocal = false;
      String remoteIP = req.getRemoteAddr();
      try{
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
          NetworkInterface intf = en.nextElement();
          for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
            InetAddress inetAddress = enumIpAddr.nextElement();
            String address = inetAddress.getHostAddress();
            if(address.equals(remoteIP)) return true;
          }
        }
View Full Code Here

    private static String findAutoHostname() {
        try {
            Enumeration<NetworkInterface> interfaces = NetworkInterface
                    .getNetworkInterfaces();
            while (interfaces.hasMoreElements()) {
                NetworkInterface nwInterface = interfaces.nextElement();
                if (!nwInterface.isUp() || nwInterface.isLoopback()
                        || nwInterface.isVirtual()) {
                    continue;
                }
                Enumeration<InetAddress> addresses = nwInterface
                        .getInetAddresses();
                while (addresses.hasMoreElements()) {
                    InetAddress address = addresses.nextElement();
                    if (address.isLoopbackAddress()) {
                        continue;
View Full Code Here

            return cachedMacAddress;
        }
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                NetworkInterface network = networkInterfaces.nextElement();
                byte[] mac = network.getHardwareAddress();
                if (mac != null && mac.length > 0 && !network.isLoopback() && !network.isVirtual() && !network.isPointToPoint()) {
                    Logger.logDebug("Interface: " + network.getDisplayName() + " : " + network.getName());
                    cachedMacAddress = new byte[mac.length * 10];
                    for (int i = 0; i < cachedMacAddress.length; i++) {
                        cachedMacAddress[i] = mac[i - (Math.round(i / mac.length) * mac.length)];
                    }
                    return cachedMacAddress;
View Full Code Here

    } catch (SocketException e) {
      throw new IllegalStateException("Error reading network addresses", e);
    }

    while (networkInterfaces.hasMoreElements()) {
      NetworkInterface networkInterface = networkInterfaces.nextElement();
      List<InterfaceAddress> interfaceAddresses = networkInterface.getInterfaceAddresses();
      for (InterfaceAddress interfaceAddress : interfaceAddresses) {
        InetAddress address = interfaceAddress.getAddress();
        addresses.add(address);
      }
    }
View Full Code Here

      String superUserShortName) throws IOException {
    ArrayList<String> ipList = new ArrayList<String>();
    Enumeration<NetworkInterface> netInterfaceList = NetworkInterface
        .getNetworkInterfaces();
    while (netInterfaceList.hasMoreElements()) {
      NetworkInterface inf = netInterfaceList.nextElement();
      Enumeration<InetAddress> addrList = inf.getInetAddresses();
      while (addrList.hasMoreElements()) {
        InetAddress addr = addrList.nextElement();
        ipList.add(addr.getHostAddress());
      }
    }
View Full Code Here

      String superUserShortName) throws IOException {
    ArrayList<String> ipList = new ArrayList<String>();
    Enumeration<NetworkInterface> netInterfaceList = NetworkInterface
        .getNetworkInterfaces();
    while (netInterfaceList.hasMoreElements()) {
      NetworkInterface inf = netInterfaceList.nextElement();
      Enumeration<InetAddress> addrList = inf.getInetAddresses();
      while (addrList.hasMoreElements()) {
        InetAddress addr = addrList.nextElement();
        ipList.add(addr.getHostAddress());
      }
    }
View Full Code Here

          .getNetworkInterfaces();
      StringBuilder addresses = new StringBuilder(1);

      int i = 0;
      while (networkInterfaces.hasMoreElements()) {
        NetworkInterface networkInterface = networkInterfaces
            .nextElement();
        Enumeration<InetAddress> inetAddresses = networkInterface
            .getInetAddresses();
        while (inetAddresses.hasMoreElements()) {

          InetAddress inetAddress = inetAddresses.nextElement();
          String hostAddress = inetAddress.getHostAddress();
View Full Code Here

      if (req.getLocalAddr() == null || req.getLocalAddr().isEmpty()) {
        return false;
      }
      final Enumeration<NetworkInterface> e = NetworkInterface
          .getNetworkInterfaces();
      NetworkInterface ni;
      InetAddress ip;
      Enumeration<InetAddress> e2;
      while (e.hasMoreElements()) {
        ni = e.nextElement();
        e2 = ni.getInetAddresses();
        while (e2.hasMoreElements()) {
          ip = e2.nextElement();
          if (req.getRemoteAddr().equals(ip.getHostAddress())) {
            final Actor actor = ServiceProvider.IMPL
                .getCredentialService().getActorById(
View Full Code Here

TOP

Related Classes of java.net.NetworkInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.