bcpkix-jdk15on-147

g.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.ocsp.CertStatus;
import org.bouncycastle.asn1.ocsp.RevokedInfo;
import org.bouncycastle.asn1.ocsp.SingleResponse;
import org.bouncycastle.asn1.x509.CRLReason;
import org.bouncycastle.asn1.x509.Extensions;

class BasicOCSPRespBuilder$ResponseObject
{
  CertificateID certId;
  CertStatus certStatus;
  DERGeneralizedTime thisUpdate;
  DERGeneralizedTime nextUpdate;
  Extensions extensions;
  
  public BasicOCSPRespBuilder$ResponseObject(BasicOCSPRespBuilder paramBasicOCSPRespBuilder, CertificateID paramCertificateID, CertificateStatus paramCertificateStatus, Date paramDate1, Date paramDate2, Extensions paramExtensions)
  {
    certId = paramCertificateID;
    if (paramCertificateStatus == null)
    {
      certStatus = new CertStatus();
    }
    else if ((paramCertificateStatus instanceof UnknownStatus))
    {
      certStatus = new CertStatus(2, new DERNull());
    }
    else
    {
      RevokedStatus localRevokedStatus = (RevokedStatus)paramCertificateStatus;
      if (localRevokedStatus.hasRevocationReason()) {
        certStatus = new CertStatus(new RevokedInfo(new DERGeneralizedTime(localRevokedStatus.getRevocationTime()), CRLReason.lookup(localRevokedStatus.getRevocationReason())));
      } else {
        certStatus = new CertStatus(new RevokedInfo(new DERGeneralizedTime(localRevokedStatus.getRevocationTime()), null));
      }
    }
    thisUpdate = new DERGeneralizedTime(paramDate1);
    if (paramDate2 != null) {
      nextUpdate = new DERGeneralizedTime(paramDate2);
    } else {
      nextUpdate = null;
    }
    extensions = paramExtensions;
  }
  
  public SingleResponse toResponse()
    throws Exception
  {
    return new SingleResponse(certId.toASN1Object(), certStatus, thisUpdate, nextUpdate, extensions);
  }
}

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

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERGeneralizedTime;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.ocsp.BasicOCSPResponse;
import org.bouncycastle.asn1.ocsp.CertStatus;
import org.bouncycastle.asn1.ocsp.ResponseData;
import org.bouncycastle.asn1.ocsp.RevokedInfo;
import org.bouncycastle.asn1.ocsp.SingleResponse;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.CRLReason;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.DigestCalculator;

public class BasicOCSPRespBuilder
{
  private List list = new ArrayList();
  private Extensions responseExtensions = null;
  private RespID responderID;
  
  public BasicOCSPRespBuilder(RespID paramRespID)
  {
    responderID = paramRespID;
  }
  
  public BasicOCSPRespBuilder(SubjectPublicKeyInfo paramSubjectPublicKeyInfo, DigestCalculator paramDigestCalculator)
    throws OCSPException
  {
    responderID = new RespID(paramSubjectPublicKeyInfo, paramDigestCalculator);
  }
  
  public BasicOCSPRespBuilder addResponse(CertificateID paramCertificateID, CertificateStatus paramCertificateStatus)
  {
    list.add(new ResponseObject(paramCertificateID, paramCertificateStatus, new Date(), null, null));
    return this;
  }
  
  public BasicOCSPRespBuilder addResponse(CertificateID paramCertificateID, CertificateStatus paramCertificateStatus, Extensions paramExtensions)
  {
    list.add(new ResponseObject(paramCertificateID, paramCertificateStatus, new Date(), null, paramExtensions));
    return this;
  }
  
  public BasicOCSPRespBuilder addResponse(CertificateID paramCertificateID, CertificateStatus paramCertificateStatus, Date paramDate, Extensions paramExtensions)
  {
    list.add(new ResponseObject(paramCertificateID, paramCertificateStatus, new Date(), paramDate, paramExtensions));
    return this;
  }
  
  public BasicOCSPRespBuilder addResponse(CertificateID paramCertificateID, CertificateStatus paramCertificateStatus, Date paramDate1, Date paramDate2, Extensions paramExtensions)
  {
    list.add(new ResponseObject(paramCertificateID, paramCertificateStatus, paramDate1, paramDate2, paramExtensions));
    return this;
  }
  
  public BasicOCSPRespBuilder setResponseExtensions(Extensions paramExtensions)
  {
    responseExtensions = paramExtensions;
    return this;
  }
  
  public BasicOCSPResp build(ContentSigner paramContentSigner, X509CertificateHolder[] paramArrayOfX509CertificateHolder, Date paramDate)
    throws OCSPException
  {
    Iterator localIterator = list.iterator();
    ASN1EncodableVector localASN1EncodableVector1 = new ASN1EncodableVector();
    while (localIterator.hasNext()) {
      try
      {
        localASN1EncodableVector1.add(((ResponseObject)localIterator.next()).toResponse());
      }
      catch (Exception localException1)
      {
        throw new OCSPException("exception creating Request", localException1);
      }
    }
    ResponseData localResponseData = new ResponseData(responderID.toASN1Object(), new DERGeneralizedTime(paramDate), new DERSequence(localASN1EncodableVector1), responseExtensions);
    DERBitString localDERBitString;
    try
    {
      OutputStream localOutputStream = paramContentSigner.getOutputStream();
      localOutputStream.write(localResponseData.getEncoded("DER"));
      localOutputStream.close();
      localDERBitString = new DERBitString(paramContentSigner.getSignature());
    }
    catch (Exception localException2)
    {
      throw new OCSPException("exception processing TBSRequest: " + localException2.getMessage(), localException2);
    }
    AlgorithmIdentifier localAlgorithmIdentifier = paramContentSigner.getAlgorithmIdentifier();
    DERSequence localDERSequence = null;
    if ((paramArrayOfX509CertificateHolder != null) && (paramArrayOfX509CertificateHolder.length > 0))
    {
      ASN1EncodableVector localASN1EncodableVector2 = new ASN1EncodableVector();
      for (int i = 0; i != paramArrayOfX509CertificateHolder.length; i++) {
        localASN1EncodableVector2.add(paramArrayOfX509CertificateHolder[i].toASN1Structure());
      }
      localDERSequence = new DERSequence(localASN1EncodableVector2);
    }
    return new BasicOCSPResp(new BasicOCSPResponse(localResponseData, localAlgorithmIdentifier, localDERBitString, localDERSequence));
  }
  
  private class ResponseObject
  {
    CertificateID certId;
    CertStatus certStatus;
    DERGeneralizedTime thisUpdate;
    DERGeneralizedTime nextUpdate;
    Extensions extensions;
    
    public ResponseObject(CertificateID paramCertificateID, CertificateStatus paramCertificateStatus, Date paramDate1, Date paramDate2, Extensions paramExtensions)
    {
      certId = paramCertificateID;
      if (paramCertificateStatus == null)
      {
        certStatus = new CertStatus();
      }
      else if ((paramCertificateStatus instanceof UnknownStatus))
      {
        certStatus = new CertStatus(2, new DERNull());
      }
      else
      {
        RevokedStatus localRevokedStatus = (RevokedStatus)paramCertificateStatus;
        if (localRevokedStatus.hasRevocationReason()) {
          certStatus = new CertStatus(new RevokedInfo(new DERGeneralizedTime(localRevokedStatus.getRevocationTime()), CRLReason.lookup(localRevokedStatus.getRevocationReason())));
        } else {
          certStatus = new CertStatus(new RevokedInfo(new DERGeneralizedTime(localRevokedStatus.getRevocationTime()), null));
        }
      }
      thisUpdate = new DERGeneralizedTime(paramDate1);
      if (paramDate2 != null) {
        nextUpdate = new DERGeneralizedTime(paramDate2);
      } else {
        nextUpdate = null;
      }
      extensions = paramExtensions;
    }
    
    public SingleResponse toResponse()
      throws Exception
    {
      return new SingleResponse(certId.toASN1Object(), certStatus, thisUpdate, nextUpdate, extensions);
    }
  }
}

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

import java.io.OutputStream;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.ocsp.CertID;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.DigestCalculator;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.operator.OperatorCreationException;

public class CertificateID
{
  public static final AlgorithmIdentifier HASH_SHA1 = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
  private final CertID id;
  
  public CertificateID(CertID paramCertID)
  {
    if (paramCertID == null) {
      throw new IllegalArgumentException("'id' cannot be null");
    }
    id = paramCertID;
  }
  
  public CertificateID(DigestCalculator paramDigestCalculator, X509CertificateHolder paramX509CertificateHolder, BigInteger paramBigInteger)
    throws OCSPException
  {
    id = createCertID(paramDigestCalculator, paramX509CertificateHolder, new ASN1Integer(paramBigInteger));
  }
  
  public ASN1ObjectIdentifier getHashAlgOID()
  {
    return id.getHashAlgorithm().getAlgorithm();
  }
  
  public byte[] getIssuerNameHash()
  {
    return id.getIssuerNameHash().getOctets();
  }
  
  public byte[] getIssuerKeyHash()
  {
    return id.getIssuerKeyHash().getOctets();
  }
  
  public BigInteger getSerialNumber()
  {
    return id.getSerialNumber().getValue();
  }
  
  public boolean matchesIssuer(X509CertificateHolder paramX509CertificateHolder, DigestCalculatorProvider paramDigestCalculatorProvider)
    throws OCSPException
  {
    try
    {
      return createCertID(paramDigestCalculatorProvider.get(id.getHashAlgorithm()), paramX509CertificateHolder, id.getSerialNumber()).equals(id);
    }
    catch (OperatorCreationException localOperatorCreationException)
    {
      throw new OCSPException("unable to create digest calculator: " + localOperatorCreationException.getMessage(), localOperatorCreationException);
    }
  }
  
  public CertID toASN1Object()
  {
    return id;
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof CertificateID)) {
      return false;
    }
    CertificateID localCertificateID = (CertificateID)paramObject;
    return id.toASN1Primitive().equals(id.toASN1Primitive());
  }
  
  public int hashCode()
  {
    return id.toASN1Primitive().hashCode();
  }
  
  public static CertificateID deriveCertificateID(CertificateID paramCertificateID, BigInteger paramBigInteger)
  {
    return new CertificateID(new CertID(id.getHashAlgorithm(), id.getIssuerNameHash(), id.getIssuerKeyHash(), new ASN1Integer(paramBigInteger)));
  }
  
  private static CertID createCertID(DigestCalculator paramDigestCalculator, X509CertificateHolder paramX509CertificateHolder, ASN1Integer paramASN1Integer)
    throws OCSPException
  {
    try
    {
      OutputStream localOutputStream = paramDigestCalculator.getOutputStream();
      localOutputStream.write(paramX509CertificateHolder.toASN1Structure().getSubject().getEncoded("DER"));
      localOutputStream.close();
      DEROctetString localDEROctetString1 = new DEROctetString(paramDigestCalculator.getDigest());
      SubjectPublicKeyInfo localSubjectPublicKeyInfo = paramX509CertificateHolder.getSubjectPublicKeyInfo();
      localOutputStream = paramDigestCalculator.getOutputStream();
      localOutputStream.write(localSubjectPublicKeyInfo.getPublicKeyData().getBytes());
      localOutputStream.close();
      DEROctetString localDEROctetString2 = new DEROctetString(paramDigestCalculator.getDigest());
      return new CertID(paramDigestCalculator.getAlgorithmIdentifier(), localDEROctetString1, localDEROctetString2, paramASN1Integer);
    }
    catch (Exception localException)
    {
      throw new OCSPException("problem creating ID: " + localException, localException);
    }
  }
}

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

public abstract interface CertificateStatus
{
  public static final CertificateStatus GOOD = null;
}

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

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

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1Exception;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OutputStream;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.ocsp.OCSPRequest;
import org.bouncycastle.asn1.ocsp.Request;
import org.bouncycastle.asn1.ocsp.Signature;
import org.bouncycastle.asn1.ocsp.TBSRequest;
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.GeneralName;
import org.bouncycastle.cert.CertIOException;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;

public class OCSPReq
{
  private static final X509CertificateHolder[] EMPTY_CERTS = new X509CertificateHolder[0];
  private OCSPRequest req;
  private Extensions extensions;
  
  public OCSPReq(OCSPRequest paramOCSPRequest)
  {
    req = paramOCSPRequest;
    extensions = paramOCSPRequest.getTbsRequest().getRequestExtensions();
  }
  
  public OCSPReq(byte[] paramArrayOfByte)
    throws IOException
  {
    this(new ASN1InputStream(paramArrayOfByte));
  }
  
  private OCSPReq(ASN1InputStream paramASN1InputStream)
    throws IOException
  {
    try
    {
      req = OCSPRequest.getInstance(paramASN1InputStream.readObject());
      extensions = req.getTbsRequest().getRequestExtensions();
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new CertIOException("malformed request: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CertIOException("malformed request: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (ASN1Exception localASN1Exception)
    {
      throw new CertIOException("malformed request: " + localASN1Exception.getMessage(), localASN1Exception);
    }
  }
  
  public int getVersionNumber()
  {
    return req.getTbsRequest().getVersion().getValue().intValue() + 1;
  }
  
  public GeneralName getRequestorName()
  {
    return GeneralName.getInstance(req.getTbsRequest().getRequestorName());
  }
  
  public Req[] getRequestList()
  {
    ASN1Sequence localASN1Sequence = req.getTbsRequest().getRequestList();
    Req[] arrayOfReq = new Req[localASN1Sequence.size()];
    for (int i = 0; i != arrayOfReq.length; i++) {
      arrayOfReq[i] = new Req(Request.getInstance(localASN1Sequence.getObjectAt(i)));
    }
    return arrayOfReq;
  }
  
  public boolean hasExtensions()
  {
    return extensions != null;
  }
  
  public Extension getExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    if (extensions != null) {
      return extensions.getExtension(paramASN1ObjectIdentifier);
    }
    return null;
  }
  
  public List getExtensionOIDs()
  {
    return OCSPUtils.getExtensionOIDs(extensions);
  }
  
  public Set getCriticalExtensionOIDs()
  {
    return OCSPUtils.getCriticalExtensionOIDs(extensions);
  }
  
  public Set getNonCriticalExtensionOIDs()
  {
    return OCSPUtils.getNonCriticalExtensionOIDs(extensions);
  }
  
  public ASN1ObjectIdentifier getSignatureAlgOID()
  {
    if (!isSigned()) {
      return null;
    }
    return req.getOptionalSignature().getSignatureAlgorithm().getAlgorithm();
  }
  
  public byte[] getSignature()
  {
    if (!isSigned()) {
      return null;
    }
    return req.getOptionalSignature().getSignature().getBytes();
  }
  
  public X509CertificateHolder[] getCerts()
  {
    if (req.getOptionalSignature() != null)
    {
      ASN1Sequence localASN1Sequence = req.getOptionalSignature().getCerts();
      if (localASN1Sequence != null)
      {
        X509CertificateHolder[] arrayOfX509CertificateHolder = new X509CertificateHolder[localASN1Sequence.size()];
        for (int i = 0; i != arrayOfX509CertificateHolder.length; i++) {
          arrayOfX509CertificateHolder[i] = new X509CertificateHolder(Certificate.getInstance(localASN1Sequence.getObjectAt(i)));
        }
        return arrayOfX509CertificateHolder;
      }
      return EMPTY_CERTS;
    }
    return EMPTY_CERTS;
  }
  
  public boolean isSigned()
  {
    return req.getOptionalSignature() != null;
  }
  
  public boolean isSignatureValid(ContentVerifierProvider paramContentVerifierProvider)
    throws OCSPException
  {
    if (!isSigned()) {
      throw new OCSPException("attempt to verify signature on unsigned object");
    }
    try
    {
      ContentVerifier localContentVerifier = paramContentVerifierProvider.get(req.getOptionalSignature().getSignatureAlgorithm());
      OutputStream localOutputStream = localContentVerifier.getOutputStream();
      localOutputStream.write(req.getTbsRequest().getEncoded("DER"));
      return localContentVerifier.verify(getSignature());
    }
    catch (Exception localException)
    {
      throw new OCSPException("exception processing signature: " + localException, localException);
    }
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    ASN1OutputStream localASN1OutputStream = new ASN1OutputStream(localByteArrayOutputStream);
    localASN1OutputStream.writeObject(req);
    return localByteArrayOutputStream.toByteArray();
  }
}

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

import org.bouncycastle.asn1.ocsp.Request;
import org.bouncycastle.asn1.x509.Extensions;

class OCSPReqBuilder$RequestObject
{
  CertificateID certId;
  Extensions extensions;
  
  public OCSPReqBuilder$RequestObject(OCSPReqBuilder paramOCSPReqBuilder, CertificateID paramCertificateID, Extensions paramExtensions)
  {
    certId = paramCertificateID;
    extensions = paramExtensions;
  }
  
  public Request toRequest()
    throws Exception
  {
    return new Request(certId.toASN1Object(), extensions);
  }
}

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

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.ocsp.OCSPRequest;
import org.bouncycastle.asn1.ocsp.Request;
import org.bouncycastle.asn1.ocsp.Signature;
import org.bouncycastle.asn1.ocsp.TBSRequest;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.ContentSigner;

public class OCSPReqBuilder
{
  private List list = new ArrayList();
  private GeneralName requestorName = null;
  private Extensions requestExtensions = null;
  
  public OCSPReqBuilder addRequest(CertificateID paramCertificateID)
  {
    list.add(new RequestObject(paramCertificateID, null));
    return this;
  }
  
  public OCSPReqBuilder addRequest(CertificateID paramCertificateID, Extensions paramExtensions)
  {
    list.add(new RequestObject(paramCertificateID, paramExtensions));
    return this;
  }
  
  public OCSPReqBuilder setRequestorName(X500Name paramX500Name)
  {
    requestorName = new GeneralName(4, paramX500Name);
    return this;
  }
  
  public OCSPReqBuilder setRequestorName(GeneralName paramGeneralName)
  {
    requestorName = paramGeneralName;
    return this;
  }
  
  public OCSPReqBuilder setRequestExtensions(Extensions paramExtensions)
  {
    requestExtensions = paramExtensions;
    return this;
  }
  
  private OCSPReq generateRequest(ContentSigner paramContentSigner, X509CertificateHolder[] paramArrayOfX509CertificateHolder)
    throws OCSPException
  {
    Iterator localIterator = list.iterator();
    ASN1EncodableVector localASN1EncodableVector1 = new ASN1EncodableVector();
    while (localIterator.hasNext()) {
      try
      {
        localASN1EncodableVector1.add(((RequestObject)localIterator.next()).toRequest());
      }
      catch (Exception localException1)
      {
        throw new OCSPException("exception creating Request", localException1);
      }
    }
    TBSRequest localTBSRequest = new TBSRequest(requestorName, new DERSequence(localASN1EncodableVector1), requestExtensions);
    Signature localSignature = null;
    if (paramContentSigner != null)
    {
      if (requestorName == null) {
        throw new OCSPException("requestorName must be specified if request is signed.");
      }
      try
      {
        OutputStream localOutputStream = paramContentSigner.getOutputStream();
        localOutputStream.write(localTBSRequest.getEncoded("DER"));
        localOutputStream.close();
      }
      catch (Exception localException2)
      {
        throw new OCSPException("exception processing TBSRequest: " + localException2, localException2);
      }
      DERBitString localDERBitString = new DERBitString(paramContentSigner.getSignature());
      AlgorithmIdentifier localAlgorithmIdentifier = paramContentSigner.getAlgorithmIdentifier();
      if ((paramArrayOfX509CertificateHolder != null) && (paramArrayOfX509CertificateHolder.length > 0))
      {
        ASN1EncodableVector localASN1EncodableVector2 = new ASN1EncodableVector();
        for (int i = 0; i != paramArrayOfX509CertificateHolder.length; i++) {
          localASN1EncodableVector2.add(paramArrayOfX509CertificateHolder[i].toASN1Structure());
        }
        localSignature = new Signature(localAlgorithmIdentifier, localDERBitString, new DERSequence(localASN1EncodableVector2));
      }
      else
      {
        localSignature = new Signature(localAlgorithmIdentifier, localDERBitString);
      }
    }
    return new OCSPReq(new OCSPRequest(localTBSRequest, localSignature));
  }
  
  public OCSPReq build()
    throws OCSPException
  {
    return generateRequest(null, null);
  }
  
  public OCSPReq build(ContentSigner paramContentSigner, X509CertificateHolder[] paramArrayOfX509CertificateHolder)
    throws OCSPException, IllegalArgumentException
  {
    if (paramContentSigner == null) {
      throw new IllegalArgumentException("no signer specified");
    }
    return generateRequest(paramContentSigner, paramArrayOfX509CertificateHolder);
  }
  
  private class RequestObject
  {
    CertificateID certId;
    Extensions extensions;
    
    public RequestObject(CertificateID paramCertificateID, Extensions paramExtensions)
    {
      certId = paramCertificateID;
      extensions = paramExtensions;
    }
    
    public Request toRequest()
      throws Exception
    {
      return new Request(certId.toASN1Object(), extensions);
    }
  }
}

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

import java.io.IOException;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Exception;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ocsp.BasicOCSPResponse;
import org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers;
import org.bouncycastle.asn1.ocsp.OCSPResponse;
import org.bouncycastle.asn1.ocsp.OCSPResponseStatus;
import org.bouncycastle.asn1.ocsp.ResponseBytes;
import org.bouncycastle.cert.CertIOException;

public class OCSPResp
{
  private OCSPResponse resp;
  
  public OCSPResp(OCSPResponse paramOCSPResponse)
  {
    resp = paramOCSPResponse;
  }
  
  public OCSPResp(byte[] paramArrayOfByte)
    throws IOException
  {
    this(new ASN1InputStream(paramArrayOfByte));
  }
  
  private OCSPResp(ASN1InputStream paramASN1InputStream)
    throws IOException
  {
    try
    {
      resp = OCSPResponse.getInstance(paramASN1InputStream.readObject());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new CertIOException("malformed response: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CertIOException("malformed response: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (ASN1Exception localASN1Exception)
    {
      throw new CertIOException("malformed response: " + localASN1Exception.getMessage(), localASN1Exception);
    }
  }
  
  public int getStatus()
  {
    return resp.getResponseStatus().getValue().intValue();
  }
  
  public Object getResponseObject()
    throws OCSPException
  {
    ResponseBytes localResponseBytes = resp.getResponseBytes();
    if (localResponseBytes == null) {
      return null;
    }
    if (localResponseBytes.getResponseType().equals(OCSPObjectIdentifiers.id_pkix_ocsp_basic)) {
      try
      {
        ASN1Primitive localASN1Primitive = ASN1Primitive.fromByteArray(localResponseBytes.getResponse().getOctets());
        return new BasicOCSPResp(BasicOCSPResponse.getInstance(localASN1Primitive));
      }
      catch (Exception localException)
      {
        throw new OCSPException("problem decoding object: " + localException, localException);
      }
    }
    return localResponseBytes.getResponse();
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return resp.getEncoded();
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof OCSPResp)) {
      return false;
    }
    OCSPResp localOCSPResp = (OCSPResp)paramObject;
    return resp.equals(resp);
  }
  
  public int hashCode()
  {
    return resp.hashCode();
  }
}

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

import java.io.IOException;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers;
import org.bouncycastle.asn1.ocsp.OCSPResponse;
import org.bouncycastle.asn1.ocsp.OCSPResponseStatus;
import org.bouncycastle.asn1.ocsp.ResponseBytes;

public class OCSPRespBuilder
{
  public static final int SUCCESSFUL = 0;
  public static final int MALFORMED_REQUEST = 1;
  public static final int INTERNAL_ERROR = 2;
  public static final int TRY_LATER = 3;
  public static final int SIG_REQUIRED = 5;
  public static final int UNAUTHORIZED = 6;
  
  public OCSPResp build(int paramInt, Object paramObject)
    throws OCSPException
  {
    if (paramObject == null) {
      return new OCSPResp(new OCSPResponse(new OCSPResponseStatus(paramInt), null));
    }
    if ((paramObject instanceof BasicOCSPResp))
    {
      BasicOCSPResp localBasicOCSPResp = (BasicOCSPResp)paramObject;
      DEROctetString localDEROctetString;
      try
      {
        localDEROctetString = new DEROctetString(localBasicOCSPResp.getEncoded());
      }
      catch (IOException localIOException)
      {
        throw new OCSPException("can't encode object.", localIOException);
      }
      ResponseBytes localResponseBytes = new ResponseBytes(OCSPObjectIdentifiers.id_pkix_ocsp_basic, localDEROctetString);
      return new OCSPResp(new OCSPResponse(new OCSPResponseStatus(paramInt), localResponseBytes));
    }
    throw new OCSPException("unknown response object");
  }
}

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

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.DERGeneralizedTime;
import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.cert.X509CertificateHolder;

class OCSPUtils
{
  static final X509CertificateHolder[] EMPTY_CERTS = new X509CertificateHolder[0];
  static Set EMPTY_SET = Collections.unmodifiableSet(new HashSet());
  static List EMPTY_LIST = Collections.unmodifiableList(new ArrayList());
  
  static Date extractDate(DERGeneralizedTime paramDERGeneralizedTime)
  {
    try
    {
      return paramDERGeneralizedTime.getDate();
    }
    catch (Exception localException)
    {
      throw new IllegalStateException("exception processing GeneralizedTime: " + localException.getMessage());
    }
  }
  
  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()));
  }
}

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

import org.bouncycastle.asn1.ocsp.Request;
import org.bouncycastle.asn1.x509.Extensions;

public class Req
{
  private Request req;
  
  public Req(Request paramRequest)
  {
    req = paramRequest;
  }
  
  public CertificateID getCertID()
  {
    return new CertificateID(req.getReqCert());
  }
  
  public Extensions getSingleRequestExtensions()
  {
    return req.getSingleRequestExtensions();
  }
}

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

import java.math.BigInteger;
import java.util.Date;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ocsp.ResponseData;
import org.bouncycastle.asn1.ocsp.SingleResponse;
import org.bouncycastle.asn1.x509.Extensions;

public class RespData
{
  private ResponseData data;
  
  public RespData(ResponseData paramResponseData)
  {
    data = paramResponseData;
  }
  
  public int getVersion()
  {
    return data.getVersion().getValue().intValue() + 1;
  }
  
  public RespID getResponderId()
  {
    return new RespID(data.getResponderID());
  }
  
  public Date getProducedAt()
  {
    return OCSPUtils.extractDate(data.getProducedAt());
  }
  
  public SingleResp[] getResponses()
  {
    ASN1Sequence localASN1Sequence = data.getResponses();
    SingleResp[] arrayOfSingleResp = new SingleResp[localASN1Sequence.size()];
    for (int i = 0; i != arrayOfSingleResp.length; i++) {
      arrayOfSingleResp[i] = new SingleResp(SingleResponse.getInstance(localASN1Sequence.getObjectAt(i)));
    }
    return arrayOfSingleResp;
  }
  
  public Extensions getResponseExtensions()
  {
    return data.getResponseExtensions();
  }
}

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

import java.io.OutputStream;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.ocsp.ResponderID;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.DigestCalculator;

public class RespID
{
  public static final AlgorithmIdentifier HASH_SHA1 = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
  ResponderID id;
  
  public RespID(ResponderID paramResponderID)
  {
    id = paramResponderID;
  }
  
  public RespID(X500Name paramX500Name)
  {
    id = new ResponderID(paramX500Name);
  }
  
  public RespID(SubjectPublicKeyInfo paramSubjectPublicKeyInfo, DigestCalculator paramDigestCalculator)
    throws OCSPException
  {
    try
    {
      if (!paramDigestCalculator.getAlgorithmIdentifier().equals(HASH_SHA1)) {
        throw new IllegalArgumentException("only SHA-1 can be used with RespID");
      }
      OutputStream localOutputStream = paramDigestCalculator.getOutputStream();
      localOutputStream.write(paramSubjectPublicKeyInfo.getPublicKeyData().getBytes());
      localOutputStream.close();
      id = new ResponderID(new DEROctetString(paramDigestCalculator.getDigest()));
    }
    catch (Exception localException)
    {
      throw new OCSPException("problem creating ID: " + localException, localException);
    }
  }
  
  public ResponderID toASN1Object()
  {
    return id;
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof RespID)) {
      return false;
    }
    RespID localRespID = (RespID)paramObject;
    return id.equals(id);
  }
  
  public int hashCode()
  {
    return id.hashCode();
  }
}

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

import java.math.BigInteger;
import java.util.Date;
import org.bouncycastle.asn1.DERGeneralizedTime;
import org.bouncycastle.asn1.ocsp.RevokedInfo;
import org.bouncycastle.asn1.x509.CRLReason;

public class RevokedStatus
  implements CertificateStatus
{
  RevokedInfo info;
  
  public RevokedStatus(RevokedInfo paramRevokedInfo)
  {
    info = paramRevokedInfo;
  }
  
  public RevokedStatus(Date paramDate, int paramInt)
  {
    info = new RevokedInfo(new DERGeneralizedTime(paramDate), CRLReason.lookup(paramInt));
  }
  
  public Date getRevocationTime()
  {
    return OCSPUtils.extractDate(info.getRevocationTime());
  }
  
  public boolean hasRevocationReason()
  {
    return info.getRevocationReason() != null;
  }
  
  public int getRevocationReason()
  {
    if (info.getRevocationReason() == null) {
      throw new IllegalStateException("attempt to get a reason where none is available");
    }
    return info.getRevocationReason().getValue().intValue();
  }
}

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

import java.util.Date;
import java.util.List;
import java.util.Set;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ocsp.CertStatus;
import org.bouncycastle.asn1.ocsp.RevokedInfo;
import org.bouncycastle.asn1.ocsp.SingleResponse;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.Extensions;

public class SingleResp
{
  private SingleResponse resp;
  private Extensions extensions;
  
  public SingleResp(SingleResponse paramSingleResponse)
  {
    resp = paramSingleResponse;
    extensions = paramSingleResponse.getSingleExtensions();
  }
  
  public CertificateID getCertID()
  {
    return new CertificateID(resp.getCertID());
  }
  
  public CertificateStatus getCertStatus()
  {
    CertStatus localCertStatus = resp.getCertStatus();
    if (localCertStatus.getTagNo() == 0) {
      return null;
    }
    if (localCertStatus.getTagNo() == 1) {
      return new RevokedStatus(RevokedInfo.getInstance(localCertStatus.getStatus()));
    }
    return new UnknownStatus();
  }
  
  public Date getThisUpdate()
  {
    return OCSPUtils.extractDate(resp.getThisUpdate());
  }
  
  public Date getNextUpdate()
  {
    if (resp.getNextUpdate() == null) {
      return null;
    }
    return OCSPUtils.extractDate(resp.getNextUpdate());
  }
  
  public boolean hasExtensions()
  {
    return extensions != null;
  }
  
  public Extension getExtension(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    if (extensions != null) {
      return extensions.getExtension(paramASN1ObjectIdentifier);
    }
    return null;
  }
  
  public List getExtensionOIDs()
  {
    return OCSPUtils.getExtensionOIDs(extensions);
  }
  
  public Set getCriticalExtensionOIDs()
  {
    return OCSPUtils.getCriticalExtensionOIDs(extensions);
  }
  
  public Set getNonCriticalExtensionOIDs()
  {
    return OCSPUtils.getNonCriticalExtensionOIDs(extensions);
  }
}

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

public class UnknownStatus
  implements CertificateStatus
{}

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

import java.security.PublicKey;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.ocsp.BasicOCSPRespBuilder;
import org.bouncycastle.cert.ocsp.OCSPException;
import org.bouncycastle.operator.DigestCalculator;

public class JcaBasicOCSPRespBuilder
  extends BasicOCSPRespBuilder
{
  public JcaBasicOCSPRespBuilder(PublicKey paramPublicKey, DigestCalculator paramDigestCalculator)
    throws OCSPException
  {
    super(SubjectPublicKeyInfo.getInstance(paramPublicKey.getEncoded()), paramDigestCalculator);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.ocsp.jcajce.JcaBasicOCSPRespBuilder
 *
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-2019. Infinite Loop Ltd