public EcPk getSubject() { return EcPk.fromPem((String) (Object) subject); }
public EcPk getAgent() { return EcPk.fromPem((String) (Object) agent); }
public void getSubjectAsync(final Callback1<EcPk> success, final Callback1<String> failure) { success.$invoke(EcPk.fromPem((String) (Object) subject)); }
public void getAgentAsync(final Callback1<EcPk> success, final Callback1<String> failure) { success.$invoke(EcPk.fromPem((String) (Object) agent)); }
@Override public void $invoke(String decryptedString) { if (decryptedString == null) failure.$invoke("Could not decrypt agent."); else success.$invoke(EcPk.fromPem(decryptedString)); } };
@Override public void $invoke(String decryptedString) { if (decryptedString == null) failure.$invoke("Could not decrypt subject."); else success.$invoke(EcPk.fromPem(decryptedString)); } };
/** * Helper function to decrypt an encrypted contact (storable version of an contact) * into an contact * * @param {EbacContact} contact * Contact to decrypt. * @param {String} secret * AES secret used to decrypt the credential. * @param {String} source * Source of the credential, used to track where a contact * came from. * @return {EcContact} * Decrypted identity object, ready for use. * @memberOf EcContact * @method fromEncryptedContact * @static */ public static EcContact fromEncryptedContact(EbacContact contact, String secret, String source) { EcContact i = new EcContact(); i.pk = EcPk.fromPem(EcAesCtr.decrypt(contact.pk, secret, contact.iv)); i.source = source; if (contact.displayName != null && contact.displayNameIv != null) i.displayName = EcAesCtr.decrypt(contact.displayName, secret, contact.iv); return i; }
private static void insertSecret(String pk, final Callback0 success, String newIv, String newSecret, final EcEncryptedValue v, Callback1<String> failure) { EbacEncryptedSecret eSecret = new EbacEncryptedSecret(); eSecret.iv = newIv; eSecret.secret = newSecret; if (v.secret == null) { v.secret = new Array<String>(); } EcRsaOaepAsync.encrypt(EcPk.fromPem(pk), eSecret.toEncryptableJson(), new Callback1<String>() { @Override public void $invoke(String encryptedSecret) { v.secret.push(encryptedSecret); success.$invoke(); } }, failure); }
/** * Determines if the object has a reader identified by pk. * Homogenizes the PEM strings for comparison. * Homogenization is necessary for comparing PKCS#1 and PKCS#8 or PKs with Certificates, etc. * * @param {EcPk} pk Public Key of the owner. * @return {boolean} True if owner is represented by the PK, false otherwise. * @method hasOwner */ public boolean hasReader(EcPk pk) { if (reader == null) return false; String pkPem = pk.toPem(); for (int i = 0; i < reader.$length(); i++) if (pkPem == EcPk.fromPem(reader.$get(i)).toPem()) return true; return false; }
/** * Determines if the object has an owner identified by pk. * Homogenizes the PEM strings for comparison. * Homogenization is necessary for comparing PKCS#1 and PKCS#8 or PKs with Certificates, etc. * * @param {EcPk} pk Public Key of the owner. * @return {boolean} True if owner is represented by the PK, false otherwise. * @method hasOwner */ public boolean hasOwner(EcPk pk) { if (owner == null) return false; String pkPem = pk.toPem(); for (int i = 0; i < owner.$length(); i++) if (pkPem == EcPk.fromPem(owner.$get(i)).toPem()) return true; return false; }
@Override public void $invoke(EcIdentity p1, final Callback0 incrementalSuccess) { EcPpk ppk = p1.ppk; EcPk pk = ppk.toPk(); boolean found = false; if (identityPksinPem != null) { for (int j = 0; j < identityPksinPem.$length(); j++) { EcPk ownerPpk = EcPk.fromPem(identityPksinPem.$get(j).trim()); if (pk.equals(ownerPpk)) { found = true; createSignatureAsync(duration, server, ppk, new Callback1<EbacSignature>() { @Override public void $invoke(EbacSignature p1) { signatures.push(p1.atIfy()); incrementalSuccess.$invoke(); } },failure); } } } if (!found) { incrementalSuccess.$invoke(); } } }, new Callback1<Array<EcIdentity>>() {
public EcPk getSubject() { if (subject == null) return null; EcEncryptedValue v = new EcEncryptedValue(); v.copyFrom(subject); AssertionCodebook codebook = Assertion.getCodebook(this); String decryptedString; if (codebook != null) decryptedString = v.decryptIntoStringUsingSecret(codebook.subject); else { decryptedString = v.decryptIntoString(); } if (decryptedString == null) return null; return EcPk.fromPem(decryptedString); }
public EcPk getAgent() { if (agent == null) return null; EcEncryptedValue v = new EcEncryptedValue(); v.copyFrom(agent); AssertionCodebook codebook = Assertion.getCodebook(this); String decryptedString; if (codebook != null) decryptedString = v.decryptIntoStringUsingSecret(codebook.agent); else { decryptedString = v.decryptIntoString(); } if (decryptedString == null) return null; return EcPk.fromPem(decryptedString); }
if (me.owner != null) for (int i = 0;i < me.owner.$length();i++) EcArray.setAdd(ary, EcPk.fromPem(me.owner.$get(i))); if (me.reader != null) for (int i = 0;i < me.reader.$length();i++) EcArray.setAdd(ary, EcPk.fromPem(me.reader.$get(i))); me.secret = new Array<>(); EcAsyncHelper<EcPk> eah = new EcAsyncHelper<>();
/** * Removes a reader from the object, if the reader does exist. * * @param {EcPk} oldReader PK of the old reader. * @memberOf EcEncryptedValue * @method removeReader */ public void removeReader(EcPk oldReader) { EbacEncryptedSecret payloadSecret = decryptSecret(); String pem = oldReader.toPem(); if (reader != null) { EcArray.setRemove(reader, pem); } if (payloadSecret == null) { Global.console.error("Cannot remove a Reader if you don't know the secret"); return; } secret = new Array<>(); if (owner != null) for (int i = 0;i < owner.$length();i++) EcArray.setAdd(secret, EcRsaOaep.encrypt(EcPk.fromPem(owner.$get(i)), payloadSecret.toEncryptableJson())); if (reader != null) for (int i = 0;i < reader.$length();i++) EcArray.setAdd(secret, EcRsaOaep.encrypt(EcPk.fromPem(reader.$get(i)), payloadSecret.toEncryptableJson())); }
for (int j = 0; j < owner.$length(); j++) { String own = owner.$get(j); EcPk pk = EcPk.fromPem(own); Boolean verify = false; try {
/** * Create a signature sheet, authorizing movement of data outside of our * control. * * @param {String[]} identityPksinPem Which identities to create signatures * for. * @param {long} duration Length of time in milliseconds to authorize * control. * @param {String} server Server that we are authorizing. * @return {String} JSON Array containing signatures. * @memberOf EcIdentityManager * @method signatureSheetFor * @static */ public static String signatureSheetFor(Array<String> identityPksinPem, long duration, String server) { Array<Object> signatures = new Array<Object>(); for (int j = 0; j < ids.$length(); j++) { EcPpk ppk = ids.$get(j).ppk; EcPk pk = ppk.toPk(); if (identityPksinPem != null) { for (int i = 0; i < identityPksinPem.$length(); i++) { EcPk ownerPpk = EcPk.fromPem(identityPksinPem.$get(i).trim()); if (pk.equals(ownerPpk)) { signatures.push(createSignature(duration, server, ppk).atIfy()); } } } } return JSGlobal.JSON.stringify(signatures); }
EcPk.fromPem(v.owner.$get(i)), eSecret.toEncryptableJson()
Map<String, Object> props = JSObjectAdapter.$properties(o); contact.displayName = (String) props.$get("displayName"); contact.pk = EcPk.fromPem((String) props.$get("pk")); contact.source = (String) props.$get("source");