Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 2005 Martin Koegler
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. #ifdef HAVE_CONFIG_H
  19. #include <config.h>
  20. #endif
  21. #include <rfb/SSecurityStack.h>
  22. using namespace rfb;
  23. SSecurityStack::SSecurityStack(SConnection* sc, int Type,
  24. SSecurity* s0, SSecurity* s1)
  25. : SSecurity(sc), state(0), state0(s0), state1(s1), type(Type)
  26. {
  27. }
  28. SSecurityStack::~SSecurityStack()
  29. {
  30. delete state0;
  31. delete state1;
  32. }
  33. bool SSecurityStack::processMsg()
  34. {
  35. bool res = true;
  36. if (state == 0) {
  37. if (state0)
  38. res = state0->processMsg();
  39. if (!res)
  40. return res;
  41. state++;
  42. }
  43. if (state == 1) {
  44. if (state1)
  45. res = state1->processMsg();
  46. if (!res)
  47. return res;
  48. state++;
  49. }
  50. return res;
  51. }
  52. const char* SSecurityStack::getUserName() const
  53. {
  54. const char* c = 0;
  55. if (state1 && !c)
  56. c = state1->getUserName();
  57. if (state0 && !c)
  58. c = state0->getUserName();
  59. return c;
  60. }
  61. SConnection::AccessRights SSecurityStack::getAccessRights() const
  62. {
  63. SConnection::AccessRights accessRights;
  64. if (!state0 && !state1)
  65. return SSecurity::getAccessRights();
  66. accessRights = SConnection::AccessFull;
  67. if (state0)
  68. accessRights &= state0->getAccessRights();
  69. if (state1)
  70. accessRights &= state1->getAccessRights();
  71. return accessRights;
  72. }