Package com.fathomdb.crypto

Examples of com.fathomdb.crypto.CryptoKey


    if (project == null) {
      throw new CliException("Project not found: " + projectKey.getKey());
    }

    SecretStore secretStore = new SecretStore(project.secretData);
    CryptoKey projectSecret = secretStore.getSecretFromUser(me);
    if (projectSecret == null) {
      String msg = "Cannot retrieve project secret.";
      msg += " Is " + me.key + " a member of " + project.getName() + "?";
      throw new CliException(msg);
    }
View Full Code Here


  public CryptoKey getSecretFromPassword(int userId, final String password) {
    SecretStoreDecoder visitor = new SecretStoreDecoder() {
      @Override
      public void visitPassword(byte[] salt, byte[] data) {
        CryptoKey secretKey = FathomdbCrypto.deriveKey(salt, password);
        setSecretKey(decryptSymetricKey(secretKey, data));
      }
    };
    try {
      read(encoded, visitor);
View Full Code Here

    public void writeUserPassword(byte[] plaintext, String password) throws IOException {
      dos.writeByte(USER_PASSWORD);

      byte[] salt = CryptoUtils.generateSecureRandom(16);
      CryptoKey derivedKey = FathomdbCrypto.deriveKey(salt, password);

      byte[] encrypted = FathomdbCrypto.encrypt(derivedKey, plaintext);
      // writeEncoded(dos, userId);
      writeArray(dos, salt);
      writeArray(dos, encrypted);
View Full Code Here

      } else {
        rs = db.selectServiceMetadata();
      }

      while (rs.next()) {
        CryptoKey secretKey = secretHelper.getSecret(rs.getBytes("secret"));

        if (secretKey instanceof AesCryptoKey) {
          log.warn("Legacy AES crypto key: findPrivateData[{}, {}, {}]", new Object[] { serviceType, project,
              metadataKey });
        }
View Full Code Here

    DbHelper db = new DbHelper(serviceType, project, metadataKey);

    // TODO: Handle updates

    try {
      CryptoKey secret = FathomdbCrypto.generateKey();

      byte[] plaintext = Utf8.getBytes(value);
      byte[] ciphertext = FathomdbCrypto.encrypt(secret, plaintext);

      // TODO: Encode this differently from items??
View Full Code Here

      String key = entity.key;
      int stateCode = entity.state;
      byte[] data = entity.data;

      SecretInfo secret = new SecretInfo(entity.secret);
      CryptoKey itemSecret = secretProvider.getItemSecret(secret);

      if (itemSecret == null) {
        throw new RepositoryException("Could not get secret to decrypt item");
      }
View Full Code Here

  @Override
  @JdbcTransaction
  public <T extends ItemBase> T createManagedItem(ProjectId project, T item) throws RepositoryException {
    DbHelper db = new DbHelper(item.getClass(), project);
    try {
      CryptoKey itemSecret = FathomdbCrypto.generateKey();

      byte[] data = serialize(item, itemSecret);
      byte[] secretData = itemSecrets.encodeItemSecret(itemSecret);

      int itemId = db.insertItem(item, data, secretData);
View Full Code Here

        throw new RepositoryException("Item not found");
      }

      byte[] secretData = rs.secret;

      CryptoKey itemSecret;

      if (secretData == null) {
        itemSecret = FathomdbCrypto.generateKey();
        secretData = itemSecrets.encodeItemSecret(itemSecret);
View Full Code Here

    return new SecretProvider() {
      @Override
      public CryptoKey getItemSecret(SecretInfo secret) {
        SecretStore secretStore = new SecretStore(secret.getEncoded());

        CryptoKey secretKey = secretStore.getSecretFromProject(project);
        return secretKey;
      }
    };
  }
View Full Code Here

    List<RoleId> roles = Lists.newArrayList();
    for (Role role : project.getRoles()) {
      roles.add(new RoleId(role.getName()));
    }

    CryptoKey projectSecret = FathomdbCrypto.deserializeKey(project.getSecret());
    return new PlatformlayerProjectAuthorization(user, name, projectSecret, roles, projectId);
  }
View Full Code Here

TOP

Related Classes of com.fathomdb.crypto.CryptoKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.