Commit 27791b112062394ee6a2d2588d0889adf8f72acf
1 parent
7a765da2
style: User-Model in PlantUML modelliert
Showing
2 changed files
with
64 additions
and
0 deletions
src/main/java/net/ziemers/swxercise/lg/model/user/Model.puml
0 → 100644
1 | +@startuml | ||
2 | + | ||
3 | +class BaseEntity { | ||
4 | + - Long id | ||
5 | +} | ||
6 | + | ||
7 | +class User { | ||
8 | + - String firstname | ||
9 | + - String lastname | ||
10 | +} | ||
11 | +class Profile { | ||
12 | + - String username | ||
13 | + - String passwordHash | ||
14 | + - String salt | ||
15 | + - PasswordHashAlgorithm hashAlgorithm | ||
16 | + - String mailaddress | ||
17 | + + String setPassword(String password) | ||
18 | + - String getPasswordHash() | ||
19 | + + boolean isValidPassword(String password) | ||
20 | + - void setPasswordHash() | ||
21 | +} | ||
22 | + | ||
23 | +class Role { | ||
24 | + - String name | ||
25 | + - Collection<RightState> rights | ||
26 | +} | ||
27 | + | ||
28 | +class Address { | ||
29 | + - String street | ||
30 | + - String zipcode | ||
31 | + - String city | ||
32 | + - String country | ||
33 | +} | ||
34 | + | ||
35 | +enum PasswordHashAlgorithm { | ||
36 | + SHA512 | ||
37 | +} | ||
38 | + | ||
39 | +enum RightState { | ||
40 | + NOT_LOGGED_IN | ||
41 | + LOGGED_IN | ||
42 | + ADMIN | ||
43 | +} | ||
44 | + | ||
45 | +BaseEntity <|-- User : MappedSuperClass | ||
46 | +User "1" --> "0..1" Profile | ||
47 | +User "1" --> "0..1" Address | ||
48 | +Profile "*" --> "1" Role | ||
49 | +Profile ..> "1" PasswordHashAlgorithm | ||
50 | +Role "*" --> "1" Role : parent | ||
51 | +Role ..> "*" RightState | ||
52 | + | ||
53 | +@enduml | ||
0 | \ No newline at end of file | 54 | \ No newline at end of file |
src/main/java/net/ziemers/swxercise/lg/model/user/Profile.java
@@ -145,6 +145,11 @@ public class Profile extends BaseEntity { | @@ -145,6 +145,11 @@ public class Profile extends BaseEntity { | ||
145 | return passwordHash; | 145 | return passwordHash; |
146 | } | 146 | } |
147 | 147 | ||
148 | + /** | ||
149 | + * Setzt das im Profil hinterlegte Kennwort. Es wird darin sicher verschlüsselt abgelegt. | ||
150 | + * | ||
151 | + * @param password das gewünschte Kennwort | ||
152 | + */ | ||
148 | public void setPassword(String password) { | 153 | public void setPassword(String password) { |
149 | // das Klartextkennwort wird niemals gespeichert! | 154 | // das Klartextkennwort wird niemals gespeichert! |
150 | this.passwordHash = cryptString(password); | 155 | this.passwordHash = cryptString(password); |
@@ -154,6 +159,12 @@ public class Profile extends BaseEntity { | @@ -154,6 +159,12 @@ public class Profile extends BaseEntity { | ||
154 | this.passwordHash = passwordHash; | 159 | this.passwordHash = passwordHash; |
155 | } | 160 | } |
156 | 161 | ||
162 | + /** | ||
163 | + * Vergleicht das übergebene Kennwort mit dem im Profil hinterlegten. | ||
164 | + * | ||
165 | + * @param password das Klartext-Kennwort, mit dem das im Profil hinterlegte verglichen werden soll | ||
166 | + * @return <code>true</code>, wenn die Kennwörter identisch sind. | ||
167 | + */ | ||
157 | public boolean isValidPassword(final String password) { | 168 | public boolean isValidPassword(final String password) { |
158 | final String passwordHash = cryptString(password); | 169 | final String passwordHash = cryptString(password); |
159 | 170 |