blob: 478ce4f61f8597c82fd14baa8555f21a096bac41 [file] [log] [blame]
Adam Tkacdfe19cf2010-04-23 14:14:11 +00001/* 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
19#include <rfb/SSecurityStack.h>
20
21using namespace rfb;
22
23SSecurityStack::SSecurityStack(int Type, SSecurity* s0, SSecurity* s1)
24 :state(0), state0(s0), state1(s1), type(Type) {}
25
26SSecurityStack::~SSecurityStack()
27{
28 if (state0)
29 delete state0;
30 if (state1)
31 delete state1;
32}
33
34bool SSecurityStack::processMsg(SConnection* cc)
35{
36 bool res = true;
37
38 if (state == 0) {
39 if (state0)
40 res = state0->processMsg(cc);
41 if (!res)
42 return res;
43 state++;
44 }
45
46 if (state == 1) {
47 if (state1)
48 res = state1->processMsg(cc);
49 if (!res)
50 return res;
51 state++;
52 }
53
54 return res;
55}
56
57const char* SSecurityStack::getUserName() const
58{
59 const char* c = 0;
60
61 if (state1 && !c)
62 c = state1->getUserName();
63 if (state0 && !c)
64 c = state0->getUserName();
65
66 return c;
67}
Pierre Ossman555815a2014-12-02 15:13:22 +010068
69SConnection::AccessRights SSecurityStack::getAccessRights() const
70{
71 SConnection::AccessRights accessRights;
72
73 if (!state0 && !state1)
74 return SSecurity::getAccessRights();
75
76 accessRights = SConnection::AccessFull;
77
78 if (state0)
79 accessRights &= state0->getAccessRights();
80 if (state1)
81 accessRights &= state1->getAccessRights();
82
83 return accessRights;
84}