gpt4 book ai didi

org.bouncycastle.cert.X509AttributeCertificateHolder类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 05:24:40 29 4
gpt4 key购买 nike

本文整理了Java中org.bouncycastle.cert.X509AttributeCertificateHolder类的一些代码示例,展示了X509AttributeCertificateHolder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509AttributeCertificateHolder类的具体详情如下:
包路径:org.bouncycastle.cert.X509AttributeCertificateHolder
类名称:X509AttributeCertificateHolder

X509AttributeCertificateHolder介绍

暂无

代码示例

代码示例来源:origin: OpenAttestation/OpenAttestation

X509AttributeCertificateHolder cert;
try {
  cert = new X509AttributeCertificateHolder(encodedCertificate);
log.debug("issuer: {}", StringUtils.join(cert.getIssuer().getNames(), "; "));  // calls toString() on each X500Name so we get the default representation; we can do it ourselves for custom display;  output example: CN=Attr CA,OU=CPG,OU=DCSG,O=Intel,ST=CA,C=US
result.issuer = StringUtils.join(cert.getIssuer().getNames(), "; "); // but expected to be only one
log.debug("serial number: {}", cert.getSerialNumber().toString()); // output example:   1
result.serialNumber = cert.getSerialNumber();
log.debug("holder: {}", StringUtils.join(cert.getHolder().getEntityNames(), ", ")); // output example:  2.25=#041092a71a228c174522a18bfd3ed3d00b39
log.debug("holder has {} entity names", cert.getHolder().getEntityNames().length);
for (X500Name entityName : cert.getHolder().getEntityNames()) {
  log.debug("holder entity name has {} rdns", entityName.getRDNs().length);
  for (RDN rdn : entityName.getRDNs()) {
  result.subject = StringUtils.join(cert.getHolder().getEntityNames(), "; ");
log.debug("not before: {}", cert.getNotBefore()); // output example: Thu Aug 08 15:21:13 PDT 2013
log.debug("not after: {}", cert.getNotAfter()); // output example: Sun Sep 08 15:21:13 PDT 2013
result.notBefore = cert.getNotBefore();
result.notAfter = cert.getNotAfter();
Attribute[] attributes = cert.getAttributes();
result.tags1 = new ArrayList<UTF8NameValueMicroformat>();
result.tags2 = new ArrayList<UTF8NameValueSequence>();

代码示例来源:origin: org.italiangrid/voms-api-java

private boolean checkAuthorityKeyIdentifierExtension(
 VOMSAttribute attributes, List<VOMSValidationErrorMessage> validationErrors) {
 Extension authKeyId = attributes.getVOMSAC().getExtension(
  Extension.authorityKeyIdentifier);
 if (authKeyId != null && authKeyId.isCritical()) {
  validationErrors.add(newErrorMessage(other,
   "AuthorityKeyIdentifier AC extension cannot be critical!"));
  return false;
 }
 return true;
}

代码示例来源:origin: OpenAttestation/OpenAttestation

/**
 * This checks the certificate's notBefore and notAfter dates against the current time.
 * This does NOT check the signature. Do that separately with isTrusted().
 * 
 * @param date to check against the certificate's validity period
 * @return true if the certificate is valid on the given date
 */
public boolean isValid(X509Certificate issuer, Date date) {
  try {
    X509AttributeCertificateHolder holder = new X509AttributeCertificateHolder(encoded);
    ContentVerifierProvider verifierProvider = new BcRSAContentVerifierProviderBuilder(new DefaultDigestAlgorithmIdentifierFinder()).build(new X509CertificateHolder(issuer.getEncoded()));
    if( !holder.isSignatureValid(verifierProvider) ) {
      log.debug("Certificate signature cannot be validated with certificate: {}", issuer.getIssuerX500Principal().getName());
      return false;
    }
    return date.compareTo(notBefore) > -1 && date.compareTo(notAfter) < 1;
  }
  catch(Exception e) {
    log.error("Cannot initialize certificate verifier", e);
    return false;
  }
}

代码示例来源:origin: org.italiangrid/voms-api-java

private boolean checkUnhandledCriticalExtensions(VOMSAttribute attributes,
 List<VOMSValidationErrorMessage> validationErrors) {
 @SuppressWarnings("unchecked")
 List<ASN1ObjectIdentifier> acExtensions = attributes.getVOMSAC()
  .getExtensionOIDs();
 for (ASN1ObjectIdentifier extId : acExtensions) {
  if (!VOMSConstants.VOMS_HANDLED_EXTENSIONS.contains(extId)
   && attributes.getVOMSAC().getExtension(extId).isCritical()) {
   validationErrors.add(newErrorMessage(other,
    "unknown critical extension found in VOMS AC: " + extId.getId()));
   return false;
  }
 }
 return true;
}

代码示例来源:origin: org.italiangrid/voms-api-java

X509AttributeCertificateHolder acHolder = new X509AttributeCertificateHolder(
 ac);
Attribute[] asn1Attrs = acHolder.getAttributes(VOMS_FQANS_OID);
 attrs.setNotBefore(acHolder.getNotBefore());
 attrs.setNotAfter(acHolder.getNotAfter());
 attrs.setSignature(acHolder.getSignature());
 attrs.setGenericAttributes(deserializeGAs(acHolder));
 attrs.setAACertificates(deserializeACCerts(acHolder));
  attrs.setIssuer(new X500Principal(acHolder.getIssuer().getNames()[0]
   .getEncoded()));
  attrs.setHolder(new X500Principal(acHolder.getHolder().getIssuer()[0]
   .getEncoded()));
  attrs.setHolderSerialNumber(acHolder.getHolder().getSerialNumber());

代码示例来源:origin: org.xipki.shells/ocsp-client-shell

new X509AttributeCertificateHolder(IoUtil.read(certFile));
 AttributeCertificateIssuer reqIssuer = cert.getIssuer();
 if (reqIssuer != null && issuerX500Name != null) {
  X500Name reqIssuerName = reqIssuer.getNames()[0];
 sn = cert.getSerialNumber();
} else {
 X509Certificate cert = X509Util.parseCert(new File(certFile));

代码示例来源:origin: org.italiangrid/voms-api-java

private boolean verifyACSignature(VOMSAttribute attributes,
  X509Certificate cert) {

  try {

   X509CertificateHolder certHolder = new JcaX509CertificateHolder(cert);
   ContentVerifierProvider cvp = new BcRSAContentVerifierProviderBuilder(
    new DefaultDigestAlgorithmIdentifierFinder()).build(certHolder);
   return attributes.getVOMSAC().isSignatureValid(cvp);

  } catch (Exception e) {
   throw new VOMSError("Error verifying AC signature: " + e.getMessage(), e);
  }
 }
}

代码示例来源:origin: org.xipki.shell/ocsp-client-shell

new X509AttributeCertificateHolder(IoUtil.read(certFile));
 AttributeCertificateIssuer reqIssuer = cert.getIssuer();
 if (reqIssuer != null && issuerX500Name != null) {
  X500Name reqIssuerName = reqIssuer.getNames()[0];
 sn = cert.getSerialNumber();
} else {
 X509Certificate cert = X509Util.parseCert(new File(certFile));

代码示例来源:origin: org.italiangrid/voms-api-java

private boolean checkNoRevAvailExtension(VOMSAttribute attributes,
 List<VOMSValidationErrorMessage> validationErrors) {
 Extension noRevAvail = attributes.getVOMSAC().getExtension(
  Extension.noRevAvail);
 if (noRevAvail != null && noRevAvail.isCritical()) {
  validationErrors.add(newErrorMessage(other,
   "NoRevAvail AC extension cannot be critical!"));
  return false;
 }
 return true;
}

代码示例来源:origin: org.xipki/security

public static byte[] getCoreExtValue(X509AttributeCertificateHolder cert,
  ASN1ObjectIdentifier type) throws CertificateEncodingException {
 Args.notNull(cert, "cert");
 Args.notNull(type, "type");
 Extension ext = cert.getExtension(type);
 if (ext == null) {
  return null;
 }
 return ext.getExtnValue().getOctets();
}

代码示例来源:origin: org.xipki.tk/security

public static byte[] getCoreExtValue(final X509AttributeCertificateHolder cert,
    final ASN1ObjectIdentifier type) throws CertificateEncodingException {
  ParamUtil.requireNonNull("cert", cert);
  ParamUtil.requireNonNull("type", type);
  Extension ext = cert.getExtension(type);
  if (ext == null) {
    return null;
  }
  return ext.getExtnValue().getOctets();
}

代码示例来源:origin: org.italiangrid/voms-api-java

Extension e = ac.getExtension(VOMS_CERTS_OID);

代码示例来源:origin: org.italiangrid/voms-api-java

Extension targetExtension = ac.getExtension(Extension.targetInformation);

代码示例来源:origin: org.italiangrid/voms-api-java

Extension gasExtension = ac.getExtension(VOMS_GENERIC_ATTRS_OID);

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com