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.

SSecurityStack.cxx 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include <rfb/SSecurityStack.h>
  19. using namespace rfb;
  20. SSecurityStack::SSecurityStack(SConnection* sc, int Type,
  21. SSecurity* s0, SSecurity* s1)
  22. : SSecurity(sc), state(0), state0(s0), state1(s1), type(Type)
  23. {
  24. }
  25. SSecurityStack::~SSecurityStack()
  26. {
  27. if (state0)
  28. delete state0;
  29. if (state1)
  30. delete state1;
  31. }
  32. bool SSecurityStack::processMsg()
  33. {
  34. bool res = true;
  35. if (state == 0) {
  36. if (state0)
  37. res = state0->processMsg();
  38. if (!res)
  39. return res;
  40. state++;
  41. }
  42. if (state == 1) {
  43. if (state1)
  44. res = state1->processMsg();
  45. if (!res)
  46. return res;
  47. state++;
  48. }
  49. return res;
  50. }
  51. const char* SSecurityStack::getUserName() const
  52. {
  53. const char* c = 0;
  54. if (state1 && !c)
  55. c = state1->getUserName();
  56. if (state0 && !c)
  57. c = state0->getUserName();
  58. return c;
  59. }
  60. SConnection::AccessRights SSecurityStack::getAccessRights() const
  61. {
  62. SConnection::AccessRights accessRights;
  63. if (!state0 && !state1)
  64. return SSecurity::getAccessRights();
  65. accessRights = SConnection::AccessFull;
  66. if (state0)
  67. accessRights &= state0->getAccessRights();
  68. if (state1)
  69. accessRights &= state1->getAccessRights();
  70. return accessRights;
  71. }