|
|
@ -559,11 +559,9 @@ public class AndroidDeviceUtils {
|
|
|
|
return errorResponse;
|
|
|
|
return errorResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void installEnrollmentApplications(ProfileFeature feature, String deviceId)
|
|
|
|
public static void installEnrollmentApplications(ProfileFeature feature, DeviceIdentifier deviceIdentifier)
|
|
|
|
throws PolicyManagementException {
|
|
|
|
throws PolicyManagementException {
|
|
|
|
String appId = "";
|
|
|
|
String uuid = "";
|
|
|
|
String payload;
|
|
|
|
|
|
|
|
StringRequestEntity requestEntity;
|
|
|
|
|
|
|
|
HttpClient httpClient;
|
|
|
|
HttpClient httpClient;
|
|
|
|
PostMethod request;
|
|
|
|
PostMethod request;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -576,36 +574,44 @@ public class AndroidDeviceUtils {
|
|
|
|
System.getProperty(AndroidConstants.ApplicationInstall.IOT_CORE_HOST) +
|
|
|
|
System.getProperty(AndroidConstants.ApplicationInstall.IOT_CORE_HOST) +
|
|
|
|
AndroidConstants.ApplicationInstall.COLON +
|
|
|
|
AndroidConstants.ApplicationInstall.COLON +
|
|
|
|
System.getProperty(AndroidConstants.ApplicationInstall.IOT_CORE_PORT) +
|
|
|
|
System.getProperty(AndroidConstants.ApplicationInstall.IOT_CORE_PORT) +
|
|
|
|
AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_CONTEXT;
|
|
|
|
AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_URL;
|
|
|
|
JsonElement appListElement = new JsonParser().parse(feature.getContent().toString()).getAsJsonObject()
|
|
|
|
JsonElement appListElement = new JsonParser().parse(feature.getContent().toString()).getAsJsonObject()
|
|
|
|
.get(AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_CODE);
|
|
|
|
.get(AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_CODE);
|
|
|
|
|
|
|
|
String payload = "[{\"id\":\"" + deviceIdentifier.getId() + "\", \"type\":\""
|
|
|
|
|
|
|
|
+ deviceIdentifier.getType() + "\"}]";
|
|
|
|
|
|
|
|
StringRequestEntity requestEntity = new StringRequestEntity(payload, MediaType.APPLICATION_JSON
|
|
|
|
|
|
|
|
, AndroidConstants.ApplicationInstall.ENCODING);
|
|
|
|
JsonArray appListArray = appListElement.getAsJsonArray();
|
|
|
|
JsonArray appListArray = appListElement.getAsJsonArray();
|
|
|
|
for (JsonElement appElement : appListArray) {
|
|
|
|
for (JsonElement appElement : appListArray) {
|
|
|
|
appId = appElement.getAsJsonObject().
|
|
|
|
uuid = appElement.getAsJsonObject().
|
|
|
|
get(AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_ID).getAsString();
|
|
|
|
get(AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_UUID).getAsString();
|
|
|
|
payload = "{\"appId\": \"" + appId + "\", \"scheduleTime\":\"2013-12-25T15:25:30-05:00\"," +
|
|
|
|
requestUrl = requestUrl.replace("{uuid}", uuid);
|
|
|
|
"\"deviceIds\": [\"{\\\"id\\\":\\\"" + deviceId + "\\\", \\\"type\\\":\\\"android\\\"}\"]}";
|
|
|
|
|
|
|
|
requestEntity = new StringRequestEntity(payload, MediaType.APPLICATION_JSON,
|
|
|
|
|
|
|
|
AndroidConstants.ApplicationInstall.ENCODING);
|
|
|
|
|
|
|
|
httpClient = new HttpClient();
|
|
|
|
httpClient = new HttpClient();
|
|
|
|
request = new PostMethod(requestUrl);
|
|
|
|
request = new PostMethod(requestUrl);
|
|
|
|
request.addRequestHeader(AndroidConstants.ApplicationInstall.AUTHORIZATION,
|
|
|
|
request.addRequestHeader(AndroidConstants.ApplicationInstall.AUTHORIZATION
|
|
|
|
AndroidConstants.ApplicationInstall.AUTHORIZATION_HEADER_VALUE + tokenInfo.getAccessToken());
|
|
|
|
, AndroidConstants.ApplicationInstall.AUTHORIZATION_HEADER_VALUE + tokenInfo.getAccessToken());
|
|
|
|
request.setRequestEntity(requestEntity);
|
|
|
|
request.setRequestEntity(requestEntity);
|
|
|
|
httpClient.executeMethod(request);
|
|
|
|
httpClient.executeMethod(request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new PolicyManagementException("Error while accessing user store for user with iOS device id: " +
|
|
|
|
String msg = "Error while accessing user store for user with Android device id: " +
|
|
|
|
deviceId, e);
|
|
|
|
deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
} catch (APIManagerException e) {
|
|
|
|
} catch (APIManagerException e) {
|
|
|
|
throw new PolicyManagementException("Error while retrieving access token for Android device id: " +
|
|
|
|
String msg = "Error while retrieving access token for Android device id: " + deviceIdentifier.getId();
|
|
|
|
deviceId, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
} catch (HttpException e) {
|
|
|
|
} catch (HttpException e) {
|
|
|
|
throw new PolicyManagementException("Error while calling the app store to install enrollment app with " +
|
|
|
|
String msg = "Error while calling the app store to install enrollment app with uuid: " + uuid +
|
|
|
|
"id: " + appId + " on device with id: " + deviceId, e);
|
|
|
|
" on device with id: " + deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new PolicyManagementException("Error while installing the enrollment app with id: " + appId +
|
|
|
|
String msg = "Error while installing the enrollment with uuid: " + uuid + " on device with id: " +
|
|
|
|
" on device with id: " + deviceId, e);
|
|
|
|
deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|