>From f054d95ab22154cfcb6d08abf5bca25903de30d4 Mon Sep 17 00:00:00 2001
From: Bryan Kearney <bkearney@redhat.com>
Date: Wed, 16 Jun 2010 15:25:20 -0400
Subject: [PATCH] Make the extensions be a set

---
 .../fedoraproject/candlepin/pki/PKIUtility.java    |    3 +-
 .../candlepin/pki/X509ExtensionWrapper.java        |   40 ++++-
 .../impl/DefaultEntitlementCertServiceAdapter.java |    6 +-
 .../service/impl/DefaultProductServiceAdapter.java |   63 +++---
 .../candlepin/util/X509ExtensionUtil.java          |  203 ++++++++++----------
 .../DefaultEntitlementCertServiceAdapterTest.java  |   13 +-
 6 files changed, 181 insertions(+), 147 deletions(-)

diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/pki/PKIUtility.java b/proxy/src/main/java/org/fedoraproject/candlepin/pki/PKIUtility.java
index fbb0efe..9e0312e 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/pki/PKIUtility.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/pki/PKIUtility.java
@@ -33,6 +33,7 @@ import java.security.spec.PKCS8EncodedKeySpec;
 import java.security.spec.X509EncodedKeySpec;
 import java.util.Date;
 import java.util.List;
+import java.util.Set;
 
 import org.bouncycastle.asn1.misc.MiscObjectIdentifiers;
 import org.bouncycastle.asn1.misc.NetscapeCertType;
@@ -64,7 +65,7 @@ public class PKIUtility {
  
     public X509Certificate createX509Certificate(
         String dn,
-        List<X509ExtensionWrapper> extensions, 
+        Set<X509ExtensionWrapper> extensions, 
         Date startDate,
         Date endDate,
         KeyPair clientKeyPair, 
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/pki/X509ExtensionWrapper.java b/proxy/src/main/java/org/fedoraproject/candlepin/pki/X509ExtensionWrapper.java
index 7cebb97..3cfad35 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/pki/X509ExtensionWrapper.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/pki/X509ExtensionWrapper.java
@@ -16,22 +16,21 @@ package org.fedoraproject.candlepin.pki;
 
 import org.bouncycastle.asn1.ASN1Encodable;
 
-
 /**
- * 
  * X509ExtensionWrapper
  */
 public class X509ExtensionWrapper {
     private String oid = null;
     private boolean critical;
     private ASN1Encodable asn1Encodable;
-    
-    public X509ExtensionWrapper(String oid, boolean critical, ASN1Encodable asn1Encodable) {
+
+    public X509ExtensionWrapper(String oid, boolean critical,
+        ASN1Encodable asn1Encodable) {
         this.oid = oid;
         this.critical = critical;
         this.asn1Encodable = asn1Encodable;
     }
-    
+
     public String getOid() {
         return oid;
     }
@@ -42,5 +41,34 @@ public class X509ExtensionWrapper {
 
     public ASN1Encodable getAsn1Encodable() {
         return asn1Encodable;
-    }   
+    }
+
+    @Override
+    public int hashCode() {
+        return oid.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        X509ExtensionWrapper other = (X509ExtensionWrapper) obj;
+        if (oid == null) {
+            if (other.oid != null) {
+                return false;
+            }
+        }
+        else if (!oid.equals(other.oid)) {
+            return false;
+        }
+        return true;
+    }
+
 }
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultEntitlementCertServiceAdapter.java b/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultEntitlementCertServiceAdapter.java
index 68f1501..c6a59be 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultEntitlementCertServiceAdapter.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultEntitlementCertServiceAdapter.java
@@ -20,8 +20,10 @@ import java.security.GeneralSecurityException;
 import java.security.KeyPair;
 import java.security.cert.X509Certificate;
 import java.util.Date;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.fedoraproject.candlepin.model.Consumer;
@@ -99,7 +101,7 @@ public class DefaultEntitlementCertServiceAdapter extends
         BigInteger serialNumber, KeyPair keyPair) 
         throws GeneralSecurityException, IOException {
         // oiduitl is busted at the moment, so do this manually
-        List<X509ExtensionWrapper> extensions = new LinkedList<X509ExtensionWrapper>();
+        Set<X509ExtensionWrapper> extensions = new LinkedHashSet<X509ExtensionWrapper>();
         
         addExtensionsForProduct(extensions, product);
         for (Product provided : sub.getProvidedProducts()) {
@@ -120,7 +122,7 @@ public class DefaultEntitlementCertServiceAdapter extends
      * @param extensions Certificate extensions.
      * @param product Product to recurse through.
      */
-    private void addExtensionsForProduct(List<X509ExtensionWrapper> extensions, 
+    private void addExtensionsForProduct(Set<X509ExtensionWrapper> extensions, 
         Product product) {
         
         // Add extensions for this product, unless it is a MKT product,
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultProductServiceAdapter.java b/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultProductServiceAdapter.java
index 64ea348..731b769 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultProductServiceAdapter.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/service/impl/DefaultProductServiceAdapter.java
@@ -14,7 +14,6 @@
  */
 package org.fedoraproject.candlepin.service.impl;
 
-import java.util.HashMap;
 import java.io.IOException;
 import java.math.BigInteger;
 import java.security.GeneralSecurityException;
@@ -22,7 +21,9 @@ import java.security.KeyPair;
 import java.security.cert.X509Certificate;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.fedoraproject.candlepin.model.Product;
@@ -40,22 +41,23 @@ import com.google.inject.Inject;
  * Default implementation of the ProductserviceAdapter.
  */
 public class DefaultProductServiceAdapter implements ProductServiceAdapter {
-    
-    private static Logger log = Logger.getLogger(DefaultProductServiceAdapter.class);
-    
+
+    private static Logger log = Logger
+        .getLogger(DefaultProductServiceAdapter.class);
+
     private ProductCurator prodCurator;
-    
-    // for product cert storage/generation - not sure if this should go in 
+
+    // for product cert storage/generation - not sure if this should go in
     // a separate service?
     private ProductCertificateCurator prodCertCurator;
     private PKIUtility pki;
     private X509ExtensionUtil extensionUtil;
 
     @Inject
-    public DefaultProductServiceAdapter(ProductCurator prodCurator, 
-        ProductCertificateCurator prodCertCurator, PKIUtility pki, 
+    public DefaultProductServiceAdapter(ProductCurator prodCurator,
+        ProductCertificateCurator prodCertCurator, PKIUtility pki,
         X509ExtensionUtil extensionUtil) {
-        
+
         this.prodCurator = prodCurator;
         this.prodCertCurator = prodCertCurator;
         this.pki = pki;
@@ -67,8 +69,7 @@ public class DefaultProductServiceAdapter implements ProductServiceAdapter {
         log.debug("called getProductById");
         return prodCurator.lookupById(id);
     }
-    
-    
+
     @Override
     public List<Product> getProducts() {
         return prodCurator.listAll();
@@ -86,7 +87,7 @@ public class DefaultProductServiceAdapter implements ProductServiceAdapter {
     @Override
     public HashMap<String, String> getProductNamesByProductId(String[] ids) {
         HashMap<String, String> names = new HashMap<String, String>();
-        for (String id : ids) { 
+        for (String id : ids) {
             Product p = getProductById(id);
             if (p != null) {
                 names.put(id, p.getName());
@@ -97,13 +98,13 @@ public class DefaultProductServiceAdapter implements ProductServiceAdapter {
         }
         return names;
     }
-    
+
     @Override
     public ProductCertificate getProductCertificate(Product product) {
         ProductCertificate cert = this.prodCertCurator.findForProduct(product);
-        
+
         if (cert == null) {
-            // TODO:  Do something better with these exceptions!
+            // TODO: Do something better with these exceptions!
             try {
                 cert = createForProduct(product);
                 this.prodCertCurator.create(cert);
@@ -115,33 +116,33 @@ public class DefaultProductServiceAdapter implements ProductServiceAdapter {
                 log.error("Error creating product certificate!", e);
             }
         }
-        
+
         return cert;
     }
-    
-    private ProductCertificate createForProduct(Product product) 
+
+    private ProductCertificate createForProduct(Product product)
         throws GeneralSecurityException, IOException {
-        
+
         KeyPair keyPair = pki.generateNewKeyPair();
-        
-        List<X509ExtensionWrapper> extensions = 
+
+        Set<X509ExtensionWrapper> extensions = 
             this.extensionUtil.productExtensions(product);
-        
-        BigInteger serial = BigInteger.valueOf(product.getId().hashCode()).abs();
-        
+
+        BigInteger serial = BigInteger.valueOf(product.getId().hashCode())
+            .abs();
+
         Calendar future = Calendar.getInstance();
         future.add(Calendar.YEAR, 10);
-       
-        X509Certificate x509Cert = this.pki.createX509Certificate(
-            "CN=" + product.getId(), 
-            extensions, new Date(), future.getTime(), 
-            keyPair, serial);
-        
+
+        X509Certificate x509Cert = this.pki.createX509Certificate("CN=" +
+            product.getId(), extensions, new Date(), future.getTime(), keyPair,
+            serial);
+
         ProductCertificate cert = new ProductCertificate();
         cert.setKeyAsBytes(pki.getPemEncoded(keyPair.getPrivate()));
         cert.setCertAsBytes(this.pki.getPemEncoded(x509Cert));
         cert.setProduct(product);
-        
+
         return cert;
     }
 
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/util/X509ExtensionUtil.java b/proxy/src/main/java/org/fedoraproject/candlepin/util/X509ExtensionUtil.java
index 95f200d..d5b4968 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/util/X509ExtensionUtil.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/util/X509ExtensionUtil.java
@@ -15,7 +15,7 @@
 package org.fedoraproject.candlepin.util;
 
 import java.util.Collections;
-import java.util.LinkedList;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -29,149 +29,150 @@ import org.fedoraproject.candlepin.model.ProductContent;
 import org.fedoraproject.candlepin.model.Subscription;
 import org.fedoraproject.candlepin.pki.X509ExtensionWrapper;
 
-
 /**
  * X509ExtensionUtil
  */
 public class X509ExtensionUtil {
 
-    
     private static Logger log = Logger.getLogger(X509ExtensionUtil.class);
-    
-    public List<X509ExtensionWrapper> consumerExtensions(Consumer consumer) {
-        List<X509ExtensionWrapper> toReturn = new LinkedList<X509ExtensionWrapper>();
-        
-        //1.3.6.1.4.1.2312.9.5.1 
+
+    public Set<X509ExtensionWrapper> consumerExtensions(Consumer consumer) {
+        Set<X509ExtensionWrapper> toReturn = new LinkedHashSet<X509ExtensionWrapper>();
+
+        // 1.3.6.1.4.1.2312.9.5.1
         // REDHAT_OID here seems wrong...
-        String consumerOid = OIDUtil.REDHAT_OID + "." + 
-                OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.SYSTEM_NAMESPACE_KEY);
-        toReturn.add(new X509ExtensionWrapper(consumerOid + "." + 
-                OIDUtil.SYSTEM_OIDS.get(OIDUtil.UUID_KEY),
-                false, new DERUTF8String(consumer.getUuid())));
-        
+        String consumerOid = OIDUtil.REDHAT_OID + "." +
+            OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.SYSTEM_NAMESPACE_KEY);
+        toReturn.add(new X509ExtensionWrapper(consumerOid + "." +
+            OIDUtil.SYSTEM_OIDS.get(OIDUtil.UUID_KEY), false,
+            new DERUTF8String(consumer.getUuid())));
+
         return toReturn;
     }
-    
-    public List<X509ExtensionWrapper> subscriptionExtensions(Subscription sub) {
-        List<X509ExtensionWrapper> toReturn = new LinkedList<X509ExtensionWrapper>();
+
+    public Set<X509ExtensionWrapper> subscriptionExtensions(Subscription sub) {
+        Set<X509ExtensionWrapper> toReturn = new LinkedHashSet<X509ExtensionWrapper>();
         // Subscription/order info
-        //need the sub product name, not id here
+        // need the sub product name, not id here
         // NOTE: order ~= subscriptio
-        //       entitlement == entitlement
+        // entitlement == entitlement
 
-        String subscriptionOid = OIDUtil.REDHAT_OID + "." + 
-                OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.ORDER_NAMESPACE_KEY);
+        String subscriptionOid = OIDUtil.REDHAT_OID + "." +
+            OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.ORDER_NAMESPACE_KEY);
         if (sub.getProduct().getId() != null) {
-            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." + 
-                    OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_NAME_KEY), 
-                    false, new DERUTF8String(sub.getProduct().getId())));
+            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
+                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_NAME_KEY), false,
+                new DERUTF8String(sub.getProduct().getId())));
         }
-        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." + 
-                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_NUMBER_KEY), 
-                false, new DERUTF8String(sub.getId().toString())));
-        //TODO: regnum? virtlimit/socketlimit?
-        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." + 
-                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_QUANTITY_KEY),
-                false, new DERUTF8String(sub.getQuantity().toString())));
-        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "."  + 
-                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_STARTDATE_KEY),
-                false, new DERUTF8String(sub.getStartDate().toString())));
-        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." + 
-                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_ENDDATE_KEY),
-                false, new DERUTF8String(sub.getEndDate().toString())));
+        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
+            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_NUMBER_KEY), false,
+            new DERUTF8String(sub.getId().toString())));
+        // TODO: regnum? virtlimit/socketlimit?
+        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
+            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_QUANTITY_KEY), false,
+            new DERUTF8String(sub.getQuantity().toString())));
+        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
+            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_STARTDATE_KEY), false,
+            new DERUTF8String(sub.getStartDate().toString())));
+        toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
+            OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_ENDDATE_KEY), false,
+            new DERUTF8String(sub.getEndDate().toString())));
         if (sub.getContractNumber() != null) {
-            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." + 
+            toReturn.add(new X509ExtensionWrapper(subscriptionOid + "." +
                 OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_CONTRACT_NUMBER_KEY),
                 false, new DERUTF8String(sub.getContractNumber())));
         }
-      
+
         return toReturn;
     }
-    
-    public List<X509ExtensionWrapper> entitlementExtensions(Entitlement entitlement) {
-        String entitlementOid = OIDUtil.REDHAT_OID + "." + 
+
+    public List<X509ExtensionWrapper> entitlementExtensions(
+        Entitlement entitlement) {
+        String entitlementOid = OIDUtil.REDHAT_OID + "." +
             OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.ORDER_NAMESPACE_KEY);
-        return Collections.singletonList(
-                   new X509ExtensionWrapper(entitlementOid + "." + 
-                       OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_QUANTITY_USED),
-                       false, new DERUTF8String(entitlement.getQuantity().toString())));
-        
+        return Collections.singletonList(new X509ExtensionWrapper(
+            entitlementOid + "." +
+                OIDUtil.ORDER_OIDS.get(OIDUtil.ORDER_QUANTITY_USED), false,
+            new DERUTF8String(entitlement.getQuantity().toString())));
+
     }
-        
-    public List<X509ExtensionWrapper> productExtensions(Product product) {
-        List<X509ExtensionWrapper> toReturn = new LinkedList<X509ExtensionWrapper>();
-        
-        String productCertOid = OIDUtil.REDHAT_OID + "." + 
+
+    public Set<X509ExtensionWrapper> productExtensions(Product product) {
+        Set<X509ExtensionWrapper> toReturn = new LinkedHashSet<X509ExtensionWrapper>();
+
+        String productCertOid = OIDUtil.REDHAT_OID + "." +
             OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.PRODUCT_CERT_NAMESPACE_KEY);
-        
+
         // XXX need to deal with non hash style IDs
-        String productOid = productCertOid  + "." + product.getId();
+        String productOid = productCertOid + "." + product.getId();
         // 10.10.10 is the product hash, arbitrary number atm
-        // replace ith approriate hash for product, we can maybe get away with faking this
+        // replace ith approriate hash for product, we can maybe get away with
+        // faking this
         toReturn.add(new X509ExtensionWrapper(productOid + "." +
-                    OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_NAME_KEY), 
-                    false, new DERUTF8String(product.getName())));
-       
+            OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_NAME_KEY), false,
+            new DERUTF8String(product.getName())));
+
         if (product.getAttribute("variant") != null) {
             toReturn.add(new X509ExtensionWrapper(productOid + "." +
-                OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_DESC_KEY),
-                false, new DERUTF8String(product.getAttributeValue("variant"))));
+                OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_DESC_KEY), false,
+                new DERUTF8String(product.getAttributeValue("variant"))));
         }
         if (product.getAttribute("arch") != null) {
-            toReturn.add(new X509ExtensionWrapper(productOid + "." + 
-                OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_ARCH_KEY),
-                false, new DERUTF8String(product.getAttributeValue("arch"))));
+            toReturn.add(new X509ExtensionWrapper(productOid + "." +
+                OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_ARCH_KEY), false,
+                new DERUTF8String(product.getAttributeValue("arch"))));
         }
         if (product.getAttribute("version") != null) {
-            toReturn.add(new X509ExtensionWrapper(productOid + "." + 
-                OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_VERSION_KEY),
-                false, new DERUTF8String(product.getAttributeValue("version"))));
+            toReturn.add(new X509ExtensionWrapper(productOid + "." +
+                OIDUtil.ORDER_PRODUCT_OIDS.get(OIDUtil.OP_VERSION_KEY), false,
+                new DERUTF8String(product.getAttributeValue("version"))));
         }
         return toReturn;
     }
 
-    public List<X509ExtensionWrapper> contentExtensions(Product product) {
-        List<X509ExtensionWrapper> toReturn = new LinkedList<X509ExtensionWrapper>();
+    public Set<X509ExtensionWrapper> contentExtensions(Product product) {
+        Set<X509ExtensionWrapper> toReturn = new LinkedHashSet<X509ExtensionWrapper>();
         Set<ProductContent> productContent = product.getProductContent();
         Set<Content> content = product.getContent();
         Set<Content> enabledContent = product.getEnabledContent();
-        
-//        for (Content con : content) {
+
+        // for (Content con : content) {
         for (ProductContent pc : productContent) {
-            String contentOid = OIDUtil.REDHAT_OID + "." +  
-                   OIDUtil.TOPLEVEL_NAMESPACES.get(OIDUtil.CHANNEL_FAMILY_NAMESPACE_KEY) + 
-                   "." + pc.getContent().getId().toString() + "." + 
-                   OIDUtil.CF_REPO_TYPE.get(pc.getContent().getType());
-            toReturn.add(new X509ExtensionWrapper(contentOid, 
-                    false, new DERUTF8String(pc.getContent().getType())));
-            toReturn.add(new X509ExtensionWrapper(contentOid + "." + 
-                    OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_NAME_KEY),
-                    false, new DERUTF8String(pc.getContent().getName())));
-            toReturn.add(new X509ExtensionWrapper(contentOid + "." + 
-                   OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_LABEL_KEY),
-                   false, new DERUTF8String(pc.getContent().getLabel())));
-            toReturn.add(new X509ExtensionWrapper(contentOid + "." + 
-                    OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_VENDOR_ID_KEY) ,
-                    false, new DERUTF8String(pc.getContent().getVendor())));
-            toReturn.add(new X509ExtensionWrapper(contentOid + "." + 
-                    OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_DOWNLOAD_URL_KEY) ,
-                    false, new DERUTF8String(pc.getContent().getContentUrl()))); 
-            toReturn.add(new X509ExtensionWrapper(contentOid + "." + 
-                    OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_GPG_URL_KEY),
-                    false, new DERUTF8String(pc.getContent().getGpgUrl())));
+            String contentOid = OIDUtil.REDHAT_OID +
+                "." +
+                OIDUtil.TOPLEVEL_NAMESPACES
+                    .get(OIDUtil.CHANNEL_FAMILY_NAMESPACE_KEY) + "." +
+                pc.getContent().getId().toString() + "." +
+                OIDUtil.CF_REPO_TYPE.get(pc.getContent().getType());
+            toReturn.add(new X509ExtensionWrapper(contentOid, false,
+                new DERUTF8String(pc.getContent().getType())));
+            toReturn.add(new X509ExtensionWrapper(contentOid + "." +
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_NAME_KEY), false,
+                new DERUTF8String(pc.getContent().getName())));
+            toReturn.add(new X509ExtensionWrapper(contentOid + "." +
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_LABEL_KEY), false,
+                new DERUTF8String(pc.getContent().getLabel())));
             toReturn.add(new X509ExtensionWrapper(contentOid + "." +
-                    OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_FLEX_QUANTITY_KEY),
-                    false, new DERUTF8String(pc.getFlexEntitlement().toString())));
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_VENDOR_ID_KEY),
+                false, new DERUTF8String(pc.getContent().getVendor())));
+            toReturn.add(new X509ExtensionWrapper(contentOid + "." +
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_DOWNLOAD_URL_KEY),
+                false, new DERUTF8String(pc.getContent().getContentUrl())));
+            toReturn.add(new X509ExtensionWrapper(contentOid + "." +
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_GPG_URL_KEY), false,
+                new DERUTF8String(pc.getContent().getGpgUrl())));
+            toReturn.add(new X509ExtensionWrapper(contentOid + "." +
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_FLEX_QUANTITY_KEY),
+                false, new DERUTF8String(pc.getFlexEntitlement().toString())));
             toReturn.add(new X509ExtensionWrapper(contentOid + "." +
                 OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_PHYS_QUANTITY_KEY),
-                false, new DERUTF8String(pc.getPhysicalEntitlement().toString())));
-                    
-            toReturn.add(new X509ExtensionWrapper(contentOid + "." + 
-                    OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_ENABLED),
-                    false,  new DERUTF8String(
-                        (pc.getEnabled()) ? "0" : "1")));
-            
-            
+                false,
+                new DERUTF8String(pc.getPhysicalEntitlement().toString())));
+
+            toReturn.add(new X509ExtensionWrapper(contentOid + "." +
+                OIDUtil.CHANNEL_FAMILY_OIDS.get(OIDUtil.CF_ENABLED), false,
+                new DERUTF8String((pc.getEnabled()) ? "0" : "1")));
+
         }
         return toReturn;
     }
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/service/impl/test/DefaultEntitlementCertServiceAdapterTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/service/impl/test/DefaultEntitlementCertServiceAdapterTest.java
index 710e68d..15f22d2 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/service/impl/test/DefaultEntitlementCertServiceAdapterTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/service/impl/test/DefaultEntitlementCertServiceAdapterTest.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.bouncycastle.asn1.DERUTF8String;
 import org.fedoraproject.candlepin.model.Consumer;
@@ -99,7 +100,7 @@ public class DefaultEntitlementCertServiceAdapterTest {
     @Test
     public void testContentExtentionCreation() {
         // AAAH!  This should be pulled out to its own test class!
-        List<X509ExtensionWrapper> content = extensionUtil.contentExtensions(product);
+        Set<X509ExtensionWrapper> content = extensionUtil.contentExtensions(product);
         assertTrue(isEncodedContentValid(content));
     }
 
@@ -129,7 +130,7 @@ public class DefaultEntitlementCertServiceAdapterTest {
             any(Date.class), any(Date.class), any(KeyPair.class), any(BigInteger.class));
     }
     
-    private boolean isEncodedContentValid(List<X509ExtensionWrapper> content) {
+    private boolean isEncodedContentValid(Set<X509ExtensionWrapper> content) {
         Map<String, X509ExtensionWrapper> encodedContent 
             = new HashMap<String, X509ExtensionWrapper>();
 
@@ -190,22 +191,22 @@ public class DefaultEntitlementCertServiceAdapterTest {
     }
     
     class ListContainsContentExtensions 
-        extends ArgumentMatcher<List<X509ExtensionWrapper>> {
+        extends ArgumentMatcher<Set<X509ExtensionWrapper>> {
         
         public boolean matches(Object list) {
-            return isEncodedContentValid((List) list);
+            return isEncodedContentValid((Set) list);
         }
     }
     
     class ListContainsEntitlementExtensions 
-        extends ArgumentMatcher<List<X509ExtensionWrapper>> {
+        extends ArgumentMatcher<Set<X509ExtensionWrapper>> {
         
         public boolean matches(Object list) {
             Map<String, X509ExtensionWrapper> encodedContent 
                 = new HashMap<String, X509ExtensionWrapper>();
 
         
-            for (X509ExtensionWrapper ext : (List<X509ExtensionWrapper>) list) {
+            for (X509ExtensionWrapper ext : (Set<X509ExtensionWrapper>) list) {
                 encodedContent.put(ext.getOid(), ext);
             }
             
-- 
1.6.6.1

