public int compareTo(Object o) { if (o instanceof NSString) { return this.getContent().compareTo(((NSString) o).getContent()); } else if (o instanceof String) { return this.getContent().compareTo((String) o); } else { return -1; } }
/** * Checks whether a given value is contained in this dictionary. * * @param val The value that will be searched for. * @return Whether the key is contained in this dictionary. */ public boolean containsValue(String val) { for (NSObject o : this.dict.values()) { if (o.getClass().equals(NSString.class)) { NSString str = (NSString) o; if (str.getContent().equals(val)) return true; } } return false; }
public AccountInfo(NSDictionary accountInfo) { appleId = PListsLegacy.getAs(accountInfo, "appleId", NSString.class).getContent(); aDsID = PListsLegacy.getAs(accountInfo, "aDsID", NSString.class).getContent(); dsPrsID = PListsLegacy.getAs(accountInfo, "dsPrsID", NSString.class).getContent(); lastName = PListsLegacy.getAs(accountInfo, "lastName", NSString.class).getContent(); firstName = PListsLegacy.getAs(accountInfo, "firstName", NSString.class).getContent(); }
/** * Prepends a string to this string. * * @param s The string to prepend. */ public void prepend(NSString s) { this.prepend(s.getContent()); }
static Map<String, String> dictionary(NSDictionary dictionary) { return dictionary.entrySet() .stream() .filter(entry -> entry.getValue() instanceof NSString) .collect(Collectors.toMap( Map.Entry::getKey, entry -> ((NSString) entry.getValue()).getContent())); }
/** * Appends a string to this string. * * @param s The string to append. */ public void append(NSString s) { this.append(s.getContent()); }
static int remainingAttempts(NSDictionary record) { String remainingAttempts = PListsLegacy.getAs(record, "remainingAttempts", NSString.class).getContent(); return Integer.parseInt(remainingAttempts); }
Optional<String> backupPropertyVersion() { return backupProperty("Lockdown", NSDictionary.class) .flatMap(u -> NSDictionaries.as(u, "ProductVersion", NSString.class)) .map(u -> u.getContent()); }
static Map<Token, String> tokens(NSDictionary dictionary) { return dictionary.entrySet() .stream() .filter(e -> Token.token(e.getKey()).isPresent()) .filter(e -> e.getValue() instanceof NSString) .collect(Collectors.toMap( e -> Token.token(e.getKey()).get(), e -> ((NSString) e.getValue()).getContent())); }
private static Object deserializeSimple(NSObject payload, Class<?> clazz) { if (payload instanceof NSNumber) { return deserializeNumber((NSNumber) payload, clazz); } if (payload instanceof NSDate) { return deserializeDate((NSDate) payload, clazz); } if (payload instanceof NSString) { return ((NSString) payload).getContent(); } throw new IllegalArgumentException("Cannot map " + payload.getClass().getSimpleName() + " to " + clazz.getSimpleName()); }
static byte[] escrowedKeys(NSDictionary record, ServiceKeySet backupBagPassword) { String metadataBase64 = PListsLegacy.getAs(record, "metadata", NSString.class).getContent(); byte[] metadata = Base64.getDecoder().decode(metadataBase64); byte[] data = ProtectedRecord.unlockData(metadata, backupBagPassword::key); logger.debug("-- escrowedKeys() - decrypted metadata: {}", Hex.toHexString(data)); return data; } }
public static Optional<InflatableData> from(byte[] bs) { InflatableData data; try { NSDictionary parse = (NSDictionary) PropertyListParser.parse(bs); byte[] escrowedKeys = ((NSData) parse.get("escrowedKeys")).bytes(); UUID deviceUuid = UUID.fromString(((NSString) parse.get("deviceUuid")).getContent()); String deviceHardWareId = ((NSString) parse.get("deviceHardWareId")).getContent(); data = new InflatableData(escrowedKeys, deviceUuid, deviceHardWareId); } catch (ClassCastException | IllegalArgumentException | IOException | NullPointerException | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException ex) { logger.warn("-- from() - exception: ", ex); data = null; } return Optional.ofNullable(data); }
static NSDictionary decrypt(SRPClient srpClient, NSDictionary recoverResponse) { String respBlob = PListsLegacy.getAs(recoverResponse, "respBlob", NSString.class).getContent(); BlobA6 blob = blobA6(respBlob); byte[] key = sessionKey(srpClient, blob); return decrypt(blob, key); }
static NSDictionary recover( HttpClient httpClient, EscrowProxyRequestFactory requests, SRPClient srpClient, NSDictionary srpInitResponse) throws IOException { validateSrpInitResponse(srpInitResponse); String dsid = PListsLegacy.getAs(srpInitResponse, "dsid", NSString.class).getContent(); String respBlob = PListsLegacy.getAs(srpInitResponse, "respBlob", NSString.class).getContent(); BlobA4 blob = blobA4(respBlob); byte[] m1 = calculateM1(srpClient, blob, dsid); byte[] uid = blob.uid(); byte[] tag = blob.tag(); return recover(httpClient, requests, uid, tag, m1); }
String mmeAuthToken = PListsLegacy.getAs(tokens, "mmeAuthToken", NSString.class).getContent();
return this.deserializeNumber(); } else if(this instanceof NSString) { return ((NSString)this).getContent(); } else if(this instanceof NSData) { return ((NSData)this).bytes();