//# 0 errors, 26 messages
//#
package net.sourceforge.pebble.web.tagext;
    //#isblogpublishertag.java:1:1: class: net.sourceforge.pebble.web.tagext.IsBlogPublisherTag
    //#isblogpublishertag.java:1:1: method: net.sourceforge.pebble.web.tagext.IsBlogPublisherTag.net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init

import net.sourceforge.pebble.domain.AbstractBlog;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.Constants;
import net.sourceforge.pebble.util.SecurityUtils;

import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.http.HttpServletRequest;

/**
 * A custom tag that includes its body content if the current user belongs to
 * the "blog publisher" role for the blog.
 *
 * @author    Simon Brown
 */
public class IsBlogPublisherTag extends TagSupport {
    //#isblogpublishertag.java:18: method: void net.sourceforge.pebble.web.tagext.IsBlogPublisherTag.net.sourceforge.pebble.web.tagext.IsBlogPublisherTag()
    //#input(void net.sourceforge.pebble.web.tagext.IsBlogPublisherTag()): this
    //#isblogpublishertag.java:18: end of method: void net.sourceforge.pebble.web.tagext.IsBlogPublisherTag.net.sourceforge.pebble.web.tagext.IsBlogPublisherTag()

  /**
   * Implementation from the Tag interface - this is called when the opening tag
   * is encountered.
   *
   * @return  an integer specifying what to do afterwards
   * @throws  javax.servlet.jsp.JspException    if something goes wrong
   */
  public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
    //#isblogpublishertag.java:28: method: int net.sourceforge.pebble.web.tagext.IsBlogPublisherTag.doStartTag()
    //#input(int doStartTag()): this
    //#input(int doStartTag()): this.pageContext
    //#output(int doStartTag()): return_value
    //#pre[2] (int doStartTag()): this.pageContext != null
    //#presumption(int doStartTag()): javax.servlet.jsp.PageContext:getRequest(...)@28 != null
    //#post(int doStartTag()): return_value in 0..1
    //#unanalyzed(int doStartTag()): Effects-of-calling:org.acegisecurity.Authentication:getName
    //#unanalyzed(int doStartTag()): Effects-of-calling:org.acegisecurity.context.SecurityContextHolder:getContext
    //#unanalyzed(int doStartTag()): Effects-of-calling:org.acegisecurity.context.SecurityContext:getAuthentication
    //#unanalyzed(int doStartTag()): Effects-of-calling:org.acegisecurity.Authentication:getAuthorities
    //#unanalyzed(int doStartTag()): Effects-of-calling:org.acegisecurity.GrantedAuthority:getAuthority
    //#unanalyzed(int doStartTag()): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(int doStartTag()): Effects-of-calling:net.sourceforge.pebble.domain.Blog:isUserInRole
    AbstractBlog abstractBlog = (AbstractBlog)request.getAttribute(Constants.BLOG_KEY);

    if (abstractBlog instanceof Blog) {
      Blog blog = (Blog)abstractBlog;
      if (SecurityUtils.isUserAuthorisedForBlogAsBlogPublisher(blog)) {
        return EVAL_BODY_INCLUDE;
      }
    }

    return SKIP_BODY;
    //#isblogpublishertag.java:38: end of method: int net.sourceforge.pebble.web.tagext.IsBlogPublisherTag.doStartTag()
  }

}
    //#output(net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init): __Descendant_Table[net/sourceforge/pebble/web/tagext/IsBlogPublisherTag]
    //#output(net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init): __Dispatch_Table.doStartTag()I
    //#post(net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init): __Descendant_Table[net/sourceforge/pebble/web/tagext/IsBlogPublisherTag] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init): __Dispatch_Table.doStartTag()I == &doStartTag
    //#isblogpublishertag.java:: end of method: net.sourceforge.pebble.web.tagext.IsBlogPublisherTag.net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init
    //#isblogpublishertag.java:: end of class: net.sourceforge.pebble.web.tagext.IsBlogPublisherTag
