| Line 19... |
Line 19... |
| 19 |
|
19 |
|
| 20 |
@Component
|
20 |
@Component
|
| 21 |
public class GoogleTokenUtil {
|
21 |
public class GoogleTokenUtil {
|
| 22 |
|
22 |
|
| 23 |
private static final String V3_HOST_NAME = "www.googleapis.com";
|
23 |
private static final String V3_HOST_NAME = "www.googleapis.com";
|
| 24 |
private static final String V3_URI = "/oauth2/v3/tokeninfo";
|
24 |
private static final String V3_URI = "oauth2/v3/tokeninfo";
|
| 25 |
private static final int PORT_NUMBER = 443;
|
25 |
private static final int PORT_NUMBER = 443;
|
| 26 |
private final ObjectMapper objectMapper = new ObjectMapper();
|
26 |
private final ObjectMapper objectMapper = new ObjectMapper();
|
| 27 |
|
27 |
|
| 28 |
public String getEmailId(String token) throws ProfitMandiBusinessException{
|
28 |
public String getEmailId(String token) throws ProfitMandiBusinessException{
|
| 29 |
RestClient restClient = new RestClient(SchemeType.HTTPS, V3_HOST_NAME, PORT_NUMBER);
|
29 |
RestClient restClient = new RestClient();
|
| 30 |
Map<String, String> params = new HashMap<>();
|
30 |
Map<String, String> params = new HashMap<>();
|
| 31 |
params.put(ProfitMandiConstants.ID_TOKEN, token);
|
31 |
params.put(ProfitMandiConstants.ID_TOKEN, token);
|
| 32 |
Map<String, String> headers = new HashMap<>(1);
|
32 |
Map<String, String> headers = new HashMap<>(1);
|
| 33 |
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
33 |
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
| 34 |
String responseString = null;
|
34 |
String responseString = null;
|
| 35 |
try {
|
35 |
try {
|
| 36 |
responseString = restClient.get(V3_URI, params, headers);
|
36 |
responseString = restClient.get(SchemeType.HTTPS, V3_HOST_NAME, PORT_NUMBER, V3_URI, params, headers);
|
| 37 |
} catch (HttpHostConnectException e) {
|
37 |
} catch (HttpHostConnectException e) {
|
| 38 |
throw new ProfitMandiBusinessException("googleServerResponse", responseString, "GE_1006");
|
38 |
throw new ProfitMandiBusinessException("googleServerResponse", responseString, "GE_1006");
|
| 39 |
}
|
39 |
}
|
| 40 |
try {
|
40 |
try {
|
| 41 |
JsonNode rootNode = objectMapper.readTree(responseString);
|
41 |
JsonNode rootNode = objectMapper.readTree(responseString);
|