parent
4bfd9a72b6
commit
02f87e7531
@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>mobile-base-plugin</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>2.2.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.mobile.ui</artifactId>
|
||||
<name>WSO2 Carbon - EMM Server UI</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.5.5</version>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}-${carbon.devicemgt.plugins.version}</finalName>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<descriptors>
|
||||
<descriptor>src/assembly/src.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-archive</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,53 +0,0 @@
|
||||
{
|
||||
"appName": "WSO2 Enterprise Mobility Manager",
|
||||
"cachingEnabled": true,
|
||||
"debuggingEnabled": false,
|
||||
"permissionRoot": "/",
|
||||
"loginPage": "cdmf.page.sign-in",
|
||||
"adminServicesUrl": "https://${server.ip}:${server.https_port}/admin/services/",
|
||||
"authModule": {
|
||||
"enabled": true,
|
||||
"login": {
|
||||
"onSuccess": {
|
||||
"script": "/app/modules/login.js",
|
||||
"page": "mdm.page.dashboard"
|
||||
},
|
||||
"onFail": {
|
||||
"script": "/app/modules/login.js",
|
||||
"page": "cdmf.page.sign-in"
|
||||
}
|
||||
},
|
||||
"logout": {
|
||||
"onSuccess": {
|
||||
"page": "cdmf.page.sign-in"
|
||||
},
|
||||
"onFail": {
|
||||
"page": "mdm.page.dashboard"
|
||||
}
|
||||
},
|
||||
"sso": {
|
||||
"enabled": false,
|
||||
"issuer" : "emm",
|
||||
"appName" : "emm",
|
||||
"identityProviderUrl" : "https://localhost:9443/samlsso",
|
||||
"acs": "https://localhost:9443/emm/uuf/sso/acs",
|
||||
"identityAlias": "wso2carbon",
|
||||
"responseSigningEnabled" : true,
|
||||
"validateAssertionValidityPeriod": true,
|
||||
"validateAudienceRestriction": true,
|
||||
"assertionSigningEnabled": true
|
||||
}
|
||||
},
|
||||
"generalConfig" : {
|
||||
"host" : "https://localhost:9443",
|
||||
"companyName" : "WSO2 Enterprise Mobility Manager",
|
||||
"browserTitle" : "WSO2 EMM",
|
||||
"copyrightPrefix" : "\u00A9 %date-year%, ",
|
||||
"copyrightOwner" : "WSO2 Inc.",
|
||||
"copyrightOwnersSite" : "http://www.wso2.org",
|
||||
"copyrightSuffix" : ""
|
||||
},
|
||||
"errorPages": {
|
||||
"default": "uuf.page.error"
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
{
|
||||
"appContext": "/emm/",
|
||||
"webAgentContext" : "/emm-web-agent/",
|
||||
"apiContext": "api",
|
||||
"httpsURL" : "%https.ip%",
|
||||
"httpURL" : "%http.ip%",
|
||||
"httpsWebURL" : "%https.ip%",
|
||||
"wssURL" : "%https.ip%",
|
||||
"wsURL" : "%http.ip%",
|
||||
"enrollmentDir": "/emm-web-agent/enrollment",
|
||||
"iOSConfigRoot" : "%https.ip%/ios-enrollment/",
|
||||
"iOSAPIRoot" : "%https.ip%/ios/",
|
||||
"adminService": "%https.ip%",
|
||||
"oauthProvider": {
|
||||
"appRegistration": {
|
||||
"appType": "webapp",
|
||||
"clientName": "emm",
|
||||
"owner": "admin@carbon.super",
|
||||
"dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register",
|
||||
"apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants",
|
||||
"grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||
"tokenScope": "admin",
|
||||
"callbackUrl": "%https.ip%/api/device-mgt/v1.0"
|
||||
},
|
||||
"tokenServiceURL": "%https.ip%/oauth2/token"
|
||||
},
|
||||
"adminUser": "admin@carbon.super",
|
||||
"adminRole": "admin",
|
||||
"usernameLength": 30,
|
||||
"pageSize":10,
|
||||
"ssoConfiguration" : {
|
||||
"enabled" : false,
|
||||
"issuer" : "devicemgt",
|
||||
"appName" : "devicemgt",
|
||||
"identityProviderURL" : "%https.ip%/sso/samlsso.jag",
|
||||
"responseSigningEnabled" : "true",
|
||||
"keyStorePassword" : "wso2carbon",
|
||||
"identityAlias" : "wso2carbon",
|
||||
"keyStoreName" : "/repository/resources/security/wso2carbon.jks"
|
||||
},
|
||||
"userValidationConfig" : {
|
||||
"usernameJSRegEx" : "^[\\S]{3,30}$",
|
||||
"usernameRegExViolationErrorMsg" : "Provided username is invalid.",
|
||||
"usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.",
|
||||
"firstnameJSRegEx" : "^[\\S]{3,30}$",
|
||||
"firstnameRegExViolationErrorMsg" : "Provided first name is invalid.",
|
||||
"lastnameJSRegEx" : "^[\\S]{3,30}$",
|
||||
"lastnameRegExViolationErrorMsg" : "Provided last name is invalid.",
|
||||
"emailJSRegEx" : "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/",
|
||||
"emailRegExViolationErrorMsg" : "Provided email is invalid."
|
||||
},
|
||||
"groupValidationConfig": {
|
||||
"groupNameJSRegEx": "^[\\S]{3,30}$",
|
||||
"groupNameRegExViolationErrorMsg": "Provided group name is invalid.",
|
||||
"groupNameHelpMsg": "Should be in minimum 3 characters long and should not include any whitespaces."
|
||||
},
|
||||
"roleValidationConfig" : {
|
||||
"roleNameJSRegEx" : "^[\\S]{3,30}$",
|
||||
"roleNameRegExViolationErrorMsg" : "Provided role name is invalid.",
|
||||
"roleNameHelpMsg" : "should be in minimum 3 characters long and do not include any whitespaces."
|
||||
},
|
||||
"generalConfig" : {
|
||||
"host" : "%https.ip%",
|
||||
"companyName" : "WSO2 Carbon Device Manager",
|
||||
"browserTitle" : "WSO2 Device Manager",
|
||||
"copyrightPrefix" : "\u00A9 %date-year%, ",
|
||||
"copyrightOwner" : "WSO2 Inc.",
|
||||
"copyrightOwnersSite" : "http://www.wso2.org",
|
||||
"copyrightSuffix" : " All Rights Reserved."
|
||||
},
|
||||
"scopes" : [
|
||||
"user:manage",
|
||||
"user:view",
|
||||
"device-type:admin:view",
|
||||
"device:view",
|
||||
"notification:view",
|
||||
"device:admin:view",
|
||||
"application:manage",
|
||||
"activity:view",
|
||||
"user:admin:reset-password",
|
||||
"policy:manage",
|
||||
"policy:view",
|
||||
"role:manage",
|
||||
"role:view",
|
||||
"configuration:view",
|
||||
"configuration:modify",
|
||||
"device:android:operation:reboot",
|
||||
"device:android:operation:camera",
|
||||
"device:android:operation:vpn",
|
||||
"device:android:operation:lock",
|
||||
"device:android:operation:ring",
|
||||
"device:android:operation:update-app",
|
||||
"device:android:operation:wipe",
|
||||
"device:android:operation:encrypt",
|
||||
"device:android:operation:blacklist-app",
|
||||
"device:android:operation:applications",
|
||||
"device:android:operation:enterprise-wipe",
|
||||
"device:android:operation:info",
|
||||
"device:android:operation:wifi",
|
||||
"device:android:operation:uninstall-app",
|
||||
"device:android:operation:change-lock",
|
||||
"device:android:operation:notification",
|
||||
"device:android:operation:upgrade",
|
||||
"device:android:operation:unlock",
|
||||
"device:android:operation:mute",
|
||||
"device:android:operation:location",
|
||||
"device:android:operation:webclip",
|
||||
"device:android:operation:clear-password",
|
||||
"device:android:operation:password-policy",
|
||||
"device:android:operation:install-app",
|
||||
"device:android:event:write",
|
||||
"device:android:event:read",
|
||||
"device:android:enroll",
|
||||
"configuration:manage",
|
||||
"configuration:view",
|
||||
"device:android:enroll",
|
||||
"certificate:view",
|
||||
"certificate:manage"
|
||||
],
|
||||
"isOAuthEnabled" : true,
|
||||
"backendRestEndpoints" : {
|
||||
"deviceMgt" : "/api/device-mgt/v1.0"
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
var log = new Log("mdm.unit.device.operation-bar");
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var viewModel = {};
|
||||
var permissions = {};
|
||||
|
||||
// adding android operations related permission checks
|
||||
permissions["android"] = [];
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) {
|
||||
permissions["android"].push("DEVICE_RING");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) {
|
||||
permissions["android"].push("DEVICE_LOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) {
|
||||
permissions["android"].push("DEVICE_UNLOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) {
|
||||
permissions["android"].push("DEVICE_LOCATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/clear-password")) {
|
||||
permissions["android"].push("CLEAR_PASSWORD");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/reboot")) {
|
||||
permissions["android"].push("DEVICE_REBOOT");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/upgrade-firmware")) {
|
||||
permissions["android"].push("UPGRADE_FIRMWARE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/mute")) {
|
||||
permissions["android"].push("DEVICE_MUTE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/send-notification")) {
|
||||
permissions["android"].push("NOTIFICATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/change-lock-code")) {
|
||||
permissions["android"].push("CHANGE_LOCK_CODE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/enterprise-wipe")) {
|
||||
permissions["android"].push("ENTERPRISE_WIPE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/wipe")) {
|
||||
permissions["android"].push("WIPE_DATA");
|
||||
}
|
||||
|
||||
// adding ios operations related permission checks
|
||||
permissions["ios"] = [];
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/lock")) {
|
||||
permissions["ios"].push("DEVICE_LOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/location")) {
|
||||
permissions["ios"].push("LOCATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/enterprise-wipe")) {
|
||||
permissions["ios"].push("ENTERPRISE_WIPE");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/notification")) {
|
||||
permissions["ios"].push("NOTIFICATION");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/ring")) {
|
||||
permissions["ios"].push("RING");
|
||||
}
|
||||
|
||||
// adding windows operations related permission checks
|
||||
permissions["windows"] = [];
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/lock")) {
|
||||
permissions["windows"].push("DEVICE_LOCK");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/disenroll/windows")) {
|
||||
permissions["windows"].push("DISENROLL");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/wipe")) {
|
||||
permissions["windows"].push("WIPE_DATA");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/ring")) {
|
||||
permissions["windows"].push("DEVICE_RING");
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/lock-reset")) {
|
||||
permissions["windows"].push("LOCK_RESET");
|
||||
}
|
||||
|
||||
viewModel["permissions"] = stringify(permissions);
|
||||
|
||||
viewModel["deviceType"] = context.unit.params.deviceType;
|
||||
viewModel["ownership"] = context.unit.params.ownership;
|
||||
|
||||
return viewModel;
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
{{!
|
||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
|
||||
WSO2 Inc. licenses this file to you under the Apache License,
|
||||
Version 2.0 (the "License"); you may not use this file except
|
||||
in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
}}
|
||||
{{#zone "navMenu-icon"}}
|
||||
<span class="icon fw-stack">
|
||||
<i class="fw fw-menu fw-stack-1x toggle-icon-down"></i>
|
||||
</span>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "navMenu-items"}}
|
||||
{{#if permissions.LIST_DEVICES}}
|
||||
<li>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/devices">
|
||||
<i class="fw fw-mobile"></i>
|
||||
Device Management
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if permissions.VIEW_DASHBOARD}}
|
||||
<li>
|
||||
<a href="/portal/t/{{currentUser.domain}}/dashboards/device-statistics-dashboard/">
|
||||
<i class="fw fw-statistics"></i>Device Statistics
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if permissions.LIST_POLICIES}}
|
||||
<li><!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/policies"><i class="fw fw-policy"></i>Policy Management</a></li>
|
||||
{{/if}}
|
||||
{{#if permissions.USER_MGT_PERMITTED}}
|
||||
<li><a><i class="fw fw-user"></i>User Management</a>
|
||||
<ul>
|
||||
{{#if permissions.LIST_USERS}}
|
||||
<li><!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/users"><i class="fw fw-user"></i>Users</a></li>
|
||||
{{/if}}
|
||||
{{#if permissions.LIST_ROLES}}
|
||||
<li><!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/roles"><i class="fw fw-bookmark"></i>Roles</a></li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if permissions.CONFIG_MGT_PERMITTED}}
|
||||
<li><a><i class="fw fw-settings"></i>Configuration Management</a>
|
||||
<ul>
|
||||
{{#if permissions.LIST_PLATFORM_CONFIGURATIONS}}
|
||||
<li><!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>Platform Configurations</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
<!-- todo change the permission and get the related permission -->
|
||||
{{#if permissions.LIST_CERTIFICATES}}
|
||||
<li><!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>Certificate Configurations</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "navbarCollapsableRightItems"}}
|
||||
<ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<!--<a href="{{@app.context}}notification-listing" title="Failures of operations on the device side will be listed here">-->
|
||||
<a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content"
|
||||
aria-expanded="false" rel="notifications-sidebar">
|
||||
<span id="notification-bubble" class="badge notifications hidden"></span>
|
||||
<span id="notifications-icon" class="icon fw-stack hidden">
|
||||
<i class="fw fw-notification fw-stack-1x"></i>
|
||||
</span>
|
||||
<span id="notifications-spacer" class="hidden"> </span>
|
||||
<span class="text-capitalize">Notifications</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{{/zone}}
|
||||
{{#zone "sidePanes"}}
|
||||
<!--suppress HtmlUnknownAttribute -->
|
||||
<div class="sidebar-wrapper" id="right-sidebar" is-authorized="{{permissions.LIST_NOTIFICATIONS}}"
|
||||
data-side="right" data-width="300" data-sidebar-fixed="true" data-fixed-offset="60" data-spy="affix"
|
||||
data-offset-top="80">
|
||||
<ul class="sidebar-messages"></ul>
|
||||
<br>
|
||||
<div class="text-center">
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/notification-listing" class="btn-operations btn-default">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stroke fw-stack-2x"></i>
|
||||
<i class="fw fw-notification fw-stack-1x"></i>
|
||||
</span>
|
||||
View All Notifications
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<script id="notifications" data-current-user="{{@user.username}}"
|
||||
data-image-resource="{{@unit.publicUri}}/images/" src="{{@unit.publicUri}}/templates/notifications.hbs"
|
||||
type="text/x-handlebars-template"></script>
|
||||
{{js "js/nav-menu.js"}}
|
||||
{{/zone}}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
var constants = require("/app/modules/constants.js");
|
||||
|
||||
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
|
||||
if (arguments.length < 3) {
|
||||
throw new Error("Handlebars Helper equal needs 2 parameters");
|
||||
}
|
||||
if (lvalue != rvalue) {
|
||||
return options.inverse(this);
|
||||
} else {
|
||||
return options.fn(this);
|
||||
}
|
||||
});
|
||||
|
||||
var links = {
|
||||
"user-mgt": [],
|
||||
"role-mgt": [],
|
||||
"policy-mgt": [],
|
||||
"device-mgt": []
|
||||
};
|
||||
var viewModel = {};
|
||||
|
||||
// following viewModel.link value comes here based on the value passed at the point
|
||||
// where units are attached to a page zone.
|
||||
// eg: {{unit "app-bar" pageLink="users" title="User Management"}}
|
||||
viewModel["currentActions"] = links[viewModel["pageLink"]];
|
||||
viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"];
|
||||
viewModel["currentUser"] = session.get(constants["USER_SESSION_KEY"]);
|
||||
|
||||
var permissions = {};
|
||||
permissions["LIST_DEVICES"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view");
|
||||
permissions["LIST_POLICIES"] = userModule.isAuthorized("/permission/admin/device-mgt/policies/view");
|
||||
permissions["LIST_USERS"] = userModule.isAuthorized("/permission/admin/device-mgt/users/view");
|
||||
permissions["LIST_ROLES"] = userModule.isAuthorized("/permission/admin/device-mgt/roles/view");
|
||||
permissions["USER_MGT_PERMITTED"] = (permissions["LIST_USERS"] || permissions["LIST_ROLES"]);
|
||||
permissions["LIST_PLATFORM_CONFIGURATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/platform-configurations/view");
|
||||
permissions["LIST_CERTIFICATES"] = userModule.isAuthorized("/permission/admin/device-mgt/certificates/view");
|
||||
permissions["CONFIG_MGT_PERMITTED"] = (permissions["LIST_PLATFORM_CONFIGURATIONS"] || permissions["LIST_CERTIFICATES"]);
|
||||
permissions["LIST_NOTIFICATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/notifications/view");
|
||||
permissions["VIEW_DASHBOARD"] = userModule.isAuthorized("/permission/admin/device-mgt/dashboard/view");
|
||||
|
||||
viewModel["permissions"] = permissions;
|
||||
viewModel["appContext"] = mdmProps["appContext"];
|
||||
viewModel["serverURL"] = mdmProps["httpsWebURL"];
|
||||
|
||||
return viewModel;
|
||||
}
|
Binary file not shown.
@ -1,148 +0,0 @@
|
||||
{
|
||||
"displayName": "EMM Web Agent",
|
||||
"logLevel": "error",
|
||||
"initScripts": ["/app/modules/init.js"],
|
||||
"urlMappings": [
|
||||
{
|
||||
"url": "/enrollment",
|
||||
"path": "/lib/pages.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/windows/login",
|
||||
"path": "/app/modules/enrollments/windows/agent-controller.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/windows/enroll",
|
||||
"path": "/app/modules/enrollments/windows/agent-enroll.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/ios/download-certificate",
|
||||
"path": "/app/modules/enrollments/ios/certificate.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/ios/download-agent",
|
||||
"path": "/app/modules/enrollments/ios/agent.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/ios/login",
|
||||
"path": "/app/modules/enrollments/ios/agent-controller.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/ios/enroll",
|
||||
"path": "/app/modules/enrollments/ios/agent-enroll.jag"
|
||||
},
|
||||
{
|
||||
"url": "/enrollment/ios/check",
|
||||
"path": "/app/modules/enrollments/ios/agent-check.jag"
|
||||
},
|
||||
{
|
||||
"url": "/api/invoker/*",
|
||||
"path": "/api/invoker-api.jag"
|
||||
},
|
||||
{
|
||||
"url": "/uuf/login",
|
||||
"path": "/lib/modules/auth/login.jag"
|
||||
},
|
||||
{
|
||||
"url": "/uuf/logout",
|
||||
"path": "/lib/modules/auth/logout.jag"
|
||||
},
|
||||
{
|
||||
"url": "/uuf/sso/acs",
|
||||
"path": "/lib/modules/auth/acs.jag"
|
||||
},
|
||||
{
|
||||
"url": "/public/*",
|
||||
"path": "/lib/static-files.jag"
|
||||
},
|
||||
{
|
||||
"url": "/unit/*",
|
||||
"path": "/lib/units.jag"
|
||||
},
|
||||
{
|
||||
"url": "/*",
|
||||
"path": "/lib/pages.jag"
|
||||
}
|
||||
],
|
||||
"securityConstraints": [
|
||||
{
|
||||
"securityConstraint": {
|
||||
"webResourceCollection": {
|
||||
"name": "EMM-WEB-AGENT",
|
||||
"urlPatterns": [
|
||||
"/*"
|
||||
]
|
||||
},
|
||||
"userDataConstraint": {
|
||||
"transportGuarantee": "CONFIDENTIAL"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"securityConstraint": {
|
||||
"webResourceCollection": {
|
||||
"name": "EMM-WEB-AGENT-http",
|
||||
"urlPatterns": [
|
||||
"/public/*",
|
||||
"/enrollments/windows/*",
|
||||
"/enrollment/windows/*"
|
||||
]
|
||||
},
|
||||
"userDataConstraint": {
|
||||
"transportGuarantee": "NONE"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
{
|
||||
"name": "URLBasedCachePreventionFilter",
|
||||
"class": "org.wso2.carbon.ui.filters.cache.URLBasedCachePreventionFilter"
|
||||
},
|
||||
{
|
||||
"name":"HttpHeaderSecurityFilter",
|
||||
"class":"org.apache.catalina.filters.HttpHeaderSecurityFilter",
|
||||
"params" : [{"name" : "hstsEnabled", "value" : "false"}]
|
||||
}
|
||||
],
|
||||
"filterMappings": [
|
||||
{
|
||||
"name": "URLBasedCachePreventionFilter",
|
||||
"url": "/api/*"
|
||||
},
|
||||
{
|
||||
"name": "URLBasedCachePreventionFilter",
|
||||
"url": "/enrollment/*"
|
||||
},
|
||||
{
|
||||
"name":"HttpHeaderSecurityFilter",
|
||||
"url":"*"
|
||||
}
|
||||
],
|
||||
"listeners" : [
|
||||
{
|
||||
"class" : "org.owasp.csrfguard.CsrfGuardServletContextListener"
|
||||
},
|
||||
{
|
||||
"class" : "org.owasp.csrfguard.CsrfGuardHttpSessionListener"
|
||||
}
|
||||
],
|
||||
"servlets" : [
|
||||
{
|
||||
"name" : "JavaScriptServlet",
|
||||
"class" : "org.owasp.csrfguard.servlet.JavaScriptServlet"
|
||||
}
|
||||
],
|
||||
"servletMappings" : [
|
||||
{
|
||||
"name" : "JavaScriptServlet",
|
||||
"url" : "/csrf.js"
|
||||
}
|
||||
],
|
||||
"contextParams" : [
|
||||
{
|
||||
"name" : "Owasp.CsrfGuard.Config",
|
||||
"value" : "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>mobile-base-plugin</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>2.2.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.mobile.url.printer</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL</name>
|
||||
<description>WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
|
||||
<Bundle-Description>Bundle Containing The Startup Handler That Prints MDM End-User Web-App URL</Bundle-Description>
|
||||
<Private-Package>org.wso2.carbon.device.mgt.mobile.url.printer.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
org.apache.axis2.*;version="${axis2.osgi.version.range}",
|
||||
org.wso2.carbon.core,
|
||||
org.wso2.carbon.utils.*,
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.mgt.mobile.url.printer.internal,
|
||||
org.wso2.carbon.device.mgt.mobile.url.printer,
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,171 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mobile-base-plugin</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>2.2.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.mobile</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Mobile Device Management Impl</name>
|
||||
<description>WSO2 Carbon - Mobile Device Management Implementation</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
|
||||
<Bundle-Description>Device Management Mobile Impl Bundle</Bundle-Description>
|
||||
<Private-Package>org.wso2.carbon.device.mgt.mobile.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
javax.xml.*; !javax.xml.parsers,
|
||||
javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
|
||||
javax.naming,
|
||||
javax.sql,
|
||||
org.w3c.dom,
|
||||
org.wso2.carbon.context,
|
||||
org.wso2.carbon.utils.*,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.ndatasource.core,
|
||||
org.wso2.carbon.policy.mgt.common.*,
|
||||
org.wso2.carbon.registry.core,
|
||||
org.wso2.carbon.registry.core.service,
|
||||
org.wso2.carbon.registry.core.session,
|
||||
org.wso2.carbon.registry.api,
|
||||
org.wso2.carbon.device.mgt.extensions.license.mgt.registry,
|
||||
com.google.gson.*
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.mgt.mobile.internal,
|
||||
!org.wso2.carbon.device.mgt.mobile.impl,
|
||||
org.wso2.carbon.device.mgt.mobile.*,
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<log4j.configuration>file:src/test/resources/log4j.properties
|
||||
</log4j.configuration>
|
||||
</systemPropertyVariables>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.wso2</groupId>
|
||||
<artifactId>jdbc-pool</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database.wso2</groupId>
|
||||
<artifactId>h2-database-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android.gcm</groupId>
|
||||
<artifactId>gcm-server</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,332 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* you may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
|
||||
import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.*;
|
||||
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
|
||||
import org.wso2.carbon.registry.api.RegistryException;
|
||||
import org.wso2.carbon.registry.api.Resource;
|
||||
import org.wso2.carbon.registry.core.Registry;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Provides utility methods required by the mobile device management bundle.
|
||||
*/
|
||||
public class MobileDeviceManagementUtil {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class);
|
||||
private static final String MOBILE_DEVICE_IMEI = "IMEI";
|
||||
private static final String MOBILE_DEVICE_IMSI = "IMSI";
|
||||
private static final String MOBILE_DEVICE_VENDOR = "VENDOR";
|
||||
private static final String MOBILE_DEVICE_OS_VERSION = "OS_VERSION";
|
||||
private static final String MOBILE_DEVICE_MODEL = "DEVICE_MODEL";
|
||||
private static final String MOBILE_DEVICE_LATITUDE = "LATITUDE";
|
||||
private static final String MOBILE_DEVICE_LONGITUDE = "LONGITUDE";
|
||||
private static final String MOBILE_DEVICE_SERIAL = "SERIAL";
|
||||
private static final String MOBILE_DEVICE_OS_BUILD_DATE = "OS_BUILD_DATE";
|
||||
|
||||
public static Document convertToDocument(File file) throws DeviceManagementException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
DocumentBuilder docBuilder = dbf.newDocumentBuilder();
|
||||
return docBuilder.parse(file);
|
||||
} catch (Exception e) {
|
||||
throw new DeviceManagementException(
|
||||
"Error occurred while parsing file, while converting " +
|
||||
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPropertyValue(Device device, String property) {
|
||||
if (device != null && device.getProperties() != null) {
|
||||
for (Device.Property prop : device.getProperties()) {
|
||||
if (property.equals(prop.getName())) {
|
||||
return prop.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Device.Property getProperty(String property, String value) {
|
||||
if (property != null) {
|
||||
Device.Property prop = new Device.Property();
|
||||
prop.setName(property);
|
||||
prop.setValue(value);
|
||||
return prop;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MobileDevice convertToMobileDevice(Device device) {
|
||||
MobileDevice mobileDevice = null;
|
||||
if (device != null) {
|
||||
mobileDevice = new MobileDevice();
|
||||
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
|
||||
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
|
||||
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
|
||||
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
||||
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
||||
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
||||
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
||||
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
||||
mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL));
|
||||
mobileDevice.setOsBuildDate(getPropertyValue(device, MOBILE_DEVICE_OS_BUILD_DATE));
|
||||
|
||||
if (device.getProperties() != null) {
|
||||
Map<String, String> deviceProperties = new HashMap<String, String>();
|
||||
for (Device.Property deviceProperty : device.getProperties()) {
|
||||
deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue());
|
||||
}
|
||||
|
||||
mobileDevice.setDeviceProperties(deviceProperties);
|
||||
} else {
|
||||
mobileDevice.setDeviceProperties(new HashMap<String, String>());
|
||||
}
|
||||
}
|
||||
return mobileDevice;
|
||||
}
|
||||
|
||||
public static Device convertToDevice(MobileDevice mobileDevice) {
|
||||
Device device = null;
|
||||
if (mobileDevice != null) {
|
||||
device = new Device();
|
||||
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_BUILD_DATE, mobileDevice.getOsBuildDate()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
|
||||
if(mobileDevice.getLatitude() != null) {
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
|
||||
}
|
||||
if(mobileDevice.getLongitude() != null) {
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
||||
}
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
|
||||
|
||||
if (mobileDevice.getDeviceProperties() != null) {
|
||||
for (Map.Entry<String, String> deviceProperty : mobileDevice.getDeviceProperties()
|
||||
.entrySet()) {
|
||||
propertyList
|
||||
.add(getProperty(deviceProperty.getKey(), deviceProperty.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
device.setProperties(propertyList);
|
||||
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
public static MobileOperation convertToMobileOperation(Operation operation) {
|
||||
MobileOperation mobileOperation = new MobileOperation();
|
||||
MobileOperationProperty operationProperty;
|
||||
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
|
||||
mobileOperation.setFeatureCode(operation.getCode());
|
||||
mobileOperation.setCreatedDate(new Date().getTime());
|
||||
Properties operationProperties = operation.getProperties();
|
||||
for (String key : operationProperties.stringPropertyNames()) {
|
||||
operationProperty = new MobileOperationProperty();
|
||||
operationProperty.setProperty(key);
|
||||
operationProperty.setValue(operationProperties.getProperty(key));
|
||||
properties.add(operationProperty);
|
||||
}
|
||||
mobileOperation.setProperties(properties);
|
||||
return mobileOperation;
|
||||
}
|
||||
|
||||
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
||||
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings) {
|
||||
List<Integer> mobileOperationIds = new ArrayList<Integer>(mobileDeviceOperationMappings.size());
|
||||
for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) {
|
||||
mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId());
|
||||
}
|
||||
return mobileOperationIds;
|
||||
}
|
||||
|
||||
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation) {
|
||||
Operation operation = new Operation();
|
||||
Properties properties = new Properties();
|
||||
operation.setCode(mobileOperation.getFeatureCode());
|
||||
for (MobileOperationProperty mobileOperationProperty : mobileOperation.getProperties()) {
|
||||
properties
|
||||
.put(mobileOperationProperty.getProperty(), mobileOperationProperty.getValue());
|
||||
}
|
||||
operation.setProperties(properties);
|
||||
return operation;
|
||||
}
|
||||
|
||||
public static MobileFeature convertToMobileFeature(Feature feature) {
|
||||
MobileFeature mobileFeature = new MobileFeature();
|
||||
mobileFeature.setName(feature.getName());
|
||||
mobileFeature.setCode(feature.getCode());
|
||||
mobileFeature.setDescription(feature.getDescription());
|
||||
mobileFeature.setDeviceType(feature.getDeviceType());
|
||||
return mobileFeature;
|
||||
}
|
||||
|
||||
public static Feature convertToFeature(MobileFeature mobileFeature) {
|
||||
Feature feature = new Feature();
|
||||
feature.setDescription(mobileFeature.getDescription());
|
||||
feature.setDeviceType(mobileFeature.getDeviceType());
|
||||
feature.setCode(mobileFeature.getCode());
|
||||
feature.setName(mobileFeature.getName());
|
||||
return feature;
|
||||
}
|
||||
|
||||
public static Registry getConfigurationRegistry() throws MobileDeviceMgtPluginException {
|
||||
try {
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
return MobileDeviceManagementDataHolder.getInstance().getRegistryService()
|
||||
.getConfigSystemRegistry(
|
||||
tenantId);
|
||||
} catch (RegistryException e) {
|
||||
throw new MobileDeviceMgtPluginException(
|
||||
"Error in retrieving conf registry instance: " +
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Resource getRegistryResource(String path) throws MobileDeviceMgtPluginException {
|
||||
try {
|
||||
if(MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)){
|
||||
return MobileDeviceManagementUtil.getConfigurationRegistry().get(path);
|
||||
}
|
||||
return null;
|
||||
} catch (RegistryException e) {
|
||||
throw new MobileDeviceMgtPluginException("Error in retrieving registry resource : " +
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean putRegistryResource(String path,
|
||||
Resource resource)
|
||||
throws MobileDeviceMgtPluginException {
|
||||
boolean status;
|
||||
try {
|
||||
MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
|
||||
MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
|
||||
MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
|
||||
status = true;
|
||||
} catch (RegistryException e) {
|
||||
throw new MobileDeviceMgtPluginException(
|
||||
"Error occurred while persisting registry resource : " +
|
||||
e.getMessage(), e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public static String getResourcePath(String resourceName, String platform) {
|
||||
String regPath = "";
|
||||
switch (platform) {
|
||||
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID:
|
||||
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID +
|
||||
"/" + resourceName;
|
||||
break;
|
||||
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS:
|
||||
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS +
|
||||
"/" + resourceName;
|
||||
break;
|
||||
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS:
|
||||
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS +
|
||||
"/" + resourceName;
|
||||
break;
|
||||
}
|
||||
return regPath;
|
||||
}
|
||||
|
||||
public static String getPlatformConfigPath(String platform) {
|
||||
String regPath = "";
|
||||
switch (platform) {
|
||||
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID:
|
||||
regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
|
||||
break;
|
||||
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS:
|
||||
regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
|
||||
break;
|
||||
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS:
|
||||
regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS;
|
||||
break;
|
||||
}
|
||||
return regPath;
|
||||
}
|
||||
|
||||
public static boolean createRegistryCollection(String path)
|
||||
throws MobileDeviceMgtPluginException {
|
||||
try {
|
||||
if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) {
|
||||
Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection();
|
||||
MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
|
||||
MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
|
||||
MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
|
||||
}
|
||||
return true;
|
||||
} catch (MobileDeviceMgtPluginException e) {
|
||||
throw new MobileDeviceMgtPluginException(
|
||||
"Error occurred while creating a registry collection : " +
|
||||
e.getMessage(), e);
|
||||
} catch (RegistryException e) {
|
||||
throw new MobileDeviceMgtPluginException(
|
||||
"Error occurred while creating a registry collection : " +
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Feature> getMissingFeatures(List<Feature> supportedFeatures, List<Feature> existingFeatures) {
|
||||
HashMap<String,Feature> featureHashMap = new HashMap();
|
||||
for (Feature feature: existingFeatures) {
|
||||
featureHashMap.put(feature.getCode(),feature);
|
||||
}
|
||||
List<Feature> missingFeatures = new ArrayList<Feature>();
|
||||
for (Feature supportedFeature : supportedFeatures) {
|
||||
if (featureHashMap.get(supportedFeature.getCode()) != null) {
|
||||
continue;
|
||||
}
|
||||
missingFeatures.add(supportedFeature);
|
||||
}
|
||||
return missingFeatures;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>mobile-plugins</artifactId>
|
||||
<version>2.2.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>mobile-base-plugin</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - Mobile Plugins</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<modules>
|
||||
<module>org.wso2.carbon.device.mgt.mobile</module>
|
||||
<module>org.wso2.carbon.device.mgt.mobile.ui</module>
|
||||
<module>org.wso2.carbon.device.mgt.mobile.url.printer</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-scr-scrdescriptor</id>
|
||||
<goals>
|
||||
<goal>scr</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
Loading…
Reference in new issue