//# 0 errors, 104 messages
//#
package net.sourceforge.pebble.confirmation;
    //#abstractconfirmationstrategy.java:1:1: class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#abstractconfirmationstrategy.java:1:1: method: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init

import net.sourceforge.pebble.PluginProperties;
import net.sourceforge.pebble.api.event.comment.CommentEvent;
import net.sourceforge.pebble.api.event.comment.CommentListener;
import net.sourceforge.pebble.api.confirmation.CommentConfirmationStrategy;
import net.sourceforge.pebble.api.confirmation.TrackBackConfirmationStrategy;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.domain.Comment;
import net.sourceforge.pebble.event.response.ContentSpamListener;
import net.sourceforge.pebble.event.response.IpAddressListener;
import net.sourceforge.pebble.event.response.LinkSpamListener;
import net.sourceforge.pebble.event.response.SpamScoreListener;
import net.sourceforge.pebble.util.SecurityUtils;
import net.sourceforge.pebble.PluginProperties;
import net.sourceforge.pebble.api.event.comment.CommentEvent;
import net.sourceforge.pebble.api.event.comment.CommentListener;
import net.sourceforge.pebble.api.confirmation.CommentConfirmationStrategy;
import net.sourceforge.pebble.api.confirmation.TrackBackConfirmationStrategy;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.domain.Comment;
import net.sourceforge.pebble.event.response.ContentSpamListener;
import net.sourceforge.pebble.event.response.IpAddressListener;
import net.sourceforge.pebble.event.response.LinkSpamListener;
import net.sourceforge.pebble.event.response.SpamScoreListener;
import net.sourceforge.pebble.util.SecurityUtils;

/**
 * Starting point for ConfirmationStrategy implementations.
 *
 * @author    Simon Brown
 */
public abstract class AbstractConfirmationStrategy implements CommentConfirmationStrategy, TrackBackConfirmationStrategy {
    //#abstractconfirmationstrategy.java:33: method: void net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy()
    //#abstractconfirmationstrategy.java:33: end of method: void net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy()

  /** the name of the required override property */
  public static final String REQUIRED_KEY = "CommentConfirmationStrategy.required";

  /**
   * Called to determine whether confirmation is required. This default
   * implementation returns false if the user is authenticated. Otherwise,
   * it runs the default set of comment listeners to determine
   * whether the comment is spam. If so, true is returned.
   *
   * @param comment the Comment being confirmed
   * @return true if the comment should be confirmed, false otherwise
   */
  public boolean confirmationRequired(Comment comment) {
    PluginProperties props = comment.getBlogEntry().getBlog().getPluginProperties();
    //#abstractconfirmationstrategy.java:48: method: bool net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.confirmationRequired(Comment)
    //#input(bool confirmationRequired(Comment)): comment
    //#input(bool confirmationRequired(Comment)): comment.__Tag
    //#input(bool confirmationRequired(Comment)): comment.blogEntry
    //#input(bool confirmationRequired(Comment)): comment.blogEntry.__Tag
    //#input(bool confirmationRequired(Comment)): comment.blogEntry.blog
    //#input(bool confirmationRequired(Comment)): comment.blogEntry.blog.__Tag
    //#input(bool confirmationRequired(Comment)): comment.blogEntry.blog.pluginProperties
    //#input(bool confirmationRequired(Comment)): comment.state
    //#input(bool confirmationRequired(Comment)): comment.state.__Tag
    //#input(bool confirmationRequired(Comment)): comment.state.name
    //#input(bool confirmationRequired(Comment)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#1).__Tag
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/api/event/comment/CommentListener.__Descendant_Table[others]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/api/event/comment/CommentListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Blog.__Descendant_Table[net/sourceforge/pebble/domain/Blog]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Blog.__Descendant_Table[others]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getPluginProperties()Lnet/sourceforge/pebble/PluginProperties;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[net/sourceforge/pebble/domain/BlogEntry]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[others]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[others]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.isApproved()Z
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/Response]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Response.__Descendant_Table[others]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/ResponseManager.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/State.APPROVED
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/State.__Descendant_Table[net/sourceforge/pebble/domain/State]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/State.__Descendant_Table[others]
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/State.__Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/State.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/AuditListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/comment/AbstractEmailNotificationListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/comment/CommentListenerSupport.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/comment/EmailAuthorNotificationListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/comment/EmailNotificationListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/ContentSpamListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/DeleteRejectedListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/DisableResponseListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/IpAddressListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/LinkSpamListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/MarkApprovedListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/MarkApprovedWhenAuthenticatedListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/MarkPendingListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/event/response/SpamScoreListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#input(bool confirmationRequired(Comment)): net/sourceforge/pebble/index/ResponseIndexListener.__Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(bool confirmationRequired(Comment)): return_value
    //#pre[1] (bool confirmationRequired(Comment)): comment != null
    //#pre[2] (bool confirmationRequired(Comment)): comment.__Tag == net/sourceforge/pebble/domain/Comment
    //#pre[3] (bool confirmationRequired(Comment)): comment.blogEntry != null
    //#pre[4] (bool confirmationRequired(Comment)): comment.blogEntry.__Tag == net/sourceforge/pebble/domain/BlogEntry
    //#pre[5] (bool confirmationRequired(Comment)): comment.blogEntry.blog != null
    //#pre[6] (bool confirmationRequired(Comment)): comment.blogEntry.blog.__Tag == net/sourceforge/pebble/domain/Blog
    //#pre[7] (bool confirmationRequired(Comment)): comment.blogEntry.blog.pluginProperties != null
    //#pre[8] (bool confirmationRequired(Comment)): (soft) comment.state != null
    //#pre[9] (bool confirmationRequired(Comment)): (soft) comment.state.__Tag == net/sourceforge/pebble/domain/State
    //#pre[10] (bool confirmationRequired(Comment)): (soft) init'ed(comment.state.name)
    //#presumption(bool confirmationRequired(Comment)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#1).name@66 != null
    //#post(bool confirmationRequired(Comment)): init'ed(return_value)
    //#unanalyzed(bool confirmationRequired(Comment)): Effects-of-calling:net.sourceforge.pebble.event.response.BlogEntryResponseListenerSupport
    //#unanalyzed(bool confirmationRequired(Comment)): Effects-of-calling:getState
    //#unanalyzed(bool confirmationRequired(Comment)): Effects-of-calling:java.util.EventObject
    //#unanalyzed(bool confirmationRequired(Comment)): Effects-of-calling:java.lang.String:equals
    //#test_vector(bool confirmationRequired(Comment)): java.lang.String:equalsIgnoreCase(...)@68: {1}, {0}
    //#test_vector(bool confirmationRequired(Comment)): net.sourceforge.pebble.PluginProperties:getProperty(...)@49: Addr_Set{null}, Inverse{null}
    //#test_vector(bool confirmationRequired(Comment)): net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(...)@52: {0}, {1}
    String required = props.getProperty(REQUIRED_KEY);
    //#abstractconfirmationstrategy.java:49: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.PluginProperties:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Comment)
    //#    unanalyzed callee: String net.sourceforge.pebble.PluginProperties:getProperty(String)

    Blog blog = comment.getBlogEntry().getBlog();
    if (SecurityUtils.isUserAuthorisedForBlog(blog)) {
    //#abstractconfirmationstrategy.java:52: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(Blog)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Comment)
    //#    unanalyzed callee: bool net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(Blog)
      return false;
    } else {
      // run a subset of the default comment listeners to figure out whether
      // the comment is spam
      CommentListener listener1 = new IpAddressListener();
      CommentListener listener2 = new LinkSpamListener();
      CommentListener listener3 = new ContentSpamListener();
      CommentListener listener4 = new SpamScoreListener();
      CommentEvent event = new CommentEvent(comment, CommentEvent.COMMENT_ADDED);

      listener1.commentAdded(event);
    //#abstractconfirmationstrategy.java:63: Warning: call too complex - analysis skipped
    //#    -- call on void commentAdded(CommentEvent)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Comment)
    //#    unanalyzed callee: void commentAdded(CommentEvent)
      listener2.commentAdded(event);
    //#abstractconfirmationstrategy.java:64: Warning: call too complex - analysis skipped
    //#    -- call on void commentAdded(CommentEvent)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Comment)
    //#    unanalyzed callee: void commentAdded(CommentEvent)
      listener3.commentAdded(event);
    //#abstractconfirmationstrategy.java:65: Warning: call too complex - analysis skipped
    //#    -- call on void commentAdded(CommentEvent)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Comment)
    //#    unanalyzed callee: void commentAdded(CommentEvent)
      listener4.commentAdded(event);
    //#abstractconfirmationstrategy.java:66: Warning: call too complex - analysis skipped
    //#    -- call on void commentAdded(CommentEvent)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Comment)
    //#    unanalyzed callee: void commentAdded(CommentEvent)

      return (required != null && required.equalsIgnoreCase("true")) || !comment.isApproved();
    //#abstractconfirmationstrategy.java:68: end of method: bool net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.confirmationRequired(Comment)
    }
  }

  /**
   * Called to determine whether confirmation is required.
   *
   * @param blog    the owning Blog
   * @return true if the confirmation is required, false otherwise
   */
  public boolean confirmationRequired(Blog blog) {
    return !SecurityUtils.isUserAuthorisedForBlog(blog);
    //#abstractconfirmationstrategy.java:79: method: bool net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.confirmationRequired(Blog)
    //#abstractconfirmationstrategy.java:79: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(Blog)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
    //#    method: bool confirmationRequired(Blog)
    //#    unanalyzed callee: bool net.sourceforge.pebble.util.SecurityUtils:isUserAuthorisedForBlog(Blog)
    //#input(bool confirmationRequired(Blog)): blog
    //#output(bool confirmationRequired(Blog)): return_value
    //#post(bool confirmationRequired(Blog)): init'ed(return_value)
    //#abstractconfirmationstrategy.java:79: end of method: bool net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.confirmationRequired(Blog)
  }

}    //#output(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): __Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy]
    //#output(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): __Dispatch_Table.confirmationRequired(Lnet/sourceforge/pebble/domain/Blog;)Z
    //#output(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): __Dispatch_Table.confirmationRequired(Lnet/sourceforge/pebble/domain/Comment;)Z
    //#output(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): net/sourceforge/pebble/api/confirmation/CommentConfirmationStrategy.__Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy]
    //#output(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): net/sourceforge/pebble/api/confirmation/ConfirmationStrategy.__Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy]
    //#output(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): net/sourceforge/pebble/api/confirmation/TrackBackConfirmationStrategy.__Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy]
    //#post(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): __Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): net/sourceforge/pebble/api/confirmation/CommentConfirmationStrategy.__Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): net/sourceforge/pebble/api/confirmation/ConfirmationStrategy.__Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): net/sourceforge/pebble/api/confirmation/TrackBackConfirmationStrategy.__Descendant_Table[net/sourceforge/pebble/confirmation/AbstractConfirmationStrategy] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): __Dispatch_Table.confirmationRequired(Lnet/sourceforge/pebble/domain/Blog;)Z == &confirmationRequired
    //#post(net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init): __Dispatch_Table.confirmationRequired(Lnet/sourceforge/pebble/domain/Comment;)Z == &confirmationRequired
    //#abstractconfirmationstrategy.java:: end of method: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy.net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy__static_init
    //#abstractconfirmationstrategy.java:: end of class: net.sourceforge.pebble.confirmation.AbstractConfirmationStrategy
