mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
fixing up hostbased auth
This commit is contained in:
@@ -19,8 +19,6 @@ import net.schmizz.sshj.common.SSHPacket;
|
|||||||
import net.schmizz.sshj.userauth.UserAuthException;
|
import net.schmizz.sshj.userauth.UserAuthException;
|
||||||
import net.schmizz.sshj.userauth.keyprovider.KeyProvider;
|
import net.schmizz.sshj.userauth.keyprovider.KeyProvider;
|
||||||
|
|
||||||
// TODO check if this even works...!
|
|
||||||
|
|
||||||
/** Implements the {@code hostbased} SSH authentication method. */
|
/** Implements the {@code hostbased} SSH authentication method. */
|
||||||
public class AuthHostbased
|
public class AuthHostbased
|
||||||
extends KeyedAuthMethod {
|
extends KeyedAuthMethod {
|
||||||
@@ -28,22 +26,17 @@ public class AuthHostbased
|
|||||||
protected final String hostname;
|
protected final String hostname;
|
||||||
protected final String hostuser;
|
protected final String hostuser;
|
||||||
|
|
||||||
public AuthHostbased(KeyProvider kProv, String hostuser) {
|
public AuthHostbased(KeyProvider kProv, String hostname, String hostuser) {
|
||||||
this(kProv, hostuser, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthHostbased(KeyProvider kProv, String hostuser, String hostname) {
|
|
||||||
super("hostbased", kProv);
|
super("hostbased", kProv);
|
||||||
assert hostuser != null;
|
|
||||||
this.hostuser = hostuser;
|
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
|
this.hostuser = hostuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SSHPacket buildReq()
|
protected SSHPacket buildReq()
|
||||||
throws UserAuthException {
|
throws UserAuthException {
|
||||||
SSHPacket req = putPubKey(super.buildReq());
|
final SSHPacket req = putPubKey(super.buildReq());
|
||||||
req.putString(hostname == null ? params.getTransport().getRemoteHost() : hostname).putString(hostuser);
|
req.putString(hostname).putString(hostuser);
|
||||||
return putSig(req);
|
return putSig(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user