Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 35 | using namespace rdr; |
| 36 | using namespace rfb; |
| 37 | |
| 38 | StringParameter SecurityServer::secTypes |
| 39 | ("SecurityTypes", |
Pierre Ossman | 906800b | 2014-09-17 16:39:28 +0200 | [diff] [blame] | 40 | "Specify which security scheme to use (None, VncAuth, Plain" |
| 41 | #ifdef HAVE_GNUTLS |
| 42 | ", TLSNone, TLSVnc, TLSPlain, X509None, X509Vnc, X509Plain" |
| 43 | #endif |
| 44 | ")", |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 45 | #ifdef HAVE_GNUTLS |
Pierre Ossman | 5e022ec | 2014-11-11 14:00:38 +0100 | [diff] [blame] | 46 | "TLSVnc,VncAuth", |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 47 | #else |
| 48 | "VncAuth", |
| 49 | #endif |
| 50 | ConfServer); |
| 51 | |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 52 | SSecurity* SecurityServer::GetSSecurity(SConnection* sc, U32 secType) |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 53 | { |
| 54 | if (!IsSupported(secType)) |
| 55 | goto bail; |
| 56 | |
| 57 | switch (secType) { |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 58 | 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 Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 62 | #ifdef HAVE_GNUTLS |
| 63 | case secTypeTLSNone: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 64 | return new SSecurityStack(sc, secTypeTLSNone, new SSecurityTLS(sc, true)); |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 65 | case secTypeTLSVnc: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 66 | return new SSecurityStack(sc, secTypeTLSVnc, new SSecurityTLS(sc, true), new SSecurityVncAuth(sc)); |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 67 | case secTypeTLSPlain: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 68 | return new SSecurityStack(sc, secTypeTLSPlain, new SSecurityTLS(sc, true), new SSecurityPlain(sc)); |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 69 | case secTypeX509None: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 70 | return new SSecurityStack(sc, secTypeX509None, new SSecurityTLS(sc, false)); |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 71 | case secTypeX509Vnc: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 72 | return new SSecurityStack(sc, secTypeX509None, new SSecurityTLS(sc, false), new SSecurityVncAuth(sc)); |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 73 | case secTypeX509Plain: |
Pierre Ossman | ad2b3c4 | 2018-09-21 15:31:11 +0200 | [diff] [blame] | 74 | return new SSecurityStack(sc, secTypeX509Plain, new SSecurityTLS(sc, false), new SSecurityPlain(sc)); |
Adam Tkac | bfd66c1 | 2010-10-01 08:33:29 +0000 | [diff] [blame] | 75 | #endif |
| 76 | } |
| 77 | |
| 78 | bail: |
| 79 | throw Exception("Security type not supported"); |
| 80 | } |
| 81 | |