blob: 97b133c7c6fc5db235a6a0266ae7fcb1419b60d3 [file] [log] [blame]
Adam Tkacbfd66c12010-10-01 08:33:29 +00001/*
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#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24#include <rdr/Exception.h>
25#include <rfb/Security.h>
26#include <rfb/SSecurityNone.h>
27#include <rfb/SSecurityStack.h>
28#include <rfb/SSecurityPlain.h>
29#include <rfb/SSecurityVncAuth.h>
30#include <rfb/SSecurityVeNCrypt.h>
31#ifdef HAVE_GNUTLS
32#include <rfb/SSecurityTLS.h>
33#endif
34
35using namespace rdr;
36using namespace rfb;
37
38StringParameter SecurityServer::secTypes
39("SecurityTypes",
Pierre Ossman906800b2014-09-17 16:39:28 +020040 "Specify which security scheme to use (None, VncAuth, Plain"
41#ifdef HAVE_GNUTLS
42 ", TLSNone, TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain"
43#endif
44 ")",
Adam Tkacbfd66c12010-10-01 08:33:29 +000045#ifdef HAVE_GNUTLS
Pierre Ossman5e022ec2014-11-11 14:00:38 +010046 "TLSVnc,VncAuth",
Adam Tkacbfd66c12010-10-01 08:33:29 +000047#else
48 "VncAuth",
49#endif
50ConfServer);
51
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020052SSecurity* SecurityServer::GetSSecurity(SConnection* sc, U32 secType)
Adam Tkacbfd66c12010-10-01 08:33:29 +000053{
54 if (!IsSupported(secType))
55 goto bail;
56
57 switch (secType) {
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020058 case secTypeNone: return new SSecurityNone(sc);
59 case secTypeVncAuth: return new SSecurityVncAuth(sc);
60 case secTypeVeNCrypt: return new SSecurityVeNCrypt(sc, this);
61 case secTypePlain: return new SSecurityPlain(sc);
Adam Tkacbfd66c12010-10-01 08:33:29 +000062#ifdef HAVE_GNUTLS
63 case secTypeTLSNone:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020064 return new SSecurityStack(sc, secTypeTLSNone, new SSecurityTLS(sc, true));
Adam Tkacbfd66c12010-10-01 08:33:29 +000065 case secTypeTLSVnc:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020066 return new SSecurityStack(sc, secTypeTLSVnc, new SSecurityTLS(sc, true), new SSecurityVncAuth(sc));
Adam Tkacbfd66c12010-10-01 08:33:29 +000067 case secTypeTLSPlain:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020068 return new SSecurityStack(sc, secTypeTLSPlain, new SSecurityTLS(sc, true), new SSecurityPlain(sc));
Adam Tkacbfd66c12010-10-01 08:33:29 +000069 case secTypeX509None:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020070 return new SSecurityStack(sc, secTypeX509None, new SSecurityTLS(sc, false));
Adam Tkacbfd66c12010-10-01 08:33:29 +000071 case secTypeX509Vnc:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020072 return new SSecurityStack(sc, secTypeX509None, new SSecurityTLS(sc, false), new SSecurityVncAuth(sc));
Adam Tkacbfd66c12010-10-01 08:33:29 +000073 case secTypeX509Plain:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020074 return new SSecurityStack(sc, secTypeX509Plain, new SSecurityTLS(sc, false), new SSecurityPlain(sc));
Adam Tkacbfd66c12010-10-01 08:33:29 +000075#endif
76 }
77
78bail:
79 throw Exception("Security type not supported");
80}
81