]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/lib/SecTask.h
Security-57337.20.44.tar.gz
[apple/security.git] / OSX / libsecurity_codesigning / lib / SecTask.h
1 /*
2 * Copyright (c) 2008-2009,2011 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _SECURITY_SECTASK_H_
25 #define _SECURITY_SECTASK_H_
26
27 #include <CoreFoundation/CoreFoundation.h>
28 #include <mach/message.h>
29 #include <Security/SecCode.h>
30
31 #if defined(__cplusplus)
32 extern "C" {
33 #endif
34
35 CF_ASSUME_NONNULL_BEGIN
36 CF_IMPLICIT_BRIDGING_ENABLED
37
38 /*!
39 @typedef SecTaskRef
40 @abstract CFType used for representing a task
41 */
42 typedef struct CF_BRIDGED_TYPE(id) __SecTask *SecTaskRef;
43
44 /*!
45 @function SecTaskGetTypeID
46 @abstract Returns the type ID for CF instances of SecTask.
47 @result A CFTypeID for SecTask
48 */
49 CFTypeID SecTaskGetTypeID(void);
50
51 /*!
52 @function SecTaskCreateWithAuditToken
53 @abstract Create a SecTask object for the task that sent the mach message
54 represented by the audit token.
55 @param token The audit token of a mach message
56 @result The newly created SecTask object or NULL on error. The caller must
57 CFRelease the returned object.
58 */
59 __nullable
60 SecTaskRef SecTaskCreateWithAuditToken(CFAllocatorRef __nullable allocator, audit_token_t token);
61
62 /*!
63 @function SecTaskCreateFromSelf
64 @abstract Create a SecTask object for the current task.
65 @result The newly created SecTask object or NULL on error. The caller must
66 CFRelease the returned object.
67 */
68 __nullable
69 SecTaskRef SecTaskCreateFromSelf(CFAllocatorRef __nullable allocator);
70
71 /*!
72 @function SecTaskCopyValueForEntitlement
73 @abstract Returns the value of a single entitlement for the represented
74 task.
75 @param task A previously created SecTask object
76 @param entitlement The name of the entitlement to be fetched
77 @param error On a NULL return, this may be contain a CFError describing
78 the problem. This argument may be NULL if the caller is not interested in
79 detailed errors.
80 @result The value of the specified entitlement for the process or NULL if
81 the entitlement value could not be retrieved. The type of the returned
82 value will depend on the entitlement specified. The caller must release
83 the returned object.
84 @discussion A NULL return may indicate an error, or it may indicate that
85 the entitlement is simply not present. In the latter case, no CFError is
86 returned.
87 */
88 __nullable
89 CFTypeRef SecTaskCopyValueForEntitlement(SecTaskRef task, CFStringRef entitlement, CFErrorRef *error);
90
91 /*!
92 @function SecTaskCopyValuesForEntitlements
93 @abstract Returns the values of multiple entitlements for the represented
94 task.
95 @param task A previously created SecTask object
96 @param entitlements An array of entitlement names to be fetched
97 @param error On a NULL return, this will contain a CFError describing
98 the problem. This argument may be NULL if the caller is not interested in
99 detailed errors. If a requested entitlement is not present for the
100 returned dictionary, the entitlement is not set on the task. The caller
101 must CFRelease the returned value
102 */
103 __nullable
104 CFDictionaryRef SecTaskCopyValuesForEntitlements(SecTaskRef task, CFArrayRef entitlements, CFErrorRef *error);
105
106 CF_IMPLICIT_BRIDGING_DISABLED
107 CF_ASSUME_NONNULL_END
108
109 #if defined(__cplusplus)
110 }
111 #endif
112
113 #endif /* !_SECURITY_SECTASK_H_ */