2 * Copyright (c) 2004,2008,2011 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
26 // SDDLSession.h - DL session for security server CSP/DL.
28 #ifndef _H_SDDLSESSION
29 #define _H_SDDLSESSION
31 #include <security_cdsa_plugin/DLsession.h>
32 #include <security_cdsa_utilities/u32handleobject.h>
33 #include <securityd_client/ssclient.h>
38 class SDDLSession
: public DLPluginSession
41 SDCSPDLSession
&mSDCSPDLSession
;
43 SDDLSession(CSSM_MODULE_HANDLE handle
,
45 const CSSM_VERSION
&version
,
47 CSSM_SERVICE_TYPE subserviceType
,
48 CSSM_ATTACH_FLAGS attachFlags
,
49 const CSSM_UPCALLS
&upcalls
,
50 DatabaseManager
&databaseManager
,
51 SDCSPDLSession
&ssCSPDLSession
);
54 SecurityServer::ClientSession
&clientSession()
55 { return mClientSession
; }
56 void GetDbNames(CSSM_NAME_LIST_PTR
&NameList
);
57 void FreeNameList(CSSM_NAME_LIST
&NameList
);
58 void DbDelete(const char *DbName
,
59 const CSSM_NET_ADDRESS
*DbLocation
,
60 const AccessCredentials
*AccessCred
);
61 void DbCreate(const char *DbName
,
62 const CSSM_NET_ADDRESS
*DbLocation
,
63 const CSSM_DBINFO
&DBInfo
,
64 CSSM_DB_ACCESS_TYPE AccessRequest
,
65 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
66 const void *OpenParameters
,
67 CSSM_DB_HANDLE
&DbHandle
);
68 void DbOpen(const char *DbName
,
69 const CSSM_NET_ADDRESS
*DbLocation
,
70 CSSM_DB_ACCESS_TYPE AccessRequest
,
71 const AccessCredentials
*AccessCred
,
72 const void *OpenParameters
,
73 CSSM_DB_HANDLE
&DbHandle
);
74 void DbClose(CSSM_DB_HANDLE DBHandle
);
75 void CreateRelation(CSSM_DB_HANDLE DBHandle
,
76 CSSM_DB_RECORDTYPE RelationID
,
77 const char *RelationName
,
78 uint32 NumberOfAttributes
,
79 const CSSM_DB_SCHEMA_ATTRIBUTE_INFO
*pAttributeInfo
,
80 uint32 NumberOfIndexes
,
81 const CSSM_DB_SCHEMA_INDEX_INFO
&pIndexInfo
);
82 void DestroyRelation(CSSM_DB_HANDLE DBHandle
,
83 CSSM_DB_RECORDTYPE RelationID
);
85 void Authenticate(CSSM_DB_HANDLE DBHandle
,
86 CSSM_DB_ACCESS_TYPE AccessRequest
,
87 const AccessCredentials
&AccessCred
);
88 void GetDbAcl(CSSM_DB_HANDLE DBHandle
,
89 const CSSM_STRING
*SelectionTag
,
90 uint32
&NumberOfAclInfos
,
91 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
92 void ChangeDbAcl(CSSM_DB_HANDLE DBHandle
,
93 const AccessCredentials
&AccessCred
,
94 const CSSM_ACL_EDIT
&AclEdit
);
95 void GetDbOwner(CSSM_DB_HANDLE DBHandle
,
96 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
97 void ChangeDbOwner(CSSM_DB_HANDLE DBHandle
,
98 const AccessCredentials
&AccessCred
,
99 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
100 void GetDbNameFromHandle(CSSM_DB_HANDLE DBHandle
,
102 void DataInsert(CSSM_DB_HANDLE DBHandle
,
103 CSSM_DB_RECORDTYPE RecordType
,
104 const CSSM_DB_RECORD_ATTRIBUTE_DATA
*Attributes
,
105 const CssmData
*Data
,
106 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
107 void DataDelete(CSSM_DB_HANDLE DBHandle
,
108 const CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
);
109 void DataModify(CSSM_DB_HANDLE DBHandle
,
110 CSSM_DB_RECORDTYPE RecordType
,
111 CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
,
112 const CSSM_DB_RECORD_ATTRIBUTE_DATA
*AttributesToBeModified
,
113 const CssmData
*DataToBeModified
,
114 CSSM_DB_MODIFY_MODE ModifyMode
);
115 CSSM_HANDLE
DataGetFirst(CSSM_DB_HANDLE DBHandle
,
116 const CssmQuery
*Query
,
117 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
119 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
120 bool DataGetNext(CSSM_DB_HANDLE DBHandle
,
121 CSSM_HANDLE ResultsHandle
,
122 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
124 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
125 void DataAbortQuery(CSSM_DB_HANDLE DBHandle
,
126 CSSM_HANDLE ResultsHandle
);
127 void DataGetFromUniqueRecordId(CSSM_DB_HANDLE DBHandle
,
128 const CSSM_DB_UNIQUE_RECORD
&UniqueRecord
,
129 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
131 void FreeUniqueRecord(CSSM_DB_HANDLE DBHandle
,
132 CSSM_DB_UNIQUE_RECORD
&UniqueRecord
);
133 void PassThrough(CSSM_DB_HANDLE DBHandle
,
134 uint32 PassThroughId
,
135 const void *InputParams
,
136 void **OutputParams
);
138 Allocator
&allocator() { return *static_cast<DatabaseSession
*>(this); }
141 void postGetRecord(SecurityServer::RecordHandle record
, U32HandleObject::Handle resultsHandle
,
143 CssmDbRecordAttributeData
*pAttributes
,
144 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes
,
145 CssmData
*inoutData
, SecurityServer::KeyHandle hKey
);
147 CSSM_DB_UNIQUE_RECORD_PTR
makeDbUniqueRecord(SecurityServer::RecordHandle recordHandle
);
148 CSSM_HANDLE
findDbUniqueRecord(const CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
149 void freeDbUniqueRecord(CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
151 SecurityServer::ClientSession mClientSession
;
152 //SecurityServer::AttachmentHandle mAttachment;
156 #endif // _H_SDDLSESSION