head	1.2;
access;
symbols
	TIGRIS_1_0_5:1.1
	TIGRIS_1_0_5RC6:1.1
	TIGRIS_1_0_5RC5:1.1
	TIGRIS_1_0_5RC4:1.1
	TIGRIS_1_0_5RC3:1.1
	TIGRIS_1_0_5RC2:1.1
	TIGRIS_1_0_5RC1:1.1
	TIGRIS_1_0_4:1.1
	TIGRIS_1_0_3:1.1
	TIGRIS_1_0_2:1.1
	TIGRIS_1_0_1:1.1
	TIGRIS_1_0:1.1.0.6
	TIGRIS_1_0_0:1.1
	TIGRIS_1_0_0_RC1:1.1.0.2;
locks; strict;
comment	@# @;


1.2
date	2001.05.07.22.43.43;	author dlr;	state dead;
branches;
next	1.1;

1.1
date	2001.03.01.01.03.21;	author dlr;	state Exp;
branches
	1.1.6.1;
next	;

1.1.6.1
date	2001.06.06.18.54.23;	author dlr;	state dead;
branches;
next	;


desc
@@


1.2
log
@Removed HostIPAllowService and its configuration.  If we do end up implementing such functionality, it will be quite different.
@
text
@package org.tigris.helm.tool;

import java.io.IOException;
import java.util.Properties;

import org.apache.turbine.services.*;
import org.apache.turbine.services.resources.*;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.TurbineException;

/**
 * Manages IP allow lists.
 *
 * http://userlocal.com/securinginetdetc.shtml
 * http://www.educ.umu.se/~bjorn/mhonarc-files/debian-user-small/msg01859.html
 */
public class HostIPAllowService extends TurbineBaseService
{
    /**
     * The name of this service.  Used to retrive it from the broker.
     */
    public static final String SERVICE_NAME = "IPAllowService";

    /**
     * The name of the file to read the allowed host entries from (including
     * the full path).
     */
    private String allowed;

    /**
     * The name of the file to read the denied host entries from (including the
     * full path).
     */
    private String denied;

    /**
     * The command run to discover denied IPs.
     */
    private String denialsHarvestCmd;

    /**
     * Creates a new instance.
     *
     * @@exception Exception Thrown by base class.
     */
    public HostIPAllowService()
        throws Exception
    {
        allowed = null;
        denied = null;
        denialsHarvestCmd = null;
    }

    /**
     * Called during late initialization of service.
     */
    public void init()
    {
        if (!getInit())
        {
            try
            {
                Log.info(SERVICE_NAME + " late init()");
                // TODO: Read files from TR.props.
                Properties props = getProperties();
                this.allowed = props.getProperty("allow");
                this.denied = props.getProperty("deny");
                this.denialsHarvestCmd =
                    props.getProperty("denialsHarvestCmd");
                setInit(true);
            }
            catch (Exception e)
            {
                Log.error(SERVICE_NAME + " initialization failed", e);
            }
        }
    }

    /**
     * @@exception TurbienException Error in external process.
     */
    public String harvestDeniedIPs()
        throws TurbineException
    {
        String s = null;

        Process p = null;
        try {
            p = Runtime.getRuntime().exec(denialsHarvestCmd);
        }
        catch (IOException e) {
            throw new TurbineException("Error harvesting denied IPs", e);
        }
        try {
            // Run the command.
            if (p != null && p.waitFor() == 0) {
                // TODO: Filter out any addresses that have already been added
                // to hosts.allow or hosts.deny.
            }
            else {
                Log.warn("Couldn't discover denied SSL accesses");
            }
        }
        catch (InterruptedException e) {
            throw new TurbineException
                ("Interrupted while harvesting denied IPs", e);
        }

        return s;
    }
}
@


1.1
log
@Start of a service to handle host IP allow/deny entries.
@
text
@@


1.1.6.1
log
@HostIPAllowService not used.
@
text
@@


