You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wagon-commits@maven.apache.org by ev...@apache.org on 2004/11/23 12:12:23 UTC
cvs commit: maven-wagon/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh ScpWagon.java
evenisse 2004/11/23 03:12:23
Modified: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh
ScpWagon.java
Log:
Authorize connection with a password and not only private key.
Revision Changes Path
1.2 +27 -26 maven-wagon/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
Index: ScpWagon.java
===================================================================
RCS file: /home/cvs/maven-wagon/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ScpWagon.java 10 Aug 2004 17:49:15 -0000 1.1
+++ ScpWagon.java 23 Nov 2004 11:12:23 -0000 1.2
@@ -92,35 +92,39 @@
session = jsch.getSession( authInfo.getUserName(), host, port );
- File privateKey;
-
- if ( authInfo.getPrivateKey() != null )
- {
- privateKey = new File( authInfo.getPrivateKey() );
- }
- else
+ // If user don't define a password, he want to use a private key
+ if ( authInfo.getPassword() == null )
{
- privateKey = findPrivateKey();
- }
+ File privateKey;
- if ( privateKey.exists() )
- {
- if ( authInfo.getPassphrase() == null )
+ if ( authInfo.getPrivateKey() != null )
{
- String msg = "Private key provided " + "without passphrase for repo: " + getRepository().getName();
-
- throw new AuthenticationException( msg );
+ privateKey = new File( authInfo.getPrivateKey() );
+ }
+ else
+ {
+ privateKey = findPrivateKey();
}
- fireSessionDebug( "Using private key: " + privateKey );
+ if ( privateKey.exists() )
+ {
+ if ( authInfo.getPassphrase() == null )
+ {
+ String msg = "Private key provided " + "without passphrase for repo: " + getRepository().getName();
- jsch.addIdentity( privateKey.getAbsolutePath(), authInfo.getPassphrase() );
- }
- else
- {
- String msg = "Private key: " + privateKey + " not found ";
+ throw new AuthenticationException( msg );
+ }
+
+ fireSessionDebug( "Using private key: " + privateKey );
+
+ jsch.addIdentity( privateKey.getAbsolutePath(), authInfo.getPassphrase() );
+ }
+ else
+ {
+ String msg = "You must define a private key or a password for repo: " + getRepository().getName();
- throw new AuthenticationException( msg );
+ throw new AuthenticationException( msg );
+ }
}
ProxyInfo proxyInfo = getRepository().getProxyInfo();
@@ -264,7 +268,6 @@
if ( checkAck( in ) != 0 )
{
-
throw new TransferFailedException( "ACK check failed" );
}
@@ -532,7 +535,6 @@
// ----------------------------------------------------------------------
// JSch user info
// ----------------------------------------------------------------------
-
public class WagonUserInfo
implements UserInfo
{
@@ -615,5 +617,4 @@
return b;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-cvs-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-cvs-help@maven.apache.org