예제 #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);
 }
예제 #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();
  }
예제 #3
0
  public void setUserData(String key, Object data) {
    if (userData == null) {
      userData = new HashMap<String, Savable>();
    }

    if (data == null) {
      userData.remove(key);
    } else if (data instanceof Savable) {
      userData.put(key, (Savable) data);
    } else {
      userData.put(key, new UserData(UserData.getObjectType(data), data));
    }
  }