PageRenderTime 44ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/build/distribution/IzPack/sample/src/PWDValidator.java

https://bitbucket.org/jorgenio/gvsig
Java | 77 lines | 23 code | 7 blank | 47 comment | 3 complexity | cdc8da389a2d55ff6784b350d45f516e MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception
  1. /*
  2. * $Id: PWDValidator.java 5819 2006-06-14 07:29:09Z cesar $
  3. * Copyright (C) 2003 Elmar Grom
  4. *
  5. * File : PWDValidator.java
  6. * Description : Example implementation of a password validator
  7. * Author's email : elmar@grom.net
  8. * Author's Website : http://www.izforge.com
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. */
  24. package com.izforge.izpack.sample;
  25. import com.izforge.izpack.panels.*;
  26. /*---------------------------------------------------------------------------*/
  27. /**
  28. * This class represents a simple validator for passwords to demonstrate
  29. * the implementation of a password validator that cooperates with the
  30. * password field in the <code>UserInputPanel</code>
  31. *
  32. * @version 0.0.1 / 02/19/03
  33. * @author Elmar Grom
  34. */
  35. /*---------------------------------------------------------------------------*/
  36. public class PWDValidator implements Validator
  37. {
  38. /*--------------------------------------------------------------------------*/
  39. /**
  40. * Validates the contend of multiple password fields. The test
  41. *
  42. * @param client the client object using the services of this validator.
  43. *
  44. * @return <code>true</code> if the validation passes, otherwise <code>false</code>.
  45. */
  46. /*--------------------------------------------------------------------------*/
  47. public boolean validate (ProcessingClient client)
  48. {
  49. int numFields = client.getNumFields ();
  50. // ----------------------------------------------------
  51. // verify that there is more than one field. If there
  52. // is only one field we have to return true.
  53. // ----------------------------------------------------
  54. if (numFields < 2)
  55. {
  56. return (true);
  57. }
  58. boolean match = true;
  59. String content = client.getFieldContents (0);
  60. for (int i = 1; i < numFields; i++)
  61. {
  62. if (!content.equals (client.getFieldContents (i)))
  63. {
  64. match = false;
  65. }
  66. }
  67. return (match);
  68. }
  69. }
  70. /*---------------------------------------------------------------------------*/