void SshConnectionPrivate::createPrivateKey() { if (m_connParams.privateKeyFile.isEmpty()) throw SshClientException(SshKeyFileError, tr("No private key file given.")); QFile keyFile(m_connParams.privateKeyFile); if (!keyFile.open(QIODevice::ReadOnly)) { throw SshClientException(SshKeyFileError, tr("Private key file error: %1").arg(keyFile.errorString())); } m_sendFacility.createAuthenticationKey(keyFile.readAll()); }
void SshChannelManager::removeChannel(ChannelIterator it) { if (it == m_channels.end()) { throw SshClientException(SshInternalError, QLatin1String("Internal error: Unexpected channel lookup failure")); } const int removeCount = m_sessions.remove(it.value()); if (removeCount != 1) { throw SshClientException(SshInternalError, QString::fromLatin1("Internal error: Unexpected session count %1 for channel.") .arg(removeCount)); } m_channels.erase(it); }
int SshCapabilities::ecdsaIntegerWidthInBytes(const QByteArray &ecdsaAlgo) { if (ecdsaAlgo == PubKeyEcdsa256) return 32; throw SshClientException(SshInternalError, SSH_TR("Unexpected ecdsa algorithm \"%1\"") .arg(QString::fromLatin1(ecdsaAlgo))); }
void SshConnectionPrivate::handlePasswordExpiredPacket() { if (m_connParams.authenticationType == SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods && m_triedAllPasswordBasedMethods) { // This means we just tried to authorize via "keyboard-interactive", in which case // this type of packet is not allowed. handleUnexpectedPacket(); return; } throw SshClientException(SshAuthenticationError, tr("Password expired.")); }
void SshConnectionPrivate::handleUserAuthFailurePacket() { // TODO: Evaluate "authentications that can continue" field and act on it. if (m_connParams.authenticationType == SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods && !m_triedAllPasswordBasedMethods) { m_triedAllPasswordBasedMethods = true; m_sendFacility.sendUserAuthByKeyboardInteractiveRequestPacket( m_connParams.userName.toUtf8(), SshCapabilities::SshConnectionService); return; } m_timeoutTimer.stop(); const QString errorMsg = m_connParams.authenticationType == SshConnectionParameters::AuthenticationTypePublicKey ? tr("Server rejected key.") : tr("Server rejected password."); throw SshClientException(SshAuthenticationError, errorMsg); }