Enum ProtectionContext

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ProtectionContext>

    public enum ProtectionContext
    extends java.lang.Enum<ProtectionContext>
    This enumeration defines the context for executing XSS protection.

    The specified rules refer to http://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      HTML_HTML_CONTENT
      Escape HTML for use inside element content (rules #6 and - to some degree - #1), using a policy to remove potentially malicous HTML
      PLAIN_HTML_CONTENT
      Escape plain text for use inside HTML content (rule #1)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ProtectionContext fromName​(java.lang.String name)
      Gets a protection context from the specified name.
      java.lang.String getName()
      Gets the name of the protection context.
      static ProtectionContext valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ProtectionContext[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • HTML_HTML_CONTENT

        public static final ProtectionContext HTML_HTML_CONTENT
        Escape HTML for use inside element content (rules #6 and - to some degree - #1), using a policy to remove potentially malicous HTML
      • PLAIN_HTML_CONTENT

        public static final ProtectionContext PLAIN_HTML_CONTENT
        Escape plain text for use inside HTML content (rule #1)
    • Method Detail

      • values

        public static ProtectionContext[] 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 (ProtectionContext c : ProtectionContext.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ProtectionContext valueOf​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getName

        public java.lang.String getName()
        Gets the name of the protection context.
        Returns:
        The name of the protection context
      • fromName

        public static ProtectionContext fromName​(java.lang.String name)
        Gets a protection context from the specified name.
        Parameters:
        name - The name to get the protection context from
        Returns:
        The protection context; null if an invalid protection context has been specified