(Session session)
| 34 | class UserAuthPublicKey extends UserAuth{ |
| 35 | |
| 36 | public boolean start(Session session) throws Exception{ |
| 37 | super.start(session); |
| 38 | |
| 39 | Vector identities=session.getIdentityRepository().getIdentities(); |
| 40 | |
| 41 | byte[] passphrase=null; |
| 42 | byte[] _username=null; |
| 43 | |
| 44 | int command; |
| 45 | |
| 46 | synchronized(identities){ |
| 47 | if(identities.size()<=0){ |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | _username=Util.str2byte(username); |
| 52 | |
| 53 | for(int i=0; i<identities.size(); i++){ |
| 54 | |
| 55 | if(session.auth_failures >= session.max_auth_tries){ |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | Identity identity=(Identity)(identities.elementAt(i)); |
| 60 | byte[] pubkeyblob=identity.getPublicKeyBlob(); |
| 61 | |
| 62 | if(pubkeyblob!=null){ |
| 63 | // send |
| 64 | // byte SSH_MSG_USERAUTH_REQUEST(50) |
| 65 | // string user name |
| 66 | // string service name ("ssh-connection") |
| 67 | // string "publickey" |
| 68 | // boolen FALSE |
| 69 | // string public key algorithm name |
| 70 | // string public key blob |
| 71 | packet.reset(); |
| 72 | buf.putByte((byte)SSH_MSG_USERAUTH_REQUEST); |
| 73 | buf.putString(_username); |
| 74 | buf.putString(Util.str2byte("ssh-connection")); |
| 75 | buf.putString(Util.str2byte("publickey")); |
| 76 | buf.putByte((byte)0); |
| 77 | buf.putString(Util.str2byte(identity.getAlgName())); |
| 78 | buf.putString(pubkeyblob); |
| 79 | session.write(packet); |
| 80 | |
| 81 | loop1: |
| 82 | while(true){ |
| 83 | buf=session.read(buf); |
| 84 | command=buf.getCommand()&0xff; |
| 85 | |
| 86 | if(command==SSH_MSG_USERAUTH_PK_OK){ |
| 87 | break; |
| 88 | } |
| 89 | else if(command==SSH_MSG_USERAUTH_FAILURE){ |
| 90 | break; |
| 91 | } |
| 92 | else if(command==SSH_MSG_USERAUTH_BANNER){ |
| 93 | buf.getInt(); buf.getByte(); buf.getByte(); |
nothing calls this directly
no test coverage detected