You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by Apache Wiki <wi...@apache.org> on 2005/06/07 12:03:05 UTC

[Jakarta-hivemind Wiki] Update of "ProxySupport" by ledents

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-hivemind Wiki" for change notification.

The following page has been changed by ledents:
http://wiki.apache.org/jakarta-hivemind/ProxySupport

New page:
#pragma section-numbers off

= Problem Description =

As of this writing (June 07 2005), the build process fails to download dependency files being behind firewall (proxy server).

= Solution =

However a small modification to <Gabber.java> and <dependency.xml> files circumvent this problem.

== Grabber.java changes ==

We need to add support for configuring the following attributes '''proxyHost''', '''proxyPort''', '''proxyUser''' and
'''proxyPwd'''.

The ''setProxyHost()'' method simply sets the '''"http.proxyHost"''' system property.

The ''setProxyPort()'' method simply sets the '''"http.proxyPort"''' system property.

The ''setProxyUser()'' and ''setProxyPwd()'' updates instance ''_proxyUser'' and ''_proxyPwd'' instance variables which are
used in the ''execute()'' method to attach a "Proxy-Authorization" request property to the urlConnection:

        ...

        try
        {

            URLConnection connection = _src.openConnection();

            if (_proxyUser != null)
            {
                sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
                String encoded = encoder.encode(
                            new String(_proxyUser + ":" + _proxyPwd).getBytes());
                connection.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
            }

            connection.connect();

            copyConnectionToFile(connection);
        }
        catch (IOException ex)
        {
            log("Failure accessing " + _src + ": " + ex.getMessage(), Project.MSG_ERR);
        }

        ...

== dependency.xml changes ==

the ''grab-file'' macro should define 4 additional attributes '''proxyHost''', '''proxyPort''', '''proxyUser''' and
'''proxyPwd''' whith configured defaults which may be empty properties in the dependency.properties file or idealy
references user configurable properties !! 
  ...

  <macrodef name="grab-file">
    <attribute name="src" description="The URL of the file to download."/>

    <attribute name="dest" description="The directory and file to copy to."/>

    <attribute name="proxyHost" default="${proxy.host}" description="The proxy hostname or ip address to used"/>

    <attribute name="proxyPort" default="${proxy.port}" description="The proxy port to used"/>

    <attribute name="proxyUser" default="${proxy.user}" description="The user used to log onto the proxy"/>

    <attribute name="proxyPwd"  default="${proxy.pwd}" description="The password used to log onto the proxy"/>

    <sequential>

      <mkdir dir="${hivebuild.classes.dir}"/>

      <javac includeantruntime="yes"
        srcdir="${hivebuild.src.dir}"
        destdir="${hivebuild.classes.dir}"/>

        <taskdef classname="org.apache.hivemind.build.Grabber" name="grabber" classpathref="grabber.classpath"/>

        <grabber src="@{src}" dest="@{dest}" proxyHost="@{proxyHost}" proxyPort="@{proxyPort}"
                proxyUser="@{proxyUser}" proxyPwd="@{proxyPwd}"/>

    </sequential>

  </macrodef>

  ...

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org