//# 0 errors, 79 messages
//#
/*
    //#CommentAuthenticatorServlet.java:1:1: class: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.rendering.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentAuthenticator;
import org.apache.roller.weblogger.ui.rendering.plugins.comments.DefaultCommentAuthenticator;


/**
 * The CommentAuthenticatorServlet is used for generating the html used for
 * comment authentication.  This is done outside of the normal rendering process
 * so that we can cache full pages and still set the comment authentication
 * section dynamically.
 *
 * @web.servlet name="CommentAuthenticatorServlet" load-on-startup="7"
 * @web.servlet-mapping url-pattern="/CommentAuthenticatorServlet"
 */
public class CommentAuthenticatorServlet extends HttpServlet {
    //#CommentAuthenticatorServlet.java:44: method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet()
    //#input(void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet()): this.authenticator
    //#post(void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet()): this.authenticator == null
    
    private static Log mLogger = 
    //#CommentAuthenticatorServlet.java:46: method: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init
    //#CommentAuthenticatorServlet.java:46: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet
    //#    method: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/servlets/CommentAuthenticatorServlet]
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Dispatch_Table.destroy()V
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Dispatch_Table.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Dispatch_Table.init(Ljavax/servlet/ServletConfig;)V
    //#output(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): mLogger
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/servlets/CommentAuthenticatorServlet] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Dispatch_Table.destroy()V == &destroy
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Dispatch_Table.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V == &doGet
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): __Dispatch_Table.init(Ljavax/servlet/ServletConfig;)V == &init
    //#post(org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init): init'ed(mLogger)
    //#CommentAuthenticatorServlet.java:46: end of method: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet__static_init
        LogFactory.getLog(CommentAuthenticatorServlet.class);
    
    private CommentAuthenticator authenticator = null;
    //#CommentAuthenticatorServlet.java:49: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet()
    
    
    /**
     * Handle incoming http GET requests.
     *
     * We only handle get requests.
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

        response.setContentType("text/html; charset=utf-8");
    //#CommentAuthenticatorServlet.java:60: method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.doGet(HttpServletRequest, HttpServletResponse)
    //#CommentAuthenticatorServlet.java:60: Warning: suspicious precondition
    //#    the precondition for this.authenticator.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet
    //#    method: void doGet(HttpServletRequest, HttpServletResponse)
    //#    suspicious precondition index: [5]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): " + "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): " = "._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "" .><.p>"._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): ""._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "<.p><p>"._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "<input name="answer" value=""._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): "<p>"._tainted
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/DefaultCommentAuthenticator]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[others]
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Dispatch_Table.getHtml(Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/DefaultCommentAuthenticator.__Dispatch_Table.getHtml(Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.__Dispatch_Table.getHtml(Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): request
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): response
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): this
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): this.authenticator
    //#input(void doGet(HttpServletRequest, HttpServletResponse)): this.authenticator.__Tag
    //#pre[2] (void doGet(HttpServletRequest, HttpServletResponse)): response != null
    //#pre[4] (void doGet(HttpServletRequest, HttpServletResponse)): this.authenticator != null
    //#pre[5] (void doGet(HttpServletRequest, HttpServletResponse)): this.authenticator.__Tag in {org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator, org/apache/roller/weblogger/ui/rendering/plugins/comments/DefaultCommentAuthenticator, org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator}
    //#presumption(void doGet(HttpServletRequest, HttpServletResponse)): javax.servlet.http.HttpServletResponse:getWriter(...)@67 != null
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getSession
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpSession:getAttribute
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.Math:random
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.Integer
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpSession:setAttribute
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:javax.servlet.http.HttpServletRequest:getParameter
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuffer:append
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.util.ResourceBundle:getString
    //#unanalyzed(void doGet(HttpServletRequest, HttpServletResponse)): Effects-of-calling:java.lang.StringBuffer:toString

        // Convince proxies and IE not to cache this.
        response.addHeader("Pragma", "no-cache");
        response.addHeader("Cache-Control", "no-cache");
        response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:00 GMT");

        PrintWriter out = response.getWriter();
        out.println(this.authenticator.getHtml(request));
    }
    //#CommentAuthenticatorServlet.java:69: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.doGet(HttpServletRequest, HttpServletResponse)
    
    
    /** 
     * Initialization.
     */
    public void init(ServletConfig config) throws ServletException {
        
        super.init(config);
    //#CommentAuthenticatorServlet.java:77: method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.init(ServletConfig)
    //#input(void init(ServletConfig)): config
    //#input(void init(ServletConfig)): mLogger
    //#input(void init(ServletConfig)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator]
    //#input(void init(ServletConfig)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/DefaultCommentAuthenticator]
    //#input(void init(ServletConfig)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator]
    //#input(void init(ServletConfig)): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator.__Descendant_Table[others]
    //#input(void init(ServletConfig)): this
    //#output(void init(ServletConfig)): new DefaultCommentAuthenticator(init#1) num objects
    //#output(void init(ServletConfig)): new DefaultCommentAuthenticator(init#1).__Tag
    //#output(void init(ServletConfig)): this.authenticator
    //#new obj(void init(ServletConfig)): new DefaultCommentAuthenticator(init#1)
    //#pre[2] (void init(ServletConfig)): (soft) mLogger != null
    //#presumption(void init(ServletConfig)): java.lang.Class:forName(...)@83 != null
    //#presumption(void init(ServletConfig)): java.lang.Class:newInstance(...).__Tag@84 in {org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentAuthenticator, org/apache/roller/weblogger/ui/rendering/plugins/comments/DefaultCommentAuthenticator, org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator}
    //#post(void init(ServletConfig)): this.authenticator != null
    //#post(void init(ServletConfig)): new DefaultCommentAuthenticator(init#1) num objects <= 1
    //#post(void init(ServletConfig)): init'ed(new DefaultCommentAuthenticator(init#1).__Tag)
        
        // lookup the authenticator we are going to use and instantiate it
        try {
            String name = WebloggerConfig.getProperty("comment.authenticator.classname");
    //#CommentAuthenticatorServlet.java:81: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet
    //#    method: void init(ServletConfig)
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
            
            Class clazz = Class.forName(name);
            this.authenticator = (CommentAuthenticator) clazz.newInstance();
            
        } catch(Exception e) {
            mLogger.error(e);
    //#CommentAuthenticatorServlet.java:87: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet
    //#    method: void init(ServletConfig)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object)
            this.authenticator = new DefaultCommentAuthenticator();
        }

    }
    //#CommentAuthenticatorServlet.java:91: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.init(ServletConfig)
    
    /** 
     * Destruction.
     */
    public void destroy() {}
    //#CommentAuthenticatorServlet.java:96: method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.destroy()
    //#CommentAuthenticatorServlet.java:96: end of method: void org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet.destroy()
    
}
    //#CommentAuthenticatorServlet.java:: end of class: org.apache.roller.weblogger.ui.rendering.servlets.CommentAuthenticatorServlet
