public String getJsonString() { return Global.JSON.stringify(this); }
@Override public void $invoke(String decryptedSecret) { if (!EcLinkedData.isProbablyJson(decryptedSecret)) { me.decryptSecretsByKeyAsync(decryptionKey, success, failure); } else { success.$invoke(EbacEncryptedSecret.fromEncryptableJson(JSGlobal.JSON.parse(decryptedSecret))); } } }, new Callback1<String>() {
private EbacEncryptedSecret tryDecryptSecretByKeyAndIndex(EcPpk decryptionKey, int j) { String decryptedSecret = null; decryptedSecret = EcRsaOaep.decrypt(decryptionKey, this.secret.$get(j)); if (EcLinkedData.isProbablyJson(decryptedSecret)) { EbacEncryptedSecret encryptedSecret = EbacEncryptedSecret.fromEncryptableJson(JSGlobal.JSON.parse(decryptedSecret)); return encryptedSecret; } return null; }
public String getJsonString() { return Global.JSON.stringify(this); }
/** * Sets the subject of an assertion. Makes a few assumptions: Owners of the * object should be able to see and change the encrypted value. Owners and * readers of the object should be persisted. * * @param pk */ public void setSubject(EcPk pk) { Array<String> owners = new Array<String>(); Array<String> readers = null; if (reader == null) readers = new Array<String>(); else readers = (Array) Global.JSON.parse(Global.JSON.stringify(reader)); if (subject != null) { if (subject.owner != null) owners.concat(subject.owner); if (subject.reader != null) readers.concat(subject.reader); } if (owner != null) owners = owners.concat(owner); readers.push(pk.toPem()); subject = EcEncryptedValue.encryptValue(pk.toPem(), id, owners, readers); }
/** * Decrypts this encrypted value into an object * * @return The Decrypted Object * @memberOf EcEncryptedValue * @method decryptIntoObject */ public EcRemoteLinkedData decryptIntoObject() { String decryptRaw = decryptIntoString(); if (decryptRaw == null) { return null; } if (!EcLinkedData.isProbablyJson(decryptRaw)) { return null; } EcRemoteLinkedData decrypted = new EcRemoteLinkedData("", ""); decrypted.copyFrom((EcRemoteLinkedData) JSGlobal.JSON.parse(decryptRaw)); encryptOnSave(decrypted.id, true); decrypted.id = this.id; return (EcRemoteLinkedData) decrypted.deAtify(); }
/** * Serializes this object to JSON. * * @return {string} JSON formatted object (with JSON-LD fields). * @method toJson */ public String toJson() { // This method serializes the fields in alphabetical order. // This is to prevent signature based errors. Object o = atIfy(); return JSGlobal.JSON.stringify(o); }
if (key.startsWith(stripNamespace + ":")) { if (EcArray.isArray(me.$get(key))) { JSObjectAdapter.$put(me, key.replace(stripNamespace + ":", ""), Global.JSON.parse(Global.JSON.stringify(me.$get(key)).replaceAll(stripNamespace + ":", ""))); } else if (EcObject.isObject(me.$get(key))) { JSObjectAdapter.$put(me, key.replace(stripNamespace + ":", ""), Global.JSON.parse(Global.JSON.stringify(me.$get(key)).replaceAll(stripNamespace + ":", ""))); } else JSObjectAdapter.$put(me, key.replace(stripNamespace + ":", ""), me.$get(key));
@Override public void $invoke(String decryptRaw) { if (decryptRaw == null) { failure.$invoke("Could not decrypt data."); } if (!EcLinkedData.isProbablyJson(decryptRaw)) { failure.$invoke("Could not decrypt data."); } EcRemoteLinkedData decrypted = new EcRemoteLinkedData("", ""); decrypted.copyFrom((EcRemoteLinkedData) JSGlobal.JSON.parse(decryptRaw)); encryptOnSave(decrypted.id, true); success.$invoke((EcRemoteLinkedData) decrypted.deAtify()); } }, failure);
@Override public void $invoke(Array<EcIdentity> pks) { success.$invoke(JSGlobal.JSON.stringify(signatures)); } });
@Override public void $invoke(String decryptRaw) { if (decryptRaw == null) { failure.$invoke("Could not decrypt data."); } if (!EcLinkedData.isProbablyJson(decryptRaw)) { failure.$invoke("Could not decrypt data."); } EcRemoteLinkedData decrypted = new EcRemoteLinkedData("", ""); decrypted.copyFrom((EcRemoteLinkedData) JSGlobal.JSON.parse(decryptRaw)); encryptOnSave(decrypted.id, true); decrypted.id = id; success.$invoke((EcRemoteLinkedData) decrypted.deAtify()); } }, failure);
/** * Encodes the object in a form where it is ready to be signed. * This method is under long term review, and may change from version to version. * * @return ASCII-sort order encoded space-free and tab-free JSON-LD. * @method toSignableJson */ public String toSignableJson() { EcLinkedData d = (EcLinkedData) JSGlobal.JSON.parse(toJson()); if (type.indexOf("http://schema.eduworks.com/") != -1 && type.indexOf("/0.1/") != -1) { JSObjectAdapter.$properties(d).$delete("@signature"); JSObjectAdapter.$properties(d).$delete("@owner"); JSObjectAdapter.$properties(d).$delete("@reader"); JSObjectAdapter.$properties(d).$delete("@id"); } else { // Whom else has signed the object does not change the contents of // the object. JSObjectAdapter.$properties(d).$delete("@signature"); // Where the object resides does not change the contents of the // object, and provides server administration capabilities. JSObjectAdapter.$properties(d).$delete("@id"); // Who owns the object, or who can read the object *does* matter // though, as administrators should not be able to change the // ownership properties of the object in a clandestine fashion. } EcLinkedData e = new EcLinkedData(d.context, d.type); e.copyFrom(d); return e.toJson(); }
@Override public void $invoke(Object p1) { EcRemoteLinkedData d = new EcRemoteLinkedData("", ""); d.copyFrom(p1); if (d.getFullType() == null) { EcRepository.findBlocking(originalUrl, Global.JSON.stringify(p1), new Object(), 0); return; } JSObjectAdapter.$put(cache, originalUrl, d); if (d.id != null) JSObjectAdapter.$put(cache, d.id, d); } }, new Callback1<String>() {
return; Array<Object> c = (Array<Object>) JSGlobal.JSON.parse((String) localStore); for (int i = 0; i < c.$length(); i++) { EcContact contact = new EcContact();
/** * Serializes the field into a compact form for RSA encryption. * * @return {string} string * @method toEncryptableJson */ public String toEncryptableJson() { Map<String, Object> o = JSObjectAdapter.$properties(new Object()); o.$put("v", iv); if (id != null) o.$put("d", id); o.$put("s", secret); if (field != null) o.$put("f", field); return JSGlobal.JSON.stringify(o); }
return; Array<Object> c = (Array<Object>) JSGlobal.JSON.parse((String) localStore); for (int i = 0; i < c.$length(); i++) { EcIdentity identity = new EcIdentity();
private static void getHandleData(Object p1, String originalUrl, Callback1<EcRemoteLinkedData> success, Callback1<String> failure, String finalUrl) { JSObjectAdapter.$properties(fetching).$delete(originalUrl); EcRemoteLinkedData d = new EcRemoteLinkedData("", ""); d.copyFrom(p1); if (d.getFullType() == null) { EcRepository.find(originalUrl, Global.JSON.stringify(p1), new Object(), 0, success, failure); return; } if (caching) { JSObjectAdapter.$put(cache, finalUrl, d); if (d.id != null) JSObjectAdapter.$put(cache, d.id, d); //See eduworks/ec#1 - fray. //JSObjectAdapter.$put(cache, d.shortId(), d); } success.$invoke(d); }
@Override public void $invoke(Array<EcIdentity> pks) { Array cache = null; String stringified = JSGlobal.JSON.stringify(signatures); if (signatureSheetCaching) { cache = new Array(); cache.$set(0, new Date().getTime() + finalDuration); cache.$set(1, stringified); JSObjectAdapter.$put(signatureSheetCache, server, cache); } success.$invoke(stringified); } });