blob: 55f3133ea6bc90b9c4351d4685178331a35c870d [file] [log] [blame]
Adam Tkacb10489b2010-04-23 14:16:04 +00001/* 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
20#include <rfb/CSecurityStack.h>
21
22using namespace rfb;
23
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020024CSecurityStack::CSecurityStack(CConnection* cc, int Type, const char* Name,
25 CSecurity* s0, CSecurity* s1)
26 : CSecurity(cc), name(Name), type(Type)
Adam Tkacb10489b2010-04-23 14:16:04 +000027{
28 state = 0;
29 state0 = s0;
30 state1 = s1;
31}
32
33CSecurityStack::~CSecurityStack()
34{
35 if (state0)
36 delete state0;
37 if (state1)
38 delete state1;
39}
40
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020041bool CSecurityStack::processMsg()
Adam Tkacb10489b2010-04-23 14:16:04 +000042{
43 bool res=true;
44 if (state == 0) {
45 if (state0)
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020046 res = state0->processMsg();
Adam Tkacb10489b2010-04-23 14:16:04 +000047
48 if (!res)
49 return res;
50
51 state++;
52 }
53
54 if (state == 1) {
55 if(state1)
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020056 res = state1->processMsg();
Adam Tkacb10489b2010-04-23 14:16:04 +000057
58 if(!res)
59 return res;
60
61 state++;
62 }
63
64 return res;
65}
Pierre Ossmandaf3d882017-09-01 11:14:35 +020066
67bool CSecurityStack::isSecure() const
68{
69 if (state0 && state0->isSecure())
70 return true;
71 if (state == 1 && state1 && state1->isSecure())
72 return true;
73 return false;
74}