ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Gentle <j.kenneth.gen...@acm.org>
Subject RE: Password task
Date Fri, 21 Feb 2003 16:17:07 GMT
This doesn't prevent the password from being echoed as the user is typing.

Generally one has to do some mechanics with the terminal from the program 
to make it not echo input characters, or to echo "*".  This isn't easily 
done from Java for System.in.

         Ken

At 03:54 PM 2/21/2003 +0000, you wrote:
>Surely the way to do it would be:
>
>public class NullOutputStream extends OutputStream {
>   public void write(int i) {/* do nothing */}
>}
>
>OutputStream osOut = System.out;
>OutputStream osErr = System.err;
>
>System.setOut(new PrintStream(new NullOutputStream()));
>System.setErr(new PrintStream(new NullOutputStream()));
>
>// do your stuff with the password
>...
>
>// restore stdout and stderr
>
>System.setOut(osOut);
>System.setErr(osErr);
>
>
>Keith
>
>
>-----Original Message-----
>From: Matt Benson [mailto:gudnabrsam@yahoo.com]
>Sent: 21 February 2003 15:44
>To: Ant Users List; mattias@expertsystem.se
>Subject: Re: Password task
>
>
>I played with this before as well but it seems to be a
>limitation of Java.  There are several related issues
>logged in Sun's bug parade, which ultimately is the
>desire to suppress System.in from being echoed to the
>screen.  It may be that a different JVM could offer
>some means to achieve this.
>
>-Matt
>
>
>--- Mattias J <mattias@expertsystem.se> wrote:
> > I need the user to input a password (for ftp) into
> > an ant script, without it
> > being echoed to the screen. I know this is a common
> > issue on this mailing
> > list, but I have searched all over and found no
> > final answer.
> >
> > I should state that the ant script is run (on a
> > Linux box) through telnet,
> > so a GUI popup is no alternative.
> >
> > I started off trying to write a shell script to read
> > the password for me,
> > but then I found out Ant steals all the input...
> >
> > So I tried to write an ant task which read the
> > password and ereased the
> > input, using information from
> > http://java.sun.com/features/2002/09/pword_mask.html
> > and
> > http://www.jguru.com/faq/view.jsp?EID=23448. I
> > succeded in making something
> > that works (if you don't type to fast...), but
> > somehow it inserts a
> > linebreak for each key pressed.
> >
> > Has really nobody else made a command line password
> > input task for ant???
> >
> > Would somebody care to look at this code and help me
> > improve it?
> >
> > (Now, let's hope this list allows attachements)
> >
> >   Mattias Jiderhamn
> >   Expert Systems
> >
> >   mattias@expertsystem.se
> >   www.expertsystem.se
> >
> > >
>---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
>user-help@ant.apache.org
>
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Tax Center - forms, calculators, tips, more
>http://taxes.yahoo.com/
>
>---------------------------------------------------------------------
>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