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_OK
indicating that the key is acceptable, it proceeds to send a request signed with the private key. Therefore, private keys are not requested from the associatedKeyProvider
unless 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 SSHPacket
buildReq()
Builds a feeler request (sans signature).private SSHPacket
buildReq(boolean signed)
Builds SSH_MSG_USERAUTH_REQUEST packet.void
handle(Message cmd, SSHPacket buf)
Internal use.private void
sendSignedReq()
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:
handle
in interfaceSSHPacketHandler
- Overrides:
handle
in classAbstractAuthMethod
- Parameters:
cmd
- the SSHmessage identifier
buf
-SSHPacket
containing rest of the request- Throws:
UserAuthException
TransportException
-
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
SSHPacket
containing the request packet - Throws:
UserAuthException
-
sendSignedReq
private void sendSignedReq() throws UserAuthException, TransportException
Send SSH_MSG_USERAUTH_REQUEST containing the signature.- Throws:
UserAuthException
TransportException
-
buildReq
protected SSHPacket buildReq() throws UserAuthException
Builds a feeler request (sans signature).- Overrides:
buildReq
in classAbstractAuthMethod
- Throws:
UserAuthException
-
-