sl@0: /* sl@0: * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "pkixcertstate.h" sl@0: sl@0: //********************************************************************************// sl@0: CPKIXValidationState* CPKIXValidationState::NewL( const TTime aValidationTime, TInt aChainLength, sl@0: const CArrayPtr* aInitialPolicies) sl@0: { sl@0: CPKIXValidationState* s = CPKIXValidationState::NewLC(aValidationTime, aChainLength, aInitialPolicies); sl@0: CleanupStack::Pop(); sl@0: return s; sl@0: } sl@0: sl@0: CPKIXValidationState* CPKIXValidationState::NewLC( const TTime aValidationTime, TInt aChainLength, sl@0: const CArrayPtr* aInitialPolicies) sl@0: { sl@0: CPKIXValidationState* s = new(ELeave) CPKIXValidationState(aValidationTime, aChainLength, aInitialPolicies); sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(); sl@0: return s; sl@0: } sl@0: sl@0: CPKIXValidationState::~CPKIXValidationState() sl@0: { sl@0: if (iAuthorityConstrainedPolicies != NULL) sl@0: { sl@0: iAuthorityConstrainedPolicies->ResetAndDestroy(); sl@0: } sl@0: delete iAuthorityConstrainedPolicies; sl@0: sl@0: if (iUserPolicies != NULL) sl@0: { sl@0: iUserPolicies->ResetAndDestroy(); sl@0: } sl@0: delete iUserPolicies; sl@0: sl@0: if (iMappedPolicies != NULL) sl@0: { sl@0: iMappedPolicies->ResetAndDestroy(); sl@0: } sl@0: delete iMappedPolicies; sl@0: sl@0: if (iExcludedDNSubtrees != NULL) sl@0: { sl@0: iExcludedDNSubtrees->ResetAndDestroy(); sl@0: } sl@0: delete iExcludedDNSubtrees; sl@0: sl@0: if (iPermittedDNSubtrees != NULL) sl@0: { sl@0: iPermittedDNSubtrees->ResetAndDestroy(); sl@0: } sl@0: delete iPermittedDNSubtrees; sl@0: sl@0: if (iExcludedRFC822Subtrees != NULL) sl@0: { sl@0: iExcludedRFC822Subtrees->ResetAndDestroy(); sl@0: } sl@0: delete iExcludedRFC822Subtrees; sl@0: sl@0: if (iPermittedRFC822Subtrees != NULL) sl@0: { sl@0: iPermittedRFC822Subtrees->ResetAndDestroy(); sl@0: } sl@0: delete iPermittedRFC822Subtrees; sl@0: sl@0: if (iExcludedDNSNameSubtrees != NULL) sl@0: { sl@0: iExcludedDNSNameSubtrees->ResetAndDestroy(); sl@0: } sl@0: delete iExcludedDNSNameSubtrees; sl@0: sl@0: if (iPermittedDNSNameSubtrees != NULL) sl@0: { sl@0: iPermittedDNSNameSubtrees->ResetAndDestroy(); sl@0: } sl@0: delete iPermittedDNSNameSubtrees; sl@0: sl@0: if (iExcludedIPAddressSubtrees != NULL) sl@0: { sl@0: iExcludedIPAddressSubtrees->ResetAndDestroy(); sl@0: } sl@0: delete iExcludedIPAddressSubtrees; sl@0: sl@0: if (iPermittedIPAddressSubtrees != NULL) sl@0: { sl@0: iPermittedIPAddressSubtrees->ResetAndDestroy(); sl@0: } sl@0: delete iPermittedIPAddressSubtrees; sl@0: delete iCriticalExts; sl@0: } sl@0: sl@0: CPKIXValidationState::CPKIXValidationState( const TTime aValidationTime, TInt aChainLength, sl@0: const CArrayPtr* aInitialPolicies) sl@0: :iValidationTime(aValidationTime), iPolicyMapping(aChainLength), iPolicyRequired(aChainLength), sl@0: iMaxPathLength(aChainLength), iPos(aChainLength-1), iAnyAuthorityPolicy(ETrue) sl@0: { sl@0: // iUserConstrainedPolicies only set if we have any sl@0: if (aInitialPolicies && aInitialPolicies->Count() != 0) sl@0: { sl@0: iUserConstrainedPolicies = aInitialPolicies; sl@0: } sl@0: } sl@0: sl@0: void CPKIXValidationState::ConstructL() sl@0: { sl@0: iAuthorityConstrainedPolicies = new(ELeave) CArrayPtrFlat (1); sl@0: iUserPolicies = new(ELeave) CArrayPtrFlat (1); sl@0: iMappedPolicies = new(ELeave) CArrayPtrFlat (1); sl@0: iExcludedDNSubtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iPermittedDNSubtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iExcludedRFC822Subtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iPermittedRFC822Subtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iExcludedDNSNameSubtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iPermittedDNSNameSubtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iExcludedIPAddressSubtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iPermittedIPAddressSubtrees = new(ELeave) CArrayPtrFlat (1); sl@0: iCriticalExts = new(ELeave) CArrayPtrFlat (1); sl@0: //copy the user-supplied policies into userpolicies sl@0: if (iUserConstrainedPolicies) sl@0: { sl@0: TInt userPolicyCount = iUserConstrainedPolicies->Count(); sl@0: for (TInt i = 0; i < userPolicyCount; i++) sl@0: { sl@0: HBufC* policy = iUserConstrainedPolicies->At(i)->AllocL(); sl@0: CleanupStack::PushL(policy); sl@0: iUserPolicies->AppendL(policy); sl@0: CleanupStack::Pop(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: