1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
@startuml
' skinparam linetype ortho
' skinparam groupInheritance 2
allowmixing
package subscriptionsAPI <<Frame>> {
package subscriptionDataAccessLayer <<Frame>> {
class SubscriptionDataAccessService <<@Repository>> {
<<create>> SubscriptionDataAccessService(JpaTemplate jpaTemplate)
int uploadSubscriptions(String username, List<SubscriptionAction> subscriptions)
List<String> getSubscriptions(String username)
List<String> getSubscriptionsSince(String username, LocalDateTime time)
int addSubscriptions(String username, List<SubscriptionAction> addedSubscriptions)
int removeSubscriptions(String username, List<SubscriptionAction> removedSubscriptions)
List<SubscriptionTitles> getTitles(String username)
}
interface SubscriptionDao {
int uploadSubscriptions(String username, List<SubscriptionAction> subscriptions)
List<String> getSubscriptions(String username)
List<String> getSubscriptionsSince(String username, LocalDateTime time)
int addSubscriptions(String username, List<SubscriptionAction> addedSubscriptions)
int removeSubscriptions(String username, List<SubscriptionAction> removedSubscriptions)
List<SubscriptionTitles> getTitles(String username)
}
}
package subscriptionService <<Frame>> {
class SubscriptionService <<@Service>> {
<<create>> SubscriptionService(SubscriptionDao subscriptionDao)
int uploadSubscriptions(String username, List<SubscriptionAction> subscriptions)
List<String> getSubscriptions(String username)
List<String> getSubscriptionsSince(String username, LocalDateTime time)
int addSubscriptions(String username, List<SubscriptionAction> addedSubscriptions)
int removeSubscriptions(String username, List<SubscriptionAction> removedSubscriptions)
List<SubscriptionTitles> getTitles(String username)
}
}
package subscriptionController <<Frame>> {
class SubscriptionController <<@Controller>>{
' @Autowired
<<create>> SubscriptionController(SubscriptionService subscriptionService)
' @GetMapping
ResponseEntity<List<String>> getSubscriptions(String username, String deviceID, String functionJSONP)
' @PutMapping
ResponseEntity<String> uploadSubscriptions(String username, String deviceID, List<String> subscriptions)
' @PostMapping
ResponseEntity<SubscriptionDelta> applySubscriptionDelta(String username, String deviceID, SubscriptionDelta delta)
' @GetMapping
ResponseEntity<SubscriptionDelta> getSubscriptionDelta(String username, String deviceID, long since)
ResponseEntity<List<SubscriptionTitles>> getTitles(String username, String deviceID)
}
class SubscriptionTitles {
<<create>> SubscriptionTitles(Subscription subscription, List<EpisodeActionPost> episodeTitles)
Subscription getSubscription()
List<EpisodeActionPost> getEpisodesTitles()
}
class SubscriptionDelta {
<<create>> SubscriptionDelta(List<String> add, List<String> remove)
List<String> getRemove()
LocalDate getTimestamp()
List<List<String>> getUpdate_urls()
}
}
}
package episodeActionsAPI <<Frame>> {
package episodeActionDataAccessLayer <<Frame>> {
class EpisodeActionDataAccessService <<@Repository>> {
<<create>> EpisodeActionDataAccessService (JpaTemplate jpaTemplate)
long addEpisodeActions(String username, List<EpisodeActionPost> episodeActionPosts)
List<EpisodeActionPost> getEpisodeActions(String username)
List<EpisodeActionPost> getEpisodeActionsOfPodcast(String username, String podcastURL)
List<EpisodeActionPost> getEpisodeActionsSince(String username, LocalDateTime since)
List<EpisodeActionPost> getEpisodeActionsOfPodcastSince(String username, String podcastURL, LocalDateTime since)
}
interface EpisodeActionDao {
long addEpisodeActions(String username, List<EpisodeActionPost> episodeActionPosts)
List<EpisodeActionPost> getEpisodeActions(String username)
List<EpisodeActionPost> getEpisodeActionsOfPodcast(String username, String podcastURL)
List<EpisodeActionPost> getEpisodeActionsSince(String username, LocalDateTime since)
List<EpisodeActionPost> getEpisodeActionsOfPodcastSince(String username, String podcastURL, LocalDateTime since)
}
}
package episodeActionService <<Frame>> {
class EpisodeActionService <<@Service>> {
<<create>> EpisodeActionService (EpisodeActionDao episodeActionDao)
LocalDateTime addEpisodeActions(String username, List<EpisodeActionPosts> episodeActionPosts)
List<EpisodeActionPost> getEpisodeActions(String username)
List<EpisodeActionPost> getEpisodeActionsOfPodcast(String username, String podcastURL)
List<EpisodeActionPost> getEpisodeActionsSince(String username, LocalDateTime since)
List<EpisodeActionPost> getEpisodeActionsOfPodcastSince(String username, String podcastURL, LocalDateTime since)
}
}
package episodeActionController <<Frame>> {
class EpisodeActionController <<@Controller>>{
<<create>> EpisodeActionController (EpisodeActionService episodeActionService)
ResponseEntity<EpisodeActionPostResponse> addEpisodeActions(String username, EpisodeActionPostRequest episodeActionPostRequest)
ResponseEntity<EpisodeActionGetResponse> getEpisodeActions(String username, String deviceID, boolean aggregated)
ResponseEntity<EpisodeActionGetResponse> getEpisodeActionsOfPodcast(String username, String podcastURL, String deviceID, boolean aggregated)
ResponseEntity<EpisodeActionGetResponse> getEpisodeActionsSince(String username, String deviceID, long since, boolean aggregated)
ResponseEntity<EpisodeActionGetResponse> getEpisodeActionsOfPodcastSince(String username, String podcastURL, String deviceID, long since, boolean aggregated)
}
class EpisodeActionPostResponse {
<<create>> EpisodeActionPostResponse(List<Pair<String, String>> updateURLs)
long getTimestamp()
List<Pair<String, String>> getUpdatedURLs()
}
class EpisodeActionPost {
<<create>> EpisodeActionPost(String podcastURL, String episodeURL, Action action, LocalDateTime timestamp, int started, int position)
String getPodcastURL()
String getEpisodeURL()
int getGUID()
Action getAction()
LocalDateTime getTimestamp()
int getStarted()
int getPosition()
EpisodeAction getEpisodeAction()
}
class EpisodeActionPostRequest {
<<create>> EpisodeActionPostRequest(List<EpisodeActionPost> episodeActionPosts)
List<EpisodeActionPost> getEpisodeActionPosts()
}
class EpisodeActionGetResponse {
<<create>> EpisodeActionGetResponse(List<EpisodeActionPost> episodeActionPosts)
List<EpisodeActionPost> getEpisodeActionPosts()
long getTimestamp()
}
}
}
package authenticationAPI <<Frame>> {
package authenticationDataAccessLayer <<Frame>> {
' interface AuthenticationDao {
' String login(String username)
' int logout(String username)
' }
' class AuthenticationDataAccessService <<@Respository>> {
' <<create>> AuthenticationDataAccessService(JpaTemplate jpaTemplate)
' String login(String username)
' int logout(String username)
' }
interface UserDetailsManager {
void createUser(UserDetails userDetails)
void changePassword(String oldPassword, String newPassword)
void deleteUser(String username)
void updateUser(UserDetails user)
boolean userExists(String username)
}
note left
Aus org.springframework.security.provisioning
- liefert Methoden zum Erstellen neuer User
und zum Aktualisieren bestehender.
end note
class JdbcUserDetailsManager <<@Repository>> {
<<create>> JdbcUserDetailsManager(DataSource dataSource)
void createUser(UserDetails user)
void changePassword(String oldPassword, String newPassword)
void deleteUser(String username)
void updateUser(UserDetails user)
boolean userExists(String username)
}
note right
User Management Service aus dem Paket
org.springframework.security.provisioning
der CRUD Operationen für User bereitstellt.
Hier sind nur die relevanten Methoden modelliert.
end note
}
package authenticationService <<Frame>> {
class AuthenticationService <<@Service>> {
--
<<create>> AuthenticationService(UserDetailsManager userDetailsManager)
List<String> verifyLogin(String username)
int logout(String username)
int forgotPassword(ForgotPasswordRequest forgotPasswordRequest)
.. via JdbcUserDetailsManager ..
int resetPassword(String username, RequestWithPassword requestWithPassword)
int registerUser(UserDetails user)
int changePassword(String username, ChangePasswordRequest changePasswordRequest)
int deleteUser(String username, RequestWithPassword requestWithPassword)
}
class JavaMailSenderImpl {}
note left
Aus org.springframework.mail.javamail.
Implementierung des JavaMailSender Interfaces,
welches das MailSender Interface durch Unterstützung
von MIME Nachrichten erweitert.
Das MailSender Interface definiert dabei eine
Strategie zum Versenden einfacher Mails.
Unterstützt sowohl JavaMail MimeMessages und
Spring SimpleMailMessages.
end note
}
package authenticationController <<Frame>> {
class AuthenticationController <<@Controller>> {
<<create>> AuthenticationController(AuthenticationService authenticationService)
ResponseEntity<List<String>> verifyLogin(String username)
ResponseEntity<Integer> logout(String username)
ResponseEntity<Integer> forgotPassword(ForgotPasswordRequest forgotPasswordRequest)
ResponseEntity<Integer> resetPassword(String username, RequestWithPassword requestWithPassword)
ResponseEntity<Integer> registerUser(UserDetails user)
ResponseEntity<Integer> changePassword(String username, ChangePasswordRequest changePasswordRequest)
ResponseEntity<Integer> deleteUser(String username, RequestWithPassword requestWithPassword)
}
class ChangePasswordRequest {
<<create>> ChangePasswordRequest(String oldPassword, String newPassword)
String getOldPassword()
String getNewPassword()
}
class ForgotPasswordRequest {
<<create>> ForgotPasswordRequest(String email)
String getEmail()
}
class RequestWithPassword {
<<create>> ResetPasswordRequest(String password)
String getPassword()
}
}
}
package model <<Frame>> {
class Subscription {
<<create>> Subscription(String url, String title)
int getID()
String getURL()
long getLastActionTimestamp()
String getTitle()
}
class SubscriptionAction {
<<create>> SubscriptionAction(int userID, int subscriptionID)
int getID()
int getUserID()
int getSubscriptionID()
long getTimestamp()
boolean getAdded()
}
class Episode {
<<create>> Episode(int subscriptionID, int id, String url, String title, String thumbnailURL, int total)
int getSubscriptionID()
int getID()
int getGUID()
String getURL()
String getTitle()
int getTotal()
}
enum Action {
Download
Play
Delete
New
Flattr
String getJsonProperty()
}
class EpisodeAction {
<<create>> EpisodeAction(Action action, LocalDateTime timestamp, int started, int position)
int getEpisodeID()
Action getAction()
long getTimestamp()
int getStarted()
int getPosition()
void setEpisodeID()
EpisodeActionPost getEpisodeActionPost(String podcastURL, String episodeURL)
}
interface UserDetails {
String getUsername()
String getPassword()
Collection<Authority> getAuthorities()
boolean isAccountExpired()
boolean isAccountLocked()
boolean isCredentialsNonExpired()
boolean isEnabled()
}
note left
Aus org.springframework.security.core.userdetails.
Wird für die Schnittstelle UserDetailsManager benötigt.
Stellt wichtige Informationen eines Users bereit.
Diese werden nur indirekt von Spring Security
benutzt, indem sie vorher in Authentication Objekten
gekapselt werden.
end note
class User {
--
<<create>> User(String username, String password)
int getID()
String getSessionToken()
boolean getEmailIsValidated()
.. interface methods ..
String getUsername()
String getPassword()
Collection<Authority> getAuthorities()
boolean isAccountExpired()
boolean isAccountLocked()
boolean isCredentialsNonExpired()
boolean isEnabled()
}
interface GrantedAuthority {
String getAuthority()
}
note right
Aus org.springframework.security.core.
Wird für die Schnittstelle UserDetails benötigt.
Repräsentiert eine Autorisierung, die einem
Authentication Objekt gewährt wird.
end note
class Authority {
<<create>> Authority()
String getAuthority()
}
}
package util <<Frame>> {
class RSSParser {
<<create>> RSSParser(String subscriptionURL)
String getSubscriptionTitle()
List<Episode> getEpisodes()
Episode getEpisodeForURL(String episodeURL)
}
note bottom
Verwendet intern Spring um
HTTP-Anfragen zu erstellen.
end note
class CleanCronJob {
<<create>> CleanCronJob(JdbcUserDetailsManager jdbcUserDetailsManager)
void cleanInvalidUsers()
}
note bottom
Hintergrundservice, der in periodischen Abständen
Nutzer, die ihre E-Mail-Adresse nicht nach 24 Stunden
bestätigt haben, wieder aus der Datenbank löscht.
(Auf die Assoziation zu JdbcUserDetailsManager wird
im Sinne der Übersichtlichkeit verzichtet.)
end note
class ResponseEntity<T> {
<<create>> ResponseEntity(T body, HttpStatusCode status)
T getBody()
HttpStatusCode getStatusCode()
}
note bottom
Aus org.springframework.http.
Erweitert die Klasse HttpEntity, welche
ein HTTP Anfrage- oder Antwort-Objekt
repräsentiert, durch einen HttpStatusCode.
Wird von den Controller-Methoden als
Rückgabewert verwendet.
end note
}
class SecurityConfigurationBasicAuth {
<<create>> SecurityConfigurationBasicAuth()
PasswordEncoder encoder()
UserDetailsManager userDetailsService()
SecuryFilterChain fiterChain(HTTPSecurity http) throws Excpetion
}
note top
Erstellt einen Servlet Filter (springSecurityFilterChain)
der für die gesamte Sicherheit zuständig ist (Schutz der URLs,
Validierung von Anmeldedaten, Weiterleitung zur Anmeldung, etc.).
end note
class PSEApplication {
<<create>> PSEApplication()
void main(String[] args)
}
database Datenbank
Datenbank <-[hidden]d- subscriptionsAPI
Datenbank <-[hidden]d- episodeActionsAPI
Datenbank <-[hidden]d- authenticationAPI
() SQL as SQLSub
() SQL as SQLAuth
() SQL as SQLEpisode
Datenbank -- SQLSub
Datenbank -- SQLAuth
Datenbank -- SQLEpisode
SubscriptionController ..o PSEApplication
AuthenticationController ..o PSEApplication
EpisodeActionController ..o PSEApplication
SecurityConfigurationBasicAuth ..o PSEApplication
PSEApplication --() HTTP
SQLSub )-- SubscriptionDataAccessService: JPA
' SQLAuth )-- AuthenticationDataAccessService: JPA
SQLAuth )-- JdbcUserDetailsManager: JDBC
SQLEpisode )-- EpisodeActionDataAccessService: JPA
Subscription <. SubscriptionAction: ID
' Subscription <.. SubscriptionDataAccessService: DB
' SubscriptionAction <.. SubscriptionDataAccessService: DB
SubscriptionService --o SubscriptionController
SubscriptionDao <.. SubscriptionService: <<use>>
Subscription --o SubscriptionTitles
EpisodeActionPost -o SubscriptionTitles
SubscriptionDao <|. SubscriptionDataAccessService: <<realize>>
' User <.. AuthenticationDataAccessService: DB
' User <.. JdbcUserDetailsManager: DB
UserDetailsManager <.. AuthenticationService: <<use>>
' AuthenticationDao <.. AuthenticationService: <<use>>
AuthenticationService --o AuthenticationController
' AuthenticationDao <|. AuthenticationDataAccessService: <<realize>>
UserDetailsManager <|. JdbcUserDetailsManager: <<realize>>
UserDetailsManager <.. SecurityConfigurationBasicAuth: <<use>>
UserDetails <|.. User: <<realize>>
User -> Authority
GrantedAuthority <|.. Authority: <<realize>>
JavaMailSenderImpl <. AuthenticationService: <<use>>
Action <-- EpisodeAction
EpisodeActionPost -o EpisodeActionGetResponse
EpisodeActionPost -o EpisodeActionPostRequest
EpisodeAction .> Episode: ID
' EpisodeAction <.. EpisodeActionDataAccessService: DB
' Episode <.. EpisodeActionDataAccessService: DB
EpisodeActionDao <.. EpisodeActionService: <<use>>
EpisodeActionService --o EpisodeActionController
EpisodeActionDao <|. EpisodeActionDataAccessService: <<realize>>
RSSParser <. SubscriptionDataAccessService: <<use>>
RSSParser <. EpisodeActionDataAccessService: <<use>>
' JdbcUserDetailsManager <-- CleanCronJob
model .o Datenbank: ORM (User, SubscriptionAction, Subscription, EpisodeAction, Episode)
' Datenbank o.. Subscription: ORM
' Datenbank o.. SubscriptionAction: ORM
' Datenbank o.. Episode: ORM
' Datenbank o.. EpisodeAction: ORM
' Datenbank o.. User: ORM
@enduml
|