@Test public void testFragmentToByteArrayCompliesWithRfc7250() throws Exception { givenARawPublicKeyCertificateMessage(serverPublicKey); serializedMessage = message.fragmentToByteArray(); assertThatSerializedRawPublicKeyMessageCompliesWithRfc7250(); }
@Override public byte[] fragmentToByteArray() { DatagramWriter writer = new DatagramWriter(); if (rawPublicKeyBytes == null) { writer.write(getMessageLength() - (CERTIFICATE_LENGTH_BITS / Byte.SIZE), CERTIFICATE_LIST_LENGTH_BITS); for (byte[] encoded : encodedChain) { writer.write(encoded.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(encoded); } } else { writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(rawPublicKeyBytes); } return writer.toByteArray(); }
CertificateMessage extends HandshakeMessage { @Override public byte[] fragmentToByteArray() { DatagramWriter writer = new DatagramWriter(); if (rawPublicKeyBytes == null) { writer.write(getMessageLength() - (CERTIFICATE_LENGTH_BITS / Byte.SIZE), CERTIFICATE_LIST_LENGTH_BITS); for (byte[] encoded : encodedChain) { writer.write(encoded.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(encoded); } } else { writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(rawPublicKeyBytes); } return writer.toByteArray(); } }
CertificateMessage extends HandshakeMessage { @Override public byte[] fragmentToByteArray() { DatagramWriter writer = new DatagramWriter(); if (rawPublicKeyBytes == null) { writer.write(getMessageLength() - (CERTIFICATE_LENGTH_BITS / Byte.SIZE), CERTIFICATE_LIST_LENGTH_BITS); for (byte[] encoded : encodedChain) { writer.write(encoded.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(encoded); } } else { writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(rawPublicKeyBytes); } return writer.toByteArray(); } CertificateMessage(List<X509Certificate> certificateChain, InetSocketAddress peerAddress);  CertificateMessage(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities,
			InetSocketAddress peerAddress); private  CertificateMessage(CertPath peerCertChain, InetSocketAddress peerAddress);  CertificateMessage(PublicKey publicKey, InetSocketAddress peerAddress);  CertificateMessage(byte[] rawPublicKeyBytes, InetSocketAddress peerAddress); }
CertificateMessage extends HandshakeMessage { @Override public byte[] fragmentToByteArray() { DatagramWriter writer = new DatagramWriter(); if (rawPublicKeyBytes == null) { writer.write(getMessageLength() - (CERTIFICATE_LENGTH_BITS / Byte.SIZE), CERTIFICATE_LIST_LENGTH_BITS); for (byte[] encoded : encodedChain) { writer.write(encoded.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(encoded); } } else { writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(rawPublicKeyBytes); } return writer.toByteArray(); } CertificateMessage(List<X509Certificate> certificateChain, InetSocketAddress peerAddress);  CertificateMessage(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities,
			InetSocketAddress peerAddress); private  CertificateMessage(CertPath peerCertChain, InetSocketAddress peerAddress);  CertificateMessage(PublicKey publicKey, InetSocketAddress peerAddress);  CertificateMessage(byte[] rawPublicKeyBytes, InetSocketAddress peerAddress); @Override HandshakeType getMessageType(); @Override int getMessageLength(); @Override String toString(); CertPath getCertificateChain(); boolean isEmpty(); @Override byte[] fragmentToByteArray(); static CertificateMessage fromReader(
			DatagramReader reader,
			CertificateType certificateType,
			InetSocketAddress peerAddress); PublicKey getPublicKey(); }
CertificateMessage extends HandshakeMessage { @Override public byte[] fragmentToByteArray() { DatagramWriter writer = new DatagramWriter(); if (rawPublicKeyBytes == null) { writer.write(getMessageLength() - (CERTIFICATE_LENGTH_BITS / Byte.SIZE), CERTIFICATE_LIST_LENGTH_BITS); for (byte[] encoded : encodedChain) { writer.write(encoded.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(encoded); } } else { writer.write(rawPublicKeyBytes.length, CERTIFICATE_LENGTH_BITS); writer.writeBytes(rawPublicKeyBytes); } return writer.toByteArray(); } CertificateMessage(List<X509Certificate> certificateChain, InetSocketAddress peerAddress);  CertificateMessage(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities,
			InetSocketAddress peerAddress); private  CertificateMessage(CertPath peerCertChain, InetSocketAddress peerAddress);  CertificateMessage(PublicKey publicKey, InetSocketAddress peerAddress);  CertificateMessage(byte[] rawPublicKeyBytes, InetSocketAddress peerAddress); @Override HandshakeType getMessageType(); @Override int getMessageLength(); @Override String toString(); CertPath getCertificateChain(); boolean isEmpty(); @Override byte[] fragmentToByteArray(); static CertificateMessage fromReader(
			DatagramReader reader,
			CertificateType certificateType,
			InetSocketAddress peerAddress); PublicKey getPublicKey();  }