Add developersAPI property and add getAccessToken method in deprecated controller.

This commit is contained in:
Konstantinos Triantafyllou 2024-10-15 14:43:29 +03:00
parent 4804ab40c8
commit e7b1e4366b
2 changed files with 34 additions and 1 deletions

View File

@ -9,6 +9,10 @@ public class Properties {
* @deprecated * @deprecated
* */ * */
private String developers; private String developers;
/**
* @deprecated
* */
private String developersApi;
private String roleManagement; private String roleManagement;
private Mail mail = new Mail(); private Mail mail = new Mail();
private Google google = new Google(); private Google google = new Google();
@ -24,6 +28,14 @@ public class Properties {
this.developers = developers; this.developers = developers;
} }
public String getDevelopersApi() {
return developersApi;
}
public void setDevelopersApi(String developersApi) {
this.developersApi = developersApi;
}
public String getRoleManagement() { public String getRoleManagement() {
return roleManagement; return roleManagement;
} }

View File

@ -1,21 +1,31 @@
package eu.dnetlib.uoausermanagment.controllers; package eu.dnetlib.uoausermanagment.controllers;
import eu.dnetlib.uoausermanagment.configuration.Properties; import eu.dnetlib.uoausermanagment.configuration.Properties;
import eu.dnetlib.uoausermanagment.services.HttpService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Controller @Controller
public class DeprecatedController { public class DeprecatedController {
private final String developers; private final String developers;
private final String developersApi;
private final HttpService httpService;
@Autowired @Autowired
public DeprecatedController(Properties properties) { public DeprecatedController(Properties properties, HttpService httpService) {
this.developers = properties.getDevelopers(); 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 { public void getPersonalToken(HttpServletResponse response) throws IOException {
response.sendRedirect(developers + "/personal-token"); 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));
}
} }