@ -1,31 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var uri = request.getRequestURI();
|
|
||||||
var uriMatcher = new URIMatcher(String(uri));
|
|
||||||
|
|
||||||
var log = new Log("api/operation-api.jag");
|
|
||||||
|
|
||||||
var deviceModule = require("/modules/device.js").deviceModule;
|
|
||||||
|
|
||||||
if (uriMatcher.match("/{context}/api/operation")) {
|
|
||||||
payload = request.getContent();
|
|
||||||
result = deviceModule.performOperation(payload.devices, payload.operation);
|
|
||||||
}
|
|
||||||
%>
|
|
@ -1,49 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var uri = request.getRequestURI();
|
|
||||||
var uriMatcher = new URIMatcher(String(uri));
|
|
||||||
|
|
||||||
var log = new Log("api/policy-api.jag");
|
|
||||||
|
|
||||||
var constants = require("/modules/constants.js");
|
|
||||||
var dcProps = require('/config/dc-props.js').config();
|
|
||||||
var policyModule = require("/modules/policy.js").policyModule;
|
|
||||||
|
|
||||||
var result;
|
|
||||||
if (uriMatcher.match("/{context}/api/policies/update")) {
|
|
||||||
payload = request.getContent();
|
|
||||||
policyModule.updatePolicyPriorities(payload);
|
|
||||||
} else if (uriMatcher.match("/{context}/api/policies/{id}/delete")) {
|
|
||||||
elements = uriMatcher.elements();
|
|
||||||
policyId = elements.id;
|
|
||||||
try {
|
|
||||||
result = policyModule.deletePolicy(policyId);
|
|
||||||
} catch (e) {
|
|
||||||
log.error("Exception occurred while trying to delete policy for id:" + policyId, e);
|
|
||||||
// http status code 500 refers to - Internal Server Error.
|
|
||||||
result = 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// returning the result.
|
|
||||||
if (result) {
|
|
||||||
response.content = result;
|
|
||||||
}
|
|
||||||
%>
|
|
@ -1,44 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>{{ defineZone "title"}}</title>
|
|
||||||
{{ defineZone "topCss"}}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
|
||||||
<div class="container-liquid">
|
|
||||||
<div class="navbar-header">
|
|
||||||
<a class="navbar-brand" href="#">{{defineZone "brand"}}</a>
|
|
||||||
</div>
|
|
||||||
<div class="navbar-collapse collapse">
|
|
||||||
<ul class="nav navbar-nav navbar-right">
|
|
||||||
<li><a href="/login">Login</a></li>
|
|
||||||
{{ defineZone "upperRight"}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="wrap">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
{{ defineZone "content"}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- /container -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
{{ defineZone "footer"}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,41 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var apiWrapperUtil = function () {
|
|
||||||
var module = {};
|
|
||||||
var tokenUtil = require("/modules/util.js").util;
|
|
||||||
module.refreshToken = function () {
|
|
||||||
var tokenPair = session.get("accessTokenPair");
|
|
||||||
tokenPair = tokenUtil.refreshToken(tokenPair);
|
|
||||||
session.put("accessTokenPair", tokenPair);
|
|
||||||
response.addCookie({'name': 'accessToken', 'value': tokenPair.accessToken});
|
|
||||||
};
|
|
||||||
module.setupAccessTokenPair = function (type, properties) {
|
|
||||||
var tokenPair;
|
|
||||||
var clientId = "pY0FbBUC_GI7mfHVS1FvhWAifEwa";
|
|
||||||
var clientSecret = "Tu5Za1R3fHtGc5yH4KK8TNiLVSca";
|
|
||||||
if (type == "password") {
|
|
||||||
//tokenPair = tokenUtil.getTokenWithPasswordGrantType(properties.username, properties.password, clientId, clientSecret);
|
|
||||||
} else if (type == "saml") {
|
|
||||||
|
|
||||||
}
|
|
||||||
//session.put("accessTokenPair", tokenPair);
|
|
||||||
//response.addCookie({'name': 'accessToken', 'value': tokenPair.accessToken});
|
|
||||||
};
|
|
||||||
return module;
|
|
||||||
}();
|
|
@ -1,85 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var policyModule;
|
|
||||||
policyModule = function () {
|
|
||||||
var log = new Log("modules/policy.js");
|
|
||||||
|
|
||||||
var constants = require("/modules/constants.js");
|
|
||||||
var utility = require("/modules/utility.js").utility;
|
|
||||||
|
|
||||||
var userManagementService = utility.getUserManagementService();
|
|
||||||
|
|
||||||
var publicMethods = {};
|
|
||||||
var privateMethods = {};
|
|
||||||
|
|
||||||
publicMethods.getPolicies = function () {
|
|
||||||
|
|
||||||
//TODO-This method returns includes dummy policy data
|
|
||||||
|
|
||||||
var policies = [];
|
|
||||||
var policyObj = {
|
|
||||||
"id":1, // Identifier of the policy.
|
|
||||||
"priorityId":1, // Priority of the policies. This will be used only for simple evaluation.
|
|
||||||
"profile":{}, // Profile
|
|
||||||
"policyName":"Turn off light", // Name of the policy.
|
|
||||||
"generic":true, // If true, this should be applied to all related device.
|
|
||||||
"roles":{}, // Roles which this policy should be applied.
|
|
||||||
"ownershipType":{}, // Ownership type (COPE, BYOD, CPE)
|
|
||||||
"devices":{}, // Individual devices this policy should be applied
|
|
||||||
"users":{}, // Individual users this policy should be applied
|
|
||||||
"Compliance":{},
|
|
||||||
"policyCriterias":{},
|
|
||||||
"startTime":283468236, // Start time to apply the policy.
|
|
||||||
"endTime":283468236, // After this time policy will not be applied
|
|
||||||
"startDate":"", // Start date to apply the policy
|
|
||||||
"endDate":"", // After this date policy will not be applied.
|
|
||||||
"tenantId":-1234,
|
|
||||||
"profileId":1
|
|
||||||
};
|
|
||||||
|
|
||||||
policies.push(policyObj);
|
|
||||||
|
|
||||||
policyObj = {
|
|
||||||
"id":2, // Identifier of the policy.
|
|
||||||
"priorityId":1, // Priority of the policies. This will be used only for simple evaluation.
|
|
||||||
"profile":{}, // Profile
|
|
||||||
"policyName":"Turn on Buzzer", // Name of the policy.
|
|
||||||
"generic":false, // If true, this should be applied to all related device.
|
|
||||||
"roles":{}, // Roles which this policy should be applied.
|
|
||||||
"ownershipType":{}, // Ownership type (COPE, BYOD, CPE)
|
|
||||||
"devices":{}, // Individual devices this policy should be applied
|
|
||||||
"users":{}, // Individual users this policy should be applied
|
|
||||||
"Compliance":{},
|
|
||||||
"policyCriterias":{},
|
|
||||||
"startTime":283468236, // Start time to apply the policy.
|
|
||||||
"endTime":283468236, // After this time policy will not be applied
|
|
||||||
"startDate":"", // Start date to apply the policy
|
|
||||||
"endDate":"", // After this date policy will not be applied.
|
|
||||||
"tenantId":-1234,
|
|
||||||
"profileId":2
|
|
||||||
};
|
|
||||||
|
|
||||||
policies.push(policyObj);
|
|
||||||
return policies;
|
|
||||||
};
|
|
||||||
|
|
||||||
return publicMethods;
|
|
||||||
}();
|
|
||||||
|
|
||||||
|
|
@ -1,89 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var util = function () {
|
|
||||||
var module = {};
|
|
||||||
var Base64 = Packages.org.apache.commons.codec.binary.Base64;
|
|
||||||
var String = Packages.java.lang.String;
|
|
||||||
var log = new Log();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encode the payload in Base64
|
|
||||||
* @param payload
|
|
||||||
* @returns {Packages.java.lang.String}
|
|
||||||
*/
|
|
||||||
function encode(payload){
|
|
||||||
return new String(Base64.encodeBase64(new String(payload).getBytes()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an AccessToken pair based on username and password
|
|
||||||
* @param username
|
|
||||||
* @param password
|
|
||||||
* @param clientId
|
|
||||||
* @param clientSecret
|
|
||||||
* @param scope
|
|
||||||
* @returns {{accessToken: "", refreshToken: ""}}
|
|
||||||
*/
|
|
||||||
module.getTokenWithPasswordGrantType = function (username, password, clientId, clientSecret, scope) {
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
var tokenEndpoint = "https://localhost:9443/oauth2/token";
|
|
||||||
var encodedClientKeys = encode(clientId + ":" + clientSecret);
|
|
||||||
xhr.open("POST", tokenEndpoint, false);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.setRequestHeader("Authorization", "Basic " + encodedClientKeys);
|
|
||||||
xhr.send("grant_type=password&username=" + username + "&password=" + password + "&scope=" + scope);
|
|
||||||
delete password, delete clientSecret, delete encodedClientKeys;
|
|
||||||
var tokenPair = {};
|
|
||||||
if (xhr.status == 200) {
|
|
||||||
var data = parse(xhr.responseText);
|
|
||||||
tokenPair.refreshToken = data.refresh_token;
|
|
||||||
tokenPair.accessToken = data.access_token;
|
|
||||||
} else if (xhr.status == 403) {
|
|
||||||
throw "Error in obtaining token with Password Grant Type";
|
|
||||||
} else {
|
|
||||||
throw "Error in obtaining token with Password Grant Type";
|
|
||||||
}
|
|
||||||
return tokenPair;
|
|
||||||
};
|
|
||||||
module.getTokenWithSAMLGrantType = function () {
|
|
||||||
|
|
||||||
};
|
|
||||||
module.refreshToken = function(tokenPair){
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
var tokenEndpoint = "https://localhost:9443/oauth2/token";
|
|
||||||
var encodedClientKeys = encode(clientId + ":" + clientSecret);
|
|
||||||
xhr.open("POST", tokenEndpoint, false);
|
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
xhr.setRequestHeader("Authorization", "Basic " + encodedClientKeys);
|
|
||||||
xhr.send("grant_type=refresh_token&refresh_token=" + tokenPair.refreshToken + "&scope=" + scope);
|
|
||||||
delete password, delete clientSecret, delete encodedClientKeys;
|
|
||||||
var tokenPair = {};
|
|
||||||
if (xhr.status == 200) {
|
|
||||||
var data = parse(xhr.responseText);
|
|
||||||
tokenPair.refreshToken = data.refresh_token;
|
|
||||||
tokenPair.accessToken = data.access_token;
|
|
||||||
} else if (xhr.status == 403) {
|
|
||||||
throw "Error in obtaining token with Password Grant Type";
|
|
||||||
} else {
|
|
||||||
throw "Error in obtaining token with Password Grant Type";
|
|
||||||
}
|
|
||||||
return tokenPair;
|
|
||||||
};
|
|
||||||
return module;
|
|
||||||
}();
|
|
@ -1,9 +0,0 @@
|
|||||||
{{authorized}}
|
|
||||||
{{layout "fluid"}}
|
|
||||||
{{#zone "title"}}
|
|
||||||
WSO2 DC | Add New Policy
|
|
||||||
{{/zone}}
|
|
||||||
{{#zone "body"}}
|
|
||||||
{{unit "appbar" link="policies" title="My Policies"}}
|
|
||||||
{{unit "policy-create"}}
|
|
||||||
{{/zone}}
|
|
@ -1,21 +0,0 @@
|
|||||||
{{authorized}}
|
|
||||||
{{layout "fluid"}}
|
|
||||||
{{#zone "title"}}
|
|
||||||
Policies
|
|
||||||
{{/zone}}
|
|
||||||
{{#zone "body"}}
|
|
||||||
{{unit "appbar" link="policies" title="My Policies"}}
|
|
||||||
{{unit "extended-search-box"}}
|
|
||||||
<div class="wr-device-list row">
|
|
||||||
<div class="wr-hidden-operations wr-advance-operations">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col-md-12 wr-page-content">
|
|
||||||
<!-- content -->
|
|
||||||
<div>
|
|
||||||
{{unit "policy-listing"}}
|
|
||||||
</div>
|
|
||||||
<!-- /content -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/zone}}
|
|
@ -1,100 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
describe('Device Module', function () {
|
|
||||||
var log = new Log();
|
|
||||||
var mobileDB;
|
|
||||||
var cdmDB;
|
|
||||||
var deviceModule = require("/modules/device.js").deviceModule;
|
|
||||||
|
|
||||||
function tearUp() {
|
|
||||||
mobileDB = new Database("MobileDM_DS");
|
|
||||||
cdmDB = new Database("DM_DS");
|
|
||||||
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
|
|
||||||
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
|
|
||||||
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
|
|
||||||
" 1,'4892813d-0b18-4a02-b7b1-61775257488e', 'admin@wso2.com', '-1234');");
|
|
||||||
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
|
|
||||||
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
|
|
||||||
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
|
|
||||||
" 1,'4892813d-0b18-4a02-b7b1-61775257488F', 'mdm@wso2.com', '-1234');");
|
|
||||||
|
|
||||||
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
|
|
||||||
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
|
|
||||||
"values ('4892813d-0b18-4a02-b7b1-61775257488e', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
|
|
||||||
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
|
|
||||||
"'ksdfjlskfjwer', '234234');");
|
|
||||||
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
|
|
||||||
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
|
|
||||||
"values ('4892813d-0b18-4a02-b7b1-61775257488F', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
|
|
||||||
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
|
|
||||||
"'ksdfjlskfjwer', '234234');");
|
|
||||||
}
|
|
||||||
|
|
||||||
function tearDown() {
|
|
||||||
deleteData();
|
|
||||||
mobileDB.close();
|
|
||||||
cdmDB.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteData(){
|
|
||||||
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488e'");
|
|
||||||
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488F'");
|
|
||||||
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488e'");
|
|
||||||
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488F'");
|
|
||||||
}
|
|
||||||
|
|
||||||
it('List all Devices - Device Module', function () {
|
|
||||||
try {
|
|
||||||
tearUp();
|
|
||||||
var results = deviceModule.listDevices();
|
|
||||||
expect(results.length).not.toBe(0);
|
|
||||||
} catch (e) {
|
|
||||||
log.error(e);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
it('List Devices for User - Device Module', function () {
|
|
||||||
try {
|
|
||||||
tearUp();
|
|
||||||
var results = deviceModule.listDevicesForUser("mdm@wso2.com");
|
|
||||||
expect(results.length).toBe(1);
|
|
||||||
} catch (e) {
|
|
||||||
log.error(e);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
it('Perform operation on the device', function(){
|
|
||||||
try {
|
|
||||||
tearUp();
|
|
||||||
var devices = [{"id": "4892813d-0b18-4a02-b7b1-61775257488e", "type": "android"}];
|
|
||||||
var operation = {"featureName": "DEVICE_LOCK", "type": "COMMAND", "properties": {"enabled": true}}
|
|
||||||
var results = deviceModule.performOperation(devices, operation);
|
|
||||||
expect(results.length).toBe(1);
|
|
||||||
} catch (e) {
|
|
||||||
log.error(e);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,88 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
describe('Device Module', function () {
|
|
||||||
var log = new Log();
|
|
||||||
var mobileDB;
|
|
||||||
var cdmDB;
|
|
||||||
var deviceModule = require("/modules/device.js").deviceModule;
|
|
||||||
var userModule = require("/modules/user.js").userModule;
|
|
||||||
var constants = require("/modules/constants.js");
|
|
||||||
function tearUp() {
|
|
||||||
mobileDB = new Database("MobileDM_DS");
|
|
||||||
cdmDB = new Database("DM_DS");
|
|
||||||
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
|
|
||||||
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
|
|
||||||
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
|
|
||||||
" 1,'4892813d-0b18-4a02-b7b1-61775257488e', 'admin@wso2.com', '-1234');");
|
|
||||||
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
|
|
||||||
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
|
|
||||||
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
|
|
||||||
" 1,'4892813d-0b18-4a02-b7b1-61775257488F', 'mdm@wso2.com', '-1234');");
|
|
||||||
|
|
||||||
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
|
|
||||||
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
|
|
||||||
"values ('4892813d-0b18-4a02-b7b1-61775257488e', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
|
|
||||||
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
|
|
||||||
"'ksdfjlskfjwer', '234234');");
|
|
||||||
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
|
|
||||||
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
|
|
||||||
"values ('4892813d-0b18-4a02-b7b1-61775257488F', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
|
|
||||||
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
|
|
||||||
"'ksdfjlskfjwer', '234234');");
|
|
||||||
session.put(constants.USER_SESSION_KEY, {"username" : "admin", "domain": "carbon.super", "tenantId": "-1234"});
|
|
||||||
}
|
|
||||||
|
|
||||||
function tearDown() {
|
|
||||||
deleteData();
|
|
||||||
mobileDB.close();
|
|
||||||
cdmDB.close();
|
|
||||||
session.put(constants.USER_SESSION_KEY, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteData(){
|
|
||||||
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488e'");
|
|
||||||
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488F'");
|
|
||||||
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488e'");
|
|
||||||
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488F'");
|
|
||||||
}
|
|
||||||
|
|
||||||
it('List all users', function () {
|
|
||||||
try {
|
|
||||||
tearUp();
|
|
||||||
var results = userModule.getUsers();
|
|
||||||
expect(results.length).not.toBe(0);
|
|
||||||
} catch (e) {
|
|
||||||
log.error(e);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
it('Check permission for user', function () {
|
|
||||||
try {
|
|
||||||
tearUp();
|
|
||||||
expect(userModule.isAuthorized("/permission/device-mgt/user/devices/list")).toBe(true);
|
|
||||||
} catch (e) {
|
|
||||||
log.error(e);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,70 +0,0 @@
|
|||||||
function updateCPUTemperatureGraph(temperatureData) {
|
|
||||||
console.log("cpuTemperatureData");
|
|
||||||
renderCPUTemperatureChart(temperatureData);
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderCPUTemperatureChart(chartDataRaw) {
|
|
||||||
var chartWrapperElmId = "#canvas-wrapper9";
|
|
||||||
var graphWidth = $(chartWrapperElmId).width() - 50;
|
|
||||||
if (chartDataRaw.length == 0) {
|
|
||||||
$(chartWrapperElmId).html("No data available...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var chartData = [];
|
|
||||||
for (var i = 0; i < chartDataRaw.length; i++) {
|
|
||||||
chartData.push({x: parseInt(chartDataRaw[i].x), y: parseInt(chartDataRaw[i].y)});
|
|
||||||
}
|
|
||||||
|
|
||||||
//var i = parseInt(fromDate);
|
|
||||||
//while (i < parseInt(toDate)){
|
|
||||||
// var rnd = Math.random() * (30 - 20) + 20;
|
|
||||||
// chartData.push({x:i * 1000, y:rnd});
|
|
||||||
// i += 60 * 5;
|
|
||||||
//}
|
|
||||||
|
|
||||||
var chartDiv = "chart9";
|
|
||||||
var sliderDiv = "slider9";
|
|
||||||
var x_axis = "x_axis9";
|
|
||||||
var y_axis = "y_axis9";
|
|
||||||
$(chartWrapperElmId).html("").html('<div id="' + y_axis + '" class="custom_y_axis"></div><div id="' + chartDiv + '" class="custom_rickshaw_graph"></div><div id="' + x_axis + '" class="custom_x_axis"></div><div id="' + sliderDiv + '" class="custom_slider"></div>');
|
|
||||||
|
|
||||||
var graph = new Rickshaw.Graph({
|
|
||||||
element: document.getElementById(chartDiv),
|
|
||||||
width: graphWidth,
|
|
||||||
height: 400,
|
|
||||||
strokeWidth: 1,
|
|
||||||
renderer: 'line',
|
|
||||||
xScale: d3.time.scale(),
|
|
||||||
padding: {top: 0.2, left: 0.02, right: 0.02, bottom: 0},
|
|
||||||
series: [
|
|
||||||
{color: '#FF4000', data: chartData}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
graph.render();
|
|
||||||
|
|
||||||
var xAxis = new Rickshaw.Graph.Axis.X({
|
|
||||||
graph: graph,
|
|
||||||
orientation: 'bottom',
|
|
||||||
element: document.getElementById(x_axis),
|
|
||||||
tickFormat: graph.x.tickFormat()
|
|
||||||
});
|
|
||||||
|
|
||||||
xAxis.render();
|
|
||||||
|
|
||||||
var yAxis = new Rickshaw.Graph.Axis.Y({
|
|
||||||
graph: graph,
|
|
||||||
orientation: 'left',
|
|
||||||
element: document.getElementById(y_axis),
|
|
||||||
width: 40,
|
|
||||||
height: 410
|
|
||||||
});
|
|
||||||
|
|
||||||
yAxis.render();
|
|
||||||
|
|
||||||
var slider = new Rickshaw.Graph.RangeSlider.Preview({
|
|
||||||
graph: graph,
|
|
||||||
element: document.getElementById(sliderDiv)
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
function onRequest(context){
|
|
||||||
context.sketchPath = "api/device/sketch/download";
|
|
||||||
return context;
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
function onRequest(context){
|
|
||||||
context.sketchPath = "api/device/sketch/download";
|
|
||||||
return context;
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
function onRequest(context){
|
|
||||||
context.sketchPath = "api/device/sketch/download";
|
|
||||||
return context;
|
|
||||||
}
|
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
@ -0,0 +1,90 @@
|
|||||||
|
{{#zone "main"}}
|
||||||
|
<div class="container container-bg white-bg">
|
||||||
|
<div class=" margin-top-double">
|
||||||
|
<div class="row row padding-top-double padding-bottom-double margin-bottom-double">
|
||||||
|
<div class="col-lg-12 margin-top-double">
|
||||||
|
<h1 class="grey ">Fire Alarm</h1>
|
||||||
|
<hr>
|
||||||
|
<p class="margin-bottom-double light-grey ">Connect your Fire Alarm device
|
||||||
|
to the WSO2 device cloud. </p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row margin-bottom-double">
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 padding-top">
|
||||||
|
<img src="{{self.publicURL}}/images/firealarm.png" class="img-responsive">
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 padding-top">
|
||||||
|
<h2 class="uppercase">Ingredients</h2>
|
||||||
|
<hr>
|
||||||
|
<p class="grey margin-top">Hardware Requirements </p>
|
||||||
|
<br><br>
|
||||||
|
<span class="fw-stack fw-lg margin-right">
|
||||||
|
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||||
|
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
|
||||||
|
</span>Arduino Uno<br><br>
|
||||||
|
<span class="fw-stack fw-lg margin-right">
|
||||||
|
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||||
|
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
|
||||||
|
</span>Arduino Ethernet / WiFi Shield
|
||||||
|
<br /><br />
|
||||||
|
<form method="POST" class="float-left margin-right"
|
||||||
|
action="{{sketchPath}}">
|
||||||
|
<input type="hidden" name="deviceType" value="firealarm" />
|
||||||
|
<input type="hidden" name="sketchType" value="firealarm_wifi" />
|
||||||
|
<button class="wr-btn" type="submit">Create Sketch for
|
||||||
|
Wifi
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" class="form-login-box float-left"
|
||||||
|
action="{{sketchPath}}">
|
||||||
|
<input type="hidden" name="deviceType" value="firealarm" />
|
||||||
|
<input type="hidden" name="sketchType" value="firealarm" />
|
||||||
|
<button class="wr-btn margin-right" type="submit">Create
|
||||||
|
Sketch
|
||||||
|
for Ethernet</button>
|
||||||
|
</form>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class ="col-xs-12 col-sm-6 col-md-3 col-lg-12 padding-double grey-bg ">
|
||||||
|
<h2 class="uppercase">Prepare</h2><hr>
|
||||||
|
<p class="grey margin-top">Get your device ready </p>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||||
|
<span class="circle">01 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||||
|
</div>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom">
|
||||||
|
<span class="circle">02 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||||
|
</div>
|
||||||
|
<div class="margin-doubles padding-top-double margin-bottom-double light-grey margin-left-double margin-bottom">
|
||||||
|
<span class="circle">03 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
|
||||||
|
<div class="col-lg-12 margin-top-double">
|
||||||
|
<h2 class="uppercase ">Connect (Quickstart)</h2>
|
||||||
|
<hr>
|
||||||
|
<p class="margin-bottom-double light-grey ">Internet of Things Foundation Quickstart connection </p>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||||
|
<span class="circle">01 </span> <span class="padding-left">Use the following command to download the installer from GitHub:</span><br>
|
||||||
|
</div>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||||
|
<span class="circle">02 </span> <span class="padding-left">Download the Sketch installer from the Arduino website http://arduino.cc/en/Main/Software</span><br>
|
||||||
|
</div>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||||
|
<span class="circle">03 </span> <span class="padding-left"> Install the Sketch program</span><br>
|
||||||
|
</div>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||||
|
<span class="circle">04 </span> <span class="padding-left">Use the Sketch program to open the samples code samples/quickstart/quickstart.ino</span><br>
|
||||||
|
</div>
|
||||||
|
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||||
|
<span class="circle">05 </span> <span class="padding-left">View the lower part of the Sketch pad window to check that the COM connection is shown as active</span><br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/zone}}
|
||||||
|
{{#zone "topCss"}}
|
||||||
|
<link href="{{self.publicURL}}/css/fontwso2.css" rel="stylesheet">
|
||||||
|
<link href="{{self.publicURL}}/css/fontwso2-extend.css" rel="stylesheet">
|
||||||
|
{{/zone}}
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
function onRequest(context){
|
||||||
|
context.sketchPath = "../api/device/sketch/download";
|
||||||
|
return context;
|
||||||
|
}
|
Before Width: | Height: | Size: 478 KiB After Width: | Height: | Size: 478 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
function onRequest(context){
|
||||||
|
context.sketchPath = "../api/device/sketch/download";
|
||||||
|
return context;
|
||||||
|
}
|
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 516 B |
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 451 B |
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 373 B |