2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
23 #include <Security/KCUtilities.h>
24 #include <Security/cssmerrno.h>
29 OSStatus
GetKeychainErrFromCSSMErr( OSStatus cssmError
)
31 if (CSSM_ERR_IS_CONVERTIBLE(cssmError
))
33 switch (CSSM_ERRCODE(cssmError
))
35 // CONVERTIBLE ERROR CODES.
36 case CSSM_ERRCODE_SERVICE_NOT_AVAILABLE
:
37 return errSecNotAvailable
;
38 case CSSM_ERRCODE_USER_CANCELED
:
39 return userCanceledErr
;
40 case CSSM_ERRCODE_OPERATION_AUTH_DENIED
:
41 return errSecAuthFailed
;
50 // DL SPECIFIC ERROR CODES
51 case CSSMERR_DL_RECORD_NOT_FOUND
:
52 return errSecItemNotFound
;
53 case CSSMERR_DL_INVALID_UNIQUE_INDEX_DATA
:
54 return errSecDuplicateItem
;
55 case CSSMERR_DL_DATABASE_CORRUPT
:
56 return errSecInvalidKeychain
;
57 case CSSMERR_DL_DATASTORE_DOESNOT_EXIST
:
58 return errSecNoSuchKeychain
;
59 case CSSMERR_DL_DATASTORE_ALREADY_EXISTS
:
60 return errSecDuplicateKeychain
;
61 case CSSMERR_DL_INVALID_FIELD_NAME
:
62 return errSecNoSuchAttr
;
69 StKCAttribute::StKCAttribute( SecKeychainAttribute
* inPtr
) :
74 StKCAttribute::~StKCAttribute( )
79 StKCItem::StKCItem( SecKeychainItemRef
* inItem
, OSStatus
* result
) :
85 StKCItem::~StKCItem( )
87 // if an error occured and the item is valid, release the item
89 if ( *fResult
!= noErr
&& *fItem
!= NULL
)
90 ::SecKeychainItemRelease(*fItem
); // %%% rjp was KCItemRelease(fitem);
93 } // end namespace Security