Add developersAPI property and add getAccessToken method in deprecated controller.
This commit is contained in:
parent
4804ab40c8
commit
e7b1e4366b
|
@ -9,6 +9,10 @@ public class Properties {
|
|||
* @deprecated
|
||||
* */
|
||||
private String developers;
|
||||
/**
|
||||
* @deprecated
|
||||
* */
|
||||
private String developersApi;
|
||||
private String roleManagement;
|
||||
private Mail mail = new Mail();
|
||||
private Google google = new Google();
|
||||
|
@ -24,6 +28,14 @@ public class Properties {
|
|||
this.developers = developers;
|
||||
}
|
||||
|
||||
public String getDevelopersApi() {
|
||||
return developersApi;
|
||||
}
|
||||
|
||||
public void setDevelopersApi(String developersApi) {
|
||||
this.developersApi = developersApi;
|
||||
}
|
||||
|
||||
public String getRoleManagement() {
|
||||
return roleManagement;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,31 @@
|
|||
package eu.dnetlib.uoausermanagment.controllers;
|
||||
|
||||
import eu.dnetlib.uoausermanagment.configuration.Properties;
|
||||
import eu.dnetlib.uoausermanagment.services.HttpService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
public class DeprecatedController {
|
||||
private final String developers;
|
||||
private final String developersApi;
|
||||
private final HttpService httpService;
|
||||
|
||||
@Autowired
|
||||
public DeprecatedController(Properties properties) {
|
||||
public DeprecatedController(Properties properties, HttpService httpService) {
|
||||
this.developers = properties.getDevelopers();
|
||||
this.developersApi = properties.getDevelopersApi();
|
||||
this.httpService = httpService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,4 +73,15 @@ public class DeprecatedController {
|
|||
public void getPersonalToken(HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect(developers + "/personal-token");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@GetMapping("/api/users/getAccessToken")
|
||||
public ResponseEntity<Object> getPersonalToken(HttpServletRequest request, @RequestParam(name = "refreshToken") String refreshToken) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("refreshToken", refreshToken);
|
||||
return ResponseEntity.ok(this.httpService.get(request, this.developersApi + "accessToken", params, Object.class));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue