bcpkix-jdk15on-147

putStream = new DEROutputStream(localOutputStream);
      localDEROutputStream.writeObject(localTBSCertificate);
      localOutputStream.close();
    }
    catch (Exception localException)
    {
      throw new CertException("unable to process signature: " + localException.getMessage(), localException);
    }
    return localContentVerifier.verify(x509Certificate.getSignature().getBytes());
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof X509CertificateHolder)) {
      return false;
    }
    X509CertificateHolder localX509CertificateHolder = (X509CertificateHolder)paramObject;
    return x509Certificate.equals(x509Certificate);
  }
  
  public int hashCode()
  {
    return x509Certificate.hashCode();
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return x509Certificate.getEncoded();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509CertificateHolder
 * 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 org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.SubjectKeyIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.DigestCalculator;

public class X509ExtensionUtils
{
  private DigestCalculator calculator;
  
  public X509ExtensionUtils(DigestCalculator paramDigestCalculator)
  {
    calculator = paramDigestCalculator;
  }
  
  public AuthorityKeyIdentifier createAuthorityKeyIdentifier(X509CertificateHolder paramX509CertificateHolder)
  {
    if (paramX509CertificateHolder.getVersionNumber() != 3)
    {
      localGeneralName = new GeneralName(paramX509CertificateHolder.getIssuer());
      localObject1 = paramX509CertificateHolder.getSubjectPublicKeyInfo();
      return new AuthorityKeyIdentifier(calculateIdentifier((SubjectPublicKeyInfo)localObject1), new GeneralNames(localGeneralName), paramX509CertificateHolder.getSerialNumber());
    }
    GeneralName localGeneralName = new GeneralName(paramX509CertificateHolder.getIssuer());
    Object localObject1 = paramX509CertificateHolder.getExtension(Extension.subjectKeyIdentifier);
    if (localObject1 != null)
    {
      localObject2 = ASN1OctetString.getInstance(((Extension)localObject1).getParsedValue());
      return new AuthorityKeyIdentifier(((ASN1OctetString)localObject2).getOctets(), new GeneralNames(localGeneralName), paramX509CertificateHolder.getSerialNumber());
    }
    Object localObject2 = paramX509CertificateHolder.getSubjectPublicKeyInfo();
    return new AuthorityKeyIdentifier(calculateIdentifier((SubjectPublicKeyInfo)localObject2), new GeneralNames(localGeneralName), paramX509CertificateHolder.getSerialNumber());
  }
  
  public AuthorityKeyIdentifier createAuthorityKeyIdentifier(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    return new AuthorityKeyIdentifier(calculateIdentifier(paramSubjectPublicKeyInfo));
  }
  
  public SubjectKeyIdentifier createSubjectKeyIdentifier(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    return new SubjectKeyIdentifier(calculateIdentifier(paramSubjectPublicKeyInfo));
  }
  
  public SubjectKeyIdentifier createTruncatedSubjectKeyIdentifier(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    byte[] arrayOfByte1 = calculateIdentifier(paramSubjectPublicKeyInfo);
    byte[] arrayOfByte2 = new byte[8];
    System.arraycopy(arrayOfByte1, arrayOfByte1.length - 8, arrayOfByte2, 0, arrayOfByte2.length);
    int tmp26_25 = 0;
    byte[] tmp26_24 = arrayOfByte2;
    tmp26_24[tmp26_25] = ((byte)(tmp26_24[tmp26_25] & 0xF));
    int tmp35_34 = 0;
    byte[] tmp35_33 = arrayOfByte2;
    tmp35_33[tmp35_34] = ((byte)(tmp35_33[tmp35_34] | 0x40));
    return new SubjectKeyIdentifier(arrayOfByte2);
  }
  
  private byte[] calculateIdentifier(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    byte[] arrayOfByte = paramSubjectPublicKeyInfo.getPublicKeyData().getBytes();
    OutputStream localOutputStream = calculator.getOutputStream();
    try
    {
      localOutputStream.write(arrayOfByte);
      localOutputStream.close();
    }
    catch (IOException localIOException) {}
    return calculator.getDigest();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509ExtensionUtils
 * 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 org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x509.Time;
import org.bouncycastle.asn1.x509.V1TBSCertificateGenerator;
import org.bouncycastle.operator.ContentSigner;

public class X509v1CertificateBuilder
{
  private V1TBSCertificateGenerator tbsGen;
  
  public X509v1CertificateBuilder(X500Name paramX500Name1, BigInteger paramBigInteger, Date paramDate1, Date paramDate2, X500Name paramX500Name2, SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    if (paramX500Name1 == null) {
      throw new IllegalArgumentException("issuer must not be null");
    }
    if (paramSubjectPublicKeyInfo == null) {
      throw new IllegalArgumentException("publicKeyInfo must not be null");
    }
    tbsGen = new V1TBSCertificateGenerator();
    tbsGen.setSerialNumber(new ASN1Integer(paramBigInteger));
    tbsGen.setIssuer(paramX500Name1);
    tbsGen.setStartDate(new Time(paramDate1));
    tbsGen.setEndDate(new Time(paramDate2));
    tbsGen.setSubject(paramX500Name2);
    tbsGen.setSubjectPublicKeyInfo(paramSubjectPublicKeyInfo);
  }
  
  public X509CertificateHolder build(ContentSigner paramContentSigner)
  {
    tbsGen.setSignature(paramContentSigner.getAlgorithmIdentifier());
    return CertUtils.generateFullCert(paramContentSigner, tbsGen.generateTBSCertificate());
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509v1CertificateBuilder
 * 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 org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERGeneralizedTime;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.x509.AttCertIssuer;
import org.bouncycastle.asn1.x509.Attribute;
import org.bouncycastle.asn1.x509.ExtensionsGenerator;
import org.bouncycastle.asn1.x509.V2AttributeCertificateInfoGenerator;
import org.bouncycastle.operator.ContentSigner;

public class X509v2AttributeCertificateBuilder
{
  private V2AttributeCertificateInfoGenerator acInfoGen = new V2AttributeCertificateInfoGenerator();
  private ExtensionsGenerator extGenerator = new ExtensionsGenerator();
  
  public X509v2AttributeCertificateBuilder(AttributeCertificateHolder paramAttributeCertificateHolder, AttributeCertificateIssuer paramAttributeCertificateIssuer, BigInteger paramBigInteger, Date paramDate1, Date paramDate2)
  {
    acInfoGen.setHolder(holder);
    acInfoGen.setIssuer(AttCertIssuer.getInstance(form));
    acInfoGen.setSerialNumber(new ASN1Integer(paramBigInteger));
    acInfoGen.setStartDate(new DERGeneralizedTime(paramDate1));
    acInfoGen.setEndDate(new DERGeneralizedTime(paramDate2));
  }
  
  public X509v2AttributeCertificateBuilder addAttribute(ASN1ObjectIdentifier paramASN1ObjectIdentifier, ASN1Encodable paramASN1Encodable)
  {
    acInfoGen.addAttribute(new Attribute(paramASN1ObjectIdentifier, new DERSet(paramASN1Encodable)));
    return this;
  }
  
  public X509v2AttributeCertificateBuilder addAttribute(ASN1ObjectIdentifier paramASN1ObjectIdentifier, ASN1Encodable[] paramArrayOfASN1Encodable)
  {
    acInfoGen.addAttribute(new Attribute(paramASN1ObjectIdentifier, new DERSet(paramArrayOfASN1Encodable)));
    return this;
  }
  
  public void setIssuerUniqueId(boolean[] paramArrayOfBoolean)
  {
    acInfoGen.setIssuerUniqueID(CertUtils.booleanToBitString(paramArrayOfBoolean));
  }
  
  public X509v2AttributeCertificateBuilder addExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier, boolean paramBoolean, ASN1Encodable paramASN1Encodable)
    throws CertIOException
  {
    CertUtils.addExtension(extGenerator, paramASN1ObjectIdentifier, paramBoolean, paramASN1Encodable);
    return this;
  }
  
  public X509AttributeCertificateHolder build(ContentSigner paramContentSigner)
  {
    acInfoGen.setSignature(paramContentSigner.getAlgorithmIdentifier());
    if (!extGenerator.isEmpty()) {
      acInfoGen.setExtensions(extGenerator.generate());
    }
    return CertUtils.generateFullAttrCert(paramContentSigner, acInfoGen.generateAttributeCertificateInfo());
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509v2AttributeCertificateBuilder
 * 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.Enumeration;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERGeneralizedTime;
import org.bouncycastle.asn1.x500.X500Name;
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.Time;
import org.bouncycastle.asn1.x509.V2TBSCertListGenerator;
import org.bouncycastle.asn1.x509.X509Extensions;
import org.bouncycastle.operator.ContentSigner;

public class X509v2CRLBuilder
{
  private V2TBSCertListGenerator tbsGen = new V2TBSCertListGenerator();
  private ExtensionsGenerator extGenerator = new ExtensionsGenerator();
  
  public X509v2CRLBuilder(X500Name paramX500Name, Date paramDate)
  {
    tbsGen.setIssuer(paramX500Name);
    tbsGen.setThisUpdate(new Time(paramDate));
  }
  
  public X509v2CRLBuilder setNextUpdate(Date paramDate)
  {
    tbsGen.setNextUpdate(new Time(paramDate));
    return this;
  }
  
  public X509v2CRLBuilder addCRLEntry(BigInteger paramBigInteger, Date paramDate, int paramInt)
  {
    tbsGen.addCRLEntry(new ASN1Integer(paramBigInteger), new Time(paramDate), paramInt);
    return this;
  }
  
  public X509v2CRLBuilder addCRLEntry(BigInteger paramBigInteger, Date paramDate1, int paramInt, Date paramDate2)
  {
    tbsGen.addCRLEntry(new ASN1Integer(paramBigInteger), new Time(paramDate1), paramInt, new DERGeneralizedTime(paramDate2));
    return this;
  }
  
  /**
   * @deprecated
   */
  public X509v2CRLBuilder addCRLEntry(BigInteger paramBigInteger, Date paramDate, X509Extensions paramX509Extensions)
  {
    tbsGen.addCRLEntry(new ASN1Integer(paramBigInteger), new Time(paramDate), Extensions.getInstance(paramX509Extensions));
    return this;
  }
  
  public X509v2CRLBuilder addCRLEntry(BigInteger paramBigInteger, Date paramDate, Extensions paramExtensions)
  {
    tbsGen.addCRLEntry(new ASN1Integer(paramBigInteger), new Time(paramDate), paramExtensions);
    return this;
  }
  
  public X509v2CRLBuilder addCRL(X509CRLHolder paramX509CRLHolder)
  {
    TBSCertList localTBSCertList = paramX509CRLHolder.toASN1Structure().getTBSCertList();
    if (localTBSCertList != null)
    {
      Enumeration localEnumeration = localTBSCertList.getRevokedCertificateEnumeration();
      while (localEnumeration.hasMoreElements()) {
        tbsGen.addCRLEntry(ASN1Sequence.getInstance(((ASN1Encodable)localEnumeration.nextElement()).toASN1Primitive()));
      }
    }
    return this;
  }
  
  public X509v2CRLBuilder addExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier, boolean paramBoolean, ASN1Encodable paramASN1Encodable)
    throws CertIOException
  {
    CertUtils.addExtension(extGenerator, paramASN1ObjectIdentifier, paramBoolean, paramASN1Encodable);
    return this;
  }
  
  public X509CRLHolder build(ContentSigner paramContentSigner)
  {
    tbsGen.setSignature(paramContentSigner.getAlgorithmIdentifier());
    if (!extGenerator.isEmpty()) {
      tbsGen.setExtensions(extGenerator.generate());
    }
    return CertUtils.generateFullCRL(paramContentSigner, tbsGen.generateTBSCertList());
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.X509v2CRLBuilder
 * 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 org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.ExtensionsGenerator;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x509.TBSCertificate;
import org.bouncycastle.asn1.x509.Time;
import org.bouncycastle.asn1.x509.V3TBSCertificateGenerator;
import org.bouncycastle.operator.ContentSigner;

public class X509v3CertificateBuilder
{
  private V3TBSCertificateGenerator tbsGen = new V3TBSCertificateGenerator();
  private ExtensionsGenerator extGenerator;
  
  public X509v3CertificateBuilder(X500Name paramX500Name1, BigInteger paramBigInteger, Date paramDate1, Date paramDate2, X500Name paramX500Name2, SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    tbsGen.setSerialNumber(new ASN1Integer(paramBigInteger));
    tbsGen.setIssuer(paramX500Name1);
    tbsGen.setStartDate(new Time(paramDate1));
    tbsGen.setEndDate(new Time(paramDate2));
    tbsGen.setSubject(paramX500Name2);
    tbsGen.setSubjectPublicKeyInfo(paramSubjectPublicKeyInfo);
    extGenerator = new ExtensionsGenerator();
  }
  
  public X509v3CertificateBuilder setSubjectUniqueID(boolean[] paramArrayOfBoolean)
  {
    tbsGen.setSubjectUniqueID(CertUtils.booleanToBitString(paramArrayOfBoolean));
    return this;
  }
  
  public X509v3CertificateBuilder setIssuerUniqueID(boolean[] paramArrayOfBoolean)
  {
    tbsGen.setIssuerUniqueID(CertUtils.booleanToBitString(paramArrayOfBoolean));
    return this;
  }
  
  public X509v3CertificateBuilder addExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier, boolean paramBoolean, ASN1Encodable paramASN1Encodable)
    throws CertIOException
  {
    CertUtils.addExtension(extGenerator, paramASN1ObjectIdentifier, paramBoolean, paramASN1Encodable);
    return this;
  }
  
  public X509v3CertificateBuilder copyAndAddExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier, boolean paramBoolean, X509CertificateHolder paramX509CertificateHolder)
  {
    Certificate localCertificate = paramX509CertificateHolder.toASN1Structure();
    Extension localExtension = localCertificate.getTBSCertificate().getExtensions().getExtension(paramASN1ObjectIdentifier);
    if (localExtension == null) {
      throw new NullPointerException("extension " + paramASN1ObjectIdentifier + " not present");
    }
    extGenerator.addExtension(paramASN1ObjectIdentifier, paramBoolean, localExtension.getExtnValue().getOctets());
    return this;
  }
  
  public X509CertificateHolder build(ContentSigner paramContentSigner)
  {
    tbsGen.setSignature(paramContentSigner.getAlgorithmIdentifier());
    if (!extGenerator.isEmpty()) {
      tbsGen.setExtensions(extGenerator.generate());
    }
    return CertUtils.generateFullCert(paramContentSigner, tbsGen.generateTBSCertificate());
  }
}

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

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

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

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

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.DEROutputStream;

class CMPUtil
{
  static void derEncodeToStream(ASN1Encodable paramASN1Encodable, OutputStream paramOutputStream)
  {
    DEROutputStream localDEROutputStream = new DEROutputStream(paramOutputStream);
    try
    {
      localDEROutputStream.writeObject(paramASN1Encodable);
      localDEROutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new CMPRuntimeException("unable to DER encode object: " + localIOException.getMessage(), localIOException);
    }
  }
}

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

import org.bouncycastle.asn1.cmp.CertConfirmContent;
import org.bouncycastle.asn1.cmp.CertStatus;
import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;

public class CertificateConfirmationContent
{
  private DigestAlgorithmIdentifierFinder digestAlgFinder;
  private CertConfirmContent content;
  
  public CertificateConfirmationContent(CertConfirmContent paramCertConfirmContent)
  {
    this(paramCertConfirmContent, new DefaultDigestAlgorithmIdentifierFinder());
  }
  
  public CertificateConfirmationContent(CertConfirmContent paramCertConfirmContent, DigestAlgorithmIdentifierFinder paramDigestAlgorithmIdentifierFinder)
  {
    digestAlgFinder = paramDigestAlgorithmIdentifierFinder;
    content = paramCertConfirmContent;
  }
  
  public CertConfirmContent toASN1Structure()
  {
    return content;
  }
  
  public CertificateStatus[] getStatusMessages()
  {
    CertStatus[] arrayOfCertStatus = content.toCertStatusArray();
    CertificateStatus[] arrayOfCertificateStatus = new CertificateStatus[arrayOfCertStatus.length];
    for (int i = 0; i != arrayOfCertificateStatus.length; i++) {
      arrayOfCertificateStatus[i] = new CertificateStatus(digestAlgFinder, arrayOfCertStatus[i]);
    }
    return arrayOfCertificateStatus;
  }
}

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

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmp.CertConfirmContent;
import org.bouncycastle.asn1.cmp.CertStatus;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestCalculator;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.operator.OperatorCreationException;

public class CertificateConfirmationContentBuilder
{
  private DigestAlgorithmIdentifierFinder digestAlgFinder;
  private List acceptedCerts = new ArrayList();
  private List acceptedReqIds = new ArrayList();
  
  public CertificateConfirmationContentBuilder()
  {
    this(new DefaultDigestAlgorithmIdentifierFinder());
  }
  
  public CertificateConfirmationContentBuilder(DigestAlgorithmIdentifierFinder paramDigestAlgorithmIdentifierFinder)
  {
    digestAlgFinder = paramDigestAlgorithmIdentifierFinder;
  }
  
  public CertificateConfirmationContentBuilder addAcceptedCertificate(X509CertificateHolder paramX509CertificateHolder, BigInteger paramBigInteger)
  {
    acceptedCerts.add(paramX509CertificateHolder);
    acceptedReqIds.add(paramBigInteger);
    return this;
  }
  
  public CertificateConfirmationContent build(DigestCalculatorProvider paramDigestCalculatorProvider)
    throws CMPException
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    for (int i = 0; i != acceptedCerts.size(); i++)
    {
      X509CertificateHolder localX509CertificateHolder = (X509CertificateHolder)acceptedCerts.get(i);
      BigInteger localBigInteger = (BigInteger)acceptedReqIds.get(i);
      AlgorithmIdentifier localAlgorithmIdentifier = digestAlgFinder.find(localX509CertificateHolder.toASN1Structure().getSignatureAlgorithm());
      if (localAlgorithmIdentifier == null) {
        throw new CMPException("cannot find algorithm for digest from signature");
      }
      DigestCalculator localDigestCalculator;
      try
      {
        localDigestCalculator = paramDigestCalculatorProvider.get(localAlgorithmIdentifier);
      }
      catch (OperatorCreationException localOperatorCreationException)
      {
        throw new CMPException("unable to create digest: " + localOperatorCreationException.getMessage(), localOperatorCreationException);
      }
      CMPUtil.derEncodeToStream(localX509CertificateHolder.toASN1Structure(), localDigestCalculator.getOutputStream());
      localASN1EncodableVector.add(new CertStatus(localDigestCalculator.getDigest(), localBigInteger));
    }
    return new CertificateConfirmationContent(CertConfirmContent.getInstance(new DERSequence(localASN1EncodableVector)), digestAlgFinder);
  }
}

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

import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.cmp.CertStatus;
import org.bouncycastle.asn1.cmp.PKIStatusInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestCalculator;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.util.Arrays;

public class CertificateStatus
{
  private DigestAlgorithmIdentifierFinder digestAlgFinder;
  private CertStatus certStatus;
  
  CertificateStatus(DigestAlgorithmIdentifierFinder paramDigestAlgorithmIdentifierFinder, CertStatus paramCertStatus)
  {
    digestAlgFinder = paramDigestAlgorithmIdentifierFinder;
    certStatus = paramCertStatus;
  }
  
  public PKIStatusInfo getStatusInfo()
  {
    return certStatus.getStatusInfo();
  }
  
  public BigInteger getCertRequestID()
  {
    return certStatus.getCertReqId().getValue();
  }
  
  public boolean isVerified(X509CertificateHolder paramX509CertificateHolder, DigestCalculatorProvider paramDigestCalculatorProvider)
    throws CMPException
  {
    AlgorithmIdentifier localAlgorithmIdentifier = digestAlgFinder.find(paramX509CertificateHolder.toASN1Structure().getSignatureAlgorithm());
    if (localAlgorithmIdentifier == null) {
      throw new CMPException("cannot find algorithm for digest from signature");
    }
    DigestCalculator localDigestCalculator;
    try
    {
      localDigestCalculator = paramDigestCalculatorProvider.get(localAlgorithmIdentifier);
    }
    catch (OperatorCreationException localOperatorCreationException)
    {
      throw new CMPException("unable to create digester: " + localOperatorCreationException.getMessage(), localOperatorCreationException);
    }
    CMPUtil.derEncodeToStream(paramX509CertificateHolder.toASN1Structure(), localDigestCalculator.getOutputStream());
    return Arrays.areEqual(certStatus.getCertHash().getOctets(), localDigestCalculator.getDigest());
  }
}

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

import java.io.IOException;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.cmp.PKIBody;
import org.bouncycastle.asn1.cmp.PKIHeader;
import org.bouncycastle.asn1.cmp.PKIMessage;
import org.bouncycastle.cert.CertIOException;

public class GeneralPKIMessage
{
  private final PKIMessage pkiMessage;
  
  private static PKIMessage parseBytes(byte[] paramArrayOfByte)
    throws IOException
  {
    try
    {
      return PKIMessage.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 GeneralPKIMessage(byte[] paramArrayOfByte)
    throws IOException
  {
    this(parseBytes(paramArrayOfByte));
  }
  
  public GeneralPKIMessage(PKIMessage paramPKIMessage)
  {
    pkiMessage = paramPKIMessage;
  }
  
  public PKIHeader getHeader()
  {
    return pkiMessage.getHeader();
  }
  
  public PKIBody getBody()
  {
    return pkiMessage.getBody();
  }
  
  public boolean hasProtection()
  {
    return pkiMessage.getHeader().getProtectionAlg() != null;
  }
  
  public PKIMessage toASN1Structure()
  {
    return pkiMessage;
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmp.CMPCertificate;
import org.bouncycastle.asn1.cmp.CMPObjectIdentifiers;
import org.bouncycastle.asn1.cmp.PBMParameter;
import org.bouncycastle.asn1.cmp.PKIBody;
import org.bouncycastle.asn1.cmp.PKIHeader;
import org.bouncycastle.asn1.cmp.PKIMessage;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.crmf.PKMACBuilder;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.util.Arrays;

public class ProtectedPKIMessage
{
  private PKIMessage pkiMessage;
  
  public ProtectedPKIMessage(GeneralPKIMessage paramGeneralPKIMessage)
  {
    if (!paramGeneralPKIMessage.hasProtection()) {
      throw new IllegalArgumentException("PKIMessage not protected");
    }
    pkiMessage = paramGeneralPKIMessage.toASN1Structure();
  }
  
  ProtectedPKIMessage(PKIMessage paramPKIMessage)
  {
    if (paramPKIMessage.getHeader().getProtectionAlg() == null) {
      throw new IllegalArgumentException("PKIMessage not protected");
    }
    pkiMessage = paramPKIMessage;
  }
  
  public PKIHeader getHeader()
  {
    return pkiMessage.getHeader();
  }
  
  public PKIBody getBody()
  {
    return pkiMessage.getBody();
  }
  
  public PKIMessage toASN1Structure()
  {
    return pkiMessage;
  }
  
  public boolean hasPasswordBasedMacProtection()
  {
    return pkiMessage.getHeader().getProtectionAlg().getAlgorithm().equals(CMPObjectIdentifiers.passwordBasedMac);
  }
  
  public X509CertificateHolder[] getCertificates()
  {
    CMPCertificate[] arrayOfCMPCertificate = pkiMessage.getExtraCerts();
    if (arrayOfCMPCertificate == null) {
      return new X509CertificateHolder[0];
    }
    X509CertificateHolder[] arrayOfX509CertificateHolder = new X509CertificateHolder[arrayOfCMPCertificate.length];
    for (int i = 0; i != arrayOfCMPCertificate.length; i++) {
      arrayOfX509CertificateHolder[i] = new X509CertificateHolder(arrayOfCMPCertificate[i].getX509v3PKCert());
    }
    return arrayOfX509CertificateHolder;
  }
  
  public boolean verify(ContentVerifierProvider paramContentVerifierProvider)
    throws CMPException
  {
    try
    {
      ContentVerifier localContentVerifier = paramContentVerifierProvider.get(pkiMessage.getHeader().getProtectionAlg());
      return verifySignature(pkiMessage.getProtection().getBytes(), localContentVerifier);
    }
    catch (Exception localException)
    {
      throw new CMPException("unable to verify signature: " + localException.getMessage(), localException);
    }
  }
  
  public boolean verify(PKMACBuilder paramPKMACBuilder, char[] paramArrayOfChar)
    throws CMPException
  {
    if (!CMPObjectIdentifiers.passwordBasedMac.equals(pkiMessage.getHeader().getProtectionAlg().getAlgorithm())) {
      throw new CMPException("protection algorithm not mac based");
    }
    try
    {
      paramPKMACBuilder.setParameters(PBMParameter.getInstance(pkiMessage.getHeader().getProtectionAlg().getParameters()));
      MacCalculator localMacCalculator = paramPKMACBuilder.build(paramArrayOfChar);
      OutputStream localOutputStream = localMacCalculator.getOutputStream();
      ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
      localASN1EncodableVector.add(pkiMessage.getHeader());
      localASN1EncodableVector.add(pkiMessage.getBody());
      localOutputStream.write(new DERSequence(localASN1EncodableVector).getEncoded("DER"));
      localOutputStream.close();
      return Arrays.areEqual(localMacCalculator.getMac(), pkiMessage.getProtection().getBytes());
    }
    catch (Exception localException)
    {
      throw new CMPException("unable to verify MAC: " + localException.getMessage(), localException);
    }
  }
  
  private boolean verifySignature(byte[] paramArrayOfByte, ContentVerifier paramContentVerifier)
    throws IOException
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(pkiMessage.getHeader());
    localASN1EncodableVector.add(pkiMessage.getBody());
    OutputStream localOutputStream = paramContentVerifier.getOutputStream();
    localOutputStream.write(new DERSequence(localASN1EncodableVector).getEncoded("DER"));
    localOutputStream.close();
    return paramContentVerifier.verify(paramArrayOfByte);
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERGeneralizedTime;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmp.CMPCertificate;
import org.bouncycastle.asn1.cmp.InfoTypeAndValue;
import org.bouncycastle.asn1.cmp.PKIBody;
import org.bouncycastle.asn1.cmp.PKIFreeText;
import org.bouncycastle.asn1.cmp.PKIHeader;
import org.bouncycastle.asn1.cmp.PKIHeaderBuilder;
import org.bouncycastle.asn1.cmp.PKIMessage;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.MacCalculator;

public class ProtectedPKIMessageBuilder
{
  private PKIHeaderBuilder hdrBuilder;
  private PKIBody body;
  private List generalInfos = new ArrayList();
  private List extraCerts = new ArrayList();
  
  public ProtectedPKIMessageBuilder(GeneralName paramGeneralName1, GeneralName paramGeneralName2)
  {
    this(2, paramGeneralName1, paramGeneralName2);
  }
  
  public ProtectedPKIMessageBuilder(int paramInt, GeneralName paramGeneralName1, GeneralName paramGeneralName2)
  {
    hdrBuilder = new PKIHeaderBuilder(paramInt, paramGeneralName1, paramGeneralName2);
  }
  
  public ProtectedPKIMessageBuilder setTransactionID(byte[] paramArrayOfByte)
  {
    hdrBuilder.setTransactionID(paramArrayOfByte);
    return this;
  }
  
  public ProtectedPKIMessageBuilder setFreeText(PKIFreeText paramPKIFreeText)
  {
    hdrBuilder.setFreeText(paramPKIFreeText);
    return this;
  }
  
  public ProtectedPKIMessageBuilder addGeneralInfo(InfoTypeAndValue paramInfoTypeAndValue)
  {
    generalInfos.add(paramInfoTypeAndValue);
    return this;
  }
  
  public ProtectedPKIMessageBuilder setMessageTime(Date paramDate)
  {
    hdrBuilder.setMessageTime(new DERGeneralizedTime(paramDate));
    return this;
  }
  
  public ProtectedPKIMessageBuilder setRecipKID(byte[] paramArrayOfByte)
  {
    hdrBuilder.setRecipKID(paramArrayOfByte);
    return this;
  }
  
  public ProtectedPKIMessageBuilder setRecipNonce(byte[] paramArrayOfByte)
  {
    hdrBuilder.setRecipNonce(paramArrayOfByte);
    return this;
  }
  
  public ProtectedPKIMessageBuilder setSenderKID(byte[] paramArrayOfByte)
  {
    hdrBuilder.setSenderKID(paramArrayOfByte);
    return this;
  }
  
  public ProtectedPKIMessageBuilder setSenderNonce(byte[] paramArrayOfByte)
  {
    hdrBuilder.setSenderNonce(paramArrayOfByte);
    return this;
  }
  
  public ProtectedPKIMessageBuilder setBody(PKIBody paramPKIBody)
  {
    body = paramPKIBody;
    return this;
  }
  
  public ProtectedPKIMessageBuilder addCMPCertificate(X509CertificateHolder paramX509CertificateHolder)
  {
    extraCerts.add(paramX509CertificateHolder);
    return this;
  }
  
  public ProtectedPKIMessage build(MacCalculator paramMacCalculator)
    throws CMPException
  {
    finaliseHeader(paramMacCalculator.getAlgorithmIdentifier());
    PKIHeader localPKIHeader = hdrBuilder.build();
    try
    {
      DERBitString localDERBitString = new DERBitString(calculateMac(paramMacCalculator, localPKIHeader, body));
      return finaliseMessage(localPKIHeader, localDERBitString);
    }
    catch (IOException localIOException)
    {
      throw new CMPException("unable to encode MAC input: " + localIOException.getMessage(), localIOException);
    }
  }
  
  public ProtectedPKIMessage build(ContentSigner paramContentSigner)
    throws CMPException
  {
    finaliseHeader(paramContentSigner.getAlgorithmIdentifier());
    PKIHeader localPKIHeader = hdrBuilder.build();
    try
    {
      DERBitString localDERBitString = new DERBitString(calculateSignature(paramContentSigner, localPKIHeader, body));
      return finaliseMessage(localPKIHeader, localDERBitString);
    }
    catch (IOException localIOException)
    {
      throw new CMPException("unable to encode signature input: " + localIOException.getMessage(), localIOException);
    }
  }
  
  private void finaliseHeader(AlgorithmIdentifier paramAlgorithmIdentifier)
  {
    hdrBuilder.setProtectionAlg(paramAlgorithmIdentifier);
    if (!generalInfos.isEmpty())
    {
      InfoTypeAndValue[] arrayOfInfoTypeAndValue = new InfoTypeAndValue[generalInfos.size()];
      hdrBuilder.setGeneralInfo((InfoTypeAndValue[])generalInfos.toArray(arrayOfInfoTypeAndValue));
    }
  }
  
  private ProtectedPKIMessage finaliseMessage(PKIHeader paramPKIHeader, DERBitString paramDERBitString)
  {
    if (!extraCerts.isEmpty())
    {
      CMPCertificate[] arrayOfCMPCertificate = new CMPCertificate[extraCerts.size()];
      for (int i = 0; i != arrayOfCMPCertificate.length; i++) {
        arrayOfCMPCertificate[i] = new CMPCertificate(((X509CertificateHolder)extraCerts.get(i)).toASN1Structure());
      }
      return new ProtectedPKIMessage(new PKIMessage(paramPKIHeader, body, paramDERBitString, arrayOfCMPCertificate));
    }
    return new ProtectedPKIMessage(new PKIMessage(paramPKIHeader, body, paramDERBitString));
  }
  
  private byte[] calculateSignature(ContentSigner paramContentSigner, PKIHeader paramPKIHeader, PKIBody paramPKIBody)
    throws IOException
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(paramPKIHeader);
    localASN1EncodableVector.add(paramPKIBody);
    OutputStream localOutputStream = paramContentSigner.getOutputStream();
    localOutputStream.write(new DERSequence(localASN1EncodableVector).getEncoded("DER"));
    localOutputStream.close();
    return paramContentSigner.getSignature();
  }
  
  private byte[] calculateMac(MacCalculator paramMacCalculator, PKIHeader paramPKIHeader, PKIBody paramPKIBody)
    throws IOException
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(paramPKIHeader);
    localASN1EncodableVector.add(paramPKIBody);
    OutputStream localOutputStream = paramMacCalculator.getOutputStream();
    localOutputStream.write(new DERSequence(localASN1EncodableVector).getEncoded("DER"));
    localOutputStream.close();
    return paramMacCalculator.getMac();
  }
}

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

import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.cmp.RevDetails;
import org.bouncycastle.asn1.crmf.CertTemplate;
import org.bouncycastle.asn1.x500.X500Name;

public class RevocationDetails
{
  private RevDetails revDetails;
  
  public RevocationDetails(RevDetails paramRevDetails)
  {
    revDetails = paramRevDetails;
  }
  
  public X500Name getSubject()
  {
    return revDetails.getCertDetails().getSubject();
  }
  
  public X500Name getIssuer()
  {
    return revDetails.getCertDetails().getIssuer();
  }
  
  public BigInteger getSerialNumber()
  {
    return revDetails.getCertDetails().getSerialNumber().getValue();
  }
  
  public RevDetails toASN1Structure()
  {
    return revDetails;
  }
}

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

import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.cmp.RevDetails;
import org.bouncycastle.asn1.crmf.CertTemplateBuilder;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;

public class RevocationDetailsBuilder
{
  private CertTemplateBuilder templateBuilder = new CertTemplateBuilder();
  
  public RevocationDetailsBuilder setPublicKey(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    if (paramSubjectPublicKeyInfo != null) {
      templateBuilder.setPublicKey(paramSubjectPublicKeyInfo);
    }
    return this;
  }
  
  public RevocationDetailsBuilder setIssuer(X500Name paramX500Name)
  {
    if (paramX500Name != null) {
      templateBuilder.setIssuer(paramX500Name);
    }
    return this;
  }
  
  public RevocationDetailsBuilder setSerialNumber(BigInteger paramBigInteger)
  {
    if (paramBigInteger != null) {
      templateBuilder.setSerialNumber(new ASN1Integer(paramBigInteger));
    }
    
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