1/* 2 * Copyright (c) 2002-2004,2011-2012,2014 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 25// 26// Policies.h 27// 28#ifndef _SECURITY_POLICY_H_ 29#define _SECURITY_POLICY_H_ 30 31#include <Security/SecPolicy.h> 32#include <security_cdsa_utilities/cssmdata.h> 33#include <security_cdsa_client/tpclient.h> 34#include <security_utilities/seccfobject.h> 35#include "SecCFTypes.h" 36 37namespace Security 38{ 39 40namespace KeychainCore 41{ 42 43using namespace CssmClient; 44 45// 46// A Policy[Impl] represents a particular 47// CSSM "policy" managed by a particular TP. 48// 49class Policy : public SecCFObject 50{ 51 NOCOPY(Policy) 52public: 53 SECCFFUNCTIONS(Policy, SecPolicyRef, errSecInvalidItemRef, gTypes().Policy) 54 55 Policy(TP supportingTp, const CssmOid &policyOid); 56 57public: 58 virtual ~Policy() throw(); 59 60 TP &tp() { return mTp; } 61 const TP &tp() const { return mTp; } 62 const CssmOid &oid() const { return mOid; } 63 const CssmData &value() const { return mValue; } 64 CssmOwnedData &value() { return mValue; } 65 66 void setValue(const CssmData &value); 67 void setProperties(CFDictionaryRef properties); 68 CFDictionaryRef properties(); 69 70 bool operator < (const Policy& other) const; 71 bool operator == (const Policy& other) const; 72 73private: 74 TP mTp; // TP module for this Policy 75 CssmAutoData mOid; // OID for this policy 76 CssmAutoData mValue; // value for this policy 77 CssmAutoData mAuxValue; // variable-length value data for this policy 78 Mutex mMutex; 79}; 80 81} // end namespace KeychainCore 82 83} // end namespace Security 84 85#endif // !_SECURITY_POLICY_H_ 86