Tabnine Logo
EcPpk
Code IndexAdd Tabnine to your IDE (free)

How to use
EcPpk
in
com.eduworks.ec.crypto

Best Java code snippets using com.eduworks.ec.crypto.EcPpk (Showing top 20 results out of 315)

origin: com.eduworks/ebac.identity

  /**
   * Converts an identity to a contact.
   *
   * @return {EcContact}
   * Contact object.
   * @memberOf EcIdentity
   * @method toContact
   */
  public EcContact toContact() {
    EcContact c = new EcContact();
    c.displayName = displayName;
    c.pk = ppk.toPk();
    c.source = source;
    return c;
  }
}
origin: com.eduworks/ebac.repository

  @Override
  public void $invoke(EcPpk decryptionKey, final Callback0 countdown) {
    int estimatedIndex = -1;
    for (int i = 0; i < ppks.$length(); i++)
      if (ppks.$get(i).equals(decryptionKey))
        estimatedIndex = estimatedIndices.$get(i);
    me.decryptSecretByKeyAsync(decryptionKey, estimatedIndex, new Callback1<EbacEncryptedSecret>() {
      @Override
      public void $invoke(EbacEncryptedSecret p1) {
        if (helper.counter == -1) {
          return;
        }
        helper.stop();
        success.$invoke(p1);
      }
    }, new Callback1<String>() {
      @Override
      public void $invoke(String arg0) {
        countdown.$invoke();
      }
    });
  }
}, new Callback1<Array<EcPpk>>() {
origin: com.eduworks/ebac.identity

/**
 * Helper function to decrypt a credential (storable version of an identity)
 * into an identity)
 *
 * @param {EbacCredential} credential
 *                         Credential to decrypt.
 * @param {String}         secret
 *                         AES secret used to decrypt the credential.
 * @param {String}         source
 *                         Source of the credential, used to track where a credential
 *                         came from.
 * @return {EcIdentity}
 * Decrypted identity object, ready for use.
 * @memberOf EcIdentity
 * @method fromCredential
 * @static
 */
public static EcIdentity fromCredential(EbacCredential credential, String secret, String source) {
  EcIdentity i = new EcIdentity();
  i.ppk = EcPpk.fromPem(EcAesCtr.decrypt(credential.ppk, secret, credential.iv));
  i.source = source;
  if (credential.displayName != null && credential.displayNameIv != null)
    i.displayName = EcAesCtr.decrypt(credential.displayName, secret, credential.iv);
  return i;
}
origin: com.eduworks/ebac.identity

Map<String, Object> props = JSObjectAdapter.$properties(o);
identity.displayName = (String) props.$get("displayName");
identity.ppk = EcPpk.fromPem((String) props.$get("ppk"));
identity.source = (String) props.$get("source");
  if (ids.$get(j).ppk.toPem() == identity.ppk.toPem()) {
    cont = true;
origin: com.eduworks/ebac.identity

@Override
public boolean equals(Object obj) {
  if (obj instanceof EcIdentity) {
    if (ppk == null)
      return false;
    if (((EcIdentity) obj).ppk == null)
      return false;
    return ppk.toPem().equals(((EcIdentity) obj).ppk.toPem());
  }
  return super.equals(obj);
}
origin: com.eduworks/ebac.repository

EcPpk decryptionKey = EcIdentityManager.getPpk(EcPk.fromPem(owner.$get(i)));
if (decryptionKey != null) {
  if (!decryptionKey.inArray(ppks)) {
    ppks.push(decryptionKey);
    estimatedIndices.push(i);
EcPpk decryptionKey = EcIdentityManager.getPpk(EcPk.fromPem(reader.$get(i)));
if (decryptionKey != null) {
  if (!decryptionKey.inArray(ppks)) {
    ppks.push(decryptionKey);
    estimatedIndices.push(i + owner.$length());
origin: com.eduworks/ebac.identity

/**
 * Helper function to encrypt an identity into a credential (storable
 * version of an identity)
 *
 * @param {String} secret
 *                 AES secret used to encrypt the credential.
 * @return {EbacCredential}
 * Encrypted credential object.
 * @memberOf EcIdentity
 * @method toCredential
 */
public EbacCredential toCredential(String secret) {
  EbacCredential c = new EbacCredential();
  c.iv = EcAes.newIv(16);
  c.ppk = EcAesCtr.encrypt(ppk.toPem(), secret, c.iv);
  c.displayNameIv = EcAes.newIv(16);
  c.displayName = EcAesCtr.encrypt(displayName, secret, c.iv);
  return c;
}
origin: com.eduworks/ebac.identity

public static String myIdentitiesSearchString() {
  String searchString = "";
  for (int i = 0; i < ids.$length(); i++) {
    if (i > 0) {
      searchString += " OR ";
    }
    searchString += "@reader:\"" + ids.$get(i).ppk.toPk().toPem() + "\"";
    searchString += " OR ";
    searchString += "@owner:\"" + ids.$get(i).ppk.toPk().toPem() + "\"";
  }
  return searchString;
}
origin: com.eduworks/ebac.identity

/**
 * Writes contact data to localstorage.
 *
 * @memberOf EcIdentityManager
 * @method saveIdentities
 * @static
 */
public static void saveIdentities() {
  Array<Object> c = new Array<Object>();
  for (int i = 0; i < ids.$length(); i++) {
    Object o = new Object();
    Map<String, Object> props = JSObjectAdapter.$properties(o);
    EcIdentity identity = ids.$get(i);
    props.$put("displayName", identity.displayName);
    props.$put("ppk", identity.ppk.toPem());
    props.$put("source", identity.source);
    c.push(o);
  }
  Global.localStorage.$put("identities", JSGlobal.JSON.stringify(c));
}
origin: com.eduworks/ebac.identity

  public static Array<EcPk> getMyPks(){
    Array<EcPk> pks = new Array<EcPk>();
    if (ids == null)
      return pks;
    for (int i = 0;i < ids.$length();i++)
      pks.push(ids.$get(i).ppk.toPk());
    return pks;
  }
}
origin: com.eduworks/ebac.identity

private void writeIdentityFile(String folderId, final EcIdentity identity, final Callback0 finished) {
  File file = BlobHelper.stringToFile(identity.ppk.toPem(), identity.displayName + ".pem", "text/plain");
  Object o = new Object();
  JSObjectAdapter.$put(o, "id", JSObjectAdapter.$get(identity, "id"));
  if (JSObjectAdapter.$get(o, "id") == Global.undefined)
    JSObjectAdapter.$put(o, "parent", folderId);
  JSObjectAdapter.$put(o, "name", file.name);
  Array<File> files = new Array<>();
  files.push(file);
  JSObjectAdapter.$put(o, "file", files);
  hello.api(network + "/" + "me/files", JSObjectAdapter.$get(identity, "id") == Global.undefined ? "post" : "put", o).then(new Callback1<Object>() {
    @Override
    public void $invoke(Object r) {
      JSObjectAdapter.$put(identity, "id", JSObjectAdapter.$get(r, "id"));
      if (finished != null)
        finished.$invoke();
    }
  });
}
origin: com.eduworks/ebac.identity

/**
 * Get Identity from PK (if we have it)
 *
 * @param {EcPk} pk PK to use to look up PPK
 * @return {EcIdentity} identity or null.
 * @memberOf EcIdentityManager
 * @method getIdentity
 * @static
 */
public static EcIdentity getIdentity(EcPk pk) {
  for (int i = 0; i < ids.$length(); i++) {
    if (pk.equals(ids.$get(i).ppk.toPk())) {
      return ids.$get(i);
    }
  }
  return null;
}
origin: com.eduworks/ebac.identity

/**
 * Get PPK from PK (if we have it)
 *
 * @param {EcPk} fromPem PK to use to look up PPK
 * @return {EcPpk} PPK or null.
 * @memberOf EcIdentityManager
 * @method getPpk
 * @static
 */
public static EcPpk getPpk(EcPk fromPem) {
  String pem = fromPem.toPem();
  for (int i = 0; i < ids.$length(); i++) {
    if (pem.equals(ids.$get(i).ppk.toPk().toPem())) {
      return ids.$get(i).ppk;
    }
  }
  return null;
}
origin: com.eduworks/ebac.identity

  @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>>() {
origin: com.eduworks/ebac.identity

/**
 * Verifies that the contact grant is valid
 *
 * @return {boolean}
 * true if valid, false if not
 */
public boolean valid() {
  if (!verify())
    return false;
  if (invalid())
    return false;
  boolean found = false;
  for (int i = 0; i < EcIdentityManager.ids.$length(); i++) {
    if (EcRsaOaep.verify(EcIdentityManager.ids.$get(i).ppk.toPk(), responseToken, responseSignature))
      found = true;
  }
  return found;
}
origin: com.eduworks/cass.competency

/**
 * Adds a relationship between this level and a target level to define
 * how they correspond to one another
 *
 * @param {EcLevel} targetLevel
 *                  Target level of the relationship
 * @param {String}  alignmentType
 *                  Type of relationship
 * @param {EcPpk}   identity
 *                  Private key that will own the new relationship
 * @param {String}  server
 *                  URL Prefix of the new relationship ID (Server it will be saved on)
 * @memberOf EcLevel
 * @method addRelationship
 */
public void addRelationship(EcLevel targetLevel, String alignmentType, final EcPpk identity, final String serverUrl, Callback1<String> success, Callback1<String> failure, final EcRepository repo) {
  final EcAlignment a = new EcAlignment();
  a.source = id;
  a.target = targetLevel.id;
  a.relationType = alignmentType;
  a.addOwner(identity.toPk());
  if (repo == null || repo.selectedServer.indexOf(serverUrl) != -1)
    a.generateId(serverUrl);
  else
    a.generateShortId(serverUrl);
  a.signWith(identity);
  a.save(success, failure, repo);
}
origin: com.eduworks/cass.competency

l.description = description;
l.name = name;
l.addOwner(owner.toPk());
origin: com.eduworks/cass.competency

r.description = description;
r.name = name;
r.addOwner(owner.toPk());
origin: com.eduworks/ebac.identity

/**
 * Create a signature for a specific identity, authorizing movement of data
 * outside of our control.
 *
 * @param {long}   duration Length of time in milliseconds to authorize
 *                 control.
 * @param {String} server Server that we are authorizing.
 * @param {EcPpk}  ppk Key of the identity to create a signature for
 * @return {Ebac Signature} Signature created
 * @memberOf EcIdentityManager
 * @method createSignature
 * @static
 */
public static EbacSignature createSignature(long duration, String server, EcPpk ppk) {
  EbacSignature s = new EbacSignature();
  s.owner = ppk.toPk().toPem();
  s.expiry = new Date().getTime() + duration;
  s.server = server;
  s.signature = EcRsaOaep.sign(ppk, s.toJson());
  return s;
}
origin: com.eduworks/cass.competency

a.target = target.shortId();
a.relationType = alignmentType;
a.addOwner(owner.toPk());
com.eduworks.ec.cryptoEcPpk

Most used methods

  • toPk
  • equals
  • fromPem
  • inArray
  • toPem

Popular in Java

  • Finding current android device location
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • JTextField (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now