| 15 | | // Either client ID or bearer token must be non-null/non-blank |
| 16 | | if (bearerToken == null || Utils.isBlank(bearerToken)) |
| 17 | | return null; |
| 18 | | JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder(); |
| 19 | | jsonObjectBuilder.add("token_type", "bearer"); |
| 20 | | jsonObjectBuilder.add("access_token", bearerToken); |
| 21 | | String json = jsonObjectBuilder.build().toString(); |
| | 15 | // Either client ID or bearer token must be non-null/non-blank |
| | 16 | if (bearerToken == null || Utils.isBlank(bearerToken)) |
| | 17 | return null; |
| | 18 | JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder(); |
| | 19 | jsonObjectBuilder.add("token_type", "bearer"); |
| | 20 | jsonObjectBuilder.add("access_token", bearerToken); |
| | 21 | String json = jsonObjectBuilder.build().toString(); |
| 23 | | String earthDataURS = "https://" + EARTHDATA_SSO_HOST + "/"; |
| 24 | | String earthDataDL = "https://" + EARTHDATA_DOWNLOAD_HOST + "/"; |
| 25 | | // Earthdata neither provides us a client ID nor a client secret |
| 26 | | String clientId = ""; |
| 27 | | String clientSecret = null; |
| 28 | | // Following two URLs are set because the parameters may not be null, but are |
| 29 | | // never used |
| 30 | | String authorizeUrl = earthDataURS; |
| 31 | | String redirectUri = earthDataURS; |
| 32 | | // These two parameters need to be set to the URL of the SRTM download server |
| 33 | | // Otherwise, OAuth20Parameters will refuse to be initialized and |
| 34 | | // OAuthToken.sign(HttpClient) will refuse to do its job |
| 35 | | String tokenUrl = earthDataDL; |
| 36 | | String apiUrl = earthDataDL; |
| | 23 | String earthDataURS = "https://" + EARTHDATA_SSO_HOST + "/"; |
| | 24 | String earthDataDL = "https://" + EARTHDATA_DOWNLOAD_HOST + "/"; |
| | 25 | // Earthdata neither provides us a client ID nor a client secret |
| | 26 | String clientId = ""; |
| | 27 | String clientSecret = null; |
| | 28 | // Following two URLs are set because the parameters may not be null, but are |
| | 29 | // never used |
| | 30 | String authorizeUrl = earthDataURS; |
| | 31 | String redirectUri = earthDataURS; |
| | 32 | // These two parameters need to be set to the URL of the SRTM download server |
| | 33 | // Otherwise, OAuth20Parameters will refuse to be initialized and |
| | 34 | // OAuthToken.sign(HttpClient) will refuse to do its job |
| | 35 | String tokenUrl = earthDataDL; |
| | 36 | String apiUrl = earthDataDL; |
| 38 | | OAuth20Parameters parameters = new OAuth20Parameters(clientId, clientSecret, tokenUrl, authorizeUrl, apiUrl, |
| 39 | | redirectUri); |
| 40 | | try { |
| 41 | | return new OAuth20Token(parameters, json); |
| 42 | | } catch (OAuth20Exception e) { |
| 43 | | Logging.error("Elevation: " + e); |
| 44 | | return null; |
| 45 | | } |
| | 38 | OAuth20Parameters parameters = new OAuth20Parameters(clientId, clientSecret, tokenUrl, authorizeUrl, apiUrl, |
| | 39 | redirectUri); |
| | 40 | try { |
| | 41 | return new OAuth20Token(parameters, json); |
| | 42 | } catch (OAuth20Exception e) { |
| | 43 | Logging.error("Elevation: " + e); |
| | 44 | return null; |