nodes.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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) 2012 Oz Nahum <nahumoz@gmail.com>
  18. #============================================================================
  19. #============================================================================
  20. # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
  21. #============================================================================
  22. from pwman.util.crypto import CryptoEngine
  23. class Node:
  24. def __init__(self,username="",password="",url="",notes="",tags=[]):
  25. """Initialise everything to null."""
  26. self._id = 0;
  27. enc = CryptoEngine.get()
  28. self._username = enc.encrypt(username)
  29. self._password = enc.encrypt(password)
  30. self._url = enc.encrypt(url)
  31. self._notes = enc.encrypt(notes)
  32. self._tags = []
  33. self.set_tags(tags)
  34. def get_tags(self):
  35. tags = []
  36. enc = CryptoEngine.get()
  37. for i in self._tags:
  38. tags.append(enc.decrypt(i))
  39. return tags
  40. def set_tags(self, tags):
  41. self._tags = []
  42. enc = CryptoEngine.get()
  43. for i in tags:
  44. self._tags.append(enc.encrypt(i))
  45. def get_id(self):
  46. return self._id
  47. def set_id(self, id):
  48. self._id = id
  49. def get_username(self):
  50. """Return the username."""
  51. enc = CryptoEngine.get()
  52. return enc.decrypt(self._username)
  53. def set_username(self, username):
  54. """Set the username."""
  55. enc = CryptoEngine.get()
  56. self._username = enc.encrypt(username)
  57. def get_password(self):
  58. """Return the password."""
  59. enc = CryptoEngine.get()
  60. return enc.decrypt(self._password)
  61. def set_password(self, password):
  62. """Set the password."""
  63. enc = CryptoEngine.get()
  64. self._password = enc.encrypt(password)
  65. def get_url(self):
  66. """Return the URL."""
  67. enc = CryptoEngine.get()
  68. return enc.decrypt(self._url)
  69. def set_url(self, url):
  70. """Set the URL."""
  71. enc = CryptoEngine.get()
  72. self._url = enc.encrypt(url)
  73. def get_notes(self):
  74. """Return the Notes."""
  75. enc = CryptoEngine.get()
  76. return enc.decrypt(self._notes)
  77. def set_notes(self, notes):
  78. """Set the Notes."""
  79. enc = CryptoEngine.get()
  80. self._notes = enc.encrypt(notes)