Java Code Examples for org.bouncycastle.asn1.x509.CertificateList#getInstance()

The following examples show how to use org.bouncycastle.asn1.x509.CertificateList#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Actions.java    From xipki with Apache License 2.0 6 votes vote down vote up
@Override
protected Object execute0() throws Exception {
  CertificateList crl = CertificateList.getInstance(
      X509Util.toDerEncoded(IoUtil.read(inFile)));

  if (crlNumber != null && crlNumber) {
    ASN1Encodable asn1 = crl.getTBSCertList().getExtensions().getExtensionParsedValue(
        Extension.cRLNumber);
    if (asn1 == null) {
      return "null";
    }
    return getNumber(ASN1Integer.getInstance(asn1).getPositiveValue());
  } else if (issuer != null && issuer) {
    return crl.getIssuer().toString();
  } else if (thisUpdate != null && thisUpdate) {
    return toUtcTimeyyyyMMddhhmmssZ(crl.getThisUpdate().getDate());
  } else if (nextUpdate != null && nextUpdate) {
    return crl.getNextUpdate() == null ? "null" :
      toUtcTimeyyyyMMddhhmmssZ(crl.getNextUpdate().getDate());
  }

  return null;
}
 
Example 2
Source File: RevocationInfoArchival.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
private RevocationInfoArchival(ASN1Sequence seq)
{
    if (seq.size() > 3)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1TaggedObject o = (ASN1TaggedObject)e.nextElement();
        switch (o.getTagNo())
        {
            case 0:
                ASN1Sequence crlValsSeq = (ASN1Sequence)o.getObject();
                Enumeration crlValsEnum = crlValsSeq.getObjects();
                while (crlValsEnum.hasMoreElements())
                {
                    CertificateList.getInstance(crlValsEnum.nextElement());
                }
                this.crlVals = crlValsSeq;
                break;
            case 1:
                ASN1Sequence ocspValsSeq = (ASN1Sequence)o.getObject();
                Enumeration ocspValsEnum = ocspValsSeq.getObjects();
                while (ocspValsEnum.hasMoreElements())
                {
                    OCSPResponse.getInstance(ocspValsEnum.nextElement());
                }
                this.ocspVals = ocspValsSeq;
                break;
            case 2:
                this.otherRevVals = OtherRevVals.getInstance(o.getObject());
                break;
            default:
                throw new IllegalArgumentException("invalid tag: "
                    + o.getTagNo());
        }
    }
}
 
Example 3
Source File: RevocationInfoArchival.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CertificateList[] getCrlVals()
{
    if (null == this.crlVals)
    {
        return new CertificateList[0];
    }
    CertificateList[] result = new CertificateList[this.crlVals.size()];
    for (int idx = 0; idx < result.length; idx++)
    {
        result[idx] = CertificateList.getInstance(this.crlVals
            .getObjectAt(idx));
    }
    return result;
}
 
Example 4
Source File: ScepUtil.java    From xipki with Apache License 2.0 5 votes vote down vote up
public static X509CRLHolder getCrlFromPkiMessage(SignedData signedData) throws CRLException {
  Args.notNull(signedData, "signedData");
  ASN1Set set = signedData.getCRLs();
  if (set == null || set.size() == 0) {
    return null;
  }

  try {
    CertificateList cl = CertificateList.getInstance(set.getObjectAt(0));
    return new X509CRLHolder(cl);
  } catch (IllegalArgumentException ex) {
    throw new CRLException(ex);
  }
}
 
Example 5
Source File: X509Ca.java    From xipki with Apache License 2.0 5 votes vote down vote up
public CertificateList getBcCrl(BigInteger crlNumber) throws OperationException {
  LOG.info("     START getCrl: ca={}, crlNumber={}", caIdent.getName(), crlNumber);
  boolean successful = false;

  try {
    byte[] encodedCrl = certstore.getEncodedCrl(caIdent, crlNumber);
    if (encodedCrl == null) {
      return null;
    }

    try {
      CertificateList crl = CertificateList.getInstance(encodedCrl);
      successful = true;
      if (LOG.isInfoEnabled()) {
        LOG.info("SUCCESSFUL getCrl: ca={}, thisUpdate={}", caIdent.getName(),
            crl.getThisUpdate().getTime());
      }
      return crl;
    } catch (RuntimeException ex) {
      throw new OperationException(SYSTEM_FAILURE, ex);
    }
  } finally {
    if (!successful) {
      LOG.info("    FAILED getCrl: ca={}", caIdent.getName());
    }
  }
}
 
Example 6
Source File: CmpAgent.java    From xipki with Apache License 2.0 4 votes vote down vote up
private X509CRLHolder evaluateCrlResponse(VerifiedPkiMessage response, Integer xipkiAction)
    throws CmpClientException, PkiErrorException {
  checkProtection(Args.notNull(response, "response"));

  PKIBody respBody = response.getPkiMessage().getBody();
  int bodyType = respBody.getType();

  if (PKIBody.TYPE_ERROR == bodyType) {
    ErrorMsgContent content = ErrorMsgContent.getInstance(respBody.getContent());
    throw new PkiErrorException(content.getPKIStatusInfo());
  } else if (PKIBody.TYPE_GEN_REP != bodyType) {
    throw new CmpClientException(String.format(
        "unknown PKI body type %s instead the expected [%s, %s]",
        bodyType, PKIBody.TYPE_GEN_REP, PKIBody.TYPE_ERROR));
  }

  ASN1ObjectIdentifier expectedType = (xipkiAction == null)
      ? CMPObjectIdentifiers.it_currentCRL : ObjectIdentifiers.Xipki.id_xipki_cmp_cmpGenmsg;

  GenRepContent genRep = GenRepContent.getInstance(respBody.getContent());

  InfoTypeAndValue[] itvs = genRep.toInfoTypeAndValueArray();
  InfoTypeAndValue itv = null;
  if (itvs != null && itvs.length > 0) {
    for (InfoTypeAndValue m : itvs) {
      if (expectedType.equals(m.getInfoType())) {
        itv = m;
        break;
      }
    }
  }

  if (itv == null) {
    throw new CmpClientException("the response does not contain InfoTypeAndValue "
        + expectedType);
  }

  ASN1Encodable certListAsn1Object = (xipkiAction == null) ? itv.getInfoValue()
      : extractXiActionContent(itv.getInfoValue(), xipkiAction);

  CertificateList certList = CertificateList.getInstance(certListAsn1Object);
  return new X509CRLHolder(certList);
}