bcpkix-jdk15on-147

16:33:07.729 INFO  jd.cli.Main - Decompiling bcpkix-jdk15on-147.jar
package org.bouncycastle.cert;

import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DEREnumerated;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.Holder;
import org.bouncycastle.asn1.x509.IssuerSerial;
import org.bouncycastle.asn1.x509.ObjectDigestInfo;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.DigestCalculator;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Selector;

public class AttributeCertificateHolder
  implements Selector
{
  private static DigestCalculatorProvider digestCalculatorProvider;
  final Holder holder;
  
  AttributeCertificateHolder(ASN1Sequence paramASN1Sequence)
  {
    holder = Holder.getInstance(paramASN1Sequence);
  }
  
  public AttributeCertificateHolder(X500Name paramX500Name, BigInteger paramBigInteger)
  {
    holder = new Holder(new IssuerSerial(new GeneralNames(new GeneralName(paramX500Name)), new ASN1Integer(paramBigInteger)));
  }
  
  public AttributeCertificateHolder(X509CertificateHolder paramX509CertificateHolder)
  {
    holder = new Holder(new IssuerSerial(generateGeneralNames(paramX509CertificateHolder.getIssuer()), new ASN1Integer(paramX509CertificateHolder.getSerialNumber())));
  }
  
  public AttributeCertificateHolder(X500Name paramX500Name)
  {
    holder = new Holder(generateGeneralNames(paramX500Name));
  }
  
  public AttributeCertificateHolder(int paramInt, ASN1ObjectIdentifier paramASN1ObjectIdentifier1, ASN1ObjectIdentifier paramASN1ObjectIdentifier2, byte[] paramArrayOfByte)
  {
    holder = new Holder(new ObjectDigestInfo(paramInt, paramASN1ObjectIdentifier2, new AlgorithmIdentifier(paramASN1ObjectIdentifier1), Arrays.clone(paramArrayOfByte)));
  }
  
  public int getDigestedObjectType()
  {
    if (holder.getObjectDigestInfo() != null) {
      return holder.getObjectDigestInfo().getDigestedObjectType().getValue().intValue();
    }
    return -1;
  }
  
  public AlgorithmIdentifier getDigestAlgorithm()
  {
    if (holder.getObjectDigestInfo() != null) {
      return holder.getObjectDigestInfo().getDigestAlgorithm();
    }
    return null;
  }
  
  public byte[] getObjectDigest()
  {
    if (holder.getObjectDigestInfo() != null) {
      return holder.getObjectDigestInfo().getObjectDigest().getBytes();
    }
    return null;
  }
  
  public ASN1ObjectIdentifier getOtherObjectTypeID()
  {
    if (holder.getObjectDigestInfo() != null) {
      new ASN1ObjectIdentifier(holder.getObjectDigestInfo().getOtherObjectTypeID().getId());
    }
    return null;
  }
  
  private GeneralNames generateGeneralNames(X500Name paramX500Name)
  {
    return new GeneralNames(new GeneralName(paramX500Name));
  }
  
  private boolean matchesDN(X500Name paramX500Name, GeneralNames paramGeneralNames)
  {
    GeneralName[] arrayOfGeneralName = paramGeneralNames.getNames();
    for (int i = 0; i != arrayOfGeneralName.length; i++)
    {
      GeneralName localGeneralName = arrayOfGeneralName[i];
      if ((localGeneralName.getTagNo() == 4) && (X500Name.getInstance(localGeneralName.getName()).equals(paramX500Name))) {
        return true;
      }
    }
    return false;
  }
  
  private X500Name[] getPrincipals(GeneralName[] paramArrayOfGeneralName)
  {
    ArrayList localArrayList = new ArrayList(paramArrayOfGeneralName.length);
    for (int i = 0; i != paramArrayOfGeneralName.length; i++) {
      if (paramArrayOfGeneralName[i].getTagNo() == 4) {
        localArrayList.add(X500Name.getInstance(paramArrayOfGeneralName[i].getName()));
      }
    }
    return (X500Name[])localArrayList.toArray(new X500Name[localArrayList.size()]);
  }
  
  public X500Name[] getEntityNames()
  {
    if (holder.getEntityName() != null) {
      return getPrincipals(holder.getEntityName().getNames());
    }
    return null;
  }
  
  public X500Name[] getIssuer()
  {
    if (holder.getBaseCertificateID() != null) {
      return getPrincipals(holder.getBaseCertificateID().getIssuer().getNames());
    }
    return null;
  }
  
  public BigInteger getSerialNumber()
  {
    if (holder.getBaseCertificateID() != null) {
      return holder.getBaseCertificateID().getSerial().getValue();
    }
    return null;
  }
  
  public Object clone()
  {
    return new AttributeCertificateHolder((ASN1Sequence)holder.toASN1Object());
  }
  
  public boolean match(Object paramObject)
  {
    if (!(paramObject instanceof X509CertificateHolder)) {
      return false;
    }
    X509CertificateHolder localX509CertificateHolder = (X509CertificateHolder)paramObject;
    if (holder.getBaseCertificateID() != null) {
      return (holder.getBaseCertificateID().getSerial().getValue().equals(localX509CertificateHolder.getSerialNumber())) && (matchesDN(localX509CertificateHolder.getIssuer(), holder.getBaseCertificateID().getIssuer()));
    }
    if ((holder.getEntityName() != null) && (matchesDN(localX509CertificateHolder.getSubject(), holder.getEntityName()))) {
      return true;
    }
    if (holder.getObjectDigestInfo() != null) {
      try
      {
        DigestCalculator localDigestCalculator = digestCalculatorProvider.get(holder.getObjectDigestInfo().getDigestAlgorithm());
        OutputStream localOutputStream = localDigestCalculator.getOutputStream();
        switch (getDigestedObjectType())
        {
        case 0: 
          localOutputStream.write(localX509CertificateHolder.getSubjectPublicKeyInfo().getEncoded());
          break;
        case 1: 
          localOutputStream.write(localX509CertificateHolder.getEncoded());
        }
        localOutputStream.close();
        if (!Arrays.areEqual(localDigestCalculator.getDigest(), getObjectDigest())) {
          return false;
        }
      }
      catch (Exception localException)
      {
        return false;
      }
    }
    return false;
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof AttributeCertificateHolder)) {
      return false;
    }
    AttributeCertificateHolder localAttributeCertificateHolder = (AttributeCertificateHolder)paramObject;
    return holder.equals(holder);
  }
  
  public int hashCode()
  {
    return holder.hashCode();
  }
  
  public static void setDigestCalculatorProvider(DigestCalculatorProvider paramDigestCalculatorProvider)
  {
    digestCalculatorProvider = paramDigestCalculatorProvider;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.AttributeCertificateHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AttCertIssuer;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.IssuerSerial;
import org.bouncycastle.asn1.x509.V2Form;
import org.bouncycastle.util.Selector;

public class AttributeCertificateIssuer
  implements Selector
{
  final ASN1Encodable form;
  
  public AttributeCertificateIssuer(AttCertIssuer paramAttCertIssuer)
  {
    form = paramAttCertIssuer.getIssuer();
  }
  
  public AttributeCertificateIssuer(X500Name paramX500Name)
  {
    form = new V2Form(new GeneralNames(new GeneralName(paramX500Name)));
  }
  
  public X500Name[] getNames()
  {
    GeneralNames localGeneralNames;
    if ((form instanceof V2Form)) {
      localGeneralNames = ((V2Form)form).getIssuerName();
    } else {
      localGeneralNames = (GeneralNames)form;
    }
    GeneralName[] arrayOfGeneralName = localGeneralNames.getNames();
    ArrayList localArrayList = new ArrayList(arrayOfGeneralName.length);
    for (int i = 0; i != arrayOfGeneralName.length; i++) {
      if (arrayOfGeneralName[i].getTagNo() == 4) {
        localArrayList.add(X500Name.getInstance(arrayOfGeneralName[i].getName()));
      }
    }
    return (X500Name[])localArrayList.toArray(new X500Name[localArrayList.size()]);
  }
  
  private boolean matchesDN(X500Name paramX500Name, GeneralNames paramGeneralNames)
  {
    GeneralName[] arrayOfGeneralName = paramGeneralNames.getNames();
    for (int i = 0; i != arrayOfGeneralName.length; i++)
    {
      GeneralName localGeneralName = arrayOfGeneralName[i];
      if ((localGeneralName.getTagNo() == 4) && (X500Name.getInstance(localGeneralName.getName()).equals(paramX500Name))) {
        return true;
      }
    }
    return false;
  }
  
  public Object clone()
  {
    return new AttributeCertificateIssuer(AttCertIssuer.getInstance(form));
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof AttributeCertificateIssuer)) {
      return false;
    }
    AttributeCertificateIssuer localAttributeCertificateIssuer = (AttributeCertificateIssuer)paramObject;
    return form.equals(form);
  }
  
  public int hashCode()
  {
    return form.hashCode();
  }
  
  public boolean match(Object paramObject)
  {
    if (!(paramObject instanceof X509CertificateHolder)) {
      return false;
    }
    X509CertificateHolder localX509CertificateHolder = (X509CertificateHolder)paramObject;
    Object localObject;
    if ((form instanceof V2Form))
    {
      localObject = (V2Form)form;
      if (((V2Form)localObject).getBaseCertificateID() != null) {
        return (((V2Form)localObject).getBaseCertificateID().getSerial().getValue().equals(localX509CertificateHolder.getSerialNumber())) && (matchesDN(localX509CertificateHolder.getIssuer(), ((V2Form)localObject).getBaseCertificateID().getIssuer()));
      }
      GeneralNames localGeneralNames = ((V2Form)localObject).getIssuerName();
      if (matchesDN(localX509CertificateHolder.getSubject(), localGeneralNames)) {
        return true;
      }
    }
    else
    {
      localObject = (GeneralNames)form;
      if (matchesDN(localX509CertificateHolder.getSubject(), (GeneralNames)localObject)) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.AttributeCertificateIssuer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

public class CertException
  extends Exception
{
  private Throwable cause;
  
  public CertException(String paramString, Throwable paramThrowable)
  {
    super(paramString);
    cause = paramThrowable;
  }
  
  public CertException(String paramString)
  {
    super(paramString);
  }
  
  public Throwable getCause()
  {
    return cause;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.CertException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.io.IOException;

public class CertIOException
  extends IOException
{
  private Throwable cause;
  
  public CertIOException(String paramString, Throwable paramThrowable)
  {
    super(paramString);
    cause = paramThrowable;
  }
  
  public CertIOException(String paramString)
  {
    super(paramString);
  }
  
  public Throwable getCause()
  {
    return cause;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.CertIOException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERGeneralizedTime;
import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.AttributeCertificate;
import org.bouncycastle.asn1.x509.AttributeCertificateInfo;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.ExtensionsGenerator;
import org.bouncycastle.asn1.x509.TBSCertList;
import org.bouncycastle.asn1.x509.TBSCertificate;
import org.bouncycastle.operator.ContentSigner;

class CertUtils
{
  private static Set EMPTY_SET = Collections.unmodifiableSet(new HashSet());
  private static List EMPTY_LIST = Collections.unmodifiableList(new ArrayList());
  
  static X509CertificateHolder generateFullCert(ContentSigner paramContentSigner, TBSCertificate paramTBSCertificate)
  {
    try
    {
      return new X509CertificateHolder(generateStructure(paramTBSCertificate, paramContentSigner.getAlgorithmIdentifier(), generateSig(paramContentSigner, paramTBSCertificate)));
    }
    catch (IOException localIOException)
    {
      throw new IllegalStateException("cannot produce certificate signature");
    }
  }
  
  static X509AttributeCertificateHolder generateFullAttrCert(ContentSigner paramContentSigner, AttributeCertificateInfo paramAttributeCertificateInfo)
  {
    try
    {
      return new X509AttributeCertificateHolder(generateAttrStructure(paramAttributeCertificateInfo, paramContentSigner.getAlgorithmIdentifier(), generateSig(paramContentSigner, paramAttributeCertificateInfo)));
    }
    catch (IOException localIOException)
    {
      throw new IllegalStateException("cannot produce attribute certificate signature");
    }
  }
  
  static X509CRLHolder generateFullCRL(ContentSigner paramContentSigner, TBSCertList paramTBSCertList)
  {
    try
    {
      return new X509CRLHolder(generateCRLStructure(paramTBSCertList, paramContentSigner.getAlgorithmIdentifier(), generateSig(paramContentSigner, paramTBSCertList)));
    }
    catch (IOException localIOException)
    {
      throw new IllegalStateException("cannot produce certificate signature");
    }
  }
  
  private static byte[] generateSig(ContentSigner paramContentSigner, ASN1Encodable paramASN1Encodable)
    throws IOException
  {
    OutputStream localOutputStream = paramContentSigner.getOutputStream();
    DEROutputStream localDEROutputStream = new DEROutputStream(localOutputStream);
    localDEROutputStream.writeObject(paramASN1Encodable);
    localOutputStream.close();
    return paramContentSigner.getSignature();
  }
  
  private static Certificate generateStructure(TBSCertificate paramTBSCertificate, AlgorithmIdentifier paramAlgorithmIdentifier, byte[] paramArrayOfByte)
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(paramTBSCertificate);
    localASN1EncodableVector.add(paramAlgorithmIdentifier);
    localASN1EncodableVector.add(new DERBitString(paramArrayOfByte));
    return Certificate.getInstance(new DERSequence(localASN1EncodableVector));
  }
  
  private static AttributeCertificate generateAttrStructure(AttributeCertificateInfo paramAttributeCertificateInfo, AlgorithmIdentifier paramAlgorithmIdentifier, byte[] paramArrayOfByte)
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(paramAttributeCertificateInfo);
    localASN1EncodableVector.add(paramAlgorithmIdentifier);
    localASN1EncodableVector.add(new DERBitString(paramArrayOfByte));
    return AttributeCertificate.getInstance(new DERSequence(localASN1EncodableVector));
  }
  
  private static CertificateList generateCRLStructure(TBSCertList paramTBSCertList, AlgorithmIdentifier paramAlgorithmIdentifier, byte[] paramArrayOfByte)
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(paramTBSCertList);
    localASN1EncodableVector.add(paramAlgorithmIdentifier);
    localASN1EncodableVector.add(new DERBitString(paramArrayOfByte));
    return CertificateList.getInstance(new DERSequence(localASN1EncodableVector));
  }
  
  static Set getCriticalExtensionOIDs(Extensions paramExtensions)
  {
    if (paramExtensions == null) {
      return EMPTY_SET;
    }
    return Collections.unmodifiableSet(new HashSet(Arrays.asList(paramExtensions.getCriticalExtensionOIDs())));
  }
  
  static Set getNonCriticalExtensionOIDs(Extensions paramExtensions)
  {
    if (paramExtensions == null) {
      return EMPTY_SET;
    }
    return Collections.unmodifiableSet(new HashSet(Arrays.asList(paramExtensions.getNonCriticalExtensionOIDs())));
  }
  
  static List getExtensionOIDs(Extensions paramExtensions)
  {
    if (paramExtensions == null) {
      return EMPTY_LIST;
    }
    return Collections.unmodifiableList(Arrays.asList(paramExtensions.getExtensionOIDs()));
  }
  
  static void addExtension(ExtensionsGenerator paramExtensionsGenerator, ASN1ObjectIdentifier paramASN1ObjectIdentifier, boolean paramBoolean, ASN1Encodable paramASN1Encodable)
    throws CertIOException
  {
    try
    {
      paramExtensionsGenerator.addExtension(paramASN1ObjectIdentifier, paramBoolean, paramASN1Encodable);
    }
    catch (IOException localIOException)
    {
      throw new CertIOException("cannot encode extension: " + localIOException.getMessage(), localIOException);
    }
  }
  
  static DERBitString booleanToBitString(boolean[] paramArrayOfBoolean)
  {
    byte[] arrayOfByte = new byte[(paramArrayOfBoolean.length + 7) / 8];
    for (int i = 0; i != paramArrayOfBoolean.length; i++)
    {
      int tmp24_23 = (i / 8);
      byte[] tmp24_19 = arrayOfByte;
      tmp24_19[tmp24_23] = ((byte)(tmp24_19[tmp24_23] | (paramArrayOfBoolean[i] != 0 ? 1 << 7 - i % 8 : 0)));
    }
    i = paramArrayOfBoolean.length % 8;
    if (i == 0) {
      return new DERBitString(arrayOfByte);
    }
    return new DERBitString(arrayOfByte, 8 - i);
  }
  
  static boolean[] bitStringToBoolean(DERBitString paramDERBitString)
  {
    if (paramDERBitString != null)
    {
      byte[] arrayOfByte = paramDERBitString.getBytes();
      boolean[] arrayOfBoolean = new boolean[arrayOfByte.length * 8 - paramDERBitString.getPadBits()];
      for (int i = 0; i != arrayOfBoolean.length; i++) {
        arrayOfBoolean[i] = ((arrayOfByte[(i / 8)] & 128 >>> i % 8) != 0 ? 1 : false);
      }
      return arrayOfBoolean;
    }
    return null;
  }
  
  static Date recoverDate(DERGeneralizedTime paramDERGeneralizedTime)
  {
    try
    {
      return paramDERGeneralizedTime.getDate();
    }
    catch (ParseException localParseException)
    {
      throw new IllegalStateException("unable to recover date: " + localParseException.getMessage());
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.CertUtils
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.AttCertValidityPeriod;
import org.bouncycastle.asn1.x509.Attribute;
import org.bouncycastle.asn1.x509.AttributeCertificate;
import org.bouncycastle.asn1.x509.AttributeCertificateInfo;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.Holder;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;

public class X509AttributeCertificateHolder
{
  private static Attribute[] EMPTY_ARRAY = new Attribute[0];
  private AttributeCertificate attrCert;
  private Extensions extensions;
  
  private static AttributeCertificate parseBytes(byte[] paramArrayOfByte)
    throws IOException
  {
    try
    {
      return AttributeCertificate.getInstance(ASN1Primitive.fromByteArray(paramArrayOfByte));
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CertIOException("malformed data: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new CertIOException("malformed data: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
  }
  
  public X509AttributeCertificateHolder(byte[] paramArrayOfByte)
    throws IOException
  {
    this(parseBytes(paramArrayOfByte));
  }
  
  public X509AttributeCertificateHolder(AttributeCertificate paramAttributeCertificate)
  {
    attrCert = paramAttributeCertificate;
    extensions = paramAttributeCertificate.getAcinfo().getExtensions();
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return attrCert.getEncoded();
  }
  
  public int getVersion()
  {
    return attrCert.getAcinfo().getVersion().getValue().intValue() + 1;
  }
  
  public BigInteger getSerialNumber()
  {
    return attrCert.getAcinfo().getSerialNumber().getValue();
  }
  
  public AttributeCertificateHolder getHolder()
  {
    return new AttributeCertificateHolder((ASN1Sequence)attrCert.getAcinfo().getHolder().toASN1Primitive());
  }
  
  public AttributeCertificateIssuer getIssuer()
  {
    return new AttributeCertificateIssuer(attrCert.getAcinfo().getIssuer());
  }
  
  public Date getNotBefore()
  {
    return CertUtils.recoverDate(attrCert.getAcinfo().getAttrCertValidityPeriod().getNotBeforeTime());
  }
  
  public Date getNotAfter()
  {
    return CertUtils.recoverDate(attrCert.getAcinfo().getAttrCertValidityPeriod().getNotAfterTime());
  }
  
  public Attribute[] getAttributes()
  {
    ASN1Sequence localASN1Sequence = attrCert.getAcinfo().getAttributes();
    Attribute[] arrayOfAttribute = new Attribute[localASN1Sequence.size()];
    for (int i = 0; i != localASN1Sequence.size(); i++) {
      arrayOfAttribute[i] = Attribute.getInstance(localASN1Sequence.getObjectAt(i));
    }
    return arrayOfAttribute;
  }
  
  public Attribute[] getAttributes(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    ASN1Sequence localASN1Sequence = attrCert.getAcinfo().getAttributes();
    ArrayList localArrayList = new ArrayList();
    for (int i = 0; i != localASN1Sequence.size(); i++)
    {
      Attribute localAttribute = Attribute.getInstance(localASN1Sequence.getObjectAt(i));
      if (localAttribute.getAttrType().equals(paramASN1ObjectIdentifier)) {
        localArrayList.add(localAttribute);
      }
    }
    if (localArrayList.size() == 0) {
      return EMPTY_ARRAY;
    }
    return (Attribute[])localArrayList.toArray(new Attribute[localArrayList.size()]);
  }
  
  public boolean hasExtensions()
  {
    return extensions != null;
  }
  
  public Extension getExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    if (extensions != null) {
      return extensions.getExtension(paramASN1ObjectIdentifier);
    }
    return null;
  }
  
  public List getExtensionOIDs()
  {
    return CertUtils.getExtensionOIDs(extensions);
  }
  
  public Set getCriticalExtensionOIDs()
  {
    return CertUtils.getCriticalExtensionOIDs(extensions);
  }
  
  public Set getNonCriticalExtensionOIDs()
  {
    return CertUtils.getNonCriticalExtensionOIDs(extensions);
  }
  
  public boolean[] getIssuerUniqueID()
  {
    return CertUtils.bitStringToBoolean(attrCert.getAcinfo().getIssuerUniqueID());
  }
  
  public AlgorithmIdentifier getSignatureAlgorithm()
  {
    return attrCert.getSignatureAlgorithm();
  }
  
  public byte[] getSignature()
  {
    return attrCert.getSignatureValue().getBytes();
  }
  
  public AttributeCertificate toASN1Structure()
  {
    return attrCert;
  }
  
  public boolean isValidOn(Date paramDate)
  {
    AttCertValidityPeriod localAttCertValidityPeriod = attrCert.getAcinfo().getAttrCertValidityPeriod();
    return (!paramDate.before(CertUtils.recoverDate(localAttCertValidityPeriod.getNotBeforeTime()))) && (!paramDate.after(CertUtils.recoverDate(localAttCertValidityPeriod.getNotAfterTime())));
  }
  
  public boolean isSignatureValid(ContentVerifierProvider paramContentVerifierProvider)
    throws CertException
  {
    AttributeCertificateInfo localAttributeCertificateInfo = attrCert.getAcinfo();
    if (!localAttributeCertificateInfo.getSignature().equals(attrCert.getSignatureAlgorithm())) {
      throw new CertException("signature invalid - algorithm identifier mismatch");
    }
    ContentVerifier localContentVerifier;
    try
    {
      localContentVerifier = paramContentVerifierProvider.get(localAttributeCertificateInfo.getSignature());
      OutputStream localOutputStream = localContentVerifier.getOutputStream();
      DEROutputStream localDEROutputStream = new DEROutputStream(localOutputStream);
      localDEROutputStream.writeObject(localAttributeCertificateInfo);
      localOutputStream.close();
    }
    catch (Exception localException)
    {
      throw new CertException("unable to process signature: " + localException.getMessage(), localException);
    }
    return localContentVerifier.verify(attrCert.getSignatureValue().getBytes());
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof X509AttributeCertificateHolder)) {
      return false;
    }
    X509AttributeCertificateHolder localX509AttributeCertificateHolder = (X509AttributeCertificateHolder)paramObject;
    return attrCert.equals(attrCert);
  }
  
  public int hashCode()
  {
    return attrCert.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509AttributeCertificateHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.TBSCertList.CRLEntry;
import org.bouncycastle.asn1.x509.Time;

public class X509CRLEntryHolder
{
  private TBSCertList.CRLEntry entry;
  private GeneralNames ca;
  
  X509CRLEntryHolder(TBSCertList.CRLEntry paramCRLEntry, boolean paramBoolean, GeneralNames paramGeneralNames)
  {
    entry = paramCRLEntry;
    ca = paramGeneralNames;
    if ((paramBoolean) && (paramCRLEntry.hasExtensions()))
    {
      Extension localExtension = paramCRLEntry.getExtensions().getExtension(Extension.certificateIssuer);
      if (localExtension != null) {
        ca = GeneralNames.getInstance(localExtension.getParsedValue());
      }
    }
  }
  
  public BigInteger getSerialNumber()
  {
    return entry.getUserCertificate().getValue();
  }
  
  public Date getRevocationDate()
  {
    return entry.getRevocationDate().getDate();
  }
  
  public boolean hasExtensions()
  {
    return entry.hasExtensions();
  }
  
  public GeneralNames getCertificateIssuer()
  {
    return ca;
  }
  
  public Extension getExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    Extensions localExtensions = entry.getExtensions();
    if (localExtensions != null) {
      return localExtensions.getExtension(paramASN1ObjectIdentifier);
    }
    return null;
  }
  
  public List getExtensionOIDs()
  {
    return CertUtils.getExtensionOIDs(entry.getExtensions());
  }
  
  public Set getCriticalExtensionOIDs()
  {
    return CertUtils.getCriticalExtensionOIDs(entry.getExtensions());
  }
  
  public Set getNonCriticalExtensionOIDs()
  {
    return CertUtils.getNonCriticalExtensionOIDs(entry.getExtensions());
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509CRLEntryHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.IssuingDistributionPoint;
import org.bouncycastle.asn1.x509.TBSCertList;
import org.bouncycastle.asn1.x509.TBSCertList.CRLEntry;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;

public class X509CRLHolder
{
  private CertificateList x509CRL;
  private boolean isIndirect;
  private Extensions extensions;
  private GeneralNames issuerName;
  
  private static CertificateList parseStream(InputStream paramInputStream)
    throws IOException
  {
    try
    {
      return CertificateList.getInstance(new ASN1InputStream(paramInputStream, true).readObject());
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CertIOException("malformed data: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new CertIOException("malformed data: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
  }
  
  private static boolean isIndirectCRL(Extensions paramExtensions)
  {
    if (paramExtensions == null) {
      return false;
    }
    Extension localExtension = paramExtensions.getExtension(Extension.issuingDistributionPoint);
    return (localExtension != null) && (IssuingDistributionPoint.getInstance(localExtension.getParsedValue()).isIndirectCRL());
  }
  
  public X509CRLHolder(byte[] paramArrayOfByte)
    throws IOException
  {
    this(parseStream(new ByteArrayInputStream(paramArrayOfByte)));
  }
  
  public X509CRLHolder(InputStream paramInputStream)
    throws IOException
  {
    this(parseStream(paramInputStream));
  }
  
  public X509CRLHolder(CertificateList paramCertificateList)
  {
    x509CRL = paramCertificateList;
    extensions = paramCertificateList.getTBSCertList().getExtensions();
    isIndirect = isIndirectCRL(extensions);
    issuerName = new GeneralNames(new GeneralName(paramCertificateList.getIssuer()));
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return x509CRL.getEncoded();
  }
  
  public X500Name getIssuer()
  {
    return X500Name.getInstance(x509CRL.getIssuer());
  }
  
  public X509CRLEntryHolder getRevokedCertificate(BigInteger paramBigInteger)
  {
    GeneralNames localGeneralNames = issuerName;
    Enumeration localEnumeration = x509CRL.getRevokedCertificateEnumeration();
    while (localEnumeration.hasMoreElements())
    {
      TBSCertList.CRLEntry localCRLEntry = (TBSCertList.CRLEntry)localEnumeration.nextElement();
      if (localCRLEntry.getUserCertificate().getValue().equals(paramBigInteger)) {
        return new X509CRLEntryHolder(localCRLEntry, isIndirect, localGeneralNames);
      }
      if ((isIndirect) && (localCRLEntry.hasExtensions()))
      {
        Extension localExtension = localCRLEntry.getExtensions().getExtension(Extension.certificateIssuer);
        if (localExtension != null) {
          localGeneralNames = GeneralNames.getInstance(localExtension.getParsedValue());
        }
      }
    }
    return null;
  }
  
  public Collection getRevokedCertificates()
  {
    TBSCertList.CRLEntry[] arrayOfCRLEntry = x509CRL.getRevokedCertificates();
    ArrayList localArrayList = new ArrayList(arrayOfCRLEntry.length);
    GeneralNames localGeneralNames = issuerName;
    Enumeration localEnumeration = x509CRL.getRevokedCertificateEnumeration();
    while (localEnumeration.hasMoreElements())
    {
      TBSCertList.CRLEntry localCRLEntry = (TBSCertList.CRLEntry)localEnumeration.nextElement();
      X509CRLEntryHolder localX509CRLEntryHolder = new X509CRLEntryHolder(localCRLEntry, isIndirect, localGeneralNames);
      localArrayList.add(localX509CRLEntryHolder);
      localGeneralNames = localX509CRLEntryHolder.getCertificateIssuer();
    }
    return localArrayList;
  }
  
  public boolean hasExtensions()
  {
    return extensions != null;
  }
  
  public Extension getExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    if (extensions != null) {
      return extensions.getExtension(paramASN1ObjectIdentifier);
    }
    return null;
  }
  
  public List getExtensionOIDs()
  {
    return CertUtils.getExtensionOIDs(extensions);
  }
  
  public Set getCriticalExtensionOIDs()
  {
    return CertUtils.getCriticalExtensionOIDs(extensions);
  }
  
  public Set getNonCriticalExtensionOIDs()
  {
    return CertUtils.getNonCriticalExtensionOIDs(extensions);
  }
  
  public CertificateList toASN1Structure()
  {
    return x509CRL;
  }
  
  public boolean isSignatureValid(ContentVerifierProvider paramContentVerifierProvider)
    throws CertException
  {
    TBSCertList localTBSCertList = x509CRL.getTBSCertList();
    if (!localTBSCertList.getSignature().equals(x509CRL.getSignatureAlgorithm())) {
      throw new CertException("signature invalid - algorithm identifier mismatch");
    }
    ContentVerifier localContentVerifier;
    try
    {
      localContentVerifier = paramContentVerifierProvider.get(localTBSCertList.getSignature());
      OutputStream localOutputStream = localContentVerifier.getOutputStream();
      DEROutputStream localDEROutputStream = new DEROutputStream(localOutputStream);
      localDEROutputStream.writeObject(localTBSCertList);
      localOutputStream.close();
    }
    catch (Exception localException)
    {
      throw new CertException("unable to process signature: " + localException.getMessage(), localException);
    }
    return localContentVerifier.verify(x509CRL.getSignature().getBytes());
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof X509CRLHolder)) {
      return false;
    }
    X509CRLHolder localX509CRLHolder = (X509CRLHolder)paramObject;
    return x509CRL.equals(x509CRL);
  }
  
  public int hashCode()
  {
    return x509CRL.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509CRLHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x509.TBSCertificate;
import org.bouncycastle.asn1.x509.Time;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;

public class X509CertificateHolder
{
  private Certificate x509Certificate;
  private Extensions extensions;
  
  private static Certificate parseBytes(byte[] paramArrayOfByte)
    throws IOException
  {
    try
    {
      return Certificate.getInstance(ASN1Primitive.fromByteArray(paramArrayOfByte));
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CertIOException("malformed data: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new CertIOException("malformed data: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
  }
  
  public X509CertificateHolder(byte[] paramArrayOfByte)
    throws IOException
  {
    this(parseBytes(paramArrayOfByte));
  }
  
  public X509CertificateHolder(Certificate paramCertificate)
  {
    x509Certificate = paramCertificate;
    extensions = paramCertificate.getTBSCertificate().getExtensions();
  }
  
  public int getVersionNumber()
  {
    return x509Certificate.getVersionNumber();
  }
  
  /**
   * @deprecated
   */
  public int getVersion()
  {
    return x509Certificate.getVersionNumber();
  }
  
  public boolean hasExtensions()
  {
    return extensions != null;
  }
  
  public Extension getExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    if (extensions != null) {
      return extensions.getExtension(paramASN1ObjectIdentifier);
    }
    return null;
  }
  
  public List getExtensionOIDs()
  {
    return CertUtils.getExtensionOIDs(extensions);
  }
  
  public Set getCriticalExtensionOIDs()
  {
    return CertUtils.getCriticalExtensionOIDs(extensions);
  }
  
  public Set getNonCriticalExtensionOIDs()
  {
    return CertUtils.getNonCriticalExtensionOIDs(extensions);
  }
  
  public BigInteger getSerialNumber()
  {
    return x509Certificate.getSerialNumber().getValue();
  }
  
  public X500Name getIssuer()
  {
    return X500Name.getInstance(x509Certificate.getIssuer());
  }
  
  public X500Name getSubject()
  {
    return X500Name.getInstance(x509Certificate.getSubject());
  }
  
  public Date getNotBefore()
  {
    return x509Certificate.getStartDate().getDate();
  }
  
  public Date getNotAfter()
  {
    return x509Certificate.getEndDate().getDate();
  }
  
  public SubjectPublicKeyInfo getSubjectPublicKeyInfo()
  {
    return x509Certificate.getSubjectPublicKeyInfo();
  }
  
  public Certificate toASN1Structure()
  {
    return x509Certificate;
  }
  
  public AlgorithmIdentifier getSignatureAlgorithm()
  {
    return x509Certificate.getSignatureAlgorithm();
  }
  
  public byte[] getSignature()
  {
    return x509Certificate.getSignature().getBytes();
  }
  
  public boolean isValidOn(Date paramDate)
  {
    return (!paramDate.before(x509Certificate.getStartDate().getDate())) && (!paramDate.after(x509Certificate.getEndDate().getDate()));
  }
  
  public boolean isSignatureValid(ContentVerifierProvider paramContentVerifierProvider)
    throws CertException
  {
    TBSCertificate localTBSCertificate = x509Certificate.getTBSCertificate();
    if (!localTBSCertificate.getSignature().equals(x509Certificate.getSignatureAlgorithm())) {
      throw new CertException("signature invalid - algorithm identifier mismatch");
    }
    ContentVerifier localContentVerifier;
    try
    {
      localContentVerifier = paramContentVerifierProvider.get(localTBSCertificate.getSignature());
      OutputStream localOutputStream = localContentVerifier.getOutputStream();
      DEROutputStream localDEROut
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd