//# 2 errors, 324 messages
//#
/*
    //#IPBanList.java:1:1: class: org.apache.roller.weblogger.util.IPBanList$ModifiedFile
    //#IPBanList.java:1:1: method: org.apache.roller.weblogger.util.IPBanList$ModifiedFile.org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init
    //#IPBanList.java:1:1: class: org.apache.roller.weblogger.util.IPBanList
* 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.util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;


/**
 * Represents a list of banned ip addresses.
 *
 * This base implementation gets its list from a file on the filesystem.  We
 * are also aware of when the file changes via some outside source and we will
 * automatically re-read the file and update the list when that happens.
 */
public class IPBanList {
    
    private static Log log = LogFactory.getLog(IPBanList.class);
    //#IPBanList.java:41: method: org.apache.roller.weblogger.util.IPBanList.org.apache.roller.weblogger.util.IPBanList__static_init
    //#IPBanList.java:41: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: org.apache.roller.weblogger.util.IPBanList__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#input(org.apache.roller.weblogger.util.IPBanList__static_init): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#input(org.apache.roller.weblogger.util.IPBanList__static_init): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[others]
    //#input(org.apache.roller.weblogger.util.IPBanList__static_init): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.clearChanged()V
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): __Descendant_Table[org/apache/roller/weblogger/util/IPBanList]
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.addBannedIp(Ljava/lang/String;)V
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.isBanned(Ljava/lang/String;)Z
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.loadBannedIps()V
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.loadBannedIpsIfNeeded(Z)V
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): instance
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): log
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new HashSet(IPBanList#1) num objects
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new HashSet(loadBannedIps#1) num objects
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2) num objects
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2).__Tag
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2).myLastModified
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2).this$0
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList(IPBanList__static_init#1) num objects
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): instance.__Tag
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): instance.bannedIps
    //#output(org.apache.roller.weblogger.util.IPBanList__static_init): instance.bannedIpsFile
    //#new obj(org.apache.roller.weblogger.util.IPBanList__static_init): new HashSet(IPBanList#1)
    //#new obj(org.apache.roller.weblogger.util.IPBanList__static_init): new HashSet(loadBannedIps#1)
    //#new obj(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2)
    //#new obj(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList(IPBanList__static_init#1)
    //#presumption(org.apache.roller.weblogger.util.IPBanList__static_init): org.apache.commons.logging.LogFactory:getLog(...)@41 != null
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): __Descendant_Table[org/apache/roller/weblogger/util/IPBanList] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.addBannedIp(Ljava/lang/String;)V == &addBannedIp
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.isBanned(Ljava/lang/String;)Z == &isBanned
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.loadBannedIps()V == &loadBannedIps
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): __Dispatch_Table.loadBannedIpsIfNeeded(Z)V == &loadBannedIpsIfNeeded
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): instance == &new IPBanList(IPBanList__static_init#1)
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): (soft) log != null
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): new HashSet(IPBanList#1) num objects == 1
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList(IPBanList__static_init#1) num objects == 1
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): new HashSet(loadBannedIps#1) num objects <= 1
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2) num objects <= 1
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2).__Tag == org/apache/roller/weblogger/util/IPBanList$ModifiedFile
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): init'ed(new IPBanList$ModifiedFile(IPBanList#2).myLastModified)
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): new IPBanList$ModifiedFile(IPBanList#2).this$0 == &new IPBanList(IPBanList__static_init#1)
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): instance.__Tag == org/apache/roller/weblogger/util/IPBanList
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): instance.bannedIps == One-of{&new HashSet(IPBanList#1), &new HashSet(loadBannedIps#1)}
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): instance.bannedIps in Addr_Set{&new HashSet(IPBanList#1),&new HashSet(loadBannedIps#1)}
    //#post(org.apache.roller.weblogger.util.IPBanList__static_init): init'ed(instance.bannedIpsFile)
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.util.HashSet
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.io.FileReader
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.util.HashSet:add
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.util.Set:size
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:getProperty
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:java.io.File
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:exists
    //#unanalyzed(org.apache.roller.weblogger.util.IPBanList__static_init): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:canRead
    
    // set of ips that are banned, use a set to ensure uniqueness
    private Set bannedIps = new HashSet();
    
    // file listing the ips that are banned
    private ModifiedFile bannedIpsFile = null;
    
    // reference to our singleton instance
    private static IPBanList instance = null;
    
    
    static {
        instance = new IPBanList();
    }
    //#IPBanList.java:55: end of method: org.apache.roller.weblogger.util.IPBanList.org.apache.roller.weblogger.util.IPBanList__static_init
    
    
    // private because we are a singleton
    private IPBanList() {
    //#IPBanList.java:59: method: void org.apache.roller.weblogger.util.IPBanList.org.apache.roller.weblogger.util.IPBanList()
    //#input(void org.apache.roller.weblogger.util.IPBanList()): " banned ips loaded"._tainted
    //#input(void org.apache.roller.weblogger.util.IPBanList()): log
    //#input(void org.apache.roller.weblogger.util.IPBanList()): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#input(void org.apache.roller.weblogger.util.IPBanList()): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[others]
    //#input(void org.apache.roller.weblogger.util.IPBanList()): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.clearChanged()V
    //#input(void org.apache.roller.weblogger.util.IPBanList()): this
    //#output(void org.apache.roller.weblogger.util.IPBanList()): new HashSet(IPBanList#1) num objects
    //#output(void org.apache.roller.weblogger.util.IPBanList()): new HashSet(loadBannedIps#1) num objects
    //#output(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2) num objects
    //#output(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2).__Tag
    //#output(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2).myLastModified
    //#output(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2).this$0
    //#output(void org.apache.roller.weblogger.util.IPBanList()): this.bannedIps
    //#output(void org.apache.roller.weblogger.util.IPBanList()): this.bannedIpsFile
    //#new obj(void org.apache.roller.weblogger.util.IPBanList()): new HashSet(IPBanList#1)
    //#new obj(void org.apache.roller.weblogger.util.IPBanList()): new HashSet(loadBannedIps#1)
    //#new obj(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2)
    //#pre[1] (void org.apache.roller.weblogger.util.IPBanList()): log != null
    //#post(void org.apache.roller.weblogger.util.IPBanList()): this.bannedIps in Addr_Set{&new HashSet(IPBanList#1),&new HashSet(loadBannedIps#1)}
    //#post(void org.apache.roller.weblogger.util.IPBanList()): init'ed(this.bannedIpsFile)
    //#post(void org.apache.roller.weblogger.util.IPBanList()): new HashSet(IPBanList#1) num objects == 1
    //#post(void org.apache.roller.weblogger.util.IPBanList()): new HashSet(loadBannedIps#1) num objects <= 1
    //#post(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2) num objects <= 1
    //#post(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2).__Tag == org/apache/roller/weblogger/util/IPBanList$ModifiedFile
    //#post(void org.apache.roller.weblogger.util.IPBanList()): init'ed(new IPBanList$ModifiedFile(IPBanList#2).myLastModified)
    //#post(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2).this$0 == this
    //#post(void org.apache.roller.weblogger.util.IPBanList()): new IPBanList$ModifiedFile(IPBanList#2).this$0 != null
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.util.HashSet
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.io.FileReader
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.util.HashSet:add
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.util.Set:size
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(void org.apache.roller.weblogger.util.IPBanList()): Effects-of-calling:java.io.File
    //#test_vector(void org.apache.roller.weblogger.util.IPBanList()): org.apache.roller.weblogger.config.WebloggerConfig:getProperty(...)@64: Addr_Set{null}, Inverse{null}
    //#test_vector(void org.apache.roller.weblogger.util.IPBanList()): org.apache.roller.weblogger.util.IPBanList_ModifiedFile:canRead(...)@68: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.util.IPBanList()): org.apache.roller.weblogger.util.IPBanList_ModifiedFile:exists(...)@68: {0}, {1}
        
        log.debug("INIT");
    //#IPBanList.java:61: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void org.apache.roller.weblogger.util.IPBanList()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        // load up set of denied ips
        String banIpsFilePath = WebloggerConfig.getProperty("ipbanlist.file");
    //#IPBanList.java:64: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void org.apache.roller.weblogger.util.IPBanList()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
        if(banIpsFilePath != null) {
            ModifiedFile banIpsFile = new ModifiedFile(banIpsFilePath);
            
            if(banIpsFile.exists() && banIpsFile.canRead()) {
    //#IPBanList.java:68: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile:exists()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void org.apache.roller.weblogger.util.IPBanList()
    //#    unanalyzed callee: bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile:exists()
    //#IPBanList.java:68: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile:canRead()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void org.apache.roller.weblogger.util.IPBanList()
    //#    unanalyzed callee: bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile:canRead()
                this.bannedIpsFile = banIpsFile;
                this.loadBannedIps();
            }
        }
    }
    //#IPBanList.java:73: end of method: void org.apache.roller.weblogger.util.IPBanList.org.apache.roller.weblogger.util.IPBanList()
    
    
    // access to the singleton instance
    public static IPBanList getInstance() {
        return instance;
    //#IPBanList.java:78: method: IPBanList org.apache.roller.weblogger.util.IPBanList.getInstance()
    //#input(IPBanList getInstance()): instance
    //#output(IPBanList getInstance()): return_value
    //#pre[1] (IPBanList getInstance()): init'ed(instance)
    //#post(IPBanList getInstance()): return_value == instance
    //#post(IPBanList getInstance()): init'ed(return_value)
    //#IPBanList.java:78: end of method: IPBanList org.apache.roller.weblogger.util.IPBanList.getInstance()
    }
    
    
    public boolean isBanned(String ip) {
        
        // update the banned ips list if needed
        this.loadBannedIpsIfNeeded(false);
    //#IPBanList.java:85: method: bool org.apache.roller.weblogger.util.IPBanList.isBanned(String)
    //#input(bool isBanned(String)): " banned ips loaded"._tainted
    //#input(bool isBanned(String)): ip
    //#input(bool isBanned(String)): log
    //#input(bool isBanned(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#input(bool isBanned(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[others]
    //#input(bool isBanned(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.clearChanged()V
    //#input(bool isBanned(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.hasChanged()Z
    //#input(bool isBanned(String)): this
    //#input(bool isBanned(String)): this.bannedIps
    //#input(bool isBanned(String)): this.bannedIpsFile
    //#input(bool isBanned(String)): this.bannedIpsFile.__Tag
    //#input(bool isBanned(String)): this.bannedIpsFile.myLastModified
    //#output(bool isBanned(String)): new HashSet(loadBannedIps#1) num objects
    //#output(bool isBanned(String)): return_value
    //#output(bool isBanned(String)): this.bannedIps
    //#output(bool isBanned(String)): this.bannedIpsFile.myLastModified
    //#new obj(bool isBanned(String)): new HashSet(loadBannedIps#1)
    //#pre[6] (bool isBanned(String)): init'ed(this.bannedIpsFile)
    //#pre[2] (bool isBanned(String)): (soft) log != null
    //#pre[3] (bool isBanned(String)): (soft) init'ed(this.bannedIps)
    //#pre[4] (bool isBanned(String)): (soft) init'ed(this.bannedIpsFile.myLastModified)
    //#pre[7] (bool isBanned(String)): (soft) this.bannedIpsFile.__Tag == org/apache/roller/weblogger/util/IPBanList$ModifiedFile
    //#post(bool isBanned(String)): init'ed(return_value)
    //#post(bool isBanned(String)): this.bannedIps == One-of{old this.bannedIps, &new HashSet(loadBannedIps#1)}
    //#post(bool isBanned(String)): (soft) init'ed(this.bannedIps)
    //#post(bool isBanned(String)): init'ed(this.bannedIpsFile.myLastModified)
    //#post(bool isBanned(String)): new HashSet(loadBannedIps#1) num objects <= 1
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:loadBannedIps
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.util.HashSet
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.io.FileReader
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.util.HashSet:add
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:java.util.Set:size
    //#unanalyzed(bool isBanned(String)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#test_vector(bool isBanned(String)): ip: Addr_Set{null}, Inverse{null}
        
        if(ip != null) {
            return this.bannedIps.contains(ip);
    //#IPBanList.java:88: ?null dereference
    //#    this.bannedIps != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: bool isBanned(String)
    //#    basic block: bb_2
    //#    assertion: this.bannedIps != null
    //#    VN: this.bannedIps
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        } else {
            return false;
    //#IPBanList.java:90: end of method: bool org.apache.roller.weblogger.util.IPBanList.isBanned(String)
        }
    }
    
    
    public void addBannedIp(String ip) {
        
        if(ip == null) {
    //#IPBanList.java:97: method: void org.apache.roller.weblogger.util.IPBanList.addBannedIp(String)
    //#input(void addBannedIp(String)): " banned ips loaded"._tainted
    //#input(void addBannedIp(String)): "ADDED "._tainted
    //#input(void addBannedIp(String)): ip
    //#input(void addBannedIp(String)): ip._tainted
    //#input(void addBannedIp(String)): log
    //#input(void addBannedIp(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#input(void addBannedIp(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[others]
    //#input(void addBannedIp(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.clearChanged()V
    //#input(void addBannedIp(String)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.hasChanged()Z
    //#input(void addBannedIp(String)): this
    //#input(void addBannedIp(String)): this.bannedIps
    //#input(void addBannedIp(String)): this.bannedIpsFile
    //#input(void addBannedIp(String)): this.bannedIpsFile.__Tag
    //#input(void addBannedIp(String)): this.bannedIpsFile.myLastModified
    //#output(void addBannedIp(String)): new HashSet(loadBannedIps#1) num objects
    //#output(void addBannedIp(String)): this.bannedIps
    //#output(void addBannedIp(String)): this.bannedIpsFile.myLastModified
    //#new obj(void addBannedIp(String)): new HashSet(loadBannedIps#1)
    //#pre[3] (void addBannedIp(String)): (soft) log != null
    //#pre[4] (void addBannedIp(String)): (soft) init'ed(this.bannedIps)
    //#pre[5] (void addBannedIp(String)): (soft) init'ed(this.bannedIpsFile.myLastModified)
    //#pre[7] (void addBannedIp(String)): (soft) init'ed(this.bannedIpsFile)
    //#pre[8] (void addBannedIp(String)): (soft) this.bannedIpsFile.__Tag == org/apache/roller/weblogger/util/IPBanList$ModifiedFile
    //#post(void addBannedIp(String)): this.bannedIps == One-of{old this.bannedIps, &new HashSet(loadBannedIps#1)}
    //#post(void addBannedIp(String)): (soft) init'ed(this.bannedIps)
    //#post(void addBannedIp(String)): (soft) init'ed(this.bannedIpsFile.myLastModified)
    //#post(void addBannedIp(String)): new HashSet(loadBannedIps#1) num objects <= 1
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:loadBannedIps
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.util.HashSet
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.io.FileReader
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.util.HashSet:add
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:java.util.Set:size
    //#unanalyzed(void addBannedIp(String)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#test_vector(void addBannedIp(String)): ip: Inverse{null}, Addr_Set{null}
    //#test_vector(void addBannedIp(String)): this.bannedIpsFile: Addr_Set{null}, Inverse{null}
    //#test_vector(void addBannedIp(String)): java.util.Set:contains(...)@104: {1}, {0}
    //#test_vector(void addBannedIp(String)): org.apache.roller.weblogger.util.IPBanList_ModifiedFile:canWrite(...)@104: {0}, {1}
            return;
        }
        
        // update the banned ips list if needed
        this.loadBannedIpsIfNeeded(false);
        
        if(!this.bannedIps.contains(ip) && 
    //#IPBanList.java:104: ?null dereference
    //#    this.bannedIps != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void addBannedIp(String)
    //#    basic block: bb_3
    //#    assertion: this.bannedIps != null
    //#    VN: this.bannedIps
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
    //#IPBanList.java:104: Warning: method not available
    //#    -- call on bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile:canWrite()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void addBannedIp(String)
    //#    unanalyzed callee: bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile:canWrite()
                (bannedIpsFile != null && bannedIpsFile.canWrite())) {
            
            try {
                synchronized(this) {
                    // add to file
                    PrintWriter out = new PrintWriter(new FileWriter(this.bannedIpsFile, true));
                    out.println(ip);
                    out.close();
                    this.bannedIpsFile.clearChanged();
                    
                    // add to Set
                    this.bannedIps.add(ip);
                }
                
                log.debug("ADDED "+ip);
    //#IPBanList.java:119: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void addBannedIp(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
            } catch(Exception e) {
                log.error("Error adding banned ip to file", e);
    //#IPBanList.java:121: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void addBannedIp(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
            }
        }
    }
    //#IPBanList.java:124: end of method: void org.apache.roller.weblogger.util.IPBanList.addBannedIp(String)
    
    
    /**
     * Check if the banned ips file has changed and needs to be reloaded.
     */
    private void loadBannedIpsIfNeeded(boolean forceLoad) {
        
        if(bannedIpsFile != null && 
    //#IPBanList.java:132: method: void org.apache.roller.weblogger.util.IPBanList.loadBannedIpsIfNeeded(bool)
    //#input(void loadBannedIpsIfNeeded(bool)): " banned ips loaded"._tainted
    //#input(void loadBannedIpsIfNeeded(bool)): forceLoad
    //#input(void loadBannedIpsIfNeeded(bool)): log
    //#input(void loadBannedIpsIfNeeded(bool)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#input(void loadBannedIpsIfNeeded(bool)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[others]
    //#input(void loadBannedIpsIfNeeded(bool)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.clearChanged()V
    //#input(void loadBannedIpsIfNeeded(bool)): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.hasChanged()Z
    //#input(void loadBannedIpsIfNeeded(bool)): this
    //#input(void loadBannedIpsIfNeeded(bool)): this.bannedIpsFile
    //#input(void loadBannedIpsIfNeeded(bool)): this.bannedIpsFile.__Tag
    //#input(void loadBannedIpsIfNeeded(bool)): this.bannedIpsFile.myLastModified
    //#output(void loadBannedIpsIfNeeded(bool)): new HashSet(loadBannedIps#1) num objects
    //#output(void loadBannedIpsIfNeeded(bool)): this.bannedIps
    //#output(void loadBannedIpsIfNeeded(bool)): this.bannedIpsFile.myLastModified
    //#new obj(void loadBannedIpsIfNeeded(bool)): new HashSet(loadBannedIps#1)
    //#pre[6] (void loadBannedIpsIfNeeded(bool)): init'ed(this.bannedIpsFile)
    //#pre[2] (void loadBannedIpsIfNeeded(bool)): (soft) log != null
    //#pre[4] (void loadBannedIpsIfNeeded(bool)): (soft) init'ed(this.bannedIpsFile.myLastModified)
    //#pre[7] (void loadBannedIpsIfNeeded(bool)): (soft) this.bannedIpsFile.__Tag == org/apache/roller/weblogger/util/IPBanList$ModifiedFile
    //#post(void loadBannedIpsIfNeeded(bool)): this.bannedIps == One-of{old this.bannedIps, &new HashSet(loadBannedIps#1)}
    //#post(void loadBannedIpsIfNeeded(bool)): (soft) init'ed(this.bannedIpsFile.myLastModified)
    //#post(void loadBannedIpsIfNeeded(bool)): new HashSet(loadBannedIps#1) num objects <= 1
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.util.HashSet
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.io.FileReader
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.util.HashSet:add
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:java.util.Set:size
    //#unanalyzed(void loadBannedIpsIfNeeded(bool)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#test_vector(void loadBannedIpsIfNeeded(bool)): forceLoad: {0}, {1}
    //#test_vector(void loadBannedIpsIfNeeded(bool)): this.bannedIpsFile: Addr_Set{null}, Inverse{null}
                (bannedIpsFile.hasChanged() || forceLoad)) {
            
            // need to reload
            this.loadBannedIps();
        }
    }
    //#IPBanList.java:138: end of method: void org.apache.roller.weblogger.util.IPBanList.loadBannedIpsIfNeeded(bool)
    
    
    /**
     * Load the list of banned ips from a file.  This clears the old list and
     * loads exactly what is in the file.
     */
    private synchronized void loadBannedIps() {
        
        if(bannedIpsFile != null) {
    //#IPBanList.java:147: method: void org.apache.roller.weblogger.util.IPBanList.loadBannedIps()
    //#input(void loadBannedIps()): " banned ips loaded"._tainted
    //#input(void loadBannedIps()): log
    //#input(void loadBannedIps()): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#input(void loadBannedIps()): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Descendant_Table[others]
    //#input(void loadBannedIps()): org/apache/roller/weblogger/util/IPBanList$ModifiedFile.__Dispatch_Table.clearChanged()V
    //#input(void loadBannedIps()): this
    //#input(void loadBannedIps()): this.bannedIpsFile
    //#input(void loadBannedIps()): this.bannedIpsFile.__Tag
    //#output(void loadBannedIps()): new HashSet(loadBannedIps#1) num objects
    //#output(void loadBannedIps()): this.bannedIps
    //#output(void loadBannedIps()): this.bannedIpsFile.myLastModified
    //#new obj(void loadBannedIps()): new HashSet(loadBannedIps#1)
    //#pre[5] (void loadBannedIps()): init'ed(this.bannedIpsFile)
    //#pre[1] (void loadBannedIps()): (soft) log != null
    //#pre[6] (void loadBannedIps()): (soft) this.bannedIpsFile.__Tag == org/apache/roller/weblogger/util/IPBanList$ModifiedFile
    //#post(void loadBannedIps()): this.bannedIps == One-of{old this.bannedIps, &new HashSet(loadBannedIps#1)}
    //#post(void loadBannedIps()): possibly_updated(this.bannedIpsFile.myLastModified)
    //#post(void loadBannedIps()): new HashSet(loadBannedIps#1) num objects <= 1
    //#unanalyzed(void loadBannedIps()): Effects-of-calling:org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified
    //#test_vector(void loadBannedIps()): this.bannedIpsFile: Addr_Set{null}, Inverse{null}
    //#test_vector(void loadBannedIps()): java.io.BufferedReader:readLine(...)@156: Addr_Set{null}, Inverse{null}
            
            try {
                HashSet newBannedIpList = new HashSet();
                
                // TODO: optimize this
                BufferedReader in = new BufferedReader(new FileReader(this.bannedIpsFile));
                
                String ip = null;
    //#IPBanList.java:155: Warning: unused assignment
    //#    unused assignment into ip
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void loadBannedIps()
    //#    Attribs:  Uncertain
                while((ip = in.readLine()) != null) {
                    newBannedIpList.add(ip);
                }
                
                in.close();
                
                // list updated, reset modified file
                this.bannedIps = newBannedIpList;
                this.bannedIpsFile.clearChanged();
                
                log.info(this.bannedIps.size()+" banned ips loaded");
    //#IPBanList.java:166: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void loadBannedIps()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
            } catch(Exception ex) {
               log.error("Error loading banned ips from file", ex);
    //#IPBanList.java:168: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList
    //#    method: void loadBannedIps()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
            }
            
        }
    }
    //#IPBanList.java:172: end of method: void org.apache.roller.weblogger.util.IPBanList.loadBannedIps()
    
    
    // a simple extension to the File class which tracks if the file has 
    // changed since the last time we checked
    private class ModifiedFile extends java.io.File {
        
        private long myLastModified = 0;
        
        public ModifiedFile(String filePath) {
    //#IPBanList.java:181: method: void org.apache.roller.weblogger.util.IPBanList$ModifiedFile.org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)
    //#input(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): Param_1
    //#input(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): filePath
    //#input(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): this
    //#output(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): this.myLastModified
    //#output(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): this.this$0
    //#post(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): init'ed(this.myLastModified)
    //#post(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): this.this$0 == Param_1
    //#post(void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)): init'ed(this.this$0)
            super(filePath);
            
            this.myLastModified = lastModified();
    //#IPBanList.java:184: Warning: method not available
    //#    -- call on long org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList$ModifiedFile
    //#    method: void org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)
    //#    unanalyzed callee: long org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified()
        }
    //#IPBanList.java:185: end of method: void org.apache.roller.weblogger.util.IPBanList$ModifiedFile.org.apache.roller.weblogger.util.IPBanList$ModifiedFile(IPBanList, String)

        public boolean hasChanged() {
            if(lastModified() != myLastModified) {
    //#IPBanList.java:188: method: bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile.hasChanged()
    //#IPBanList.java:188: Warning: method not available
    //#    -- call on long org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList$ModifiedFile
    //#    method: bool hasChanged()
    //#    unanalyzed callee: long org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified()
    //#input(bool hasChanged()): this
    //#input(bool hasChanged()): this.myLastModified
    //#output(bool hasChanged()): return_value
    //#pre[2] (bool hasChanged()): init'ed(this.myLastModified)
    //#post(bool hasChanged()): init'ed(return_value)
                return true;
            } else {
                return false;
    //#IPBanList.java:191: end of method: bool org.apache.roller.weblogger.util.IPBanList$ModifiedFile.hasChanged()
            }
        }
        
        public void clearChanged() {
            myLastModified = lastModified();
    //#IPBanList.java:196: method: void org.apache.roller.weblogger.util.IPBanList$ModifiedFile.clearChanged()
    //#IPBanList.java:196: Warning: method not available
    //#    -- call on long org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.IPBanList$ModifiedFile
    //#    method: void clearChanged()
    //#    unanalyzed callee: long org.apache.roller.weblogger.util.IPBanList$ModifiedFile:lastModified()
    //#input(void clearChanged()): this
    //#output(void clearChanged()): this.myLastModified
    //#post(void clearChanged()): init'ed(this.myLastModified)
        }
    //#IPBanList.java:197: end of method: void org.apache.roller.weblogger.util.IPBanList$ModifiedFile.clearChanged()
    }
    
}
    //#output(org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init): __Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile]
    //#output(org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init): __Dispatch_Table.clearChanged()V
    //#output(org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init): __Dispatch_Table.hasChanged()Z
    //#post(org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init): __Descendant_Table[org/apache/roller/weblogger/util/IPBanList$ModifiedFile] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init): __Dispatch_Table.clearChanged()V == &clearChanged
    //#post(org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init): __Dispatch_Table.hasChanged()Z == &hasChanged
    //#IPBanList.java:: end of method: org.apache.roller.weblogger.util.IPBanList$ModifiedFile.org.apache.roller.weblogger.util.IPBanList$ModifiedFile__static_init
    //#IPBanList.java:: end of class: org.apache.roller.weblogger.util.IPBanList$ModifiedFile
    //#IPBanList.java:: end of class: org.apache.roller.weblogger.util.IPBanList
