Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Better error message when both Key and Password authentication fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptdeboer authored and ptdeboer committed Jan 23, 2014
1 parent 4dea0f5 commit aae40b1
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,17 @@ private FileSystem authenticateSftpFileSystem(URI fsUri,ServerInfo info) throws

info.getUserinfo();
Credential sshCred=null;
String sshKey=info.getAttributeValue(ServerInfo.ATTR_SSH_IDENTITY);
String sshKeyFile=info.getAttributeValue(ServerInfo.ATTR_SSH_IDENTITY);
String sshUser=info.getUserinfo();

if (sshKey!=null)
if (sshKeyFile!=null)
{
try
{
sshCred=xenonClient.createSSHKeyCredential(info, credentialErrorH1);
if (sshCred==null)
{
logger.warnPrintf("Couldn't use SSH Key authentication for key:%s, error=%s\n",sshKey,credentialErrorH1.value);
logger.warnPrintf("Couldn't use SSH Key authentication for key:%s, error=%s\n",sshKeyFile,credentialErrorH1.value);
// keep credentialErrorH1
}
else
Expand All @@ -186,7 +187,15 @@ private FileSystem authenticateSftpFileSystem(URI fsUri,ServerInfo info) throws
}
catch (XenonException e)
{
throw new VrsException(e.getMessage(),e);
if (e.getMessage().contains("Auth cancel"))
{
credentialErrorH1.value="Invalid User+Keyfile combination for '"+fsUri.getUserInfo()+" and '"+sshKeyFile+"'";
logger.warnPrintf("SSH Keyfile authentication failed:%s\n",credentialErrorH2.value);
}
else
{
throw new VrsException(e.getMessage(),e);
}
}
}

Expand All @@ -202,7 +211,7 @@ private FileSystem authenticateSftpFileSystem(URI fsUri,ServerInfo info) throws
}
else
{
logger.warnPrintf("Couldn't use SSH Password authentication for key:%s, error=%s\n",sshKey,credentialErrorH2.value);
logger.warnPrintf("SSH Password authentication failed for user:'%s', error=%s\n",fsUri.getUserInfo(),credentialErrorH2.value);
}
}
catch (XenonException e)
Expand Down

0 comments on commit aae40b1

Please sign in to comment.