Example #1
0
 @Override
 public UserPublicKey getPublicKey(String username) {
   byte[] dummy = null;
   UserData user = new UserData(username, dummy);
   RowData[] users = user.select();
   if (users == null || users.length != 1) return null;
   return new UserPublicKey(users[0].data);
 }
Example #2
0
  @Override
  public boolean addUsername(
      String username, byte[] encodedUserKey, byte[] signed, byte[] staticData) {
    UserPublicKey key = new UserPublicKey(encodedUserKey);

    if (!key.isValidSignature(
        signed, ArrayOps.concat(username.getBytes(), encodedUserKey, staticData))) return false;

    UserPublicKey existingKey = getPublicKey(username);
    if (existingKey != null) return false;
    String existingUsername = getUsername(key.getPublicKeys());
    if (existingUsername.length() > 0) return false;

    UserData user = new UserData(username, key.getPublicKeys());
    return user.insert();
  }