1 2 29 30 package com.jcraft.jsch; 31 32 class UserAuthNone extends UserAuth{ 33 private String methods=null; 34 35 public boolean start(Session session, UserInfo userinfo) throws Exception { 36 super.start(session, userinfo); 37 Packet packet=session.packet; 39 Buffer buf=session.buf; 40 final String username=session.username; 41 42 byte[] _username=null; 43 _username=Util.str2byte(username); 44 45 packet.reset(); 51 buf.putByte((byte)SSH_MSG_USERAUTH_REQUEST); 52 buf.putString(_username); 53 buf.putString("ssh-connection".getBytes()); 54 buf.putString("none".getBytes()); 55 session.write(packet); 56 57 loop: 58 while(true){ 59 buf=session.read(buf); 63 if(buf.buffer[5]==SSH_MSG_USERAUTH_SUCCESS){ 65 return true; 66 } 67 if(buf.buffer[5]==SSH_MSG_USERAUTH_BANNER){ 68 buf.getInt(); buf.getByte(); buf.getByte(); 69 byte[] _message=buf.getString(); 70 byte[] lang=buf.getString(); 71 String message=null; 72 try{ 73 message=new String (_message, "UTF-8"); 74 } 75 catch(java.io.UnsupportedEncodingException e){ 76 message=new String (_message); 77 } 78 if(userinfo!=null){ 79 try{ 80 userinfo.showMessage(message); 81 } 82 catch(RuntimeException ee){ 83 } 84 } 85 continue loop; 86 } 87 if(buf.buffer[5]==SSH_MSG_USERAUTH_FAILURE){ 88 buf.getInt(); buf.getByte(); buf.getByte(); 89 byte[] foo=buf.getString(); 90 int partial_success=buf.getByte(); 91 methods=new String (foo); 92 98 break; 99 } 100 else{ 101 throw new JSchException("USERAUTH fail ("+buf.buffer[5]+")"); 103 } 104 } 105 return false; 107 } 108 String getMethods(){ 109 return methods; 110 } 111 } 112 | Popular Tags |