Class Encode

java.lang.Object
org.keycloak.common.util.Encode

public class Encode extends Object
Version:
$Revision: 1 $
Author:
Bill Burke
  • Constructor Details

    • Encode

      public Encode()
  • Method Details

    • encodeQueryString

      public static String encodeQueryString(String value)
      Keep encoded values "%..." and template parameters intact.
    • encodeQueryStringNotTemplateParameters

      public static String encodeQueryStringNotTemplateParameters(String value)
      Keep encoded values "%..." but not the template parameters.
      Parameters:
      value -
      Returns:
    • encodePath

      public static String encodePath(String value)
      Keep encoded values "%...", matrix parameters, template parameters, and '/' characters intact.
    • encodePathSegment

      public static String encodePathSegment(String value)
      Keep encoded values "%...", matrix parameters and template parameters intact.
    • encodeFragment

      public static String encodeFragment(String value)
      Keep encoded values "%..." and template parameters intact.
    • encodeFragmentNotTemplateParameters

      public static String encodeFragmentNotTemplateParameters(String value)
      Keep encoded values "%..." but not the template parameters.
      Parameters:
      value -
      Returns:
    • encodeMatrixParam

      public static String encodeMatrixParam(String value)
      Keep encoded values "%..." and template parameters intact.
    • encodeQueryParam

      public static String encodeQueryParam(String value)
      Keep encoded values "%..." and template parameters intact.
    • decodePath

      public static String decodePath(String path)
    • encodeNonCodes

      public static String encodeNonCodes(String string)
      Encode '%' if it is not an encoding sequence
      Parameters:
      string -
      Returns:
    • savePathParams

      public static boolean savePathParams(String segment, StringBuilder newSegment, List<String> params)
    • encodeValue

      public static String encodeValue(String segment, String[] encoding)
      Keep encoded values "%..." and template parameters intact i.e. "{x}"
      Parameters:
      segment -
      encoding -
      Returns:
    • encodePathAsIs

      public static String encodePathAsIs(String segment)
      Encode via RFC 3986. PCHAR is allowed allong with '/'

      unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

    • encodePathSaveEncodings

      public static String encodePathSaveEncodings(String segment)
      Keep any valid encodings from string i.e. keep "%2D" but don't keep "%p"
      Parameters:
      segment -
      Returns:
    • encodePathSegmentAsIs

      public static String encodePathSegmentAsIs(String segment)
      Encode via RFC 3986. PCHAR is allowed allong with '/'

      unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

    • encodePathSegmentSaveEncodings

      public static String encodePathSegmentSaveEncodings(String segment)
      Keep any valid encodings from string i.e. keep "%2D" but don't keep "%p"
      Parameters:
      segment -
      Returns:
    • encodeQueryParamAsIs

      public static String encodeQueryParamAsIs(String nameOrValue)
      Encodes everything of a query parameter name or value.
      Parameters:
      nameOrValue -
      Returns:
    • encodeQueryParamSaveEncodings

      public static String encodeQueryParamSaveEncodings(String segment)
      Keep any valid encodings from string i.e. keep "%2D" but don't keep "%p"
      Parameters:
      segment -
      Returns:
    • encodeFragmentAsIs

      public static String encodeFragmentAsIs(String nameOrValue)
    • encodeFromArray

      protected static String encodeFromArray(String segment, String[] encodingMap, boolean encodePercent)
    • pathParamReplacement

      public static String pathParamReplacement(String segment, List<String> params)
    • decode

      decode an encoded map
      Parameters:
      map -
      Returns:
    • decode

      public static MultivaluedHashMap<String,String> decode(MultivaluedHashMap<String,String> map, String charset)
      decode an encoded map
      Parameters:
      map -
      charset -
      Returns:
    • encode

    • decode

      public static String decode(String string)
    • urlEncode

      public static String urlEncode(String string)
      Parameters:
      string -
      Returns:
      URL encoded input
    • urlDecode

      public static String urlDecode(String string)
      Parameters:
      string -
      Returns:
      URL decoded input