public SshPublicKey [ ] list ( ) throws SshException , PublicKeySubsystemException { try { Packet msg = createPacket ( ) ; msg . writeString ( "list" ) ; sendMessage ( msg ) ; Vector < SshPublicKey > keys = new Vector < SshPublicKey > ( ) ; while ( true ) { ByteArrayReader response = new ByteArrayReader ( nextMessage ( ) ) ; try { String type = response . readString ( ) ; if ( type . equals ( "publickey" ) ) { @ SuppressWarnings ( "unused" ) String comment = response . readString ( ) ; String algorithm = response . readString ( ) ; keys . addElement ( SshPublicKeyFileFactory . decodeSSH2PublicKey ( algorithm , response . readBinaryString ( ) ) ) ; } else if ( type . equals ( "status" ) ) { int status = ( int ) response . readInt ( ) ; String desc = response . readString ( ) ; if ( status != PublicKeySubsystemException . SUCCESS ) { throw new PublicKeySubsystemException ( status , desc ) ; } SshPublicKey [ ] array = new SshPublicKey [ keys . size ( ) ] ; keys . copyInto ( array ) ; return array ; } else { throw new SshException ( "The server sent an invalid response to a list command" , SshException . PROTOCOL_VIOLATION ) ; } } finally { try { response . close ( ) ; } catch ( IOException e ) { } } } } catch ( IOException ex ) { throw new SshException ( ex ) ; } }
List all of the users acceptable keys .