1
+ /*
2
+ * Copyright (c) 2022 Institute of Software Chinese Academy of Sciences (ISCAS)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
package space .ao .services .support .platform ;
2
17
3
- //import io.github.ren2003u.authentication.model.ObtainBoxRegKeyResponse;
4
- import com .fasterxml .jackson .databind .ObjectMapper ;
18
+ import io .github .ren2003u .authentication .model .ObtainBoxRegKeyResponse ;
5
19
import io .github .ren2003u .client .Client ;
6
20
import io .github .ren2003u .domain .errorHandle .ApiResponse ;
7
- // import io.github.ren2003u.register.model.RegisterClientResponse;
8
- // import io.github.ren2003u.register.model.RegisterUserResponse;
21
+ import io .github .ren2003u .register .model .RegisterClientResponse ;
22
+ import io .github .ren2003u .register .model .RegisterUserResponse ;
9
23
import jakarta .annotation .PostConstruct ;
10
24
import jakarta .enterprise .context .ApplicationScoped ;
11
25
import jakarta .inject .Inject ;
18
32
import space .ao .services .support .platform .info .registry .UserRegistryInfo ;
19
33
import space .ao .services .support .platform .info .registry .UserRegistryResult ;
20
34
import space .ao .services .support .platform .info .token .TokenVerifySignInfo ;
21
- import space .ao .services .support .platform .model .*;
22
35
import space .ao .services .support .security .SecurityUtils ;
23
36
24
37
import java .nio .charset .StandardCharsets ;
@@ -70,19 +83,8 @@ public UserRegistryResult registerUser(String requestId, UserRegistryInfo userRe
70
83
return null ;
71
84
}
72
85
73
- // Prepare RegisterUserRequest object
74
- RegisterUserRequest request = new RegisterUserRequest ();
75
- request .setBoxUUID (properties .boxUuid ());
76
- request .setUserId (userRegistryInfo .userId ());
77
- request .setSubdomain (userRegistryInfo .subdomain ());
78
- request .setUserType (userRegistryInfo .userType ());
79
- request .setClientUUID (userRegistryInfo .clientUUID ());
80
-
81
- // Convert RegisterUserRequest object to JSON
82
- String jsonRequest = new ObjectMapper ().writeValueAsString (request );
83
-
84
86
// Register User
85
- ApiResponse <RegisterUserResponse > response = client .registerUser (jsonRequest , requestId , boxRegKey );
87
+ ApiResponse <RegisterUserResponse > response = client .registerUser (properties . boxUuid (), userRegistryInfo . userId (), userRegistryInfo . subdomain (), userRegistryInfo . userType (), userRegistryInfo . clientUUID () , requestId , boxRegKey );
86
88
if (response .getError () != null ) {
87
89
LOG .error ("Error registering user: {}" , response .getError ().getMessage ());
88
90
return null ;
@@ -103,16 +105,8 @@ public ClientRegistryResult registerClient(String requestId, ClientRegistryInfo
103
105
return null ;
104
106
}
105
107
106
- // Prepare RegisterClientRequest object
107
- RegisterClientRequest request = new RegisterClientRequest ();
108
- request .setClientUUID (clientRegistryInfo .clientUUID ());
109
- request .setClientType (clientRegistryInfo .clientType ());
110
-
111
- // Convert RegisterClientRequest object to JSON
112
- String jsonRequest = new ObjectMapper ().writeValueAsString (request );
113
-
114
108
// Register Client
115
- ApiResponse <RegisterClientResponse > response = client .registerClient (properties .boxUuid (), userId , jsonRequest , requestId , boxRegKey );
109
+ ApiResponse <RegisterClientResponse > response = client .registerClient (properties .boxUuid (), userId , clientRegistryInfo . clientUUID (), clientRegistryInfo . clientType () , requestId , boxRegKey );
116
110
if (response .getError () != null ) {
117
111
LOG .error ("Error registering client: {}" , response .getError ().getMessage ());
118
112
return null ;
@@ -135,16 +129,7 @@ private String obtainBoxRegKey(String requestId) {
135
129
Base64 .getEncoder ().encodeToString (
136
130
utils .objectToJson (TokenVerifySignInfo .of (properties .boxUuid (), List .of ("10001" )))
137
131
.getBytes (StandardCharsets .UTF_8 )));
138
-
139
- ObtainBoxRegKeyRequest request = new ObtainBoxRegKeyRequest ();
140
- request .setBoxUUID (properties .boxUuid ());
141
- request .setServiceIds (List .of ("10001" ));
142
- request .setSign (sign );
143
-
144
- String jsonRequest = new ObjectMapper ().writeValueAsString (request );
145
-
146
- //ApiResponse<ObtainBoxRegKeyResponse> response = client.obtainBoxRegKey(properties.boxUuid(), List.of("10001"), requestId,sign);
147
- ApiResponse <ObtainBoxRegKeyResponse > response = client .obtainBoxRegKey (jsonRequest , requestId );
132
+ ApiResponse <ObtainBoxRegKeyResponse > response = client .obtainBoxRegKey (properties .boxUuid (), List .of ("10001" ), requestId ,sign );
148
133
if (response .getError () != null ) {
149
134
LOG .error ("Error obtaining BoxRegKey: {}" , response .getError ().getMessage ());
150
135
return null ;
0 commit comments