Author: dkulp
Date: Mon Mar  5 11:02:29 2007
New Revision: 514821

URL: http://svn.apache.org/viewvc?view=rev&rev=514821
Log:
Consume any garbage on System.in before asking for the passphrase

Modified:
    
maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java

Modified: 
maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java?view=diff&rev=514821&r1=514820&r2=514821
==============================================================================
--- 
maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/GpgSignAttachedMojo.java
 Mon Mar  5 11:02:29 2007
@@ -341,11 +341,18 @@
         {
             //TODO: with JDK 1.6, we could call 
System.console().readPassword("GPG Passphrase: ", null);
             
+            BufferedReader in = new BufferedReader(new 
InputStreamReader(System.in));
+            while (System.in.available() != 0)
+            {
+                //there's some junk already on the input stream, consume it
+                //so we can get the real passphrase
+                System.in.read();
+            }
+            
             System.out.print("GPG Passphrase: ");
             MaskingThread thread = new MaskingThread();
             thread.start();
     
-            BufferedReader in = new BufferedReader(new 
InputStreamReader(System.in));
     
             pass = in.readLine();
     


Reply via email to