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.

SecurityClient.cxx 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  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 <assert.h>
  23. #include <rfb/CSecurityNone.h>
  24. #include <rfb/CSecurityStack.h>
  25. #include <rfb/CSecurityVeNCrypt.h>
  26. #include <rfb/CSecurityVncAuth.h>
  27. #include <rfb/CSecurityPlain.h>
  28. #include <rdr/Exception.h>
  29. #include <rfb/Security.h>
  30. #ifdef HAVE_GNUTLS
  31. #include <rfb/CSecurityTLS.h>
  32. #endif
  33. using namespace rdr;
  34. using namespace rfb;
  35. UserPasswdGetter *CSecurity::upg = NULL;
  36. #ifdef HAVE_GNUTLS
  37. UserMsgBox *CSecurityTLS::msg = NULL;
  38. #endif
  39. StringParameter SecurityClient::secTypes
  40. ("SecurityTypes",
  41. "Specify which security scheme to use (None, VncAuth, Plain"
  42. #ifdef HAVE_GNUTLS
  43. ", TLSNone, TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain"
  44. #endif
  45. ")",
  46. #ifdef HAVE_GNUTLS
  47. "X509Plain,TLSPlain,X509Vnc,TLSVnc,X509None,TLSNone,VncAuth,None",
  48. #else
  49. "VncAuth,None",
  50. #endif
  51. ConfViewer);
  52. CSecurity* SecurityClient::GetCSecurity(CConnection* cc, U32 secType)
  53. {
  54. assert (CSecurity::upg != NULL); /* (upg == NULL) means bug in the viewer */
  55. #ifdef HAVE_GNUTLS
  56. assert (CSecurityTLS::msg != NULL);
  57. #endif
  58. if (!IsSupported(secType))
  59. goto bail;
  60. switch (secType) {
  61. case secTypeNone: return new CSecurityNone(cc);
  62. case secTypeVncAuth: return new CSecurityVncAuth(cc);
  63. case secTypeVeNCrypt: return new CSecurityVeNCrypt(cc, this);
  64. case secTypePlain: return new CSecurityPlain(cc);
  65. #ifdef HAVE_GNUTLS
  66. case secTypeTLSNone:
  67. return new CSecurityStack(cc, secTypeTLSNone,
  68. "TLS with no password",
  69. new CSecurityTLS(cc, true));
  70. case secTypeTLSVnc:
  71. return new CSecurityStack(cc, secTypeTLSVnc,
  72. "TLS with VNCAuth",
  73. new CSecurityTLS(cc, true),
  74. new CSecurityVncAuth(cc));
  75. case secTypeTLSPlain:
  76. return new CSecurityStack(cc, secTypeTLSPlain,
  77. "TLS with Username/Password",
  78. new CSecurityTLS(cc, true),
  79. new CSecurityPlain(cc));
  80. case secTypeX509None:
  81. return new CSecurityStack(cc, secTypeX509None,
  82. "X509 with no password",
  83. new CSecurityTLS(cc, false));
  84. case secTypeX509Vnc:
  85. return new CSecurityStack(cc, secTypeX509Vnc,
  86. "X509 with VNCAuth",
  87. new CSecurityTLS(cc, false),
  88. new CSecurityVncAuth(cc));
  89. case secTypeX509Plain:
  90. return new CSecurityStack(cc, secTypeX509Plain,
  91. "X509 with Username/Password",
  92. new CSecurityTLS(cc, false),
  93. new CSecurityPlain(cc));
  94. #endif
  95. }
  96. bail:
  97. throw Exception("Security type not supported");
  98. }