geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r291352 [5/10] - in /geronimo/trunk: applications/console-core/ applications/console-ear/src/plan/ applications/console-standard/src/java/org/apache/geronimo/console/util/ applications/console-standard/src/webapp/WEB-INF/ assemblies/j2ee-se...
Date Sun, 25 Sep 2005 00:32:39 GMT
Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertPolicyId.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertPolicyId.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertPolicyId.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertPolicyId.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.DERObjectIdentifier;
+
+
+/**
+ * CertPolicyId, used in the CertificatePolicies and PolicyMappings
+ * X509V3 Extensions.
+ *
+ * <pre>
+ *     CertPolicyId ::= OBJECT IDENTIFIER
+ * </pre>
+ */
+public class CertPolicyId extends DERObjectIdentifier
+{
+   public CertPolicyId (String id)
+   {
+     super(id);
+   }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificateList.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificateList.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificateList.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificateList.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,136 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERBitString;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+/**
+ * PKIX RFC-2459
+ *
+ * The X.509 v2 CRL syntax is as follows.  For signature calculation,
+ * the data that is to be signed is ASN.1 DER encoded.
+ *
+ * <pre>
+ * CertificateList  ::=  SEQUENCE  {
+ *      tbsCertList          TBSCertList,
+ *      signatureAlgorithm   AlgorithmIdentifier,
+ *      signatureValue       BIT STRING  }
+ * </pre>
+ */
+public class CertificateList
+    extends ASN1Encodable
+{
+    TBSCertList            tbsCertList;
+    AlgorithmIdentifier    sigAlgId;
+    DERBitString           sig;
+
+    public static CertificateList getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public static CertificateList getInstance(
+        Object  obj)
+    {
+        if (obj instanceof CertificateList)
+        {
+            return (CertificateList)obj;
+        }
+        else if (obj instanceof ASN1Sequence)
+        {
+            return new CertificateList((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
+
+    public CertificateList(
+        ASN1Sequence seq)
+    {
+        if (seq.size() == 3)
+        {
+            tbsCertList = TBSCertList.getInstance(seq.getObjectAt(0));
+            sigAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
+            sig = (DERBitString)seq.getObjectAt(2);
+        }
+        else
+        {
+            throw new IllegalArgumentException("sequence wrong size for CertificateList");
+        }
+    }
+
+    public TBSCertList getTBSCertList()
+    {
+        return tbsCertList;
+    }
+
+    public TBSCertList.CRLEntry[] getRevokedCertificates()
+    {
+        return tbsCertList.getRevokedCertificates();
+    }
+
+    public AlgorithmIdentifier getSignatureAlgorithm()
+    {
+        return sigAlgId;
+    }
+
+    public DERBitString getSignature()
+    {
+        return sig;
+    }
+
+    public int getVersion()
+    {
+        return tbsCertList.getVersion();
+    }
+
+    public X509Name getIssuer()
+    {
+        return tbsCertList.getIssuer();
+    }
+
+    public Time getThisUpdate()
+    {
+        return tbsCertList.getThisUpdate();
+    }
+
+    public Time getNextUpdate()
+    {
+        return tbsCertList.getNextUpdate();
+    }
+
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector v = new ASN1EncodableVector();
+
+        v.add(tbsCertList);
+        v.add(sigAlgId);
+        v.add(sig);
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificatePolicies.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificatePolicies.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificatePolicies.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/CertificatePolicies.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,160 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERObjectIdentifier;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+public class CertificatePolicies
+    extends ASN1Encodable
+{
+    static final DERObjectIdentifier anyPolicy = new DERObjectIdentifier("2.5.29.32.0");
+
+    Vector policies = new Vector();
+
+/**
+ * @deprecated use an ASN1Sequence of PolicyInformation
+ */
+    public static CertificatePolicies getInstance(
+        ASN1TaggedObject obj,
+        boolean explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+/**
+ * @deprecated use an ASN1Sequence of PolicyInformation
+ */
+    public static CertificatePolicies getInstance(
+        Object  obj)
+    {
+        if (obj instanceof CertificatePolicies)
+        {
+            return (CertificatePolicies)obj;
+        }
+        else if (obj instanceof ASN1Sequence)
+        {
+            return new CertificatePolicies((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
+
+/**
+ * @deprecated use an ASN1Sequence of PolicyInformation
+ */
+    public CertificatePolicies(
+        ASN1Sequence   seq)
+    {
+        Enumeration e = seq.getObjects();
+        while (e.hasMoreElements())
+        {
+            ASN1Sequence s = (ASN1Sequence)e.nextElement();
+            policies.addElement(s.getObjectAt(0));
+        }
+        // For now we just don't handle PolicyQualifiers
+    }
+
+    /**
+     * create a certificate policy with the given OID.
+     * @deprecated use an ASN1Sequence of PolicyInformation
+     */
+    public CertificatePolicies(
+        DERObjectIdentifier p)
+    {
+        policies.addElement(p);
+    }
+
+    /**
+     * create a certificate policy with the policy given by the OID represented
+     * by the string p.
+     * @deprecated use an ASN1Sequence of PolicyInformation
+     */
+    public CertificatePolicies(
+        String p)
+    {
+        this(new DERObjectIdentifier(p));
+    }
+
+    public void addPolicy(
+        String p)
+    {
+        policies.addElement(new DERObjectIdentifier(p));
+    }
+
+    public String getPolicy(int nr)
+    {
+        if (policies.size() > nr)
+            return ((DERObjectIdentifier)policies.elementAt(nr)).getId();
+
+        return null;
+    }
+
+    /**
+     * <pre>
+     * certificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
+     *
+     * PolicyInformation ::= SEQUENCE {
+     *   policyIdentifier   CertPolicyId,
+     *   policyQualifiers   SEQUENCE SIZE (1..MAX) OF
+     *                           PolicyQualifierInfo OPTIONAL }
+     *
+     * CertPolicyId ::= OBJECT IDENTIFIER
+     *
+     * PolicyQualifierInfo ::= SEQUENCE {
+     *   policyQualifierId  PolicyQualifierId,
+     *   qualifier          ANY DEFINED BY policyQualifierId }
+     *
+     * PolicyQualifierId ::=
+     *   OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice )
+     * </pre>
+     * @deprecated use an ASN1Sequence of PolicyInformation
+     */
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector  v = new ASN1EncodableVector();
+
+        // We only do policyIdentifier yet...
+        for (int i=0;i<policies.size();i++)
+        {
+            v.add(new DERSequence((DERObjectIdentifier)policies.elementAt(i)));
+        }
+
+        return new DERSequence(v);
+    }
+
+    public String toString()
+    {
+        String p = null;
+        for (int i=0;i<policies.size();i++)
+        {
+            if (p != null)
+                p += ", ";
+            p += ((DERObjectIdentifier)policies.elementAt(i)).getId();
+        }
+        return "CertificatePolicies: "+p;
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DSAParameter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DSAParameter.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DSAParameter.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DSAParameter.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,104 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.math.BigInteger;
+import java.util.Enumeration;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERInteger;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+public class DSAParameter
+    extends ASN1Encodable
+{
+    DERInteger      p, q, g;
+
+    public static DSAParameter getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public static DSAParameter getInstance(
+        Object obj)
+    {
+        if(obj == null || obj instanceof DSAParameter)
+        {
+            return (DSAParameter)obj;
+        }
+
+        if(obj instanceof ASN1Sequence)
+        {
+            return new DSAParameter((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("Invalid DSAParameter: " + obj.getClass().getName());
+    }
+
+    public DSAParameter(
+        BigInteger  p,
+        BigInteger  q,
+        BigInteger  g)
+    {
+        this.p = new DERInteger(p);
+        this.q = new DERInteger(q);
+        this.g = new DERInteger(g);
+    }
+
+    public DSAParameter(
+        ASN1Sequence  seq)
+    {
+        Enumeration     e = seq.getObjects();
+
+        p = (DERInteger)e.nextElement();
+        q = (DERInteger)e.nextElement();
+        g = (DERInteger)e.nextElement();
+    }
+
+    public BigInteger getP()
+    {
+        return p.getPositiveValue();
+    }
+
+    public BigInteger getQ()
+    {
+        return q.getPositiveValue();
+    }
+
+    public BigInteger getG()
+    {
+        return g.getPositiveValue();
+    }
+
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector  v = new ASN1EncodableVector();
+
+        v.add(p);
+        v.add(q);
+        v.add(g);
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DigestInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DigestInfo.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DigestInfo.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DigestInfo.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,103 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.util.Enumeration;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1OctetString;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DEROctetString;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+/**
+ * The DigestInfo object.
+ * <pre>
+ * DigestInfo::=SEQUENCE{
+ *          digestAlgorithm  AlgorithmIdentifier,
+ *          digest OCTET STRING }
+ * </pre>
+ */
+public class DigestInfo
+    extends ASN1Encodable
+{
+    private byte[]                  digest;
+    private AlgorithmIdentifier     algId;
+
+    public static DigestInfo getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public static DigestInfo getInstance(
+        Object  obj)
+    {
+        if (obj instanceof DigestInfo)
+        {
+            return (DigestInfo)obj;
+        }
+        else if (obj instanceof ASN1Sequence)
+        {
+            return new DigestInfo((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
+
+    public DigestInfo(
+        AlgorithmIdentifier  algId,
+        byte[]               digest)
+    {
+        this.digest = digest;
+        this.algId = algId;
+    }
+
+    public DigestInfo(
+        ASN1Sequence  obj)
+    {
+        Enumeration             e = obj.getObjects();
+
+        algId = AlgorithmIdentifier.getInstance(e.nextElement());
+        digest = ((ASN1OctetString)e.nextElement()).getOctets();
+    }
+
+    public AlgorithmIdentifier getAlgorithmId()
+    {
+        return algId;
+    }
+
+    public byte[] getDigest()
+    {
+        return digest;
+    }
+
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector  v = new ASN1EncodableVector();
+
+        v.add(algId);
+        v.add(new DEROctetString(digest));
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DisplayText.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DisplayText.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DisplayText.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DisplayText.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,205 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Choice;
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERBMPString;
+import org.apache.geronimo.util.asn1.DERIA5String;
+import org.apache.geronimo.util.asn1.DERUTF8String;
+import org.apache.geronimo.util.asn1.DERVisibleString;
+import org.apache.geronimo.util.asn1.DERString;
+
+/**
+ * <code>DisplayText</code> class, used in
+ * <code>CertificatePolicies</code> X509 V3 extensions (in policy qualifiers).
+ *
+ * <p>It stores a string in a chosen encoding.
+ * <pre>
+ * DisplayText ::= CHOICE {
+ *      ia5String        IA5String      (SIZE (1..200)),
+ *      visibleString    VisibleString  (SIZE (1..200)),
+ *      bmpString        BMPString      (SIZE (1..200)),
+ *      utf8String       UTF8String     (SIZE (1..200)) }
+ * </pre>
+ * @see PolicyQualifierInfo
+ * @see PolicyInformation
+ */
+public class DisplayText
+    extends ASN1Encodable
+    implements ASN1Choice
+{
+   /**
+    * Constant corresponding to ia5String encoding.
+    *
+    */
+   public static final int CONTENT_TYPE_IA5STRING = 0;
+   /**
+    * Constant corresponding to bmpString encoding.
+    *
+    */
+   public static final int CONTENT_TYPE_BMPSTRING = 1;
+   /**
+    * Constant corresponding to utf8String encoding.
+    *
+    */
+   public static final int CONTENT_TYPE_UTF8STRING = 2;
+   /**
+    * Constant corresponding to visibleString encoding.
+    *
+    */
+   public static final int CONTENT_TYPE_VISIBLESTRING = 3;
+
+   /**
+    * Describe constant <code>DISPLAY_TEXT_MAXIMUM_SIZE</code> here.
+    *
+    */
+   public static final int DISPLAY_TEXT_MAXIMUM_SIZE = 200;
+
+   int contentType;
+   DERString contents;
+
+   /**
+    * Creates a new <code>DisplayText</code> instance.
+    *
+    * @param type the desired encoding type for the text.
+    * @param text the text to store. Strings longer than 200
+    * characters are truncated.
+    */
+   public DisplayText (int type, String text)
+   {
+      if (text.length() > DISPLAY_TEXT_MAXIMUM_SIZE) {
+         // RFC3280 limits these strings to 200 chars
+         // truncate the string
+         text = text.substring (0, DISPLAY_TEXT_MAXIMUM_SIZE);
+      }
+
+      contentType = type;
+      switch (type) {
+         case CONTENT_TYPE_IA5STRING:
+            contents = (DERString)new DERIA5String (text);
+            break;
+         case CONTENT_TYPE_UTF8STRING:
+            contents = (DERString)new DERUTF8String(text);
+            break;
+         case CONTENT_TYPE_VISIBLESTRING:
+            contents = (DERString)new DERVisibleString(text);
+            break;
+         case CONTENT_TYPE_BMPSTRING:
+            contents = (DERString)new DERBMPString(text);
+            break;
+         default:
+            contents = (DERString)new DERUTF8String(text);
+            break;
+      }
+   }
+
+   /**
+    * return true if the passed in String can be represented without
+    * loss as a UTF8String, false otherwise.
+    */
+   private boolean canBeUTF8(
+       String  str)
+   {
+       for (int i = str.length() - 1; i >= 0; i--)
+       {
+           if (str.charAt(i) > 0x00ff)
+           {
+               return false;
+           }
+       }
+
+       return true;
+   }
+
+   /**
+    * Creates a new <code>DisplayText</code> instance.
+    *
+    * @param text the text to encapsulate. Strings longer than 200
+    * characters are truncated.
+    */
+   public DisplayText (String text)
+   {
+      // by default use UTF8String
+      if (text.length() > DISPLAY_TEXT_MAXIMUM_SIZE) {
+         text = text.substring(0, DISPLAY_TEXT_MAXIMUM_SIZE);
+      }
+
+      if (canBeUTF8(text))
+      {
+          contentType = CONTENT_TYPE_UTF8STRING;
+          contents = new DERUTF8String(text);
+      }
+      else
+      {
+          contentType = CONTENT_TYPE_BMPSTRING;
+          contents = new DERBMPString(text);
+      }
+   }
+
+   /**
+    * Creates a new <code>DisplayText</code> instance.
+    * <p>Useful when reading back a <code>DisplayText</code> class
+    * from it's ASN1Encodable/DEREncodable form.
+    *
+    * @param de a <code>DEREncodable</code> instance.
+    */
+   public DisplayText(DERString de)
+   {
+      contents = de;
+   }
+
+   public static DisplayText getInstance(Object de)
+   {
+      if (de instanceof DERString)
+      {
+          return new DisplayText((DERString)de);
+      }
+      else if (de instanceof DisplayText)
+      {
+          return (DisplayText)de;
+      }
+
+      throw new IllegalArgumentException("illegal object in getInstance");
+   }
+
+   public static DisplayText getInstance(
+       ASN1TaggedObject obj,
+       boolean          explicit)
+   {
+       return getInstance(obj.getObject()); // must be explicitly tagged
+   }
+
+   public DERObject toASN1Object()
+   {
+      return (DERObject)contents;
+   }
+
+   /**
+    * Returns the stored <code>String</code> object.
+    *
+    * @return the stored text as a <code>String</code>.
+    */
+   public String getString()
+   {
+      return contents.getString();
+   }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPoint.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPoint.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPoint.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPoint.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,138 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERBitString;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+
+/**
+ * The DistributionPoint object.
+ * <pre>
+ * DistributionPoint ::= SEQUENCE {
+ *      distributionPoint [0] DistributionPointName OPTIONAL,
+ *      reasons           [1] ReasonFlags OPTIONAL,
+ *      cRLIssuer         [2] GeneralNames OPTIONAL
+ * }
+ * </pre>
+ */
+public class DistributionPoint
+    extends ASN1Encodable
+{
+    DistributionPointName       distributionPoint;
+    ReasonFlags                 reasons;
+    GeneralNames                cRLIssuer;
+
+    public static DistributionPoint getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public static DistributionPoint getInstance(
+        Object obj)
+    {
+        if(obj == null || obj instanceof DistributionPoint)
+        {
+            return (DistributionPoint)obj;
+        }
+
+        if(obj instanceof ASN1Sequence)
+        {
+            return new DistributionPoint((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("Invalid DistributionPoint: " + obj.getClass().getName());
+    }
+
+    public DistributionPoint(
+        ASN1Sequence seq)
+    {
+        for (int i = 0; i != seq.size(); i++)
+        {
+            ASN1TaggedObject    t = (ASN1TaggedObject)seq.getObjectAt(i);
+            switch (t.getTagNo())
+            {
+            case 0:
+                distributionPoint = DistributionPointName.getInstance(t, true);
+                break;
+            case 1:
+                reasons = new ReasonFlags(DERBitString.getInstance(t, false));
+                break;
+            case 2:
+                cRLIssuer = GeneralNames.getInstance(t, false);
+            }
+        }
+    }
+
+    public DistributionPoint(
+        DistributionPointName distributionPoint,
+        ReasonFlags                 reasons,
+        GeneralNames            cRLIssuer)
+    {
+        this.distributionPoint = distributionPoint;
+        this.reasons = reasons;
+        this.cRLIssuer = cRLIssuer;
+    }
+
+    public DistributionPointName getDistributionPoint()
+    {
+        return distributionPoint;
+    }
+
+    public ReasonFlags getReasons()
+    {
+        return reasons;
+    }
+
+    public GeneralNames getCRLIssuer()
+    {
+        return cRLIssuer;
+    }
+
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector  v = new ASN1EncodableVector();
+
+        if (distributionPoint != null)
+        {
+            //
+            // as this is a CHOICE it must be explicitly tagged
+            //
+            v.add(new DERTaggedObject(0, distributionPoint));
+        }
+
+        if (reasons != null)
+        {
+            v.add(new DERTaggedObject(false, 1, reasons));
+        }
+
+        if (cRLIssuer != null)
+        {
+            v.add(new DERTaggedObject(false, 2, cRLIssuer));
+        }
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPointName.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPointName.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPointName.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/DistributionPointName.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,127 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Choice;
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1Set;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DEREncodable;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+
+/**
+ * The DistributionPointName object.
+ * <pre>
+ * DistributionPointName ::= CHOICE {
+ *     fullName                 [0] GeneralNames,
+ *     nameRelativeToCRLIssuer  [1] RelativeDistinguishedName
+ * }
+ * </pre>
+ */
+public class DistributionPointName
+    extends ASN1Encodable
+    implements ASN1Choice
+{
+    DEREncodable        name;
+    int                 type;
+
+    public static final int FULL_NAME = 0;
+    public static final int NAME_RELATIVE_TO_CRL_ISSUER = 1;
+
+    public static DistributionPointName getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1TaggedObject.getInstance(obj, true));
+    }
+
+    public static DistributionPointName getInstance(
+        Object  obj)
+    {
+        if (obj == null || obj instanceof DistributionPointName)
+        {
+            return (DistributionPointName)obj;
+        }
+        else if (obj instanceof ASN1TaggedObject)
+        {
+            return new DistributionPointName((ASN1TaggedObject)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
+
+    /*
+     * @deprecated use ASN1Encodable
+     */
+    public DistributionPointName(
+        int             type,
+        DEREncodable    name)
+    {
+        this.type = type;
+        this.name = name;
+    }
+
+    public DistributionPointName(
+        int             type,
+        ASN1Encodable   name)
+    {
+        this.type = type;
+        this.name = name;
+    }
+
+    /**
+     * Return the tag number applying to the underlying choice.
+     *
+     * @return the tag number for this point name.
+     */
+    public int getType()
+    {
+        return this.type;
+    }
+
+    /**
+     * Return the tagged object inside the distribution point name.
+     *
+     * @return the underlying choice item.
+     */
+    public ASN1Encodable getName()
+    {
+        return (ASN1Encodable)name;
+    }
+
+    public DistributionPointName(
+        ASN1TaggedObject    obj)
+    {
+        this.type = obj.getTagNo();
+
+        if (type == 0)
+        {
+            this.name = GeneralNames.getInstance(obj, false);
+        }
+        else
+        {
+            this.name = ASN1Set.getInstance(obj, false);
+        }
+    }
+
+    public DERObject toASN1Object()
+    {
+        return new DERTaggedObject(false, type, name);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/ExtendedKeyUsage.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/ExtendedKeyUsage.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/ExtendedKeyUsage.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/ExtendedKeyUsage.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,121 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+/**
+ * The extendedKeyUsage object.
+ * <pre>
+ *      extendedKeyUsage ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
+ * </pre>
+ */
+public class ExtendedKeyUsage
+    extends ASN1Encodable
+{
+    Hashtable     usageTable = new Hashtable();
+    ASN1Sequence  seq;
+
+    public static ExtendedKeyUsage getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public static ExtendedKeyUsage getInstance(
+        Object obj)
+    {
+        if(obj == null || obj instanceof ExtendedKeyUsage)
+        {
+            return (ExtendedKeyUsage)obj;
+        }
+
+        if(obj instanceof ASN1Sequence)
+        {
+            return new ExtendedKeyUsage((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("Invalid ExtendedKeyUsage: " + obj.getClass().getName());
+    }
+
+    public ExtendedKeyUsage(
+        KeyPurposeId  usage)
+    {
+        this.seq = new DERSequence(usage);
+
+        this.usageTable.put(usage, usage);
+    }
+
+    public ExtendedKeyUsage(
+        ASN1Sequence  seq)
+    {
+        this.seq = seq;
+
+        Enumeration e = seq.getObjects();
+
+        while (e.hasMoreElements())
+        {
+            Object  o = e.nextElement();
+
+            this.usageTable.put(o, o);
+        }
+    }
+
+    public ExtendedKeyUsage(
+        Vector  usages)
+    {
+        ASN1EncodableVector v = new ASN1EncodableVector();
+        Enumeration         e = usages.elements();
+
+        while (e.hasMoreElements())
+        {
+            DERObject  o = (DERObject)e.nextElement();
+
+            v.add(o);
+            this.usageTable.put(o, o);
+        }
+
+        this.seq = new DERSequence(v);
+    }
+
+    public boolean hasKeyPurposeId(
+        KeyPurposeId keyPurposeId)
+    {
+        return (usageTable.get(keyPurposeId) != null);
+    }
+
+    public int size()
+    {
+        return usageTable.size();
+    }
+
+    public DERObject toASN1Object()
+    {
+        return seq;
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralName.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralName.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralName.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralName.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,218 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Choice;
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1OctetString;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DEREncodable;
+import org.apache.geronimo.util.asn1.DERIA5String;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERObjectIdentifier;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+
+/**
+ * The GeneralName object.
+ * <pre>
+ * GeneralName ::= CHOICE {
+ *      otherName                       [0]     OtherName,
+ *      rfc822Name                      [1]     IA5String,
+ *      dNSName                         [2]     IA5String,
+ *      x400Address                     [3]     ORAddress,
+ *      directoryName                   [4]     Name,
+ *      ediPartyName                    [5]     EDIPartyName,
+ *      uniformResourceIdentifier       [6]     IA5String,
+ *      iPAddress                       [7]     OCTET STRING,
+ *      registeredID                    [8]     OBJECT IDENTIFIER}
+ *
+ * OtherName ::= SEQUENCE {
+ *      type-id    OBJECT IDENTIFIER,
+ *      value      [0] EXPLICIT ANY DEFINED BY type-id }
+ *
+ * EDIPartyName ::= SEQUENCE {
+ *      nameAssigner            [0]     DirectoryString OPTIONAL,
+ *      partyName               [1]     DirectoryString }
+ *
+ * Name ::= CHOICE { RDNSequence }
+ * </pre>
+ */
+public class GeneralName
+    extends ASN1Encodable
+    implements ASN1Choice
+{
+    public static final int otherName                     = 0;
+    public static final int rfc822Name                    = 1;
+    public static final int dNSName                       = 2;
+    public static final int x400Address                   = 3;
+    public static final int directoryName                 = 4;
+    public static final int ediPartyName                  = 5;
+    public static final int uniformResourceIdentifier     = 6;
+    public static final int iPAddress                     = 7;
+    public static final int registeredID                  = 8;
+
+    DEREncodable      obj;
+    int               tag;
+
+    public GeneralName(
+        X509Name  dirName)
+    {
+        this.obj = dirName;
+        this.tag = 4;
+    }
+
+    /**
+     * @deprecated this constructor seems the wrong way round! Use GeneralName(tag, name).
+     */
+    public GeneralName(
+        DERObject name, int tag)
+    {
+        this.obj = name;
+        this.tag = tag;
+    }
+
+    /**
+     * When the subjectAltName extension contains an Internet mail address,
+     * the address MUST be included as an rfc822Name. The format of an
+     * rfc822Name is an "addr-spec" as defined in RFC 822 [RFC 822].
+     *
+     * When the subjectAltName extension contains a domain name service
+     * label, the domain name MUST be stored in the dNSName (an IA5String).
+     * The name MUST be in the "preferred name syntax," as specified by RFC
+     * 1034 [RFC 1034].
+     *
+     * When the subjectAltName extension contains a URI, the name MUST be
+     * stored in the uniformResourceIdentifier (an IA5String). The name MUST
+     * be a non-relative URL, and MUST follow the URL syntax and encoding
+     * rules specified in [RFC 1738].  The name must include both a scheme
+     * (e.g., "http" or "ftp") and a scheme-specific-part.  The scheme-
+     * specific-part must include a fully qualified domain name or IP
+     * address as the host.
+     *
+     * When the subjectAltName extension contains a iPAddress, the address
+     * MUST be stored in the octet string in "network byte order," as
+     * specified in RFC 791 [RFC 791]. The least significant bit (LSB) of
+     * each octet is the LSB of the corresponding byte in the network
+     * address. For IP Version 4, as specified in RFC 791, the octet string
+     * MUST contain exactly four octets.  For IP Version 6, as specified in
+     * RFC 1883, the octet string MUST contain exactly sixteen octets [RFC
+     * 1883].
+     */
+    public GeneralName(
+        int           tag,
+        ASN1Encodable name)
+    {
+        this.obj = name;
+        this.tag = tag;
+    }
+
+    /**
+     * Create a General name for the given tag from the passed in String.
+     *
+     * @param tag tag number
+     * @param name string representation of name
+     */
+    public GeneralName(
+        int       tag,
+        String    name)
+    {
+        if (tag == rfc822Name || tag == dNSName || tag == uniformResourceIdentifier)
+        {
+            this.tag = tag;
+            this.obj = new DERIA5String(name);
+        }
+        else if (tag == registeredID)
+        {
+            this.tag = tag;
+            this.obj = new DERObjectIdentifier(name);
+        }
+        else
+        {
+            throw new IllegalArgumentException("can't process String for tag: " + tag);
+        }
+    }
+
+    public static GeneralName getInstance(
+        Object obj)
+    {
+        if (obj == null || obj instanceof GeneralName)
+        {
+            return (GeneralName)obj;
+        }
+
+        if (obj instanceof ASN1TaggedObject)
+        {
+            ASN1TaggedObject    tagObj = (ASN1TaggedObject)obj;
+            int                 tag = tagObj.getTagNo();
+
+            switch (tag)
+            {
+            case otherName:
+                return new GeneralName(ASN1Sequence.getInstance(tagObj, false), tag);
+            case rfc822Name:
+                return new GeneralName(DERIA5String.getInstance(tagObj, false), tag);
+            case dNSName:
+                return new GeneralName(DERIA5String.getInstance(tagObj, false), tag);
+            case x400Address:
+                throw new IllegalArgumentException("unknown tag: " + tag);
+            case directoryName:
+                return new GeneralName(ASN1Sequence.getInstance(tagObj, true), tag);
+            case ediPartyName:
+                return new GeneralName(ASN1Sequence.getInstance(tagObj, false), tag);
+            case uniformResourceIdentifier:
+                return new GeneralName(DERIA5String.getInstance(tagObj, false), tag);
+            case iPAddress:
+                return new GeneralName(ASN1OctetString.getInstance(tagObj, false), tag);
+            case registeredID:
+                return new GeneralName(DERObjectIdentifier.getInstance(tagObj, false), tag);
+            }
+        }
+
+        throw new IllegalArgumentException("unknown object in getInstance");
+    }
+
+    public static GeneralName getInstance(
+        ASN1TaggedObject tagObj,
+        boolean          explicit)
+    {
+        return GeneralName.getInstance(ASN1TaggedObject.getInstance(tagObj, true));
+    }
+
+    public int getTagNo()
+    {
+        return tag;
+    }
+
+    public DEREncodable getName()
+    {
+        return obj;
+    }
+
+    public DERObject toASN1Object()
+    {
+        if (tag == directoryName)       // directoryName is explicitly tagged as it is a CHOICE
+        {
+            return new DERTaggedObject(true, tag, obj);
+        }
+        else
+        {
+            return new DERTaggedObject(false, tag, obj);
+        }
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralNames.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralNames.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralNames.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralNames.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,93 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+public class GeneralNames
+    extends ASN1Encodable
+{
+    ASN1Sequence            seq;
+
+    public static GeneralNames getInstance(
+        Object  obj)
+    {
+        if (obj == null || obj instanceof GeneralNames)
+        {
+            return (GeneralNames)obj;
+        }
+
+        if (obj instanceof ASN1Sequence)
+        {
+            return new GeneralNames((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
+    }
+
+    public static GeneralNames getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    /**
+     * Construct a GeneralNames object containing one GeneralName.
+     *
+     * @param name the name to be contained.
+     */
+    public GeneralNames(
+        GeneralName  name)
+    {
+        this.seq = new DERSequence(name);
+    }
+
+    public GeneralNames(
+        ASN1Sequence  seq)
+    {
+        this.seq = seq;
+    }
+
+    public GeneralName[] getNames()
+    {
+        GeneralName[]   names = new GeneralName[seq.size()];
+
+        for (int i = 0; i != seq.size(); i++)
+        {
+            names[i] = GeneralName.getInstance(seq.getObjectAt(i));
+        }
+
+        return names;
+    }
+
+    /**
+     * Produce an object suitable for an ASN1OutputStream.
+     * <pre>
+     * GeneralNames ::= SEQUENCE SIZE {1..MAX} OF GeneralName
+     * </pre>
+     */
+    public DERObject toASN1Object()
+    {
+        return seq;
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralSubtree.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralSubtree.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralSubtree.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/GeneralSubtree.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.math.BigInteger;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERInteger;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+
+public class GeneralSubtree
+    extends ASN1Encodable
+{
+    private GeneralName  base;
+    private DERInteger minimum;
+    private DERInteger maximum;
+
+    public GeneralSubtree(
+        ASN1Sequence seq)
+    {
+        base = GeneralName.getInstance(seq.getObjectAt(0));
+
+        switch (seq.size())
+        {
+        case 1:
+            break;
+        case 2:
+            ASN1TaggedObject o = (ASN1TaggedObject)seq.getObjectAt(1);
+            switch (o.getTagNo())
+            {
+            case 0 :
+                minimum = DERInteger.getInstance(o, false);
+                break;
+            case 1 :
+                maximum = DERInteger.getInstance(o, false);
+                break;
+            default:
+                throw new IllegalArgumentException("Bad tag number: " + o.getTagNo());
+            }
+            break;
+        case 3 :
+            minimum = DERInteger.getInstance((ASN1TaggedObject)seq.getObjectAt(1), false);
+            maximum = DERInteger.getInstance((ASN1TaggedObject)seq.getObjectAt(2), false);
+            break;
+        default:
+            throw new IllegalArgumentException("Bad sequence size: " + seq.size());
+        }
+    }
+
+    public static GeneralSubtree getInstance(
+        ASN1TaggedObject    o,
+        boolean             explicit)
+    {
+        return new GeneralSubtree(ASN1Sequence.getInstance(o, explicit));
+    }
+
+    public static GeneralSubtree getInstance(
+        Object obj)
+    {
+        if (obj == null)
+        {
+            return null;
+        }
+
+        if (obj instanceof GeneralSubtree)
+        {
+            return (GeneralSubtree)obj;
+        }
+
+        return new GeneralSubtree(ASN1Sequence.getInstance(obj));
+    }
+
+    public GeneralName getBase()
+    {
+        return base;
+    }
+
+    public BigInteger getMinimum()
+    {
+        if (minimum == null)
+        {
+            return BigInteger.valueOf(0);
+        }
+
+        return minimum.getValue();
+    }
+
+    public BigInteger getMaximum()
+    {
+        if (maximum == null)
+        {
+            return null;
+        }
+
+        return maximum.getValue();
+    }
+
+    /*
+     * GeneralSubtree ::= SEQUENCE {
+     *      base                    GeneralName,
+     *      minimum         [0]     BaseDistance DEFAULT 0,
+     *      maximum         [1]     BaseDistance OPTIONAL }
+     */
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector v = new ASN1EncodableVector();
+
+        v.add(base);
+
+        if (minimum != null)
+        {
+            v.add(new DERTaggedObject(false, 0, minimum));
+        }
+
+        if (maximum != null)
+        {
+            v.add(new DERTaggedObject(false, 1, maximum));
+        }
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/Holder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/Holder.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/Holder.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/Holder.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,137 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+
+/**
+ * The Holder object.
+ * <pre>
+ *  Holder ::= SEQUENCE {
+ *        baseCertificateID   [0] IssuerSerial OPTIONAL,
+ *                 -- the issuer and serial number of
+ *                 -- the holder's Public Key Certificate
+ *        entityName          [1] GeneralNames OPTIONAL,
+ *                 -- the name of the claimant or role
+ *        objectDigestInfo    [2] ObjectDigestInfo OPTIONAL
+ *                 -- used to directly authenticate the holder,
+ *                 -- for example, an executable
+ *  }
+ * </pre>
+ */
+public class Holder
+    extends ASN1Encodable
+{
+    IssuerSerial        baseCertificateID;
+    GeneralNames        entityName;
+    ObjectDigestInfo    objectDigestInfo;
+
+    public static Holder getInstance(
+            Object  obj)
+    {
+        if (obj instanceof Holder)
+        {
+            return (Holder)obj;
+        }
+        else if (obj instanceof ASN1Sequence)
+        {
+            return new Holder((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
+
+    public Holder(
+        ASN1Sequence    seq)
+    {
+        for (int i = 0; i != seq.size(); i++)
+        {
+            ASN1TaggedObject    tObj = (ASN1TaggedObject)seq.getObjectAt(i);
+
+            switch (tObj.getTagNo())
+            {
+            case 0:
+                baseCertificateID = IssuerSerial.getInstance(tObj, false);
+                break;
+            case 1:
+                entityName = GeneralNames.getInstance(tObj, false);
+                break;
+            case 2:
+                objectDigestInfo = ObjectDigestInfo.getInstance(tObj, false);
+                break;
+            default:
+                throw new IllegalArgumentException("unknown tag in Holder");
+            }
+        }
+    }
+
+    public Holder(
+        IssuerSerial    baseCertificateID)
+    {
+        this.baseCertificateID = baseCertificateID;
+    }
+
+    public Holder(
+        GeneralNames    entityName)
+    {
+        this.entityName = entityName;
+    }
+
+    public IssuerSerial getBaseCertificateID()
+    {
+        return baseCertificateID;
+    }
+
+    public GeneralNames getEntityName()
+    {
+        return entityName;
+    }
+
+    public ObjectDigestInfo getObjectDigestInfo()
+    {
+        return objectDigestInfo;
+    }
+
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector  v = new ASN1EncodableVector();
+
+        if (baseCertificateID != null)
+        {
+            v.add(new DERTaggedObject(false, 0, baseCertificateID));
+        }
+
+        if (entityName != null)
+        {
+            v.add(new DERTaggedObject(false, 1, entityName));
+        }
+
+        if (objectDigestInfo != null)
+        {
+            v.add(new DERTaggedObject(false, 2, objectDigestInfo));
+        }
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IetfAttrSyntax.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IetfAttrSyntax.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IetfAttrSyntax.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IetfAttrSyntax.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,191 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1OctetString;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERObjectIdentifier;
+import org.apache.geronimo.util.asn1.DEROctetString;
+import org.apache.geronimo.util.asn1.DERSequence;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+import org.apache.geronimo.util.asn1.DERUTF8String;
+
+/**
+ * Implementation of <code>IetfAttrSyntax</code> as specified by RFC3281.
+ */
+public class IetfAttrSyntax
+    extends ASN1Encodable
+{
+    public static final int VALUE_OCTETS    = 1;
+    public static final int VALUE_OID       = 2;
+    public static final int VALUE_UTF8      = 3;
+    GeneralNames            policyAuthority = null;
+    Vector                  values          = new Vector();
+    int                     valueChoice     = -1;
+
+    /**
+     *
+     */
+    public IetfAttrSyntax(ASN1Sequence seq)
+    {
+        int i = 0;
+
+        if (seq.getObjectAt(0) instanceof ASN1TaggedObject)
+        {
+            policyAuthority = GeneralNames.getInstance(((ASN1TaggedObject)seq.getObjectAt(0)), false);
+            i++;
+        }
+        else if (seq.size() == 2)
+        { // VOMS fix
+            policyAuthority = GeneralNames.getInstance(seq.getObjectAt(0));
+            i++;
+        }
+
+        if (!(seq.getObjectAt(i) instanceof ASN1Sequence))
+        {
+            throw new IllegalArgumentException("Non-IetfAttrSyntax encoding");
+        }
+
+        seq = (ASN1Sequence)seq.getObjectAt(i);
+
+        for (Enumeration e = seq.getObjects(); e.hasMoreElements();)
+        {
+            DERObject obj = (DERObject)e.nextElement();
+            int type;
+
+            if (obj instanceof DERObjectIdentifier)
+            {
+                type = VALUE_OID;
+            }
+            else if (obj instanceof DERUTF8String)
+            {
+                type = VALUE_UTF8;
+            }
+            else if (obj instanceof DEROctetString)
+            {
+                type = VALUE_OCTETS;
+            }
+            else
+            {
+                throw new IllegalArgumentException("Bad value type encoding IetfAttrSyntax");
+            }
+
+            if (valueChoice < 0)
+            {
+                valueChoice = type;
+            }
+
+            if (type != valueChoice)
+            {
+                throw new IllegalArgumentException("Mix of value types in IetfAttrSyntax");
+            }
+
+            values.addElement(obj);
+        }
+    }
+
+    public GeneralNames getPolicyAuthority()
+    {
+        return policyAuthority;
+    }
+
+    public int getValueType()
+    {
+        return valueChoice;
+    }
+
+    public Object[] getValues()
+    {
+        if (this.getValueType() == VALUE_OCTETS)
+        {
+            ASN1OctetString[] tmp = new ASN1OctetString[values.size()];
+
+            for (int i = 0; i != tmp.length; i++)
+            {
+                tmp[i] = (ASN1OctetString)values.elementAt(i);
+            }
+
+            return tmp;
+        }
+        else if (this.getValueType() == VALUE_OID)
+        {
+            DERObjectIdentifier[] tmp = new DERObjectIdentifier[values.size()];
+
+            for (int i = 0; i != tmp.length; i++)
+            {
+                tmp[i] = (DERObjectIdentifier)values.elementAt(i);
+            }
+
+            return tmp;
+        }
+        else
+        {
+            DERUTF8String[] tmp = new DERUTF8String[values.size()];
+
+            for (int i = 0; i != tmp.length; i++)
+            {
+                tmp[i] = (DERUTF8String)values.elementAt(i);
+            }
+
+            return tmp;
+        }
+    }
+
+    /**
+     *
+     * <pre>
+     *
+     *  IetfAttrSyntax ::= SEQUENCE {
+     *    policyAuthority [0] GeneralNames OPTIONAL,
+     *    values SEQUENCE OF CHOICE {
+     *      octets OCTET STRING,
+     *      oid OBJECT IDENTIFIER,
+     *      string UTF8String
+     *    }
+     *  }
+     *
+     * </pre>
+     */
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector v = new ASN1EncodableVector();
+
+        if (policyAuthority != null)
+        {
+            v.add(new DERTaggedObject(0, policyAuthority));
+        }
+
+        ASN1EncodableVector v2 = new ASN1EncodableVector();
+
+        for (Enumeration i = values.elements(); i.hasMoreElements();)
+        {
+            v2.add((ASN1Encodable)i.nextElement());
+        }
+
+        v.add(new DERSequence(v2));
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuerSerial.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuerSerial.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuerSerial.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuerSerial.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,118 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERBitString;
+import org.apache.geronimo.util.asn1.DERInteger;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+public class IssuerSerial
+    extends ASN1Encodable
+{
+    GeneralNames            issuer;
+    DERInteger              serial;
+    DERBitString            issuerUID;
+
+    public static IssuerSerial getInstance(
+            Object  obj)
+    {
+        if (obj == null || obj instanceof GeneralNames)
+        {
+            return (IssuerSerial)obj;
+        }
+
+        if (obj instanceof ASN1Sequence)
+        {
+            return new IssuerSerial((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
+    }
+
+    public static IssuerSerial getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public IssuerSerial(
+        ASN1Sequence    seq)
+    {
+        issuer = GeneralNames.getInstance(seq.getObjectAt(0));
+        serial = (DERInteger)seq.getObjectAt(1);
+
+        if (seq.size() == 3)
+        {
+            issuerUID = (DERBitString)seq.getObjectAt(2);
+        }
+    }
+
+    public IssuerSerial(
+        GeneralNames    issuer,
+        DERInteger      serial)
+    {
+        this.issuer = issuer;
+        this.serial = serial;
+    }
+
+    public GeneralNames getIssuer()
+    {
+        return issuer;
+    }
+
+    public DERInteger getSerial()
+    {
+        return serial;
+    }
+
+    public DERBitString getIssuerUID()
+    {
+        return issuerUID;
+    }
+
+    /**
+     * Produce an object suitable for an ASN1OutputStream.
+     * <pre>
+     *  IssuerSerial  ::=  SEQUENCE {
+     *       issuer         GeneralNames,
+     *       serial         CertificateSerialNumber,
+     *       issuerUID      UniqueIdentifier OPTIONAL
+     *  }
+     * </pre>
+     */
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector  v = new ASN1EncodableVector();
+
+        v.add(issuer);
+        v.add(serial);
+
+        if (issuerUID != null)
+        {
+            v.add(issuerUID);
+        }
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuingDistributionPoint.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuingDistributionPoint.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuingDistributionPoint.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/IssuingDistributionPoint.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,127 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERBoolean;
+import org.apache.geronimo.util.asn1.DERObject;
+
+/**
+ * IssuingDistributionPoint ::= SEQUENCE {
+ *      distributionPoint          [0] DistributionPointName OPTIONAL,
+ *      onlyContainsUserCerts      [1] BOOLEAN DEFAULT FALSE,
+ *      onlyContainsCACerts        [2] BOOLEAN DEFAULT FALSE,
+ *      onlySomeReasons            [3] ReasonFlags OPTIONAL,
+ *      indirectCRL                [4] BOOLEAN DEFAULT FALSE,
+ *      onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE }
+ */
+public class IssuingDistributionPoint
+    extends ASN1Encodable
+{
+    private boolean         onlyContainsUserCerts;
+    private boolean         onlyContainsCACerts;
+    private boolean         indirectCRL;
+    private boolean         onlyContainsAttributeCerts;
+
+    private ASN1Sequence    seq;
+
+    public static IssuingDistributionPoint getInstance(
+        ASN1TaggedObject obj,
+        boolean          explicit)
+    {
+        return getInstance(ASN1Sequence.getInstance(obj, explicit));
+    }
+
+    public static IssuingDistributionPoint getInstance(
+        Object  obj)
+    {
+        if (obj == null || obj instanceof IssuingDistributionPoint)
+        {
+            return (IssuingDistributionPoint)obj;
+        }
+        else if (obj instanceof ASN1Sequence)
+        {
+            return new IssuingDistributionPoint((ASN1Sequence)obj);
+        }
+
+        throw new IllegalArgumentException("unknown object in factory");
+    }
+
+    /**
+     * Constructor from ASN1Sequence
+     */
+    public IssuingDistributionPoint(
+        ASN1Sequence  seq)
+    {
+        this.seq = seq;
+
+        for (int i = 0; i != seq.size(); i++)
+        {
+            ASN1TaggedObject  o = (ASN1TaggedObject)seq.getObjectAt(i);
+
+            switch (o.getTagNo())
+            {
+            case 0:
+                break;
+            case 1:
+                onlyContainsUserCerts = DERBoolean.getInstance(o, false).isTrue();
+                break;
+            case 2:
+                onlyContainsCACerts = DERBoolean.getInstance(o, false).isTrue();
+                break;
+            case 3:
+                break;
+            case 4:
+                indirectCRL = DERBoolean.getInstance(o, false).isTrue();
+                break;
+            case 5:
+                onlyContainsAttributeCerts = DERBoolean.getInstance(o, false).isTrue();
+                break;
+            default:
+                throw new IllegalArgumentException("unknown tag in IssuingDistributionPoint");
+            }
+        }
+    }
+
+    public boolean onlyContainsUserCerts()
+    {
+        return onlyContainsUserCerts;
+    }
+
+    public boolean onlyContainsCACerts()
+    {
+        return onlyContainsCACerts;
+    }
+
+    public boolean isIndirectCRL()
+    {
+        return indirectCRL;
+    }
+
+    public boolean onlyContainsAttributeCerts()
+    {
+        return onlyContainsAttributeCerts;
+    }
+
+    public DERObject toASN1Object()
+    {
+        return seq;
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyPurposeId.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyPurposeId.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyPurposeId.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyPurposeId.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.DERObjectIdentifier;
+
+/**
+ * The KeyPurposeId object.
+ * <pre>
+ *     KeyPurposeId ::= OBJECT IDENTIFIER
+ * </pre>
+ */
+public class KeyPurposeId
+    extends DERObjectIdentifier
+{
+    private static final String id_kp = "1.3.6.1.5.5.7.3";
+
+    private KeyPurposeId(
+        String  id)
+    {
+        super(id);
+    }
+
+    public static final KeyPurposeId anyExtendedKeyUsage = new KeyPurposeId(X509Extensions.ExtendedKeyUsage.getId() + ".0");
+    public static final KeyPurposeId id_kp_serverAuth = new KeyPurposeId(id_kp + ".1");
+    public static final KeyPurposeId id_kp_clientAuth = new KeyPurposeId(id_kp + ".2");
+    public static final KeyPurposeId id_kp_codeSigning = new KeyPurposeId(id_kp + ".3");
+    public static final KeyPurposeId id_kp_emailProtection = new KeyPurposeId(id_kp + ".4");
+    public static final KeyPurposeId id_kp_ipsecEndSystem = new KeyPurposeId(id_kp + ".5");
+    public static final KeyPurposeId id_kp_ipsecTunnel = new KeyPurposeId(id_kp + ".6");
+    public static final KeyPurposeId id_kp_ipsecUser = new KeyPurposeId(id_kp + ".7");
+    public static final KeyPurposeId id_kp_timeStamping = new KeyPurposeId(id_kp + ".8");
+    public static final KeyPurposeId id_kp_OCSPSigning = new KeyPurposeId(id_kp + ".9");
+
+    //
+    // microsoft key purpose ids
+    //
+    public static final KeyPurposeId id_kp_smartcardlogon = new KeyPurposeId("1.3.6.1.4.1.311.20.2.2");
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyUsage.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyUsage.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyUsage.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/KeyUsage.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,79 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import org.apache.geronimo.util.asn1.DERBitString;
+
+/**
+ * The KeyUsage object.
+ * <pre>
+ *    id-ce-keyUsage OBJECT IDENTIFIER ::=  { id-ce 15 }
+ *
+ *    KeyUsage ::= BIT STRING {
+ *         digitalSignature        (0),
+ *         nonRepudiation          (1),
+ *         keyEncipherment         (2),
+ *         dataEncipherment        (3),
+ *         keyAgreement            (4),
+ *         keyCertSign             (5),
+ *         cRLSign                 (6),
+ *         encipherOnly            (7),
+ *         decipherOnly            (8) }
+ * </pre>
+ */
+public class KeyUsage
+    extends DERBitString
+{
+    public static final int        digitalSignature = (1 << 7);
+    public static final int        nonRepudiation   = (1 << 6);
+    public static final int        keyEncipherment  = (1 << 5);
+    public static final int        dataEncipherment = (1 << 4);
+    public static final int        keyAgreement     = (1 << 3);
+    public static final int        keyCertSign      = (1 << 2);
+    public static final int        cRLSign          = (1 << 1);
+    public static final int        encipherOnly     = (1 << 0);
+    public static final int        decipherOnly     = (1 << 15);
+
+    /**
+     * Basic constructor.
+     *
+     * @param usage - the bitwise OR of the Key Usage flags giving the
+     * allowed uses for the key.
+     * e.g. (KeyUsage.keyEncipherment | KeyUsage.dataEncipherment)
+     */
+    public KeyUsage(
+        int usage)
+    {
+        super(getBytes(usage), getPadBits(usage));
+    }
+
+    public KeyUsage(
+        DERBitString usage)
+    {
+        super(usage.getBytes(), usage.getPadBits());
+    }
+
+    public String toString()
+    {
+        if (data.length == 1)
+        {
+            return "KeyUsage: 0x" + Integer.toHexString(data[0] & 0xff);
+        }
+        return "KeyUsage: 0x" + Integer.toHexString((data[1] & 0xff) << 8 | (data[0] & 0xff));
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NameConstraints.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NameConstraints.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NameConstraints.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NameConstraints.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,85 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.util.Enumeration;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.ASN1TaggedObject;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+import org.apache.geronimo.util.asn1.DERTaggedObject;
+
+public class NameConstraints
+    extends ASN1Encodable
+{
+    ASN1Sequence    permitted, excluded;
+
+    public NameConstraints(
+        ASN1Sequence    seq)
+    {
+        Enumeration e = seq.getObjects();
+        while (e.hasMoreElements())
+        {
+            ASN1TaggedObject    o = (ASN1TaggedObject)e.nextElement();
+            switch (o.getTagNo())
+            {
+            case 0:
+                permitted = ASN1Sequence.getInstance(o, false);
+                break;
+            case 1:
+                excluded = ASN1Sequence.getInstance(o, false);
+                break;
+            }
+        }
+    }
+
+    public ASN1Sequence getPermittedSubtrees()
+    {
+        return permitted;
+    }
+
+    public ASN1Sequence getExcludedSubtrees()
+    {
+        return excluded;
+    }
+
+    /*
+     * NameConstraints ::= SEQUENCE {
+     *      permittedSubtrees       [0]     GeneralSubtrees OPTIONAL,
+     *      excludedSubtrees        [1]     GeneralSubtrees OPTIONAL }
+     */
+    public DERObject toASN1Object()
+    {
+        ASN1EncodableVector   v = new ASN1EncodableVector();
+
+        if (permitted != null)
+        {
+            v.add(new DERTaggedObject(false, 0, permitted));
+        }
+
+        if (excluded != null)
+        {
+            v.add(new DERTaggedObject(false, 1, excluded));
+        }
+
+        return new DERSequence(v);
+    }
+}

Added: geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NoticeReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NoticeReference.java?rev=291352&view=auto
==============================================================================
--- geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NoticeReference.java (added)
+++ geronimo/trunk/modules/util/src/java/org/apache/geronimo/util/asn1/x509/NoticeReference.java Sat Sep 24 17:31:10 2005
@@ -0,0 +1,146 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.geronimo.util.asn1.x509;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.apache.geronimo.util.asn1.ASN1Encodable;
+import org.apache.geronimo.util.asn1.ASN1EncodableVector;
+import org.apache.geronimo.util.asn1.ASN1Sequence;
+import org.apache.geronimo.util.asn1.DERInteger;
+import org.apache.geronimo.util.asn1.DERObject;
+import org.apache.geronimo.util.asn1.DERSequence;
+
+/**
+ * <code>NoticeReference</code> class, used in
+ * <code>CertificatePolicies</code> X509 V3 extensions
+ * (in policy qualifiers).
+ *
+ * <pre>
+ *  NoticeReference ::= SEQUENCE {
+ *      organization     DisplayText,
+ *      noticeNumbers    SEQUENCE OF INTEGER }
+ *
+ * </pre>
+ *
+ * @see PolicyQualifierInfo
+ * @see PolicyInformation
+ */
+public class NoticeReference
+    extends ASN1Encodable
+{
+   DisplayText organization;
+   ASN1Sequence noticeNumbers;
+
+   /**
+    * Creates a new <code>NoticeReference</code> instance.
+    *
+    * @param orgName a <code>String</code> value
+    * @param numbers a <code>Vector</code> value
+    */
+   public NoticeReference (String orgName, Vector numbers)
+   {
+      organization = new DisplayText(orgName);
+
+      Object o = numbers.elementAt(0);
+
+      ASN1EncodableVector av = new ASN1EncodableVector();
+      if (o instanceof Integer) {
+         Enumeration it = numbers.elements();
+
+         while (it.hasMoreElements()) {
+            Integer nm = (Integer) it.nextElement();
+               DERInteger di = new DERInteger(nm.intValue());
+            av.add (di);
+         }
+      }
+
+      noticeNumbers = new DERSequence(av);
+   }
+
+   /**
+    * Creates a new <code>NoticeReference</code> instance.
+    *
+    * @param orgName a <code>String</code> value
+    * @param numbers an <code>ASN1EncodableVector</code> value
+    */
+   public NoticeReference (String orgName, ASN1Sequence numbers)
+   {
+      organization = new DisplayText (orgName);
+      noticeNumbers = numbers;
+   }
+
+   /**
+    * Creates a new <code>NoticeReference</code> instance.
+    *
+    * @param displayTextType an <code>int</code> value
+    * @param orgName a <code>String</code> value
+    * @param numbers an <code>ASN1EncodableVector</code> value
+    */
+   public NoticeReference (int displayTextType,
+                           String orgName, ASN1Sequence numbers)
+   {
+      organization = new DisplayText(displayTextType,
+                                     orgName);
+      noticeNumbers = numbers;
+   }
+
+   /**
+    * Creates a new <code>NoticeReference</code> instance.
+    * <p>Useful for reconstructing a <code>NoticeReference</code>
+    * instance from its encodable/encoded form.
+    *
+    * @param as an <code>ASN1Sequence</code> value obtained from either
+    * calling @{link toASN1Object()} for a <code>NoticeReference</code>
+    * instance or from parsing it from a DER-encoded stream.
+    */
+   public NoticeReference (ASN1Sequence as)
+   {
+      organization = DisplayText.getInstance(as.getObjectAt(0));
+      noticeNumbers = (ASN1Sequence) as.getObjectAt(1);
+   }
+
+   public static NoticeReference getInstance (Object as)
+   {
+      if (as instanceof NoticeReference)
+      {
+          return (NoticeReference)as;
+      }
+      else if (as instanceof ASN1Sequence)
+      {
+          return new NoticeReference((ASN1Sequence)as);
+      }
+
+      throw new IllegalArgumentException("unknown object in getInstance.");
+   }
+
+   /**
+    * Describe <code>toASN1Object</code> method here.
+    *
+    * @return a <code>DERObject</code> value
+    */
+   public DERObject toASN1Object()
+   {
+      ASN1EncodableVector av = new ASN1EncodableVector();
+      av.add (organization);
+      av.add (noticeNumbers);
+      return new DERSequence (av);
+   }
+}



Mime
View raw message