3.1.1.11.2.15 CollapseMultiValuedClaims

 procedure CollapseMultiValuedClaims (
     cTAClaims : set of Claim,
     pOutputClaims : ADDRESS OF CLAIMS_ARRAY) : ULONG

This is a helper procedure that converts a given set of Claim structures (defined in [MS-CTA] section 2.1.2) into a CLAIMS_ARRAY structure. This procedure also aggregates more than one single-valued claim of the same type, removes any duplicates from each aggregate, and collapses the remaining single-valued claims in that aggregate into one multi-valued claim.

cTAClaims: The input set of Claim structures.

pOutputClaims: The address of the output CLAIMS_ARRAY structure.

Return Values: This procedure returns zero upon success or an error otherwise.

Logical Processing:

 tempClaim : CLAIM_ENTRY;
 valueType : USHORT;
  
 tempClaim := null;
 valueType := 0;
  
 for each claim1 in cTAClaims
         if (claim1.VALUE_TYPE = "int64")
             valueType := CLAIM_TYPE_INT64;
         else if (claim1.VALUE_TYPE = "uint64")
             valueType := CLAIM_TYPE_UINT64;
         else if (claim1.VALUE_TYPE = "boolean")
             valueType := CLAIM_TYPE_BOOLEAN;
         else if (claim1.VALUE_TYPE = "string")
             valueType := CLAIM_TYPE_STRING;
         endif
  
        tempClaim := (Id = claim1.TYPE, Type = valueType,
            ValueCount = count of claim1.VALUE, Values = claim1.VALUE);
        for each claim2 in (cTAClaims – claim1)
          if (claim1.TYPE = claim2.TYPE and
              claim1.VALUE_TYPE = claim2.VALUE_TYPE and
              (claim2.VALUE_TYPE NOT in tempClaim.Values))
              tempClaim.Values := tempClaim.Values + Claim2.VALUE;
           endif
        endfor
     pOutputClaims^.claims := pOutputClaims^.claims + tempClaim;
 endfor
  
 return 0;