Class CsrfProtectionFilter

  • All Implemented Interfaces:
    javax.ws.rs.client.ClientRequestFilter

    public class CsrfProtectionFilter
    extends java.lang.Object
    implements javax.ws.rs.client.ClientRequestFilter
    Simple client-side filter that adds X-Requested-By headers to all state-changing request (i.e. request for methods other than GET, HEAD and OPTIONS). This is to satisfy the requirements of the org.glassfish.jersey.server.filter.CsrfProtectionFilter on the server side.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HEADER_NAME
      Name of the header this filter will attach to the request.
      private static java.util.Set<java.lang.String> METHODS_TO_IGNORE  
      private java.lang.String requestedBy  
    • Constructor Summary

      Constructors 
      Constructor Description
      CsrfProtectionFilter()
      Creates a new instance of the filter with X-Requested-By header value set to empty string.
      CsrfProtectionFilter​(java.lang.String requestedBy)
      Initialized the filter with a desired value of the X-Requested-By header.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void filter​(javax.ws.rs.client.ClientRequestContext rc)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HEADER_NAME

        public static final java.lang.String HEADER_NAME
        Name of the header this filter will attach to the request.
        See Also:
        Constant Field Values
      • METHODS_TO_IGNORE

        private static final java.util.Set<java.lang.String> METHODS_TO_IGNORE
      • requestedBy

        private final java.lang.String requestedBy
    • Constructor Detail

      • CsrfProtectionFilter

        public CsrfProtectionFilter()
        Creates a new instance of the filter with X-Requested-By header value set to empty string.
      • CsrfProtectionFilter

        public CsrfProtectionFilter​(java.lang.String requestedBy)
        Initialized the filter with a desired value of the X-Requested-By header.
        Parameters:
        requestedBy - Desired value of X-Requested-By header the filter will be adding for all potentially state changing requests.
    • Method Detail

      • filter

        public void filter​(javax.ws.rs.client.ClientRequestContext rc)
                    throws java.io.IOException
        Specified by:
        filter in interface javax.ws.rs.client.ClientRequestFilter
        Throws:
        java.io.IOException