AEM 6.3 OSGi HTTP Whiteboard Filter not registering | Community
Skip to main content
Level 2
April 4, 2018
Solved

AEM 6.3 OSGi HTTP Whiteboard Filter not registering

  • April 4, 2018
  • 3 replies
  • 2552 views

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?

Best answer by smacdonald2008

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

smacdonald2008
Level 10
April 4, 2018

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

smacdonald2008
smacdonald2008Accepted solution
Level 10
April 4, 2018

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.

Level 2
April 4, 2018

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