null
if failed.
* @throws IOException If an error occurs when try to retry the request.
*/
- public static ProxyResponse retryRequestWithRefreshedToken(HttpServletRequest req, HttpRequestBase httpRequest,
+ public static ProxyResponse retryRequestWithRefreshedToken(HttpServletRequest req, ClassicHttpRequest httpRequest,
String apiEndpoint) throws IOException {
ProxyResponse retryResponse = refreshToken(req, apiEndpoint);
if (isResponseSuccessful(retryResponse)) {
@@ -628,7 +594,6 @@ public class HandlerUtil {
return proxyResponse;
}
return proxyResponse;
-
}
return retryResponse;
}
@@ -650,7 +615,6 @@ public class HandlerUtil {
if (session == null) {
log.error("Couldn't find a session, hence it is required to login and proceed.");
tokenResultResponse = constructProxyResponseByErrorCode(HttpStatus.SC_UNAUTHORIZED);
-// handleError(resp, HttpStatus.SC_UNAUTHORIZED);
return tokenResultResponse;
}
@@ -658,23 +622,20 @@ public class HandlerUtil {
tokenResultResponse = getTokenResult(authData, keymanagerUrl);
if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) {
log.error("Error occurred while refreshing access token.");
-// HandlerUtil.handleError(resp, tokenResultResponse);
return tokenResultResponse;
}
- JsonParser jsonParser = new JsonParser();
- JsonElement jTokenResult = jsonParser.parse(tokenResultResponse.getData());
-
- if (jTokenResult.isJsonObject()) {
- setNewAuthData(constructAuthDataFromTokenResult(jTokenResult, authData), session);
+ JsonNode tokenResponse = tokenResultResponse.getData();
+ if (tokenResponse != null) {
+ setNewAuthData(constructAuthDataFromTokenResult(tokenResponse, authData), session);
return tokenResultResponse;
}
log.error("Error Occurred in token renewal process.");
tokenResultResponse = constructProxyResponseByErrorCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-// handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR);
return tokenResultResponse;
}
+
public static ProxyResponse getTokenResult(AuthData authData, String keymanagerUrl) throws IOException {
HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT);
StringEntity tokenEndpointPayload = new StringEntity(
@@ -694,12 +655,17 @@ public class HandlerUtil {
session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, newAuthData);
}
- public static AuthData constructAuthDataFromTokenResult(JsonElement tokenResult, AuthData authData) {
- JsonObject jTokenResultAsJsonObject = tokenResult.getAsJsonObject();
+ /**
+ * Construct {@link AuthData} from token response
+ * @param tokenResult {@link JsonNode}
+ * @param authData {@link AuthData} existing auth data values
+ * @return new {@link AuthData} object
+ */
+ public static AuthData constructAuthDataFromTokenResult(JsonNode tokenResult, AuthData authData) {
AuthData newAuthData = new AuthData();
- newAuthData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString());
- newAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString());
- newAuthData.setScope(jTokenResultAsJsonObject.get("scope").getAsString());
+ newAuthData.setAccessToken(tokenResult.get("access_token").textValue());
+ newAuthData.setRefreshToken(tokenResult.get("refresh_token").textValue());
+ newAuthData.setScope(tokenResult.get("scope").textValue());
newAuthData.setClientId(authData.getClientId());
newAuthData.setClientSecret(authData.getClientSecret());
newAuthData.setEncodedClientApp(authData.getEncodedClientApp());
@@ -716,7 +682,7 @@ public class HandlerUtil {
* This should be set to false
when handling multipart requests as Http
* client will generate the Content-Type header automatically.
*/
- public static void copyRequestHeaders(HttpServletRequest req, HttpRequestBase httpRequest, boolean preserveContentType) {
+ public static void copyRequestHeaders(HttpServletRequest req, ClassicHttpRequest httpRequest, boolean preserveContentType) {
Enumeration- Hi $first-name, -
-- Thank you very much for your interest in the Entgra IoT server. Please click - here to download the latest release of the Entgra IoT server.
- -- If you need assistance, please contact us through Entgra - contact us -
- -- Regards, -
- -- Entgra IoT Administrator -
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
+
- Hi $first-name, -
-- Congratulations!!! Thank you for registering with Entgra. Please click on the - following link to complete your registration with us. Click here. -
- -- If you need further assistance, please contact your administrator. -
- -- Regards, -
- -- Entgra IoT Administrator -
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
+
- Hi $first-name, -
-- Welcome to Entgra Evaluation Cloud!! Entgra server support offers managing Android, iOS and Windows - devices along with a wide range of features that support cooperate (COPE) or personal device (BYOD) - enrollments. -
-Your log-in credentials to any of our portals(endpoint-mgt, store, publisher) are,
-Username: $portal-username
-Password: password provided at registration for an evaluation account.
-- This is the portal used to send operations and policies to devices and overall management of - the server. -
-- This is an in-house corporate app store where you can host all your corporate applications. - Users may browse apps and install them to their devices if the administrator has made the apps - publicly visible to users. Administrator can install, uninstall and update apps in the user - device or device groups. -
-- The portal for publishing new applications for internal use. This is the developer view of the - enterprise application store that comes with the product. -
-- Please find here a set of videos on how to enroll and onboard devices to our Cloud platform. - [Cloud Enrollment Guide] - When enrolling a device, Make sure to use the following log-in format: -
-Organisation: $tenant-domain
-Username: $agent-username
-Password: password provided at registration.
-- If you have any further questions, please reach out to us using your registered mail to - bizdev-group@entgra.io. Looking forward to working with you. -
-- Best Regards, -
-- Entgra Cloud Team -
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
+