You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CSecurityPlain.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2005 Martin Koegler
  2. * Copyright (C) 2010 TigerVNC Team
  3. * Copyright (C) 2011-2017 Brian P. Hinz
  4. *
  5. * This is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This software is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this software; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  18. * USA.
  19. */
  20. package com.tigervnc.rfb;
  21. import com.tigervnc.rdr.*;
  22. import com.tigervnc.vncviewer.*;
  23. public class CSecurityPlain extends CSecurity {
  24. public CSecurityPlain() { }
  25. public boolean processMsg(CConnection cc)
  26. {
  27. OutStream os = cc.getOutStream();
  28. StringBuffer username = new StringBuffer();
  29. StringBuffer password = new StringBuffer();
  30. upg.getUserPasswd(cc.isSecure(), username, password);
  31. // Return the response to the server
  32. os.writeU32(username.length());
  33. os.writeU32(password.length());
  34. byte[] utf8str;
  35. try {
  36. utf8str = username.toString().getBytes("UTF8");
  37. os.writeBytes(utf8str, 0, username.length());
  38. utf8str = password.toString().getBytes("UTF8");
  39. os.writeBytes(utf8str, 0, password.length());
  40. } catch(java.io.UnsupportedEncodingException e) {
  41. e.printStackTrace();
  42. }
  43. os.flush();
  44. return true;
  45. }
  46. public int getType() { return Security.secTypePlain; }
  47. public String description() { return "ask for username and password"; }
  48. static LogWriter vlog = new LogWriter("Plain");
  49. }