First public contribution.
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "pkixcertstate.h"
21 //********************************************************************************//
22 CPKIXValidationState* CPKIXValidationState::NewL( const TTime aValidationTime, TInt aChainLength,
23 const CArrayPtr<HBufC>* aInitialPolicies)
25 CPKIXValidationState* s = CPKIXValidationState::NewLC(aValidationTime, aChainLength, aInitialPolicies);
30 CPKIXValidationState* CPKIXValidationState::NewLC( const TTime aValidationTime, TInt aChainLength,
31 const CArrayPtr<HBufC>* aInitialPolicies)
33 CPKIXValidationState* s = new(ELeave) CPKIXValidationState(aValidationTime, aChainLength, aInitialPolicies);
34 CleanupStack::PushL(s);
39 CPKIXValidationState::~CPKIXValidationState()
41 if (iAuthorityConstrainedPolicies != NULL)
43 iAuthorityConstrainedPolicies->ResetAndDestroy();
45 delete iAuthorityConstrainedPolicies;
47 if (iUserPolicies != NULL)
49 iUserPolicies->ResetAndDestroy();
53 if (iMappedPolicies != NULL)
55 iMappedPolicies->ResetAndDestroy();
57 delete iMappedPolicies;
59 if (iExcludedDNSubtrees != NULL)
61 iExcludedDNSubtrees->ResetAndDestroy();
63 delete iExcludedDNSubtrees;
65 if (iPermittedDNSubtrees != NULL)
67 iPermittedDNSubtrees->ResetAndDestroy();
69 delete iPermittedDNSubtrees;
71 if (iExcludedRFC822Subtrees != NULL)
73 iExcludedRFC822Subtrees->ResetAndDestroy();
75 delete iExcludedRFC822Subtrees;
77 if (iPermittedRFC822Subtrees != NULL)
79 iPermittedRFC822Subtrees->ResetAndDestroy();
81 delete iPermittedRFC822Subtrees;
83 if (iExcludedDNSNameSubtrees != NULL)
85 iExcludedDNSNameSubtrees->ResetAndDestroy();
87 delete iExcludedDNSNameSubtrees;
89 if (iPermittedDNSNameSubtrees != NULL)
91 iPermittedDNSNameSubtrees->ResetAndDestroy();
93 delete iPermittedDNSNameSubtrees;
95 if (iExcludedIPAddressSubtrees != NULL)
97 iExcludedIPAddressSubtrees->ResetAndDestroy();
99 delete iExcludedIPAddressSubtrees;
101 if (iPermittedIPAddressSubtrees != NULL)
103 iPermittedIPAddressSubtrees->ResetAndDestroy();
105 delete iPermittedIPAddressSubtrees;
106 delete iCriticalExts;
109 CPKIXValidationState::CPKIXValidationState( const TTime aValidationTime, TInt aChainLength,
110 const CArrayPtr<HBufC>* aInitialPolicies)
111 :iValidationTime(aValidationTime), iPolicyMapping(aChainLength), iPolicyRequired(aChainLength),
112 iMaxPathLength(aChainLength), iPos(aChainLength-1), iAnyAuthorityPolicy(ETrue)
114 // iUserConstrainedPolicies only set if we have any
115 if (aInitialPolicies && aInitialPolicies->Count() != 0)
117 iUserConstrainedPolicies = aInitialPolicies;
121 void CPKIXValidationState::ConstructL()
123 iAuthorityConstrainedPolicies = new(ELeave) CArrayPtrFlat<CX509CertPolicyInfo> (1);
124 iUserPolicies = new(ELeave) CArrayPtrFlat<HBufC> (1);
125 iMappedPolicies = new(ELeave) CArrayPtrFlat<CX509PolicyMapping> (1);
126 iExcludedDNSubtrees = new(ELeave) CArrayPtrFlat<CX500DistinguishedName> (1);
127 iPermittedDNSubtrees = new(ELeave) CArrayPtrFlat<CX500DistinguishedName> (1);
128 iExcludedRFC822Subtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
129 iPermittedRFC822Subtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
130 iExcludedDNSNameSubtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
131 iPermittedDNSNameSubtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
132 iExcludedIPAddressSubtrees = new(ELeave) CArrayPtrFlat<CX509IPSubnetMask> (1);
133 iPermittedIPAddressSubtrees = new(ELeave) CArrayPtrFlat<CX509IPSubnetMask> (1);
134 iCriticalExts = new(ELeave) CArrayPtrFlat<CX509CertExtension> (1);
135 //copy the user-supplied policies into userpolicies
136 if (iUserConstrainedPolicies)
138 TInt userPolicyCount = iUserConstrainedPolicies->Count();
139 for (TInt i = 0; i < userPolicyCount; i++)
141 HBufC* policy = iUserConstrainedPolicies->At(i)->AllocL();
142 CleanupStack::PushL(policy);
143 iUserPolicies->AppendL(policy);