passphera-core 0.13.1__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passphera_core/application/generator.py +6 -3
- passphera_core/application/password.py +12 -18
- passphera_core/entities.py +1 -3
- passphera_core/interfaces.py +0 -1
- passphera_core/utilities.py +10 -0
- {passphera_core-0.13.1.dist-info → passphera_core-0.15.0.dist-info}/METADATA +1 -1
- passphera_core-0.15.0.dist-info/RECORD +12 -0
- passphera_core-0.13.1.dist-info/RECORD +0 -11
- {passphera_core-0.13.1.dist-info → passphera_core-0.15.0.dist-info}/WHEEL +0 -0
- {passphera_core-0.13.1.dist-info → passphera_core-0.15.0.dist-info}/top_level.txt +0 -0
@@ -25,32 +25,35 @@ class UpdateGeneratorPropertyUseCase:
|
|
25
25
|
def __init__(self, generator_repository: GeneratorRepository):
|
26
26
|
self.generator_repository: GeneratorRepository = generator_repository
|
27
27
|
|
28
|
-
def execute(self, field: str, value: str) ->
|
28
|
+
def execute(self, field: str, value: str) -> Generator:
|
29
29
|
generator_entity: Generator = self.generator_repository.get()
|
30
30
|
setattr(generator_entity, field, value)
|
31
31
|
if field == 'algorithm':
|
32
32
|
generator_entity.get_algorithm()
|
33
33
|
generator_entity.updated_at = datetime.now(timezone.utc)
|
34
34
|
self.generator_repository.update(generator_entity)
|
35
|
+
return generator_entity
|
35
36
|
|
36
37
|
|
37
38
|
class AddCharacterReplacementUseCase:
|
38
39
|
def __init__(self, generator_repository: GeneratorRepository):
|
39
40
|
self.generator_repository: GeneratorRepository = generator_repository
|
40
41
|
|
41
|
-
def execute(self, character: str, replacement: str) ->
|
42
|
+
def execute(self, character: str, replacement: str) -> Generator:
|
42
43
|
generator_entity: Generator = self.generator_repository.get()
|
43
44
|
generator_entity.replace_character(character, replacement)
|
44
45
|
generator_entity.updated_at = datetime.now(timezone.utc)
|
45
46
|
self.generator_repository.update(generator_entity)
|
47
|
+
return generator_entity
|
46
48
|
|
47
49
|
|
48
50
|
class ResetCharacterReplacementUseCase:
|
49
51
|
def __init__(self, generator_repository: GeneratorRepository,):
|
50
52
|
self.generator_repository: GeneratorRepository = generator_repository
|
51
53
|
|
52
|
-
def execute(self, character: str) ->
|
54
|
+
def execute(self, character: str) -> Generator:
|
53
55
|
generator_entity: Generator = self.generator_repository.get()
|
54
56
|
generator_entity.reset_character(character)
|
55
57
|
generator_entity.updated_at = datetime.now(timezone.utc)
|
56
58
|
self.generator_repository.update(generator_entity)
|
59
|
+
return generator_entity
|
@@ -1,8 +1,9 @@
|
|
1
|
-
from
|
1
|
+
from datetime import datetime, timezone
|
2
2
|
|
3
3
|
from passphera_core.entities import Password, Generator
|
4
|
-
from passphera_core.exceptions import DuplicatePasswordException
|
4
|
+
from passphera_core.exceptions import DuplicatePasswordException
|
5
5
|
from passphera_core.interfaces import PasswordRepository, GeneratorRepository
|
6
|
+
from passphera_core.utilities import get_password
|
6
7
|
|
7
8
|
|
8
9
|
class GeneratePasswordUseCase:
|
@@ -14,11 +15,11 @@ class GeneratePasswordUseCase:
|
|
14
15
|
self.password_repository: PasswordRepository = password_repository
|
15
16
|
self.generator_repository: GeneratorRepository = generator_repository
|
16
17
|
|
17
|
-
def execute(self,
|
18
|
+
def execute(self, context: str, text: str) -> Password:
|
18
19
|
password_entity: Password = self.password_repository.get_by_context(context)
|
19
|
-
if password_entity
|
20
|
+
if password_entity:
|
20
21
|
raise DuplicatePasswordException(password_entity)
|
21
|
-
generator_entity: Generator = self.generator_repository.get(
|
22
|
+
generator_entity: Generator = self.generator_repository.get()
|
22
23
|
password: str = generator_entity.generate_password(text)
|
23
24
|
password_entity: Password = Password(context=context, text=text, password=password)
|
24
25
|
password_entity.encrypt()
|
@@ -31,10 +32,7 @@ class GetPasswordByContextUseCase:
|
|
31
32
|
self.password_repository: PasswordRepository = password_repository
|
32
33
|
|
33
34
|
def execute(self, context: str) -> Password:
|
34
|
-
|
35
|
-
if not password_entity:
|
36
|
-
raise PasswordNotFoundException()
|
37
|
-
return password_entity
|
35
|
+
return get_password(self.password_repository, context)
|
38
36
|
|
39
37
|
|
40
38
|
class UpdatePasswordUseCase:
|
@@ -46,14 +44,13 @@ class UpdatePasswordUseCase:
|
|
46
44
|
self.password_repository: PasswordRepository = password_repository
|
47
45
|
self.generator_repository: GeneratorRepository = generator_repository
|
48
46
|
|
49
|
-
def execute(self,
|
50
|
-
password_entity: Password = self.password_repository
|
51
|
-
|
52
|
-
raise PasswordNotFoundException()
|
53
|
-
generator_entity: Generator = self.generator_repository.get(generator_id)
|
47
|
+
def execute(self, context: str, text: str) -> Password:
|
48
|
+
password_entity: Password = get_password(self.password_repository, context)
|
49
|
+
generator_entity: Generator = self.generator_repository.get()
|
54
50
|
password: str = generator_entity.generate_password(text)
|
55
51
|
password_entity.text = text
|
56
52
|
password_entity.password = password
|
53
|
+
password_entity.updated_at = datetime.now(timezone.utc)
|
57
54
|
password_entity.encrypt()
|
58
55
|
self.password_repository.update(password_entity)
|
59
56
|
return password_entity
|
@@ -64,10 +61,7 @@ class DeletePasswordUseCase:
|
|
64
61
|
self.password_repository: PasswordRepository = password_repository
|
65
62
|
|
66
63
|
def execute(self, context: str) -> None:
|
67
|
-
|
68
|
-
if not password_entity:
|
69
|
-
raise PasswordNotFoundException()
|
70
|
-
self.password_repository.delete(password_entity)
|
64
|
+
self.password_repository.delete(get_password(self.password_repository, context))
|
71
65
|
|
72
66
|
|
73
67
|
class GetAllPasswordsUseCase:
|
passphera_core/entities.py
CHANGED
@@ -14,7 +14,6 @@ class Password:
|
|
14
14
|
id: UUID = field(default_factory=uuid4)
|
15
15
|
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
16
16
|
updated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
17
|
-
deleted_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
18
17
|
context: str = field(default_factory=str)
|
19
18
|
text: str = field(default_factory=str)
|
20
19
|
password: str = field(default_factory=str)
|
@@ -82,8 +81,7 @@ class Generator:
|
|
82
81
|
:param password: The password to perform the action on it
|
83
82
|
:return: str: The new ciphered password after character replacements
|
84
83
|
"""
|
85
|
-
|
86
|
-
return password.translate(translation_table)
|
84
|
+
return password.translate(str.maketrans(self.characters_replacements))
|
87
85
|
|
88
86
|
def generate_password(self, text: str) -> str:
|
89
87
|
"""
|
passphera_core/interfaces.py
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
from passphera_core.entities import Password
|
2
|
+
from passphera_core.exceptions import DuplicatePasswordException
|
3
|
+
from passphera_core.interfaces import PasswordRepository
|
4
|
+
|
5
|
+
|
6
|
+
def get_password(password_repository: PasswordRepository, context: str) -> Password:
|
7
|
+
password_entity: Password = password_repository.get_by_context(context)
|
8
|
+
if password_entity:
|
9
|
+
raise DuplicatePasswordException(password_entity)
|
10
|
+
return password_entity
|
@@ -0,0 +1,12 @@
|
|
1
|
+
passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
passphera_core/entities.py,sha256=g1elnWnNQufnQn9hY6vtAovKWQnfjlJ0tmwCDTWcayc,4179
|
3
|
+
passphera_core/exceptions.py,sha256=Xir2lYIH7QYHfjDQu8WJ9qIhCvP-mYcPWYN2LbbbDj8,640
|
4
|
+
passphera_core/interfaces.py,sha256=zk-9X28Vful3bdZO5q4crsl06AFmI6N9cdGu0UfuEws,869
|
5
|
+
passphera_core/utilities.py,sha256=N-JNJ7hfJnOV4XP06t2f1zEkIoThNLl5nrcvoB3mlmg,439
|
6
|
+
passphera_core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
passphera_core/application/generator.py,sha256=UKsukvpItbq2Vn3XZSZf8Iwr1WPmDFYP7i14R_Hp9pU,2420
|
8
|
+
passphera_core/application/password.py,sha256=uwYo1PBIIC0pDRNYjU33Iccr0jqXxfhSZKxP5NQZqjg,3196
|
9
|
+
passphera_core-0.15.0.dist-info/METADATA,sha256=BsJjUaestF2SbgegeXdQVQ5m_JBXqP3XSHr_0tkDIPE,868
|
10
|
+
passphera_core-0.15.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
11
|
+
passphera_core-0.15.0.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
|
12
|
+
passphera_core-0.15.0.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
passphera_core/entities.py,sha256=OvVU6HzWF0GWElq_VFU-GUyittaOf5x8yMHYlAjemsE,4326
|
3
|
-
passphera_core/exceptions.py,sha256=Xir2lYIH7QYHfjDQu8WJ9qIhCvP-mYcPWYN2LbbbDj8,640
|
4
|
-
passphera_core/interfaces.py,sha256=8_V_08Q2_u56qVIkOOBkkFfyYKqP0aj7IpdMgoQbydI,891
|
5
|
-
passphera_core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
passphera_core/application/generator.py,sha256=8VELQch3pl0vP7g2GmSzxEgcjDuuGEZ82jB5Ry_MfL4,2309
|
7
|
-
passphera_core/application/password.py,sha256=YPnNTgBHclvsq88ZfbJMn5VHol8YizCYE-9Mv3MwTlU,3539
|
8
|
-
passphera_core-0.13.1.dist-info/METADATA,sha256=7aDIL4Y3jV-rF51-9xiFkVBUb0UKfjJ34Mke_h6GSkQ,868
|
9
|
-
passphera_core-0.13.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
10
|
-
passphera_core-0.13.1.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
|
11
|
-
passphera_core-0.13.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|