os/security/cryptoservices/certificateandkeymgmt/pkixcertbase/pkixCertState.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/pkixcertbase/pkixCertState.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,149 @@
     1.4 +/*
     1.5 +* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "pkixcertstate.h"
    1.23 +
    1.24 +//********************************************************************************//
    1.25 +CPKIXValidationState* CPKIXValidationState::NewL(	const TTime aValidationTime, TInt aChainLength,
    1.26 +													const CArrayPtr<HBufC>* aInitialPolicies)
    1.27 +	{
    1.28 +	CPKIXValidationState* s = CPKIXValidationState::NewLC(aValidationTime, aChainLength, aInitialPolicies);
    1.29 +	CleanupStack::Pop();
    1.30 +	return s;
    1.31 +	}
    1.32 +
    1.33 +CPKIXValidationState* CPKIXValidationState::NewLC(	const TTime aValidationTime, TInt aChainLength,
    1.34 +													const CArrayPtr<HBufC>* aInitialPolicies)
    1.35 +	{
    1.36 +	CPKIXValidationState* s = new(ELeave) CPKIXValidationState(aValidationTime, aChainLength, aInitialPolicies);
    1.37 +	CleanupStack::PushL(s);
    1.38 +	s->ConstructL();
    1.39 +	return s;
    1.40 +	}
    1.41 +
    1.42 +CPKIXValidationState::~CPKIXValidationState()
    1.43 +	{
    1.44 +	if (iAuthorityConstrainedPolicies != NULL)
    1.45 +		{
    1.46 +		iAuthorityConstrainedPolicies->ResetAndDestroy();
    1.47 +		}
    1.48 +	delete iAuthorityConstrainedPolicies;
    1.49 +
    1.50 +	if (iUserPolicies != NULL)
    1.51 +		{
    1.52 +		iUserPolicies->ResetAndDestroy();
    1.53 +		}
    1.54 +	delete iUserPolicies;
    1.55 +
    1.56 +	if (iMappedPolicies != NULL)
    1.57 +		{
    1.58 +		iMappedPolicies->ResetAndDestroy();
    1.59 +		}
    1.60 +	delete iMappedPolicies;
    1.61 +
    1.62 +	if (iExcludedDNSubtrees != NULL)
    1.63 +		{
    1.64 +		iExcludedDNSubtrees->ResetAndDestroy();
    1.65 +		}
    1.66 +	delete iExcludedDNSubtrees;
    1.67 +
    1.68 +	if (iPermittedDNSubtrees != NULL)
    1.69 +		{
    1.70 +		iPermittedDNSubtrees->ResetAndDestroy();
    1.71 +		}
    1.72 +	delete iPermittedDNSubtrees;
    1.73 +
    1.74 +	if (iExcludedRFC822Subtrees != NULL)
    1.75 +		{
    1.76 +		iExcludedRFC822Subtrees->ResetAndDestroy();
    1.77 +		}
    1.78 +	delete iExcludedRFC822Subtrees;
    1.79 +
    1.80 +	if (iPermittedRFC822Subtrees != NULL)
    1.81 +		{
    1.82 +		iPermittedRFC822Subtrees->ResetAndDestroy();
    1.83 +		}
    1.84 +	delete iPermittedRFC822Subtrees;
    1.85 +
    1.86 +	if (iExcludedDNSNameSubtrees != NULL)
    1.87 +		{
    1.88 +		iExcludedDNSNameSubtrees->ResetAndDestroy();
    1.89 +		}
    1.90 +	delete iExcludedDNSNameSubtrees;
    1.91 +
    1.92 +	if (iPermittedDNSNameSubtrees != NULL)
    1.93 +		{
    1.94 +		iPermittedDNSNameSubtrees->ResetAndDestroy();
    1.95 +		}
    1.96 +	delete iPermittedDNSNameSubtrees;
    1.97 +
    1.98 +	if (iExcludedIPAddressSubtrees != NULL)
    1.99 +		{
   1.100 +		iExcludedIPAddressSubtrees->ResetAndDestroy();
   1.101 +		}
   1.102 +	delete iExcludedIPAddressSubtrees;
   1.103 +
   1.104 +	if (iPermittedIPAddressSubtrees != NULL)
   1.105 +		{
   1.106 +		iPermittedIPAddressSubtrees->ResetAndDestroy();
   1.107 +		}
   1.108 +	delete iPermittedIPAddressSubtrees;
   1.109 +	delete iCriticalExts;
   1.110 +	}
   1.111 +
   1.112 +CPKIXValidationState::CPKIXValidationState(	const TTime aValidationTime, TInt aChainLength, 
   1.113 +											const CArrayPtr<HBufC>* aInitialPolicies)
   1.114 +	:iValidationTime(aValidationTime), iPolicyMapping(aChainLength), iPolicyRequired(aChainLength),
   1.115 +	iMaxPathLength(aChainLength), iPos(aChainLength-1), iAnyAuthorityPolicy(ETrue)
   1.116 +	{
   1.117 +	// iUserConstrainedPolicies only set if we have any
   1.118 +	if (aInitialPolicies && aInitialPolicies->Count() != 0)
   1.119 +		{
   1.120 +		iUserConstrainedPolicies = aInitialPolicies;
   1.121 +		}
   1.122 +	}
   1.123 +
   1.124 +void CPKIXValidationState::ConstructL()
   1.125 +	{
   1.126 +	iAuthorityConstrainedPolicies = new(ELeave) CArrayPtrFlat<CX509CertPolicyInfo> (1);
   1.127 +	iUserPolicies = new(ELeave) CArrayPtrFlat<HBufC> (1);
   1.128 +	iMappedPolicies = new(ELeave) CArrayPtrFlat<CX509PolicyMapping> (1);
   1.129 +	iExcludedDNSubtrees = new(ELeave) CArrayPtrFlat<CX500DistinguishedName> (1);
   1.130 +	iPermittedDNSubtrees = new(ELeave) CArrayPtrFlat<CX500DistinguishedName> (1);
   1.131 +	iExcludedRFC822Subtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
   1.132 +	iPermittedRFC822Subtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
   1.133 +	iExcludedDNSNameSubtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
   1.134 +	iPermittedDNSNameSubtrees = new(ELeave) CArrayPtrFlat<CX509DomainName> (1);
   1.135 +	iExcludedIPAddressSubtrees = new(ELeave) CArrayPtrFlat<CX509IPSubnetMask> (1);
   1.136 +	iPermittedIPAddressSubtrees = new(ELeave) CArrayPtrFlat<CX509IPSubnetMask> (1);
   1.137 +	iCriticalExts = new(ELeave) CArrayPtrFlat<CX509CertExtension> (1);
   1.138 +	//copy the user-supplied policies into userpolicies
   1.139 +	if (iUserConstrainedPolicies)
   1.140 +		{
   1.141 +		TInt userPolicyCount = iUserConstrainedPolicies->Count();
   1.142 +		for (TInt i = 0; i < userPolicyCount; i++)
   1.143 +			{
   1.144 +			HBufC* policy = iUserConstrainedPolicies->At(i)->AllocL();
   1.145 +			CleanupStack::PushL(policy);
   1.146 +			iUserPolicies->AppendL(policy);
   1.147 +			CleanupStack::Pop();
   1.148 +			}
   1.149 +		}
   1.150 +	}
   1.151 +
   1.152 +