blob: e0aee137d61f835cdda6bb6b6941ccf59ec3f68b [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
52SSecurity* SecurityServer::GetSSecurity(U32 secType)
53{
54 if (!IsSupported(secType))
55 goto bail;
56
57 switch (secType) {
58 case secTypeNone: return new SSecurityNone();
59 case secTypeVncAuth: return new SSecurityVncAuth();
60 case secTypeVeNCrypt: return new SSecurityVeNCrypt(this);
61 case secTypePlain: return new SSecurityPlain();
62#ifdef HAVE_GNUTLS
63 case secTypeTLSNone:
64 return new SSecurityStack(secTypeTLSNone, new SSecurityTLS(true));
65 case secTypeTLSVnc:
66 return new SSecurityStack(secTypeTLSVnc, new SSecurityTLS(true), new SSecurityVncAuth());
67 case secTypeTLSPlain:
68 return new SSecurityStack(secTypeTLSPlain, new SSecurityTLS(true), new SSecurityPlain());
69 case secTypeX509None:
70 return new SSecurityStack(secTypeX509None, new SSecurityTLS(false));
71 case secTypeX509Vnc:
72 return new SSecurityStack(secTypeX509None, new SSecurityTLS(false), new SSecurityVncAuth());
73 case secTypeX509Plain:
74 return new SSecurityStack(secTypeX509Plain, new SSecurityTLS(false), new SSecurityPlain());
75#endif
76 }
77
78bail:
79 throw Exception("Security type not supported");
80}
81