Enum ChannelEncryption

  • All Implemented Interfaces:
    Serializable, Comparable<ChannelEncryption>

    public enum ChannelEncryption
    extends Enum<ChannelEncryption>
    Represents different channel encryption modes.

    Channel encryption uses the SSL/TLS protocol and can either be negotiated during stream negotiation with the STARTTLS command or used directly.

    • Enum Constant Detail

      • REQUIRED

        public static final ChannelEncryption REQUIRED
        Channel encryption via TLS is required. If TLS is not negotiated during stream negotiation, the connection fails. This mode refers to the STARTTLS command used during stream negotiation.

        Receiving entities (servers) advertise support for STARTTLS and mark it as mandatory-to-negotiate by including an empty <required/> element in the <starttls/> element. Either entity closes the connection, if TLS has not been successfully negotiated.

        Also known as explicit TLS mode.

        See Also:
        STARTTLS Negotiation
      • OPTIONAL

        public static final ChannelEncryption OPTIONAL
        Channel encryption via TLS is optional.

        Communication starts in plain text and is then optionally upgraded to a secured connection, via the STARTTLS command during stream negotiation. Initiating entities (clients) try to negotiate TLS, if the receiving entity supports it, but do not enforce it. Receiving entities (servers) advertise support for STARTTLS, but do not mark it as mandatory-to-negotiate.

        This mode should be used with caution, since it's weak to a man-in-the-middle attack: an attacker could strip the STARTTLS command and the connection will be left unencrypted even if the server advertises support for TLS.

        See Also:
        STARTTLS Negotiation
      • DISABLED

        public static final ChannelEncryption DISABLED
        Channel encryption via TLS is disabled, i.e. the communication channel is unencrypted (using plain text).

        Initiating entities (clients) neither negotiate TLS via the STARTTLS command nor connect via a non-XMPP secure transport layer. Receiving entities (servers) do not advertise support for STARTTLS in their stream features.

        See Also:
        STARTTLS Negotiation
      • DIRECT

        public static final ChannelEncryption DIRECT
        TLS is attempted immediately on connect to a TCP socket, like how HTTPS works, not like how STARTTLS works with any protocol. The channel is always encrypted, communication never takes place in plain text.

        Also known as implicit TLS mode.

        See Also:
        XEP-0368: SRV records for XMPP over TLS
    • Method Detail

      • values

        public static ChannelEncryption[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ChannelEncryption c : ChannelEncryption.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ChannelEncryption valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null