/** * Saves a property list with the given object as root into a ASCII file. * * @param root The root object. * @param out The output file. * @throws IOException If an error occurs during the writing process. */ public static void saveAsASCII(NSDictionary root, File out) throws IOException { File parent = out.getParentFile(); if (!parent.exists() && !parent.mkdirs()) { throw new IOException("The output directory does not exist and could not be created."); } OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(out), "ASCII"); try { w.write(root.toASCIIPropertyList()); } finally { try { w.close(); } catch (IOException ex) { // ignore } } }
public static Auth from(HttpClient client, String id, String password) throws BadDataException, IOException { logger.trace("<< from() < id: {} password: {}", id, password); byte[] data = authClient.get(client, id, password); NSDictionary authentication = parse(data); logger.debug("-- from() > authentication: {}", authentication.toASCIIPropertyList()); NSDictionary appleAccountInfo = get(authentication, "appleAccountInfo"); String dsPrsID = string(appleAccountInfo, "dsPrsID"); NSDictionary tokens = get(authentication, "tokens"); String mmeAuthToken = string(tokens, "mmeAuthToken"); logger.debug("-- from() > dsPrsID: {}", dsPrsID); logger.debug("-- from() > mmeAuthToken: {}", mmeAuthToken); Auth auth = new Auth(dsPrsID, mmeAuthToken); logger.trace(">> from > auth: {}", auth); return auth; }
public static Account account(NSDictionary settings) { logger.debug("-- account() - settings: {}", settings.toASCIIPropertyList()); NSDictionary accountInfoDict = PListsLegacy.getAs(settings, "appleAccountInfo", NSDictionary.class); NSDictionary tokensDict = PListsLegacy.getAs(settings, "tokens", NSDictionary.class); NSDictionary mobileMeDict = PListsLegacy.getAs(settings, "com.apple.mobileme", NSDictionary.class); AccountInfo accountInfo = new AccountInfo(accountInfoDict); Tokens tokens = new Tokens(tokensDict); MobileMe mobileMe = new MobileMe(mobileMeDict); return new Account(mobileMe, accountInfo, tokens); } }
HttpUriRequest request = authenticationRequestFactory.apply(id, password); NSDictionary authentication = httpClient.execute(request, nsDictionaryResponseHandler); logger.debug("-- authenticate() - authentication: {}", authentication.toASCIIPropertyList());
logger.debug("-- from() > settings: {}", settings.toASCIIPropertyList());