I created a ticket for that: https://issues.apache.org/jira/browse/SLING-6559 
<https://issues.apache.org/jira/browse/SLING-6559>
and attached a simple project that can be built with:

        mvn clean install

With Composum it can also be auto-deployed (include the Trace Logger):

        mvn clean install -P auto-deploy-all

Cheers - Andy Schaefer

> On Feb 23, 2017, at 7:00 AM, Andreas Schaefer Sr. <schaef...@me.com> wrote:
> 
> I finally was able to place my filter where I wanted it. I could not figure 
> it out
> in the Sling source but the bundle provided my the necessary info.
> 
> This is the Filter Service configuration to make it appear right after the 
> SSL Filter:
> 
> @Component( immediate = true, label="Parameter Issue Filter", 
> description="Filters Requests to demonstrate the Parameter Issue in Sling", 
> metatype=false )
> @Service
> @Properties(
>     {
>         @Property(name = "osgi.http.whiteboard.filter.pattern", value="/"),
>         @Property(name = "osgi.http.whiteboard.context.select", 
> value="(osgi.http.whiteboard.context.name=*)"),
>         @Property(name = Constants.SERVICE_DESCRIPTION, value = "Filters 
> Requests to demonstrate the Parameter Issue in Sling"),
>         @Property(name = Constants.SERVICE_VENDOR, value = "Madplanet.com 
> <http://madplanet.com/>")
>     }
> )
> 
> With that I am setting the missing parameters which appear in an attribute of
> type SlingBindings.
> 
> - Andy
> 
>> On Feb 20, 2017, at 1:45 PM, Andreas Schaefer Sr. <schaef...@me.com 
>> <mailto:schaef...@me.com>> wrote:
>> 
>> Hi Julian
>> 
>> Thanks for the help.
>> 
>> I tried to figure out how the I18NFilter is registered in Sling but it 
>> eludes me.
>> Any hint would be appreciated.
>> 
>> Cheers - Andy
>> 
>>> On Feb 20, 2017, at 1:47 AM, Julian Sedding <jsedd...@gmail.com 
>>> <mailto:jsedd...@gmail.com>> wrote:
>>> 
>>> Hi Andy
>>> 
>>> You can register a javax.servlet.Filter with Sling OR with the Felix
>>> Whiteboard. If you want to run before the SlingMainServlet, you have
>>> to register your filter in the Felix whiteboard (which is what the
>>> I18NFilter does). Note that you will not have access to
>>> SlingHttpServletRequest objects in that case.
>>> 
>>> The documentation for the Felix Whiteboard describes properties to
>>> select a specific HTTP context[0] by adding some properties. Maybe
>>> that helps you to get your code working.
>>> 
>>> Regards
>>> Julian
>>> 
>>> [0] 
>>> https://felix.apache.org/documentation/subprojects/apache-felix-http-service.html#filter-service-properties
>>>  
>>> <https://felix.apache.org/documentation/subprojects/apache-felix-http-service.html#filter-service-properties>
>>> 
>>> 
>>> On Sat, Feb 18, 2017 at 1:59 AM, Andreas Schaefer Sr. <schaef...@me.com 
>>> <mailto:schaef...@me.com>> wrote:
>>>> Hi
>>>> 
>>>> I tried to create a Filter to showcase the issue but I do fail with the 
>>>> latest
>>>> code base.
>>>> 
>>>> The reason is that I cannot add a filter ahead of the Sling Main Servlet 
>>>> even
>>>> though there is the I18N and SSL Filter that are running ahead of it.
>>>> For a customer I use that in order to adjust the query string and the 
>>>> parameters
>>>> and of late also the session timeout (bug in felix).
>>>> 
>>>> Funny thing is that my filter is called when I access the OSGi Console then
>>>> the filter is called just not when I work with a sling page (slingshot).
>>>> 
>>>> Question: is is still possible to add a filter ahead of Sling Main Servlet 
>>>> and if
>>>> so what are the configuration. This is what I tried:
>>>> 
>>>> 1) Does only work if sling some is enabled but then I am not ahead of the 
>>>> Sling Main Servlet
>>>> 
>>>> //@Component( immediate = true, label="Parameter Issue Filter", 
>>>> description="Filters Requests to demonstrate the Parameter Issue in 
>>>> Sling", metatype=false )
>>>> //@Service
>>>> //@Properties(
>>>> //    {
>>>> //        @Property( name="service.description", value="Parameter Issue 
>>>> Filter" ),
>>>> //        @Property( name="service.vendor", value="Adobe" ),
>>>> ////        @Property(name="sling.filter.scope", value="request")
>>>> //        @Property( name="pattern", value="/", propertyPrivate=true )
>>>> //    }
>>>> //)
>>>> 
>>>> 2) Taken from the SslFilter but I am not ahead of the Sling Main Servlet
>>>> 
>>>> //@SlingFilter(generateService = true, label = "Parameter Issue Filter",
>>>> //    order = 500, scope = { SlingFilterScope.REQUEST, 
>>>> SlingFilterScope.ERROR })
>>>> //@Properties({
>>>> //    @Property(name = "pattern", value="/.*"),
>>>> //    @Property(name = Constants.SERVICE_DESCRIPTION, value = "Filters 
>>>> Requests to demonstrate the Parameter Issue in Sling"),
>>>> //    @Property(name = Constants.SERVICE_VENDOR, value = "Madplanet.com 
>>>> <http://madplanet.com/>") })
>>>> 
>>>> 2) Taken from the I18NFilter but this one is not called for Sling page
>>>> 
>>>> @Component(immediate = true, policy = ConfigurationPolicy.IGNORE, label = 
>>>> "Parameter Issue Filter")
>>>> @Service(value = Filter.class)
>>>> @Properties({
>>>>    @Property(name = "pattern", value = "/.*"),
>>>>    @Property(name = Constants.SERVICE_RANKING, intValue = 0x8100),
>>>>    @Property(name = "service.description", value = "Filters Requests to 
>>>> demonstrate the Parameter Issue in Sling"),
>>>>    @Property(name = "service.vendor", value = "Madplanet.com 
>>>> <http://madplanet.com/>")
>>>> })
>>>> 
>>>> I traced it down to the Per Context Handler Registry but I am unable to 
>>>> register
>>>> my Filter with the one responsible for Sling pages.
>>>> 
>>>> Any help would be greatly appreciated.
>>>> 
>>>> This is 3rd client where I had to use a Filter ahead of the Sling Resource 
>>>> Resolution
>>>> do make changes to the request before the resource is resolved.
>>>> 
>>>> 
>>>> If that is not possible is there a way to make changes to the sling 
>>>> resource
>>>> in a filter like when I rewrite the URL to manage (AEM) dispatcher cache
>>>> for stuff like CSS or images?
>>>> 
>>>> Thanks - Andy Schaefer
>>>> 
>>>>> On Feb 16, 2017, at 4:05 AM, Robert Munteanu <romb...@apache.org 
>>>>> <mailto:romb...@apache.org>> wrote:
>>>>> 
>>>>> Hi Andy,
>>>>> 
>>>>> On Tue, 2017-02-14 at 14:05 -0800, Andreas Schaefer Sr. wrote:
>>>>>> While working on AEM 6.2 SP1 with a Servlet Filter
>>>>>> I came across issues with the Parameter Support
>>>>>> as they interfere with the Servlet Filters or at least
>>>>>> with Servlet Filters that are handled before entering
>>>>>> the “Sling domain”.
>>>>>> 
>>>>>> 1) Because of the SlingHttpContext.handleSecurity()
>>>>>> the Parameter Support is created as one of the first
>>>>>> Servlet Filters.
>>>>>> 2) That Parameter Support reads the parameters from the
>>>>>> Servlet Input stream
>>>>>> 
>>>>>> 3) The Parameter Support Request Wrapper is ditched later
>>>>>> 
>>>>>> 4) Any later filter will not have access to the parameters
>>>>>> from the request
>>>>>> 
>>>>>> 5) Any Filter that wraps the Servlet Request to change
>>>>>> either the Query String or Parameter(s) will do that in vein
>>>>>> as the stored Parameter Support in 1) will provide the
>>>>>> parameters for anything in Sling
>>>>>> 
>>>>>> In my current project I am storing the Query String
>>>>>> which can be quite long in a Session and re-hydrate
>>>>>> that in a Filter. This worked in AEM 6.0 but now fails
>>>>>> due to the issues from above.
>>>>>> 
>>>>>> I don’t mind the Parameter Support but it should
>>>>>> check in the getInstance() method if the request was wrapped
>>>>>> and if then update the parameters from it.
>>>>> 
>>>>> This is not my domain of expertise, but creating a new ticket with a
>>>>> failing test would make this issue easier to tackle.
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> Robert
>>>>> 
>>>>>> 
>>>>>> I think this issue is related to this ticket:
>>>>>> 
>>>>>> https://issues.apache.org/jira/browse/SLING-3439?jql=text%20~%20%22Pa 
>>>>>> <https://issues.apache.org/jira/browse/SLING-3439?jql=text%20~%20%22Pa> 
>>>>>> <https://issues.apache.org/jira/browse/SLING-3439?jql=text%20~%20%22Pa 
>>>>>> <https://issues.apache.org/jira/browse/SLING-3439?jql=text%20~%20%22Pa>>
>>>>>> rameterSupport%22 <https://issues.apache.org/jira/browse/SLING- 
>>>>>> <https://issues.apache.org/jira/browse/SLING-> 
>>>>>> <https://issues.apache.org/jira/browse/SLING- 
>>>>>> <https://issues.apache.org/jira/browse/SLING->>
>>>>>> 3439?jql=text%20~%20%22ParameterSupport%22>
>>>>>> 
>>>>>> Cheers - Andy Schaefer
>> 
> 

Reply via email to