You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SecurityClient.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2010 TigerVNC Team
  3. * Copyright (C) 2011-2017 Brian P. Hinz
  4. *
  5. * This is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This software is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this software; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  18. * USA.
  19. */
  20. package com.tigervnc.rfb;
  21. public class SecurityClient extends Security {
  22. public SecurityClient() { super(secTypes); }
  23. public CSecurity GetCSecurity(int secType)
  24. {
  25. assert (CSecurity.upg != null); /* (upg == null) means bug in the viewer */
  26. assert (CSecurityTLS.msg != null);
  27. if (!IsSupported(secType))
  28. throw new Exception("Security type not supported");
  29. switch (secType) {
  30. case Security.secTypeNone: return (new CSecurityNone());
  31. case Security.secTypeVncAuth: return (new CSecurityVncAuth());
  32. case Security.secTypeVeNCrypt: return (new CSecurityVeNCrypt(this));
  33. case Security.secTypePlain: return (new CSecurityPlain());
  34. case Security.secTypeIdent: return (new CSecurityIdent());
  35. case Security.secTypeTLSNone:
  36. return (new CSecurityStack(secTypeTLSNone, "TLS with no password",
  37. new CSecurityTLS(true), null));
  38. case Security.secTypeTLSVnc:
  39. return (new CSecurityStack(secTypeTLSVnc, "TLS with VNCAuth",
  40. new CSecurityTLS(true), new CSecurityVncAuth()));
  41. case Security.secTypeTLSPlain:
  42. return (new CSecurityStack(secTypeTLSPlain, "TLS with Username/Password",
  43. new CSecurityTLS(true), new CSecurityPlain()));
  44. case Security.secTypeTLSIdent:
  45. return (new CSecurityStack(secTypeTLSIdent, "TLS with username only",
  46. new CSecurityTLS(true), new CSecurityIdent()));
  47. case Security.secTypeX509None:
  48. return (new CSecurityStack(secTypeX509None, "X509 with no password",
  49. new CSecurityTLS(false), null));
  50. case Security.secTypeX509Vnc:
  51. return (new CSecurityStack(secTypeX509Vnc, "X509 with VNCAuth",
  52. new CSecurityTLS(false), new CSecurityVncAuth()));
  53. case Security.secTypeX509Plain:
  54. return (new CSecurityStack(secTypeX509Plain, "X509 with Username/Password",
  55. new CSecurityTLS(false), new CSecurityPlain()));
  56. case Security.secTypeX509Ident:
  57. return (new CSecurityStack(secTypeX509Ident, "X509 with username only",
  58. new CSecurityTLS(false), new CSecurityIdent()));
  59. default:
  60. throw new Exception("Security type not supported");
  61. }
  62. }
  63. public static void setDefaults()
  64. {
  65. CSecurityTLS.setDefaults();
  66. }
  67. public static StringParameter secTypes
  68. = new StringParameter("SecurityTypes",
  69. "Specify which security scheme to use (None, VncAuth, Plain, Ident, TLSNone, TLSVnc, TLSPlain, TLSIdent, X509None, X509Vnc, X509Plain, X509Ident)",
  70. "X509Ident,X509Plain,TLSIdent,TLSPlain,X509Vnc,TLSVnc,X509None,TLSNone,Ident,VncAuth,None", Configuration.ConfigurationObject.ConfViewer);
  71. }