ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Velagapudi, Murali" <murali.velagap...@citigroup.com>
Subject RE: reading password for FTP task (problem when calling ant from java)
Date Tue, 17 Aug 2004 20:49:38 GMT
Jan

  I did I am able to run my ftp task if i run from command line like 
ant -Dpassword=chowdary(this is the dummy password to get the encrypted password) which runs
very well ,but if i am trying to run that from java class i am getting problem due to ftp
task (it says Could not create task or type of type: ftp.) ,what should i do here is there
any issue with class path or some thing i kept the required jars for ftp ,i am giving the
part of build.xml and java class here getftppwd target gets the decrypted password for ftp,let
me know if you need any more inputs

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="send_ist" name="cisbuild">

<target name="_init">
  <property name="home" value="c:/root" /> 
  <property name="ist_code_host" value="server.com" />
  <property name="ist_code_user" value="loginname" />
</target>

<target name="getftppwd" >
<taskdef name="getpassword" classname="GetPassword"/>          
<getpassword password="${password}"
property="ftpserverpwd"/>  
</target>

<target name="send_ist"
 depends="_init,getftppwd">  
  <ftp server="${ist_code_host}"
       remotedir="/home/javacode"
       userid="${ist_code_user}"
       password="${ftpserverpwd}"
       separator="/"
       verbose="yes"
       binary="yes"
  >   
    <fileset dir="${home}">
      <include name="filename.zip"/>
    </fileset>

  </ftp>
</target>
</project>

and the java source is 
public class RunAntBuild extends Ant {



    public RunAntBuild(String propertyName1, String propertyValue1) {

        project = new Project();
        project.init();        
        Property property1 = createProperty();
        property1.setName(propertyName1);
        property1.setValue(propertyValue1);
    }

    public static void main(String args[])
    {
		try{
			RunAntBuild rab=new RunAntBuild("password","chowdary");
			rab.execute();
		}catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}

thanks,
Murali

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: Friday, August 13, 2004 9:33 AM
To: user@ant.apache.org
Subject: AW: reading password for FTP task


If you store a value inside Ant´s project, you can access that.
You could
- store the encrypted value as property
- extend <ftp> to decrypt that password before doing its work
  class MyFtp extends FTP /* search for right classname */ {
      private boolean pwdIsEncrypted = false; // setter
      public void execute() {
          if (pwdIsEncrypted) {
              password = ...  // overwrite the set (encrypted) pwd by the
decrypted one
          }
          super.execute(); // let the <ftp> work
      }

But that is also very easy to hack. Maybe via decompilation ... but by
simply using your
Decrypt-Class.


Jan
              


> -----Ursprüngliche Nachricht-----
> Von: Velagapudi, Murali [mailto:murali.velagapudi@citigroup.com]
> Gesendet am: Freitag, 13. August 2004 15:26
> An: Ant Users List
> Betreff: RE: reading password for FTP task
> 
>    Not me if any one wants to know the password then then can 
> do that by simply including  the echo the password that is 
> what my concern over here.
> 
> thanks,
> Murali
> 
> -----Original Message-----
> From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> Sent: Friday, August 13, 2004 1:36 AM
> To: user@ant.apache.org
> Subject: AW: reading password for FTP task
> 
> 
> "echo"?
> Why using <echo> when you dont want to print something?
> 
> Jan
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Velagapudi, Murali [mailto:murali.velagapudi@citigroup.com]
> > Gesendet am: Donnerstag, 12. August 2004 17:54
> > An: Ant Users List
> > Betreff: RE: reading password for FTP task
> > 
> > Jan,
> > 
> >     Thank you vey much ,it worked i could get that using your 
> > approach, and also
> > Is there any way i could supress the echo task, because after 
> > getting the cleartext from encrypted password if i do echo 
> > its(the pwd) get displayed ,even if i change the execute 
> > method in Echo class ,i can stop that for the Ant build in my 
> > local system ,if any one else executes this with another Ant 
> > then they can know the password.
> > 
> > thanks,
> > Murali
> > 
> > -----Original Message-----
> > From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> > Sent: Thursday, August 12, 2004 2:52 AM
> > To: user@ant.apache.org
> > Subject: AW: reading password for FTP task
> > 
> > 
> > Simplest thing would writing a task which stores the password as
> > property.
> > 
> > public class GetPassword extends Task {
> >     private String property;
> >     public void setProperty(String p) { property = p; }
> >     public void execute() {
> >         String pwd = getPassword(); 
> >         getProject().setNewProperty(property, pwd);
> >     }
> >     private String getPassword();
> >         String rv;
> >         // do your work
> >         return rv;
> >     }
> > }
> > 
> > <project>
> >     <taskdef name="getpassword" classname="GetPassword"/>
> >     <getpassword property="ftp.pwd"/>
> >     <ftp password="${ftp.pwd}"/>
> > </project>
> > 
> > 
> > Jan
> > 
> > 
> > > -----Ursprüngliche Nachricht-----
> > > Von: Velagapudi, Murali [mailto:murali.velagapudi@citigroup.com]
> > > Gesendet am: Mittwoch, 11. August 2004 23:01
> > > An: Ant Users List
> > > Betreff: reading password for FTP task
> > > 
> > > Hi All,
> > > 
> > >    I have a key/password stored in properties file(key file) 
> > > ,i need to invoke  a java class which decrypts that key and 
> > > give me the correct(clear text) password which i can use for 
> > > connecting to ftp server, how can i include that in ftp task, 
> > > that is to invoke that class and get the return string  back 
> > > and should be passed as value for "password" property in ftp task?
> > > 
> > > thanks in advance,
> > > Murali
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message