mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Modify enrollment app install android policy to support new app manager
This commit is contained in:
parent
b83c8806af
commit
51f74d7744
@ -291,7 +291,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
for (ProfileFeature feature : effectiveProfileFeatures) {
|
for (ProfileFeature feature : effectiveProfileFeatures) {
|
||||||
if (AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_FEATURE_CODE
|
if (AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_FEATURE_CODE
|
||||||
.equals(feature.getFeatureCode())) {
|
.equals(feature.getFeatureCode())) {
|
||||||
AndroidDeviceUtils.installEnrollmentApplications(feature, deviceIdentifier.getId());
|
AndroidDeviceUtils.installEnrollmentApplications(feature, deviceIdentifier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,7 +187,7 @@ public final class AndroidConstants {
|
|||||||
public static final String DEFAULT_TOKEN_TYPE = "PRODUCTION";
|
public static final String DEFAULT_TOKEN_TYPE = "PRODUCTION";
|
||||||
public static final String DEFAULT_VALIDITY_PERIOD = "3600";
|
public static final String DEFAULT_VALIDITY_PERIOD = "3600";
|
||||||
public static final String SUBSCRIPTION_SCOPE = "appm:subscribe";
|
public static final String SUBSCRIPTION_SCOPE = "appm:subscribe";
|
||||||
public static final String ENROLLMENT_APP_INSTALL_ID = "appId";
|
public static final String ENROLLMENT_APP_INSTALL_UUID = "uuid";
|
||||||
public static final String ENROLLMENT_APP_INSTALL_CODE = "enrollmentAppInstall";
|
public static final String ENROLLMENT_APP_INSTALL_CODE = "enrollmentAppInstall";
|
||||||
public static final String ENCODING = "UTF-8";
|
public static final String ENCODING = "UTF-8";
|
||||||
public static final String AT = "@";
|
public static final String AT = "@";
|
||||||
@ -195,7 +195,7 @@ public final class AndroidConstants {
|
|||||||
public static final String IOT_CORE_HOST = "iot.core.host";
|
public static final String IOT_CORE_HOST = "iot.core.host";
|
||||||
public static final String IOT_CORE_PORT = "iot.core.https.port";
|
public static final String IOT_CORE_PORT = "iot.core.https.port";
|
||||||
public static final String ENROLLMENT_APP_INSTALL_PROTOCOL = "https://";
|
public static final String ENROLLMENT_APP_INSTALL_PROTOCOL = "https://";
|
||||||
public static final String ENROLLMENT_APP_INSTALL_CONTEXT = "/api/appm/store/v1.1/apps/mobile/schedule-install";
|
public static final String ENROLLMENT_APP_INSTALL_URL = "/api/application-mgt-store/v1.0/subscription/{uuid}/devices/install";
|
||||||
public static final String AUTHORIZATION = "Authorization";
|
public static final String AUTHORIZATION = "Authorization";
|
||||||
public static final String AUTHORIZATION_HEADER_VALUE = "Bearer ";
|
public static final String AUTHORIZATION_HEADER_VALUE = "Bearer ";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2999,7 +2999,7 @@
|
|||||||
<input class="enrollment-app-install-input" type="hidden" data-child-key="version" value="{{this.version}}"/>
|
<input class="enrollment-app-install-input" type="hidden" data-child-key="version" value="{{this.version}}"/>
|
||||||
</td>
|
</td>
|
||||||
<td data-title="enrollment-app-install-app-selection">
|
<td data-title="enrollment-app-install-app-selection">
|
||||||
<input class="enrollment-app-install-input" type="hidden" data-child-key="packageName" value="{{this.packageName}}"/>
|
<input class="enrollment-app-install-input" type="hidden" data-child-key="uuid" value="{{this.uuid}}"/>
|
||||||
<input class="enrollment-app-install-input" type="hidden" data-child-key="appId" value="{{this.appId}}"/>
|
<input class="enrollment-app-install-input" type="hidden" data-child-key="appId" value="{{this.appId}}"/>
|
||||||
<a href="#enrollment-app-install-grid" data-click-event="add-enrollment-app">
|
<a href="#enrollment-app-install-grid" data-click-event="add-enrollment-app">
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@ -3020,7 +3020,7 @@
|
|||||||
<input class="enrollment-app-install-input" type="hidden" data-child-key="version" value="{{this.version}}"/>
|
<input class="enrollment-app-install-input" type="hidden" data-child-key="version" value="{{this.version}}"/>
|
||||||
</td>
|
</td>
|
||||||
<td data-title="enrollment-app-install-app-selection">
|
<td data-title="enrollment-app-install-app-selection">
|
||||||
<input class="enrollment-app-install-input" type="hidden" data-child-key="packageName" value="{{this.packageName}}"/>
|
<input class="enrollment-app-install-input" type="hidden" data-child-key="uuid" value="{{this.uuid}}"/>
|
||||||
<input class="enrollment-app-install-input" type="hidden" data-child-key="appId" value="{{this.appId}}"/>
|
<input class="enrollment-app-install-input" type="hidden" data-child-key="appId" value="{{this.appId}}"/>
|
||||||
<a href="#enrollment-app-install-grid" data-click-event="add-enrollment-app">
|
<a href="#enrollment-app-install-grid" data-click-event="add-enrollment-app">
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user