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.

CSecurityStack.cxx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Copyright (C) 2005 Martin Koegler
  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. #include <rfb/CSecurityStack.h>
  20. using namespace rfb;
  21. CSecurityStack::CSecurityStack(int Type, const char*Name, CSecurity* s0,
  22. CSecurity* s1)
  23. :name(Name),type(Type)
  24. {
  25. state = 0;
  26. state0 = s0;
  27. state1 = s1;
  28. }
  29. CSecurityStack::~CSecurityStack()
  30. {
  31. if (state0)
  32. delete state0;
  33. if (state1)
  34. delete state1;
  35. }
  36. bool CSecurityStack::processMsg(CConnection* cc)
  37. {
  38. bool res=true;
  39. if (state == 0) {
  40. if (state0)
  41. res = state0->processMsg(cc);
  42. if (!res)
  43. return res;
  44. state++;
  45. }
  46. if (state == 1) {
  47. if(state1)
  48. res = state1->processMsg(cc);
  49. if(!res)
  50. return res;
  51. state++;
  52. }
  53. return res;
  54. }
  55. bool CSecurityStack::isSecure() const
  56. {
  57. if (state0 && state0->isSecure())
  58. return true;
  59. if (state == 1 && state1 && state1->isSecure())
  60. return true;
  61. return false;
  62. }