Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.x509;
  
  import java.util.List;
 
 
Carrying class for an attribute certificate issuer.

Deprecated:
use org.bouncycastle.cert.AttributeCertificateIssuer
 
     implements CertSelectorSelector
 {
     final ASN1Encodable form;

    
Set the issuer directly with the ASN.1 structure.

Parameters:
issuer The issuer
 
     public AttributeCertificateIssuer(AttCertIssuer issuer)
     {
          = issuer.getIssuer();
     }
 
     public AttributeCertificateIssuer(X500Principal principal)
         throws IOException
     {
         this(new X509Principal(principal.getEncoded()));
     }
 
     public AttributeCertificateIssuer(X509Principal principal)
     {
          = new V2Form(GeneralNames.getInstance(new DERSequence(new GeneralName(principal))));
     }
 
     private Object[] getNames()
     {
         GeneralNames name;
 
         if ( instanceof V2Form)
         {
             name = ((V2Form)).getIssuerName();
         }
         else
         {
             name = (GeneralNames);
         }
 
         GeneralName[] names = name.getNames();
 
         List l = new ArrayList(names.length);
 
         for (int i = 0; i != names.lengthi++)
         {
             if (names[i].getTagNo() == .)
             {
                 try
                 {
                     l.add(new X500Principal(
                         ((ASN1Encodable)names[i].getName()).toASN1Primitive().getEncoded()));
                 }
                 catch (IOException e)
                 {
                     throw new RuntimeException("badly formed Name object");
                 }
             }
         }
 
         return l.toArray(new Object[l.size()]);
     }

    
Return any principal objects inside the attribute certificate issuer object.

Returns:
an array of Principal objects (usually X500Principal)
 
     public Principal[] getPrincipals()
     {
         Object[] p = this.getNames();
         List l = new ArrayList();
 
         for (int i = 0; i != p.lengthi++)
        {
            if (p[iinstanceof Principal)
            {
                l.add(p[i]);
            }
        }
        return (Principal[])l.toArray(new Principal[l.size()]);
    }
    private boolean matchesDN(X500Principal subjectGeneralNames targets)
    {
        GeneralName[] names = targets.getNames();
        for (int i = 0; i != names.lengthi++)
        {
            GeneralName gn = names[i];
            if (gn.getTagNo() == .)
            {
                try
                {
                    if (new X500Principal(((ASN1Encodable)gn.getName()).toASN1Primitive().getEncoded()).equals(subject))
                    {
                        return true;
                    }
                }
                catch (IOException e)
                {
                }
            }
        }
        return false;
    }
    public Object clone()
    {
        return new AttributeCertificateIssuer(AttCertIssuer.getInstance());
    }
    public boolean match(Certificate cert)
    {
        if (!(cert instanceof X509Certificate))
        {
            return false;
        }
        X509Certificate x509Cert = (X509Certificate)cert;
        if ( instanceof V2Form)
        {
            V2Form issuer = (V2Form);
            if (issuer.getBaseCertificateID() != null)
            {
                return issuer.getBaseCertificateID().getSerial().getValue().equals(x509Cert.getSerialNumber())
                    && matchesDN(x509Cert.getIssuerX500Principal(), issuer.getBaseCertificateID().getIssuer());
            }
            GeneralNames name = issuer.getIssuerName();
            if (matchesDN(x509Cert.getSubjectX500Principal(), name))
            {
                return true;
            }
        }
        else
        {
            GeneralNames name = (GeneralNames);
            if (matchesDN(x509Cert.getSubjectX500Principal(), name))
            {
                return true;
            }
        }
        return false;
    }
    public boolean equals(Object obj)
    {
        if (obj == this)
        {
            return true;
        }
        if (!(obj instanceof AttributeCertificateIssuer))
        {
            return false;
        }
        return this..equals(other.form);
    }
    public int hashCode()
    {
        return this..hashCode();
    }
    public boolean match(Object obj)
    {
        if (!(obj instanceof X509Certificate))
        {
            return false;
        }
        return match((Certificate)obj);
    }
New to GrepCode? Check out our FAQ X