@@ -5,16 +5,16 @@ import nl.myndocs.oauth2.exception.*
5
5
import nl.myndocs.oauth2.request.AuthorizationCodeRequest
6
6
import nl.myndocs.oauth2.request.ClientCredentialsRequest
7
7
import nl.myndocs.oauth2.request.PasswordGrantRequest
8
- import nl.myndocs.oauth2.response.TokenResponse
9
8
import nl.myndocs.oauth2.scope.ScopeParser
9
+ import nl.myndocs.oauth2.token.AccessToken
10
10
11
11
12
12
/* *
13
13
* @throws InvalidIdentityException
14
14
* @throws InvalidClientException
15
15
* @throws InvalidScopeException
16
16
*/
17
- fun GrantingCall.authorize (passwordGrantRequest : PasswordGrantRequest ): TokenResponse {
17
+ fun GrantingCall.authorize (passwordGrantRequest : PasswordGrantRequest ): AccessToken {
18
18
throwExceptionIfUnverifiedClient(passwordGrantRequest)
19
19
20
20
if (passwordGrantRequest.username == null ) {
@@ -50,22 +50,22 @@ fun GrantingCall.authorize(passwordGrantRequest: PasswordGrantRequest): TokenRes
50
50
validateScopes(requestedClient, requestedIdentity, requestedScopes)
51
51
52
52
val accessToken = converters.accessTokenConverter.convertToToken(
53
- requestedIdentity.username ,
53
+ requestedIdentity,
54
54
requestedClient.clientId,
55
55
requestedScopes,
56
56
converters.refreshTokenConverter.convertToToken(
57
- requestedIdentity.username ,
57
+ requestedIdentity,
58
58
requestedClient.clientId,
59
59
requestedScopes
60
60
)
61
61
)
62
62
63
63
tokenStore.storeAccessToken(accessToken)
64
64
65
- return accessToken.toTokenResponse()
65
+ return accessToken
66
66
}
67
67
68
- fun GrantingCall.authorize (authorizationCodeRequest : AuthorizationCodeRequest ): TokenResponse {
68
+ fun GrantingCall.authorize (authorizationCodeRequest : AuthorizationCodeRequest ): AccessToken {
69
69
throwExceptionIfUnverifiedClient(authorizationCodeRequest)
70
70
71
71
if (authorizationCodeRequest.code == null ) {
@@ -85,22 +85,22 @@ fun GrantingCall.authorize(authorizationCodeRequest: AuthorizationCodeRequest):
85
85
}
86
86
87
87
val accessToken = converters.accessTokenConverter.convertToToken(
88
- consumeCodeToken.username ,
88
+ consumeCodeToken.identity ,
89
89
consumeCodeToken.clientId,
90
90
consumeCodeToken.scopes,
91
91
converters.refreshTokenConverter.convertToToken(
92
- consumeCodeToken.username ,
92
+ consumeCodeToken.identity ,
93
93
consumeCodeToken.clientId,
94
94
consumeCodeToken.scopes
95
95
)
96
96
)
97
97
98
98
tokenStore.storeAccessToken(accessToken)
99
99
100
- return accessToken.toTokenResponse()
100
+ return accessToken
101
101
}
102
102
103
- fun GrantingCall.authorize (clientCredentialsRequest : ClientCredentialsRequest ): TokenResponse {
103
+ fun GrantingCall.authorize (clientCredentialsRequest : ClientCredentialsRequest ): AccessToken {
104
104
throwExceptionIfUnverifiedClient(clientCredentialsRequest)
105
105
106
106
val requestedClient = clientService.clientOf(clientCredentialsRequest.clientId!! ) ? : throw InvalidClientException ()
@@ -110,17 +110,17 @@ fun GrantingCall.authorize(clientCredentialsRequest: ClientCredentialsRequest):
110
110
? : requestedClient.clientScopes
111
111
112
112
val accessToken = converters.accessTokenConverter.convertToToken(
113
- username = null ,
113
+ identity = null ,
114
114
clientId = clientCredentialsRequest.clientId,
115
115
requestedScopes = scopes,
116
116
refreshToken = converters.refreshTokenConverter.convertToToken(
117
- username = null ,
117
+ identity = null ,
118
118
clientId = clientCredentialsRequest.clientId,
119
119
requestedScopes = scopes
120
120
)
121
121
)
122
122
123
123
tokenStore.storeAccessToken(accessToken)
124
124
125
- return accessToken.toTokenResponse()
125
+ return accessToken
126
126
}
0 commit comments