nodes.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. #============================================================================
  17. # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
  18. #============================================================================
  19. from pwman.util.crypto import CryptoEngine
  20. class Node:
  21. def __init__(self,username="",password="",url="",notes="",tags=[]):
  22. """Initialise everything to null."""
  23. self._id = 0;
  24. enc = CryptoEngine.get()
  25. self._username = enc.encrypt(username)
  26. self._password = enc.encrypt(password)
  27. self._url = enc.encrypt(url)
  28. self._notes = enc.encrypt(notes)
  29. self._tags = []
  30. self.set_tags(tags)
  31. def get_tags(self):
  32. tags = []
  33. enc = CryptoEngine.get()
  34. for i in self._tags:
  35. tags.append(enc.decrypt(i))
  36. return tags
  37. def set_tags(self, tags):
  38. self._tags = []
  39. enc = CryptoEngine.get()
  40. for i in tags:
  41. self._tags.append(enc.encrypt(i))
  42. def get_id(self):
  43. return self._id
  44. def set_id(self, id):
  45. self._id = id
  46. def get_username(self):
  47. """Return the username."""
  48. enc = CryptoEngine.get()
  49. return enc.decrypt(self._username)
  50. def set_username(self, username):
  51. """Set the username."""
  52. enc = CryptoEngine.get()
  53. self._username = enc.encrypt(username)
  54. def get_password(self):
  55. """Return the password."""
  56. enc = CryptoEngine.get()
  57. return enc.decrypt(self._password)
  58. def set_password(self, password):
  59. """Set the password."""
  60. enc = CryptoEngine.get()
  61. self._password = enc.encrypt(password)
  62. def get_url(self):
  63. """Return the URL."""
  64. enc = CryptoEngine.get()
  65. return enc.decrypt(self._url)
  66. def set_url(self, url):
  67. """Set the URL."""
  68. enc = CryptoEngine.get()
  69. self._url = enc.encrypt(url)
  70. def get_notes(self):
  71. """Return the Notes."""
  72. enc = CryptoEngine.get()
  73. return enc.decrypt(self._notes)
  74. def set_notes(self, notes):
  75. """Set the Notes."""
  76. enc = CryptoEngine.get()
  77. self._notes = enc.encrypt(notes)