AEM 6.3 OSGi HTTP Whiteboard Filter not registering | Community
Skip to main content
Level 2
Apr 4, 2018 1:13 PM UTC
Solved

AEM 6.3 OSGi HTTP Whiteboard Filter not registering

I am trying to get a filter to fire before the authentication service fires, it looks like the HTTP whiteboard is the way to go.

I've been following instructions here https://helpx.adobe.com/experience-manager/kt/platform-repository/using/osgi-http-whiteboard-code-sample-develop.html and here https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/filters/impl/SampleServletFilter.java.

i see the init and activate methods firing when I install my code but the doFilter method never fires. If I go to http://localhost:4502/system/console/httpwhiteboard I see theres nothing under registered filter service (not sure if this is expected or not)

My annotations on the class look like this:

@Component

@Properties({

        @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX,

        value = { "/*"}),

        @Property( name = HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,

        value = ("(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=org.osgi.service.http)"

        )

)

})

@Service

-------

Any thoughts? Ideas?

smacdonald2008
smacdonald2008Accepted solution
Level 10
Apr 4, 2018 2:26 PM UTC

Our eng member noticed that you were not following the example as is.

@Component

@Properties({

                    // A major difference from Sling Filters is Servlet Filters can be registered via the Felix HTTP Whiteboard to URL path patterns.

                    // A Pattern OR Regex must be provided.

                    // http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.html#HTTP_WHITEBOARD_FILTER_PATTERN

                    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN,

                                value = { "/content/samples/" }),

                    // http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.html#HTTP_WHITEBOARD_FILTER_REGEX

                    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX,

                              value = { "/[a-z]*" }),

                    // http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.html#HTTP_WHITEBOARD_CONTEXT_SELECT

                    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,

                                value = "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)")

})

@Service

Can you try to use this exact sample and see if its working for you.

3 replies

Level 2
Apr 4, 2018 6:23 PM UTC

Thanks! This appears to work.

I was confused in the git file where it said " // A Pattern OR Regex must be provided."so I thought we had to use one or the other

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Apr 4, 2018 2:26 PM UTC

Our eng member noticed that you were not following the example as is.

@Component

@Properties({

                    // A major difference from Sling Filters is Servlet Filters can be registered via the Felix HTTP Whiteboard to URL path patterns.

                    // A Pattern OR Regex must be provided.

                    // http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.html#HTTP_WHITEBOARD_FILTER_PATTERN

                    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN,

                                value = { "/content/samples/" }),

                    // http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.html#HTTP_WHITEBOARD_FILTER_REGEX

                    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX,

                              value = { "/[a-z]*" }),

                    // http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.html#HTTP_WHITEBOARD_CONTEXT_SELECT

                    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,

                                value = "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)")

})

@Service

Can you try to use this exact sample and see if its working for you.

Translate
smacdonald2008
Level 10
Apr 4, 2018 1:58 PM UTC

We are checking with the team that wrote the Github code.

Translate