cordova plugin add kapsel-plugin-encryptedstorage --searchpath %KAPSEL_HOME%/plugins
or
cordova plugin add kapsel-plugin-encryptedstorage --searchpath $KAPSEL_HOME/plugins
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="serverContext.js"></script>
<script>
window.onerror = onError;
keyTextField = "";
valueTextField = "";
resultsTextArea = "";
storeName = "testStore";
store = null;
function onError(msg, url, line) {
var idx = url.lastIndexOf("/");
var file = "unknown";
if (idx > -1) {
file = url.substring(idx + 1);
}
alert("An error occurred in " + file + " (at line # " + line + "): " + msg);
return false; //suppressErrorAlert;
}
function init() {
if (sap.Logger) {
sap.Logger.setLogLevel(sap.Logger.DEBUG); //enables the display of debug log messages from the Kapsel plugins.
sap.Logger.debug("Log level set to DEBUG");
}
if (navigator.notification) { // Override default HTML alert with native dialog. alert is not supported on Windows
window.alert = navigator.notification.alert;
}
keyTextField = document.getElementById("keyTextField");
valueTextField = document.getElementById("valueTextField");
resultsTextArea = document.getElementById("resultsTextArea");
var passcodePolicy = {
"expirationDays":"0",
"hasDigits":"false",
"hasLowerCaseLetters":"false",
"hasSpecialLetters":"false",
"hasUpperCaseLetters":"false",
"defaultAllowed":"true",
"lockTimeout":"5",
"minLength":"6",
"minUniqueChars":"0",
"retryLimit":"5"
};
//Used if the application is not registering with the SMP 3.0 server. New to SP03.
sap.Logon.initPasscodeManager(successCallback, errorCallback, appId, null, passcodePolicy, context);
//Used if the application registers with the SMP 3.0 server
//sap.Logon.init(successCallback, errorCallback, appId, context);
createStore();
}
function createStore() {
store = new sap.EncryptedStorage(storeName); //SP03 the Encrypted Storage plugin requires logon. API changed no password required.
//store = new sap.EncryptedStorage(storeName, "securePassword123"); //SP02
}
function deleteStore() {
store.deleteStore(successCallback, errorCallback);
}
function successCallback(info) {
console.log("Success: " + JSON.stringify(info));
}
function errorCallback(errorInfo) {
alert("Error: " + JSON.stringify(errorInfo));
}
function setItem(key, value) {
store.setItem(key, value, successCallback, errorCallback);
}
function getItem(key) {
store.getItem(key, function(value) {
console.log(value);
resultsTextArea.value = resultsTextArea.value + key + ":" + value + "\n";
}, errorCallback);
}
function setItemLogon(key, value) {
sap.Logon.set(successCallback, errorCallback, key, value);
}
function getItemLogon(key) {
sap.Logon.get(function(value) {
console.log(value);
resultsTextArea.value = resultsTextArea.value + key + ":" + value + "\n";
}, errorCallback, key);
}
function removeItem(key) {
store.removeItem(key, successCallback, errorCallback);
}
function clearAll() {
store.clear(successCallback, errorCallback);
}
function showAll() {
resultsTextArea.value = "";
store.length(function(length) {
for (var i = 0; i < length; i++) {
store.key(i, function(key) {
getItem(key);
}, errorCallback);
}
}, errorCallback);
}
document.addEventListener("deviceready", init, false);
</script>
</head>
<body>
<h1>EncryptedStorage Sample</h1>
<button id="setItem" onclick="setItem(keyTextField.value, valueTextField.value)">Set Item</button>
<button id="getItem" onclick="resultsTextArea.value='';getItem(keyTextField.value)">Get Item</button>
<button id="removeItem" onclick="removeItem(keyTextField.value)">Remove Item</button>
<button id="clearAll" onclick="clearAll()">Clear All Items</button>
<button id="showAll" onclick="showAll()">Show All Items</button>
<button id="deleteStore" onclick="deleteStore()">Delete Store</button>
<button id="createStore" onclick="createStore()">Create Store</button><br><br>
<button id="setItemLogon" onclick="setItemLogon(keyTextField.value, valueTextField.value)">Set Item from Logon</button>
<button id="getItemLogon" onclick="resultsTextArea.value='';getItemLogon(keyTextField.value)">Get Item from Logon</button>
<button id="lockDV" onclick="sap.Logon.lock(successCallback, errorCallback)">Lock Data Vault</button>
<button id="unlockDV" onclick="sap.Logon.unlock(successCallback, errorCallback)">Unlock Data Vault</button>
<button id="deletePCM" onclick="sap.Logon.deletePasscodeManager(successCallback, errorCallback)">Delete PasscodeManager</button>
<button id="initPCM" onclick="init()">Init PasscodeManager</button>
<button id="dataVaultState" onclick="sap.Logon.core.getState(function(value) {alert(JSON.stringify(value))}, errorCallback)">Show Data Vault state</button><br>
Key:<input type="text" id="keyTextField"><br>
Value:<input type="text" id="valueTextField"><br>
<textarea rows="10" cols="30" id="resultsTextArea"></textarea><br>
</body>
</html>
cordova run android
or
cordova run windows -- --archs=x64
or
cordova run windows --device -- --archs=arm --phone
or
cordova run ios
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
24 | |
21 | |
13 | |
11 | |
9 | |
9 | |
9 | |
8 | |
8 |