Annotation Type UnencryptedJsonCookie


  • @Target(PARAMETER)
    @Retention(RUNTIME)
    public @interface UnencryptedJsonCookie
    Create a cookie that is parsed to and from JSON. If setInResponse = true, the cookie will be written back to the response after the method completes. If the cookie is not read, it is initialized as "{}" (an empty JSON object) For example:
     @POST("/changeUser")
     public void changeUser(
         @UnencryptedJsonCookie(value = "userSession", setInResponse = true) Map<String, String> userSession,
         @RequestParameter("newUserName") String newUserName
     ) {
        logger.info("Changing username from {} to {}", userSession.get("username"), newUserName);
        userSession.set("username");
     }
     
    The first time this method (or any like it) is called over http, the client gets a cookie with a value like {"username": "something"}. Every time the method is called, a new cookie is returned to the client
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean isHttpOnly
      If false, omits the HttpOnly flag on the cookie, meaning that the cookie can be read by client-side JavaScript.
      boolean secure
      If false, omits the Secure flag on the cookie, meaning that the cookie will be sent over HTTP as well as HTTPS.
      boolean setInResponse  
      String value
      The name of the cookie
    • Element Detail

      • value

        String value
        The name of the cookie
        Default:
        ""
      • secure

        boolean secure
        If false, omits the Secure flag on the cookie, meaning that the cookie will be sent over HTTP as well as HTTPS. For testing purposes, action-controller always omits the Secure flag for localhost addresses
        Default:
        true
      • isHttpOnly

        boolean isHttpOnly
        If false, omits the HttpOnly flag on the cookie, meaning that the cookie can be read by client-side JavaScript. You normally want HttpOnly to mitigate the impact of Cross-site Scripting attacks
        Default:
        true
      • setInResponse

        boolean setInResponse
        Default:
        false