@Test public void testFromByteArrayHandlesEmptyMessageCorrectly() throws HandshakeException { serializedMessage = new byte[]{0x00, 0x00, 0x00}; message = CertificateMessage.fromReader(new DatagramReader(serializedMessage), CertificateType.X_509, peerAddress); assertSerializedMessageLength(3); message = CertificateMessage.fromReader(new DatagramReader(serializedMessage), CertificateType.RAW_PUBLIC_KEY, peerAddress); assertSerializedMessageLength(3); }
public static CertificateMessage fromReader( DatagramReader reader, CertificateType certificateType, InetSocketAddress peerAddress) throws HandshakeException { if (CertificateType.RAW_PUBLIC_KEY == certificateType) { LOGGER.debug("Parsing RawPublicKey CERTIFICATE message"); int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS); byte[] rawPublicKey = reader.readBytes(certificateLength); return new CertificateMessage(rawPublicKey, peerAddress); } else if (CertificateType.X_509 == certificateType) { return readX509CertificateMessage(reader, peerAddress); } else { throw new IllegalArgumentException("Certificate type " + certificateType + " not supported!"); } }
CertificateMessage extends HandshakeMessage { public static CertificateMessage fromReader( DatagramReader reader, CertificateType certificateType, InetSocketAddress peerAddress) throws HandshakeException { if (CertificateType.RAW_PUBLIC_KEY == certificateType) { LOGGER.debug("Parsing RawPublicKey CERTIFICATE message"); int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS); byte[] rawPublicKey = reader.readBytes(certificateLength); return new CertificateMessage(rawPublicKey, peerAddress); } else if (CertificateType.X_509 == certificateType) { return readX509CertificateMessage(reader, peerAddress); } else { throw new IllegalArgumentException("Certificate type " + certificateType + " not supported!"); } } }
CertificateMessage extends HandshakeMessage { public static CertificateMessage fromReader( DatagramReader reader, CertificateType certificateType, InetSocketAddress peerAddress) throws HandshakeException { if (CertificateType.RAW_PUBLIC_KEY == certificateType) { LOGGER.debug("Parsing RawPublicKey CERTIFICATE message"); int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS); byte[] rawPublicKey = reader.readBytes(certificateLength); return new CertificateMessage(rawPublicKey, peerAddress); } else if (CertificateType.X_509 == certificateType) { return readX509CertificateMessage(reader, peerAddress); } else { throw new IllegalArgumentException("Certificate type " + certificateType + " not supported!"); } } 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 { public static CertificateMessage fromReader( DatagramReader reader, CertificateType certificateType, InetSocketAddress peerAddress) throws HandshakeException { if (CertificateType.RAW_PUBLIC_KEY == certificateType) { LOGGER.debug("Parsing RawPublicKey CERTIFICATE message"); int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS); byte[] rawPublicKey = reader.readBytes(certificateLength); return new CertificateMessage(rawPublicKey, peerAddress); } else if (CertificateType.X_509 == certificateType) { return readX509CertificateMessage(reader, peerAddress); } else { throw new IllegalArgumentException("Certificate type " + certificateType + " not supported!"); } } 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 { public static CertificateMessage fromReader( DatagramReader reader, CertificateType certificateType, InetSocketAddress peerAddress) throws HandshakeException { if (CertificateType.RAW_PUBLIC_KEY == certificateType) { LOGGER.debug("Parsing RawPublicKey CERTIFICATE message"); int certificateLength = reader.read(CERTIFICATE_LENGTH_BITS); byte[] rawPublicKey = reader.readBytes(certificateLength); return new CertificateMessage(rawPublicKey, peerAddress); } else if (CertificateType.X_509 == certificateType) { return readX509CertificateMessage(reader, peerAddress); } else { throw new IllegalArgumentException("Certificate type " + certificateType + " not supported!"); } } 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();  }