/**
  * finds a device pair in the DB. Returns <code>null</code> if no pair found.
  *
  * @param computerId
  * @return
  */
 public DevicePair findDevicePair(UUID computerId) {
   try {
     return pairingDB.findPairing(computerId);
   } catch (IOException e) {
     Log.e(TAG, "Couldn't find device pairing", e);
   } catch (NullPointerException e) {
     Log.e(TAG, "Couldn't find device pairing", e);
   }
   return null;
 }
 public DevicePair pairNewDevice(
     String computerIdString, String computerNameB64, String deviceIdString, String psk64)
     throws IOException, IllegalArgumentException {
   UUID computerId, deviceId;
   String computerName;
   byte[] psk;
   try {
     computerId = UUID.fromString(computerIdString);
     computerName = new String(Base64.decode(computerNameB64, Base64.URL_SAFE));
     deviceId = UUID.fromString(deviceIdString);
     psk = Base64.decode(psk64, Base64.URL_SAFE);
   } catch (IllegalArgumentException e) {
     throw new IllegalArgumentException("Incorrect format for pairing string", e);
   } catch (IOException e) {
     throw new IllegalArgumentException("Incorrect format for pairing string", e);
   }
   pairingDB.addPairing(computerId, computerName, deviceId, psk);
   return new DevicePair(computerId, computerName, deviceId, psk);
 }
 /**
  * Adds a new paired device to the database. String must be in the form: "Computer uuid Computer
  * name Device uuid PSK (base64)"
  *
  * @param pairingString The {@link String} to add
  * @throws IOException An error occurs during database IO
  * @throws IllegalArgumentException An error occurs decoding the data
  */
 public DevicePair pairNewDevice(String pairingString)
     throws IOException, IllegalArgumentException {
   StringTokenizer tkz = new StringTokenizer(pairingString, "\n");
   if (tkz.countTokens() < 4)
     throw new IllegalArgumentException("Incorrect format for pairing string");
   UUID computerId, deviceId;
   String computerName;
   byte[] psk;
   try {
     computerId = UUID.fromString(tkz.nextToken());
     computerName = tkz.nextToken();
     deviceId = UUID.fromString(tkz.nextToken());
     psk = Base64.decode(tkz.nextToken());
   } catch (IllegalArgumentException e) {
     throw new IllegalArgumentException("Incorrect format for pairing string", e);
   } catch (IOException e) {
     throw new IllegalArgumentException("Incorrect format for pairing string", e);
   }
   pairingDB.addPairing(computerId, computerName, deviceId, psk);
   return new DevicePair(computerId, computerName, deviceId, psk);
 }