maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r312680 - in /maven/wagon/trunk/wagon-providers/wagon-ssh: ./ src/main/java/org/apache/maven/wagon/providers/ssh/ src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ src/main/resources/META-INF/plexus/ src/test/resources/org/apa...
Date Mon, 10 Oct 2005 16:37:36 GMT
Author: brett
Date: Mon Oct 10 09:37:16 2005
New Revision: 312680

URL: http://svn.apache.org/viewcvs?rev=312680&view=rev
Log:
PR: WAGONSSH-13
add interactive password

Added:
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
  (contents, props changed)
      - copied, changed from r312660, maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ConsoleInteractiveUserInfo.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
  (contents, props changed)
      - copied, changed from r312660, maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
  (contents, props changed)
      - copied, changed from r312660, maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/NullInteractiveUserInfo.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java
  (with props)
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java
  (with props)
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java
  (with props)
Removed:
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ConsoleInteractiveUserInfo.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/NullInteractiveUserInfo.java
Modified:
    maven/wagon/trunk/wagon-providers/wagon-ssh/pom.xml
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/resources/META-INF/plexus/components.xml
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/pom.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/pom.xml?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/pom.xml (original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/pom.xml Mon Oct 10 09:37:16 2005
@@ -25,12 +25,10 @@
       <version>1.3</version>
     </dependency>
     <dependency> 
-      <!-- used by org.apache.maven.wagon.providers.ssh.InteractiveUserInfo -->
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-input-handler-api</artifactId>
-      <version>1.0-alpha-3</version>
+      <version>1.0-alpha-4-SNAPSHOT</version>
     </dependency>
-
   </dependencies>
   <build>
     <plugins>

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
Mon Oct 10 09:37:16 2005
@@ -23,15 +23,18 @@
 import com.jcraft.jsch.ProxyHTTP;
 import com.jcraft.jsch.ProxySOCKS5;
 import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UIKeyboardInteractive;
 import com.jcraft.jsch.UserInfo;
 import org.apache.maven.wagon.AbstractWagon;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
 import org.apache.maven.wagon.authentication.AuthenticationException;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
+import org.apache.maven.wagon.providers.ssh.interactive.UserInfoUIKeyboardInteractiveProxy;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
 import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.util.IOUtil;
 
@@ -44,6 +47,8 @@
 /**
  * Common SSH operations.
  *
+ * @todo cache pass[words|phases]
+ *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
  */
@@ -67,6 +72,8 @@
 
     private InteractiveUserInfo interactiveUserInfo;
 
+    private UIKeyboardInteractive uIKeyboardInteractive;
+
     private JSch sch;
 
     public void openConnection()
@@ -74,7 +81,8 @@
     {
         if ( authenticationInfo == null )
         {
-            throw new IllegalArgumentException( "Authentication Credentials cannot be null
for SSH protocol" );
+            authenticationInfo = new AuthenticationInfo();
+            authenticationInfo.setUserName( System.getProperty( "user.name" ) );
         }
 
         sch = new JSch();
@@ -133,13 +141,6 @@
                     throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
                 }
             }
-            else
-            {
-                String msg = "Private key was not found. You must define a private key or
a password for repo: " +
-                    getRepository().getName();
-
-                throw new AuthenticationException( msg );
-            }
         }
 
         if ( proxyInfo != null && proxyInfo.getHost() != null )
@@ -177,6 +178,11 @@
         // username and password will be given via UserInfo interface.
         UserInfo ui = new WagonUserInfo( authenticationInfo, interactiveUserInfo );
 
+        if ( uIKeyboardInteractive != null )
+        {
+            ui = new UserInfoUIKeyboardInteractiveProxy( ui, uIKeyboardInteractive );
+        }
+
         if ( knownHostsProvider != null )
         {
             try
@@ -312,7 +318,10 @@
     {
         if ( knownHostsProvider != null )
         {
-            knownHostsProvider.storeKnownHosts( sch );
+            if ( sch != null )
+            {
+                knownHostsProvider.storeKnownHosts( sch );
+            }
         }
 
         if ( session != null )
@@ -320,7 +329,7 @@
             session.disconnect();
             session = null;
         }
-        
+
         sch = null;
     }
 
@@ -352,42 +361,54 @@
         }
     }
 
-    // ----------------------------------------------------------------------
-    // JSch user info
-    // ----------------------------------------------------------------------
-    // TODO: are the prompt values really right? Is there an alternative to UserInfo?
-
-    private static class WagonUserInfo
+    private class WagonUserInfo
         implements UserInfo
     {
-        private final AuthenticationInfo authInfo;
-
         private final InteractiveUserInfo userInfo;
 
+        private String password;
+
+        private String passphrase;
+
+        private String username;
+
         WagonUserInfo( AuthenticationInfo authInfo, InteractiveUserInfo userInfo )
         {
-            this.authInfo = authInfo;
             this.userInfo = userInfo;
+
+            this.username = authInfo.getUserName();
+
+            this.password = authInfo.getPassword();
+
+            this.passphrase = authInfo.getPassphrase();
         }
 
         public String getPassphrase()
         {
-            return authInfo.getPassphrase();
+            return passphrase;
         }
 
         public String getPassword()
         {
-            return authInfo.getPassword();
+            return password;
         }
 
         public boolean promptPassphrase( String arg0 )
         {
-            return true;
+            if ( passphrase == null && userInfo != null )
+            {
+                passphrase = userInfo.promptPassphrase( arg0 );
+            }
+            return passphrase != null;
         }
 
         public boolean promptPassword( String arg0 )
         {
-            return true;
+            if ( password == null && userInfo != null )
+            {
+                password = userInfo.promptPassword( arg0 );
+            }
+            return password != null;
         }
 
         public boolean promptYesNo( String arg0 )

Copied: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
(from r312660, maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ConsoleInteractiveUserInfo.java)
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java?p2=maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java&p1=maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ConsoleInteractiveUserInfo.java&r1=312660&r2=312680&rev=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ConsoleInteractiveUserInfo.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
Mon Oct 10 09:37:16 2005
@@ -1,4 +1,4 @@
-package org.apache.maven.wagon.providers.ssh;
+package org.apache.maven.wagon.providers.ssh.interactive;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -16,13 +16,13 @@
  * limitations under the License.
  */
 
-import org.codehaus.plexus.components.inputhandler.InputHandler;
-import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
 
-import java.io.IOException;
+import java.util.Arrays;
 
 /**
- * Shows messages to System.out, and ask replies using an InputHandler 
+ * Shows messages to System.out, and ask replies using an InputHandler
  *
  * @author Juan F. Codagnone
  * @since Sep 12, 2005
@@ -30,61 +30,64 @@
 public class ConsoleInteractiveUserInfo
     implements InteractiveUserInfo
 {
-    private InputHandler inputHandler;
+    private Prompter prompter;
 
     public ConsoleInteractiveUserInfo()
     {
     }
 
-    public ConsoleInteractiveUserInfo( InputHandler inputHandler )
+    public ConsoleInteractiveUserInfo( Prompter prompter )
     {
-        this.inputHandler = inputHandler;
+        this.prompter = prompter;
     }
 
-    /** @see InteractiveUserInfo#promptYesNo(java.lang.String) */
+    /**
+     * @see InteractiveUserInfo#promptYesNo(String)
+     */
     public boolean promptYesNo( String message )
     {
-        boolean ret = false;
-
-        showMessage( message );
-        String answer;
+        String ret;
         try
         {
-            answer = inputHandler.readLine();
-            if ( !StringUtils.isEmpty( answer ) )
-            {
-                answer = answer.toLowerCase();
-
-                // TODO: localization and i18n? 
-                if ( answer.startsWith( "y" ) )
-                {
-                    ret = true;
-                }
-                else if ( answer.startsWith( "n" ) )
-                {
-                    ret = false;
-
-                }
-            }
-        }
-        catch ( final IOException e )
-        {
-            // TODO log?
-            
-            // nothing to do
+            ret = prompter.prompt( message, Arrays.asList( new String[]{"yes", "no"} ) );
         }
-
-        return ret;
+        catch ( PrompterException e )
+        {
+            // no op
+            ret = null;
+        }
+        return "yes".equalsIgnoreCase( ret );
     }
 
-    /** @see InteractiveUserInfo#showMessage(java.lang.String) */
+    /**
+     * @see InteractiveUserInfo#showMessage(String)
+     */
     public void showMessage( String message )
     {
-        System.out.println( message );
+        try
+        {
+            prompter.showMessage( message );
+        }
+        catch ( PrompterException e )
+        {
+            // no op
+        }
+    }
+
+    public String promptPassword( String message )
+    {
+        try
+        {
+            return prompter.promptForPassword( message );
+        }
+        catch ( PrompterException e )
+        {
+            return null;
+        }
     }
 
-    public void setInputHandler( InputHandler inputHandler )
+    public String promptPassphrase( String message )
     {
-        this.inputHandler = inputHandler;
+        return promptPassword( message );
     }
 }

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
(from r312660, maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.java)
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java?p2=maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java&p1=maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.java&r1=312660&r2=312680&rev=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
Mon Oct 10 09:37:16 2005
@@ -1,4 +1,4 @@
-package org.apache.maven.wagon.providers.ssh;
+package org.apache.maven.wagon.providers.ssh.interactive;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -32,4 +32,10 @@
 
     /*** @see com.jcraft.jsch.UserInfo#showMessage(java.lang.String) */
     void showMessage( String message );
+
+    /** @see com.jcraft.jsch.UserInfo#promptPassword(String) */
+    String promptPassword( String message );
+
+    /** @see com.jcraft.jsch.UserInfo#promptPassphrase(String) */
+    String promptPassphrase( String message );
 }

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
(from r312660, maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/NullInteractiveUserInfo.java)
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java?p2=maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java&p1=maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/NullInteractiveUserInfo.java&r1=312660&r2=312680&rev=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/NullInteractiveUserInfo.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
Mon Oct 10 09:37:16 2005
@@ -1,4 +1,4 @@
-package org.apache.maven.wagon.providers.ssh;
+package org.apache.maven.wagon.providers.ssh.interactive;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-import org.apache.maven.wagon.providers.ssh.InteractiveUserInfo;
+import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
 
 /**
  * Dummy Implementation for <code>InteractiveUserInfo</code>, nice for
@@ -24,7 +24,7 @@
  *
  * @author Juan F. Codagnone
  * @since Sep 12, 2005
- * @see org.apache.maven.wagon.providers.ssh.InteractiveUserInfo
+ * @see org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo
  */
 public class NullInteractiveUserInfo
     implements InteractiveUserInfo
@@ -37,7 +37,7 @@
         this( false ); // the safest value
     }
 
-    /** 
+    /**
      * Creates a <code>NullInteractiveUserInfo</code> with a hardcoded 
      * prompYesNo result
      * 
@@ -58,5 +58,15 @@
     public void showMessage( final String message )
     {
         // nothing to do
+    }
+
+    public String promptPassword( String message )
+    {
+        return null;
+    }
+
+    public String promptPassphrase( String message )
+    {
+        return null;
     }
 }

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java?rev=312680&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java
(added)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java
Mon Oct 10 09:37:16 2005
@@ -0,0 +1,86 @@
+package org.apache.maven.wagon.providers.ssh.interactive;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.jcraft.jsch.UIKeyboardInteractive;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
+
+/**
+ * UIKeyboardInteractive that use pluxus-prompter
+ * <p/>
+ * <code>UIKeyboardInteractive</code> are usefull when you don't use user with
+ * password authentication with a server that use keyboard-interactive and
+ * doesn't allow password method <code>PasswordAuthentication no</code>.
+ *
+ * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
+ * @since Sep 22, 2005
+ */
+public class PrompterUIKeyboardInteractive
+    implements UIKeyboardInteractive
+{
+    private Prompter prompter;
+
+    public PrompterUIKeyboardInteractive()
+    {
+    }
+
+    public PrompterUIKeyboardInteractive( Prompter promper )
+    {
+        this.prompter = promper;
+    }
+
+    /**
+     * @see UIKeyboardInteractive#promptKeyboardInteractive(String, String,
+     *      String, String[], boolean[])
+     */
+    public String[] promptKeyboardInteractive( String destination, String name, String instruction,
String[] prompt,
+                                               boolean[] echo )
+    {
+
+        if ( prompt.length != echo.length )
+        {
+            // jcsh is buggy?
+            throw new IllegalArgumentException( "prompt and echo size arrays are different!"
);
+        }
+        String[] ret = new String[prompt.length];
+
+        try
+        {
+
+            for ( int i = 0; i < ret.length; i++ )
+            {
+                if ( echo[i] )
+                {
+                    ret[i] = prompter.prompt( prompt[i] );
+                }
+                else
+                {
+                    ret[i] = prompter.promptForPassword( prompt[i] );
+                }
+            }
+        }
+        catch ( PrompterException e )
+        {
+            // TODO: log
+            // the user canceled?
+            ret = null;
+        }
+
+        return ret;
+    }
+}

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/PrompterUIKeyboardInteractive.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java?rev=312680&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java
(added)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java
Mon Oct 10 09:37:16 2005
@@ -0,0 +1,69 @@
+package org.apache.maven.wagon.providers.ssh.interactive;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.jcraft.jsch.UIKeyboardInteractive;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+
+/**
+ * A conservative <code>UIKeyboardInteractive</code> that avoids real
+ * user interaction :). This implementation expects only one prompt with the
+ * word password in it.
+ * <p/>
+ * <code>UIKeyboardInteractive</code> are usefull when you don't use user with
+ * password authentication with a server that use keyboard-interactive and
+ * doesn't allow password method <code>PasswordAuthentication no</code>.
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 21, 2005
+ */
+public class TraditionalUIKeyboardInteractive
+    implements UIKeyboardInteractive
+{
+    private final AuthenticationInfo authInfo;
+
+    public TraditionalUIKeyboardInteractive( AuthenticationInfo authInfo )
+    {
+        this.authInfo = authInfo;
+    }
+
+    /**
+     * @see UIKeyboardInteractive#promptKeyboardInteractive(String, String,
+     *      String, String[], boolean[])
+     */
+    public String[] promptKeyboardInteractive( String destination, String name, String instruction,
String[] prompt,
+                                               boolean[] echo )
+    {
+
+        String[] ret;
+
+        if ( prompt.length == echo.length && prompt.length == 1 && !echo[0]
&&
+            prompt[0].toLowerCase().contains( "password" ) )
+        {
+
+            ret = new String[1];
+            ret[0] = authInfo.getPassword();
+        }
+        else
+        {
+            // jsch-0.1.21/examples/UserAuthKI.java returns null to cancel
+            ret = null;
+        }
+
+        return ret;
+    }
+}

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/TraditionalUIKeyboardInteractive.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java?rev=312680&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java
(added)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java
Mon Oct 10 09:37:16 2005
@@ -0,0 +1,99 @@
+package org.apache.maven.wagon.providers.ssh.interactive;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.jcraft.jsch.UIKeyboardInteractive;
+import com.jcraft.jsch.UserInfo;
+
+/**
+ * A proxy that let you merge a <code>UserInfo</code> and a
+ * <code>UIKeyboardInteractive</code>
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 22, 2005
+ */
+public class UserInfoUIKeyboardInteractiveProxy
+    implements UserInfo, UIKeyboardInteractive
+{
+    private final UIKeyboardInteractive interactive;
+
+    private final UserInfo userInfo;
+
+    public UserInfoUIKeyboardInteractiveProxy( UserInfo userInfo, UIKeyboardInteractive interactive
)
+    {
+        this.userInfo = userInfo;
+        this.interactive = interactive;
+    }
+
+    /**
+     * @see com.jcraft.jsch.UIKeyboardInteractive#promptKeyboardInteractive(String, String,
String, String[], boolean[])
+     */
+    public String[] promptKeyboardInteractive( String destination, String name, String instruction,
String[] prompt,
+                                               boolean[] echo )
+    {
+        return interactive.promptKeyboardInteractive( destination, name, instruction, prompt,
echo );
+    }
+
+    /**
+     * @see com.jcraft.jsch.UserInfo#getPassphrase()
+     */
+    public String getPassphrase()
+    {
+        return userInfo.getPassphrase();
+    }
+
+    /**
+     * @see com.jcraft.jsch.UserInfo#getPassword()
+     */
+    public String getPassword()
+    {
+        return userInfo.getPassword();
+    }
+
+    /**
+     * @see com.jcraft.jsch.UserInfo#promptPassword(String)
+     */
+    public boolean promptPassword( String arg0 )
+    {
+        return userInfo.promptPassword( arg0 );
+    }
+
+    /**
+     * @see com.jcraft.jsch.UserInfo#promptPassphrase(String)
+     */
+    public boolean promptPassphrase( String arg0 )
+    {
+        return userInfo.promptPassphrase( arg0 );
+    }
+
+    /**
+     * @see com.jcraft.jsch.UserInfo#promptYesNo(String)
+     */
+    public boolean promptYesNo( String arg0 )
+    {
+        return userInfo.promptYesNo( arg0 );
+    }
+
+    /**
+     * @see com.jcraft.jsch.UserInfo#showMessage(String)
+     */
+    public void showMessage( String arg0 )
+    {
+        userInfo.showMessage( arg0 );
+    }
+
+}

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/UserInfoUIKeyboardInteractiveProxy.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/resources/META-INF/plexus/components.xml?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/resources/META-INF/plexus/components.xml
Mon Oct 10 09:37:16 2005
@@ -10,7 +10,10 @@
           <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
+          <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+        </requirement>
+        <requirement>
+          <role>com.jcraft.jsch.UIKeyboardInteractive</role>
         </requirement>
       </requirements>
     </component>
@@ -24,7 +27,10 @@
           <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
+          <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+        </requirement>
+        <requirement>
+          <role>com.jcraft.jsch.UIKeyboardInteractive</role>
         </requirement>
       </requirements>
     </component>
@@ -37,17 +43,20 @@
           <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
+          <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+        </requirement>
+        <requirement>
+          <role>com.jcraft.jsch.UIKeyboardInteractive</role>
         </requirement>
       </requirements>
     </component>
     <component>
-      <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
-      <implementation>org.apache.maven.wagon.providers.ssh.ConsoleInteractiveUserInfo</implementation>
+      <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+      <implementation>org.apache.maven.wagon.providers.ssh.interactive.ConsoleInteractiveUserInfo</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
       <requirements>
         <requirement>
-          <role>org.codehaus.plexus.components.inputhandler.InputHandler</role>
+          <role>org.codehaus.plexus.components.interactivity.Prompter</role>
         </requirement>
       </requirements>
     </component>
@@ -58,6 +67,15 @@
       <configuration>
         <hostKeyChecking>ask</hostKeyChecking>
       </configuration>
+    </component>
+    <component>
+      <role>com.jcraft.jsch.UIKeyboardInteractive</role>
+      <implementation>org.apache.maven.wagon.providers.ssh.interactive.PrompterUIKeyboardInteractive</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.components.interactivity.Prompter</role>
+        </requirement>
+      </requirements>
     </component>
   </components>
 </component-set>

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
Mon Oct 10 09:37:16 2005
@@ -1,8 +1,8 @@
 <component-set>
   <components>
     <component>
-      <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
-      <implementation>org.apache.maven.wagon.providers.ssh.NullInteractiveUserInfo</implementation>
+      <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+      <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
     </component>
     <component>

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
Mon Oct 10 09:37:16 2005
@@ -1,8 +1,8 @@
 <component-set>
   <components>
     <component>
-      <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
-      <implementation>org.apache.maven.wagon.providers.ssh.NullInteractiveUserInfo</implementation>
+      <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+      <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
     </component>
     <component>

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
Mon Oct 10 09:37:16 2005
@@ -1,8 +1,8 @@
 <component-set>
   <components>
     <component>
-      <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
-      <implementation>org.apache.maven.wagon.providers.ssh.NullInteractiveUserInfo</implementation>
+      <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+      <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
     </component>
     <component>

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml?rev=312680&r1=312679&r2=312680&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml
Mon Oct 10 09:37:16 2005
@@ -1,8 +1,8 @@
 <component-set>
   <components>
     <component>
-      <role>org.apache.maven.wagon.providers.ssh.InteractiveUserInfo</role>
-      <implementation>org.apache.maven.wagon.providers.ssh.NullInteractiveUserInfo</implementation>
+      <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+      <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
     </component>
     <component>



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message