mirror of https://github.com/apache/maven.git
[MNG-4877] Regression: Deploy to SCP with privateKey fails - privateKey and passphrase gets lost
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1029208 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
545fa2b101
commit
3a53a3caf2
|
@ -20,7 +20,12 @@ package org.apache.maven.artifact.repository;
|
|||
*/
|
||||
|
||||
public class Authentication
|
||||
{
|
||||
{
|
||||
|
||||
private String privateKey;
|
||||
|
||||
private String passphrase;
|
||||
|
||||
public Authentication( String userName, String password )
|
||||
{
|
||||
this.username = userName;
|
||||
|
@ -76,4 +81,46 @@ public class Authentication
|
|||
{
|
||||
this.username = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the passphrase of the private key file. The passphrase is used only when host/protocol supports
|
||||
* authentication via exchange of private/public keys and private key was used for authentication.
|
||||
*
|
||||
* @return passphrase of the private key file
|
||||
*/
|
||||
public String getPassphrase()
|
||||
{
|
||||
return passphrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the passphrase of the private key file.
|
||||
*
|
||||
* @param passphrase passphrase of the private key file
|
||||
*/
|
||||
public void setPassphrase( final String passphrase )
|
||||
{
|
||||
this.passphrase = passphrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute path to the private key file.
|
||||
*
|
||||
* @return absolute path to private key
|
||||
*/
|
||||
public String getPrivateKey()
|
||||
{
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the absolute path to private key file.
|
||||
*
|
||||
* @param privateKey path to private key in local file system
|
||||
*/
|
||||
public void setPrivateKey( final String privateKey )
|
||||
{
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -550,6 +550,8 @@ public class LegacyRepositorySystem
|
|||
}
|
||||
|
||||
Authentication authentication = new Authentication( server.getUsername(), server.getPassword() );
|
||||
authentication.setPrivateKey( server.getPrivateKey() );
|
||||
authentication.setPassphrase( server.getPassphrase() );
|
||||
|
||||
repository.setAuthentication( authentication );
|
||||
}
|
||||
|
@ -572,7 +574,10 @@ public class LegacyRepositorySystem
|
|||
selector.getAuthentication( RepositoryUtils.toRepo( repository ) );
|
||||
if ( auth != null )
|
||||
{
|
||||
return new Authentication( auth.getUsername(), auth.getPassword() );
|
||||
Authentication result = new Authentication( auth.getUsername(), auth.getPassword() );
|
||||
result.setPrivateKey( auth.getPrivateKeyFile() );
|
||||
result.setPassphrase( auth.getPassphrase() );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,8 @@ public class RepositoryUtils
|
|||
Authentication result = null;
|
||||
if ( auth != null )
|
||||
{
|
||||
result = new Authentication( auth.getUsername(), auth.getPassword() );
|
||||
result =
|
||||
new Authentication( auth.getUsername(), auth.getPassword(), auth.getPrivateKey(), auth.getPassphrase() );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue