Java Code Examples for sun.security.util.BitArray#toByteArray()
The following examples show how to use
sun.security.util.BitArray#toByteArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IPAddressName.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 2
Source File: IPAddressName.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 3
Source File: IPAddressName.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen > 128) throw new IOException("IPv6Address prefix is longer than 128"); // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 4
Source File: IPAddressName.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 5
Source File: IPAddressName.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 6
Source File: IPAddressName.java From Bytecoder with Apache License 2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 7
Source File: IPAddressName.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 8
Source File: IPAddressName.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 9
Source File: IPAddressName.java From hottub with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 10
Source File: IPAddressName.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen > 128) throw new IOException("IPv6Address prefix is longer than 128"); // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 11
Source File: IPAddressName.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen > 128) throw new IOException("IPv6Address prefix is longer than 128"); // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 12
Source File: IPAddressName.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen < 0 || prefixLen > 128) { throw new IOException("IPv6Address prefix length (" + prefixLen + ") in out of valid range [0,128]"); } // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 13
Source File: IPAddressName.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen > 128) throw new IOException("IPv6Address prefix is longer than 128"); // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 14
Source File: IPAddressName.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen > 128) throw new IOException("IPv6Address prefix is longer than 128"); // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }
Example 15
Source File: IPAddressName.java From j2objc with Apache License 2.0 | 5 votes |
private void parseIPv6(String name) throws IOException { int slashNdx = name.indexOf('/'); if (slashNdx == -1) { address = InetAddress.getByName(name).getAddress(); } else { address = new byte[32]; byte[] base = InetAddress.getByName (name.substring(0, slashNdx)).getAddress(); System.arraycopy(base, 0, address, 0, 16); // append a mask corresponding to the num of prefix bits specified int prefixLen = Integer.parseInt(name.substring(slashNdx+1)); if (prefixLen > 128) throw new IOException("IPv6Address prefix is longer than 128"); // create new bit array initialized to zeros BitArray bitArray = new BitArray(MASKSIZE * 8); // set all most significant bits up to prefix length for (int i = 0; i < prefixLen; i++) bitArray.set(i, true); byte[] maskArray = bitArray.toByteArray(); // copy mask bytes into mask portion of address for (int i = 0; i < MASKSIZE; i++) address[MASKSIZE+i] = maskArray[i]; } }