Esempio n. 1
0
  public static HelloExtension fromByteArray(byte[] byteArray, ExtensionType type)
      throws HandshakeException {

    switch (type) {
        // the currently supported extensions, throws an exception if other extension type received
      case ELLIPTIC_CURVES:
        return SupportedEllipticCurvesExtension.fromByteArray(byteArray);
      case EC_POINT_FORMATS:
        return SupportedPointFormatsExtension.fromByteArray(byteArray);
      case CLIENT_CERT_TYPE:
        return ClientCertificateTypeExtension.fromByteArray(byteArray);
      case SERVER_CERT_TYPE:
        return ServerCertificateTypeExtension.fromByteArray(byteArray);

      default:
        AlertMessage alert =
            new AlertMessage(AlertLevel.FATAL, AlertDescription.UNSUPPORTED_EXTENSION);
        throw new HandshakeException(
            "Unsupported extension type received: " + type.toString(), alert);
    }
  }