Package net.schmizz.sshj.userauth.method
Class AuthPublickey
- java.lang.Object
-
- net.schmizz.sshj.userauth.method.AbstractAuthMethod
-
- net.schmizz.sshj.userauth.method.KeyedAuthMethod
-
- net.schmizz.sshj.userauth.method.AuthPublickey
-
- All Implemented Interfaces:
SSHPacketHandler,AuthMethod
public class AuthPublickey extends KeyedAuthMethod
Implements the"publickey"SSH authentication method. Requesting authentication with this method first sends a "feeler" request with just the public key, and if the server responds withSSH_MSG_USERAUTH_PK_OKindicating that the key is acceptable, it proceeds to send a request signed with the private key. Therefore, private keys are not requested from the associatedKeyProviderunless needed.
-
-
Field Summary
-
Fields inherited from class net.schmizz.sshj.userauth.method.KeyedAuthMethod
kProv
-
Fields inherited from class net.schmizz.sshj.userauth.method.AbstractAuthMethod
log, params
-
-
Constructor Summary
Constructors Constructor Description AuthPublickey(KeyProvider kProv)Initialize this method with the provider for public and private key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SSHPacketbuildReq()Builds a feeler request (sans signature).private SSHPacketbuildReq(boolean signed)Builds SSH_MSG_USERAUTH_REQUEST packet.voidhandle(Message cmd, SSHPacket buf)Internal use.private voidsendSignedReq()Send SSH_MSG_USERAUTH_REQUEST containing the signature.-
Methods inherited from class net.schmizz.sshj.userauth.method.KeyedAuthMethod
putPubKey, putSig, shouldRetry
-
Methods inherited from class net.schmizz.sshj.userauth.method.AbstractAuthMethod
getName, init, makeAccountResource, request, setLoggerFactory
-
-
-
-
Constructor Detail
-
AuthPublickey
public AuthPublickey(KeyProvider kProv)
Initialize this method with the provider for public and private key.
-
-
Method Detail
-
handle
public void handle(Message cmd, SSHPacket buf) throws UserAuthException, TransportException
Internal use.- Specified by:
handlein interfaceSSHPacketHandler- Overrides:
handlein classAbstractAuthMethod- Parameters:
cmd- the SSHmessage identifierbuf-SSHPacketcontaining rest of the request- Throws:
UserAuthExceptionTransportException
-
buildReq
private SSHPacket buildReq(boolean signed) throws UserAuthException
Builds SSH_MSG_USERAUTH_REQUEST packet.- Parameters:
signed- whether the request packet will contain signature- Returns:
- the
SSHPacketcontaining the request packet - Throws:
UserAuthException
-
sendSignedReq
private void sendSignedReq() throws UserAuthException, TransportExceptionSend SSH_MSG_USERAUTH_REQUEST containing the signature.- Throws:
UserAuthExceptionTransportException
-
buildReq
protected SSHPacket buildReq() throws UserAuthException
Builds a feeler request (sans signature).- Overrides:
buildReqin classAbstractAuthMethod- Throws:
UserAuthException
-
-