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.

SecurityServer.cxx 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2010 TigerVNC Team
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This software is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this software; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17. * USA.
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include <config.h>
  21. #endif
  22. #include <rdr/Exception.h>
  23. #include <rfb/Security.h>
  24. #include <rfb/SSecurityNone.h>
  25. #include <rfb/SSecurityStack.h>
  26. #include <rfb/SSecurityPlain.h>
  27. #include <rfb/SSecurityVncAuth.h>
  28. #include <rfb/SSecurityVeNCrypt.h>
  29. #ifdef HAVE_GNUTLS
  30. #include <rfb/SSecurityTLS.h>
  31. #endif
  32. using namespace rdr;
  33. using namespace rfb;
  34. StringParameter SecurityServer::secTypes
  35. ("SecurityTypes",
  36. "Specify which security scheme to use (None, VncAuth)",
  37. #ifdef HAVE_GNUTLS
  38. "VncAuth,TLSVnc",
  39. #else
  40. "VncAuth",
  41. #endif
  42. ConfServer);
  43. SSecurity* SecurityServer::GetSSecurity(U32 secType)
  44. {
  45. if (!IsSupported(secType))
  46. goto bail;
  47. switch (secType) {
  48. case secTypeNone: return new SSecurityNone();
  49. case secTypeVncAuth: return new SSecurityVncAuth();
  50. case secTypeVeNCrypt: return new SSecurityVeNCrypt(this);
  51. case secTypePlain: return new SSecurityPlain();
  52. #ifdef HAVE_GNUTLS
  53. case secTypeTLSNone:
  54. return new SSecurityStack(secTypeTLSNone, new SSecurityTLS(true));
  55. case secTypeTLSVnc:
  56. return new SSecurityStack(secTypeTLSVnc, new SSecurityTLS(true), new SSecurityVncAuth());
  57. case secTypeTLSPlain:
  58. return new SSecurityStack(secTypeTLSPlain, new SSecurityTLS(true), new SSecurityPlain());
  59. case secTypeX509None:
  60. return new SSecurityStack(secTypeX509None, new SSecurityTLS(false));
  61. case secTypeX509Vnc:
  62. return new SSecurityStack(secTypeX509None, new SSecurityTLS(false), new SSecurityVncAuth());
  63. case secTypeX509Plain:
  64. return new SSecurityStack(secTypeX509Plain, new SSecurityTLS(false), new SSecurityPlain());
  65. #endif
  66. }
  67. bail:
  68. throw Exception("Security type not supported");
  69. }