summaryrefslogtreecommitdiff
path: root/21-implementierungsheft-kolloquium/assets/diagrams/classdiagram-authentication.puml
blob: a2b3518c8162fe35bb22e568057caedafc8516d7 (plain)
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
@startuml

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()
        }
    }
}

' User <.. AuthenticationDataAccessService: DB
' User <.. JdbcUserDetailsManager: DB
UserDetailsManager <.. AuthenticationService: <<use>>
' AuthenticationDao <.. AuthenticationService: <<use>>
AuthenticationService --o AuthenticationController
' AuthenticationDao <|. AuthenticationDataAccessService: <<realize>>
UserDetailsManager <|. JdbcUserDetailsManager: <<realize>>
JavaMailSenderImpl <. AuthenticationService: <<use>>

@enduml