Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

AEM 6.3 OSGi HTTP Whiteboard Filter not registering

Avatar

Level 3

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-sa... and here https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/ad....

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?

1 Accepted Solution

Avatar

Correct answer by
Level 10

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...

                    @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...

                    @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...

                    @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.

View solution in original post

3 Replies

Avatar

Level 10

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

Avatar

Correct answer by
Level 10

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...

                    @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...

                    @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...

                    @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.

Avatar

Level 3

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