os/security/cryptoservices/certificateandkeymgmt/pkixcertbase/pkixCertState.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include "pkixcertstate.h"
    20 
    21 //********************************************************************************//
    22 CPKIXValidationState* CPKIXValidationState::NewL(	const TTime aValidationTime, TInt aChainLength,
    23 													const CArrayPtr<HBufC>* aInitialPolicies)
    24 	{
    25 	CPKIXValidationState* s = CPKIXValidationState::NewLC(aValidationTime, aChainLength, aInitialPolicies);
    26 	CleanupStack::Pop();
    27 	return s;
    28 	}
    29 
    30 CPKIXValidationState* CPKIXValidationState::NewLC(	const TTime aValidationTime, TInt aChainLength,
    31 													const CArrayPtr<HBufC>* aInitialPolicies)
    32 	{
    33 	CPKIXValidationState* s = new(ELeave) CPKIXValidationState(aValidationTime, aChainLength, aInitialPolicies);
    34 	CleanupStack::PushL(s);
    35 	s->ConstructL();
    36 	return s;
    37 	}
    38 
    39 CPKIXValidationState::~CPKIXValidationState()
    40 	{
    41 	if (iAuthorityConstrainedPolicies != NULL)
    42 		{
    43 		iAuthorityConstrainedPolicies->ResetAndDestroy();
    44 		}
    45 	delete iAuthorityConstrainedPolicies;
    46 
    47 	if (iUserPolicies != NULL)
    48 		{
    49 		iUserPolicies->ResetAndDestroy();
    50 		}
    51 	delete iUserPolicies;
    52 
    53 	if (iMappedPolicies != NULL)
    54 		{
    55 		iMappedPolicies->ResetAndDestroy();
    56 		}
    57 	delete iMappedPolicies;
    58 
    59 	if (iExcludedDNSubtrees != NULL)
    60 		{
    61 		iExcludedDNSubtrees->ResetAndDestroy();
    62 		}
    63 	delete iExcludedDNSubtrees;
    64 
    65 	if (iPermittedDNSubtrees != NULL)
    66 		{
    67 		iPermittedDNSubtrees->ResetAndDestroy();
    68 		}
    69 	delete iPermittedDNSubtrees;
    70 
    71 	if (iExcludedRFC822Subtrees != NULL)
    72 		{
    73 		iExcludedRFC822Subtrees->ResetAndDestroy();
    74 		}
    75 	delete iExcludedRFC822Subtrees;
    76 
    77 	if (iPermittedRFC822Subtrees != NULL)
    78 		{
    79 		iPermittedRFC822Subtrees->ResetAndDestroy();
    80 		}
    81 	delete iPermittedRFC822Subtrees;
    82 
    83 	if (iExcludedDNSNameSubtrees != NULL)
    84 		{
    85 		iExcludedDNSNameSubtrees->ResetAndDestroy();
    86 		}
    87 	delete iExcludedDNSNameSubtrees;
    88 
    89 	if (iPermittedDNSNameSubtrees != NULL)
    90 		{
    91 		iPermittedDNSNameSubtrees->ResetAndDestroy();
    92 		}
    93 	delete iPermittedDNSNameSubtrees;
    94 
    95 	if (iExcludedIPAddressSubtrees != NULL)
    96 		{
    97 		iExcludedIPAddressSubtrees->ResetAndDestroy();
    98 		}
    99 	delete iExcludedIPAddressSubtrees;
   100 
   101 	if (iPermittedIPAddressSubtrees != NULL)
   102 		{
   103 		iPermittedIPAddressSubtrees->ResetAndDestroy();
   104 		}
   105 	delete iPermittedIPAddressSubtrees;
   106 	delete iCriticalExts;
   107 	}
   108 
   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)
   113 	{
   114 	// iUserConstrainedPolicies only set if we have any
   115 	if (aInitialPolicies && aInitialPolicies->Count() != 0)
   116 		{
   117 		iUserConstrainedPolicies = aInitialPolicies;
   118 		}
   119 	}
   120 
   121 void CPKIXValidationState::ConstructL()
   122 	{
   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)
   137 		{
   138 		TInt userPolicyCount = iUserConstrainedPolicies->Count();
   139 		for (TInt i = 0; i < userPolicyCount; i++)
   140 			{
   141 			HBufC* policy = iUserConstrainedPolicies->At(i)->AllocL();
   142 			CleanupStack::PushL(policy);
   143 			iUserPolicies->AppendL(policy);
   144 			CleanupStack::Pop();
   145 			}
   146 		}
   147 	}
   148 
   149