X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/libsecurity_manifest/lib/SecureDownload.cpp diff --git a/libsecurity_manifest/lib/SecureDownload.cpp b/libsecurity_manifest/lib/SecureDownload.cpp deleted file mode 100644 index 4d031f18..00000000 --- a/libsecurity_manifest/lib/SecureDownload.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#include -#include -#include -#include <../sec/Security/SecBase.h> -#include "Download.h" -#include "SecureDownload.h" - - -#define API_BEGIN \ - try { - -#define API_END \ - } \ - catch (const MacOSError &err) { return err.osStatus(); } \ - catch (const std::bad_alloc &) { return errSecAllocate; } \ - catch (...) { return errSecInternalComponent; } \ - return errSecSuccess; - -#define API_END_GENERIC_CATCH } catch (...) { return; } - -#define API_END_ERROR_CATCH(bad) } catch (...) { return bad; } - - - -OSStatus SecureDownloadCreateWithTicket (CFDataRef ticket, - SecureDownloadTrustSetupCallback setup, - void* setupContext, - SecureDownloadTrustEvaluateCallback evaluate, - void* evaluateContext, - SecureDownloadRef* downloadRef) -{ - API_BEGIN - - Download* sd = new Download (); - sd->Initialize (ticket, setup, setupContext, evaluate, evaluateContext); - Required (downloadRef) = sd; - - API_END -} - - - -OSStatus SecureDownloadCopyURLs (SecureDownloadRef downloadRef, CFArrayRef* urls) -{ - API_BEGIN - - Required (downloadRef); - Download* d = (Download*) downloadRef; - Required (urls) = d->CopyURLs (); - - API_END -} - - - -OSStatus SecureDownloadCopyName (SecureDownloadRef downloadRef, CFStringRef* name) -{ - API_BEGIN - - Required (downloadRef); - Download* d = (Download*) downloadRef; - Required (name) = d->CopyName (); - - API_END -} - - - -OSStatus SecureDownloadCopyCreationDate (SecureDownloadRef downloadRef, CFDateRef* date) -{ - API_BEGIN - - Required (downloadRef); - Download* d = (Download*) downloadRef; - Required (date) = d->CopyDate (); - - API_END -} - - - -OSStatus SecureDownloadGetDownloadSize (SecureDownloadRef downloadRef, SInt64* size) -{ - API_BEGIN - - Required (downloadRef); - Download* d = (Download*) downloadRef; - Required (size) = d->GetDownloadSize (); - - API_END -} - - - -OSStatus SecureDownloadUpdateWithData (SecureDownloadRef downloadRef, CFDataRef data) -{ - API_BEGIN - Required (downloadRef); - Required (data); - Download* d = (Download*) downloadRef; - d->UpdateWithData (data); - API_END -} - - - -OSStatus SecureDownloadFinished (SecureDownloadRef downloadRef) -{ - API_BEGIN - Required (downloadRef); - Download* d = (Download*) downloadRef; - d->Finalize (); - API_END -} - - - -OSStatus SecureDownloadRelease (SecureDownloadRef downloadRef) -{ - API_BEGIN - Required (downloadRef); - delete (Download*) downloadRef; - API_END -} - - - -OSStatus SecureDownloadCopyTicketLocation (CFURLRef url, CFURLRef *ticketLocation) -{ - API_BEGIN - Required (ticketLocation); - Required (url); - - // copy the resource specifier - CFStringRef resourceSpecifier = CFURLCopyResourceSpecifier (url); - if (resourceSpecifier == NULL) - { - CFError::throwMe (); - } - - // make a new URL from the resource specifier - *ticketLocation = CFURLCreateWithString (NULL, resourceSpecifier, NULL); - if (*ticketLocation == NULL) - { - CFError::throwMe (); - } - - // check the scheme to make sure that it isn't a file url - CFStringRef scheme = CFURLCopyScheme (*ticketLocation); - if (scheme != NULL) - { - CFComparisonResult equal = CFStringCompare (scheme, CFSTR("file"), kCFCompareCaseInsensitive); - CFRelease (scheme); - - if (equal == kCFCompareEqualTo) - { - CFRelease (*ticketLocation); - *ticketLocation = NULL; - MacOSError::throwMe (errSecureDownloadInvalidDownload); - } - } - - CFRelease (resourceSpecifier); - API_END -}