Class ParameterUtils

java.lang.Object
io.github.enxign.shed.toolkit.ParameterUtils

public final class ParameterUtils extends Object
파라미터 유틸리티 클래스 이 클래스는 HttpServletRequest에서 파라미터를 추출하고, XSS 공격을 방지하는 기능을 제공합니다.
Since:
2020-01-09
Version:
1.0
 수정일       수정자      수정내용
 ----------   ---------   -------------------------------
 2020-01-09   first       create
 
Author:
enxign
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    cleanXSS(Object object)
    XSS 공격을 방지하기 위해 객체의 모든 문자열 필드에서 위험한 문자를 제거합니다.
    static Map
    getParameterMap(javax.servlet.http.HttpServletRequest request, Map paramerterMap)
    HttpServletRequest에서 파라미터를 추출하여 Map 형태로 반환합니다.
    static Map
    getParameterMapWithOutSession(javax.servlet.http.HttpServletRequest request, Map paramerterMap)
    HttpServletRequest에서 파라미터를 추출하여 Map 형태로 반환합니다.
    static String
    replace(String text, String searchString, String replacement, int max)
    Replaces a String with another String inside a larger String, for the first max values of the search String.
    static String
    XSS 공격을 방지하기 위해 문자열에서 위험한 문자를 제거합니다.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ParameterUtils

      public ParameterUtils()
  • Method Details

    • getParameterMapWithOutSession

      public static Map getParameterMapWithOutSession(javax.servlet.http.HttpServletRequest request, Map paramerterMap)
      HttpServletRequest에서 파라미터를 추출하여 Map 형태로 반환합니다.
      Parameters:
      request - HttpServletRequest 객체
      paramerterMap - 파라미터 Map
      Returns:
      파라미터를 담은 Map
    • getParameterMap

      public static Map getParameterMap(javax.servlet.http.HttpServletRequest request, Map paramerterMap)
      HttpServletRequest에서 파라미터를 추출하여 Map 형태로 반환합니다.
      Parameters:
      request - HttpServletRequest 객체
      paramerterMap - 파라미터 Map
      Returns:
      파라미터를 담은 Map
    • replaceHTMLtoText

      public static String replaceHTMLtoText(String value)
      XSS 공격을 방지하기 위해 문자열에서 위험한 문자를 제거합니다.
      Parameters:
      value - 검사할 문자열
      Returns:
      XSS 공격이 제거된 문자열
    • replace

      public static String replace(String text, String searchString, String replacement, int max)

      Replaces a String with another String inside a larger String, for the first max values of the search String.

      A null reference passed to this method is a no-op.

       StringUtils.replace(null, *, *, *)         = null
       StringUtils.replace("", *, *, *)           = ""
       StringUtils.replace("any", null, *, *)     = "any"
       StringUtils.replace("any", *, null, *)     = "any"
       StringUtils.replace("any", "", *, *)       = "any"
       StringUtils.replace("any", *, *, 0)        = "any"
       StringUtils.replace("abaa", "a", null, -1) = "abaa"
       StringUtils.replace("abaa", "a", "", -1)   = "b"
       StringUtils.replace("abaa", "a", "z", 0)   = "abaa"
       StringUtils.replace("abaa", "a", "z", 1)   = "zbaa"
       StringUtils.replace("abaa", "a", "z", 2)   = "zbza"
       StringUtils.replace("abaa", "a", "z", -1)  = "zbzz"
       
      Parameters:
      text - text to search and replace in, may be null
      searchString - the String to search for, may be null
      replacement - the String to replace it with, may be null
      max - maximum number of values to replace, or -1 if no maximum
      Returns:
      the text with any replacements processed, null if null String input
    • cleanXSS

      public static Object cleanXSS(Object object)
      XSS 공격을 방지하기 위해 객체의 모든 문자열 필드에서 위험한 문자를 제거합니다.
      Parameters:
      object - 검사할 객체
      Returns:
      XSS 공격이 제거된 객체