Post Processor

What is a Sling Post Processor?

The SlingPostProcessor interface defines a service API to be implemented by service providers extending the Sling default POST servlet. Service providers may register OSGi services of this type to be used by the Sling default POST servlet to handle specific operations.

During a request the SlingPostOperation service is called with a list of registered post processors. After the operation has performed its changes but before the changes are persistent, all post processors are called.

To be more specific of its working, the SlingPostServlet service collects all available PostProcessor implementations. When a POST call occurs, each of the post processors can modify the metadata for doing something after the POST.

Sample Implementation for a Post Processor

@Component(metatype = false, immediate = true)
public class SamplePostProcessor implements SlingPostProcessor {
	public void process(SlingHttpServletRequest request, List<Modification> modificationList) throws Exception {
// Write your custom code here.
//POST servlet had already made its changes but the session hasn't been commited yet

Sometimes there might be a need to modify the AuthenticationInfo object using the post processor after authentication has been performed. In that scenario you have to implement AuthenticationInfoPostProcessor as shown in the below example:

@Component(label = "Sample Authentication Post Processor",
        description = "Sample Authentication Post Processor ensures that WCMMode is disabled for previewers.",
        immediate = true, metatype = true)
public class SampleAuthenticationInfoPostProcessor implements AuthenticationInfoPostProcessor {

    public static final Logger LOG = LoggerFactory.getLogger(SampleAuthenticationInfoPostProcessor.class);
    public void postProcess(AuthenticationInfo info, HttpServletRequest request, HttpServletResponse response) {

    	if(info == null) {
    		LOG.debug("AuthenticationInfo is null. " + "Skip post processing this request.");
    	String userId = info.getUser();
        if (StringUtils.isNotBlank(userId)) {
           /*Write your custom code here*/

    protected void activate(final ComponentContext componentContext) {
        final Dictionary<?, ?> properties = componentContext.getProperties();



2 thoughts on “Post Processor

  1. Pingback: Using Sling Post Processor to Ease Workflow’s Heavy Load | Terra Beata

  2. Hi Hashim,
    Is there a way to read SAML response in AuthenticationInfoPostProcessor instead of from samlResponse property which stores encrypted SAML response under the user node created after successful login?


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s