当前位置: 首页>>代码示例>>Java>>正文


Java BasicConstraints.isCA方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.x509.BasicConstraints.isCA方法的典型用法代码示例。如果您正苦于以下问题:Java BasicConstraints.isCA方法的具体用法?Java BasicConstraints.isCA怎么用?Java BasicConstraints.isCA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.x509.BasicConstraints的用法示例。


在下文中一共展示了BasicConstraints.isCA方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkExtensionBasicConstraints

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
private void checkExtensionBasicConstraints(StringBuilder failureMsg, byte[] extensionValue) {
    BasicConstraints bc = BasicConstraints.getInstance(extensionValue);
    X509CertLevel certLevel = certProfile.certLevel();
    boolean ca = (X509CertLevel.RootCA == certLevel) || (X509CertLevel.SubCA == certLevel);
    if (ca != bc.isCA()) {
        addViolation(failureMsg, "ca", bc.isCA(), ca);
    }

    if (bc.isCA()) {
        BigInteger tmpPathLen = bc.getPathLenConstraint();
        Integer pathLen = certProfile.pathLen();
        if (pathLen == null) {
            if (tmpPathLen != null) {
                addViolation(failureMsg, "pathLen", tmpPathLen, "absent");
            }
        } else {
            if (tmpPathLen == null) {
                addViolation(failureMsg, "pathLen", "null", pathLen);
            } else if (!BigInteger.valueOf(pathLen).equals(tmpPathLen)) {
                addViolation(failureMsg, "pathLen", tmpPathLen, pathLen);
            }
        }
    }
}
 
开发者ID:xipki,项目名称:xipki,代码行数:25,代码来源:ExtensionsChecker.java

示例2: getCAPathConstraint

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
protected int getCAPathConstraint(TBSCertificateStructure crt) 
throws IOException {
X509Extensions extensions = crt.getExtensions();
if (extensions == null) {
    return -1;
}
X509Extension ext =
    extensions.getExtension(X509Extensions.BasicConstraints);
if (ext != null) {
    BasicConstraints basicExt = BouncyCastleUtil.getBasicConstraints(ext);
    if (basicExt.isCA()) {
	BigInteger pathLen = basicExt.getPathLenConstraint();
	return (pathLen == null) ? Integer.MAX_VALUE : pathLen.intValue();
    } else {
	return -1;
    }
}
return -1;
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:20,代码来源:ProxyPathValidator.java

示例3: getCAPathConstraint

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
protected int getCAPathConstraint(TBSCertificateStructure crt) throws IOException {
	X509Extensions extensions = crt.getExtensions();
	if (extensions == null) {
		return -1;
	}
	X509Extension ext = extensions.getExtension(X509Extensions.BasicConstraints);
	if (ext != null) {
		BasicConstraints basicExt = BouncyCastleUtil.getBasicConstraints(ext);
		if (basicExt.isCA()) {
			BigInteger pathLen = basicExt.getPathLenConstraint();
			return (pathLen == null) ? Integer.MAX_VALUE : pathLen.intValue();
		} else {
			return -1;
		}
	}
	return -1;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:18,代码来源:ProxyPathValidator.java

示例4: prepareNextCertK

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
protected static void prepareNextCertK(
    CertPath certPath,
    int index)
    throws CertPathValidatorException
{
    List certs = certPath.getCertificates();
    X509Certificate cert = (X509Certificate)certs.get(index);
    //
    // (k)
    //
    BasicConstraints bc = null;
    try
    {
        bc = BasicConstraints.getInstance(CertPathValidatorUtilities.getExtensionValue(cert,
            RFC3280CertPathUtilities.BASIC_CONSTRAINTS));
    }
    catch (Exception e)
    {
        throw new ExtCertPathValidatorException("Basic constraints extension cannot be decoded.", e, certPath,
            index);
    }
    if (bc != null)
    {
        if (!(bc.isCA()))
        {
            throw new CertPathValidatorException("Not a CA certificate");
        }
    }
    else
    {
        throw new CertPathValidatorException("Intermediate certificate lacks BasicConstraints");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:RFC3280CertPathUtilities.java

示例5: isCa

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
public boolean isCa() {
  Extensions extensions = certificateHolder.getExtensions();
  BasicConstraints basicConstraints = null;

  if (extensions != null) {
    basicConstraints = BasicConstraints
        .fromExtensions(Extensions.getInstance(extensions));
  }

  return basicConstraints != null && basicConstraints.isCA();
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:12,代码来源:CertificateReader.java

示例6: validate

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
public void validate(CertPathValidationContext context, X509CertificateHolder certificate)
    throws CertPathValidationException
{
    if (maxPathLength < 0)
    {
        throw new CertPathValidationException("BasicConstraints path length exceeded");
    }

    context.addHandledExtension(Extension.basicConstraints);

    BasicConstraints certBC = BasicConstraints.fromExtensions(certificate.getExtensions());

    if (certBC != null)
    {
        if (bc != null)
        {
            if (certBC.isCA())
            {
                BigInteger pathLengthConstraint = certBC.getPathLenConstraint();

                if (pathLengthConstraint != null)
                {
                    int plc = pathLengthConstraint.intValue();

                    if (plc < maxPathLength)
                    {
                        maxPathLength = plc;
                        bc = certBC;
                    }
                }
            }
        }
        else
        {
            bc = certBC;
            if (certBC.isCA())
            {
                maxPathLength = certBC.getPathLenConstraint().intValue();
            }
        }
    }
    else
    {
        if (bc != null)
        {
            maxPathLength--;
        }
    }

    if (isMandatory && bc == null)
    {
        throw new CertPathValidationException("BasicConstraints not present in path");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:55,代码来源:BasicConstraintsValidation.java

示例7: getBasicConstraintsStringValue

import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
private String getBasicConstraintsStringValue(byte[] value) throws IOException {
	// @formatter:off

	/*
	 * BasicConstraints ::= ASN1Sequence { cA ASN1Boolean DEFAULT FALSE,
	 * pathLenConstraint ASN1Integer (0..MAX) OPTIONAL }
	 */

	// @formatter:on

	/*
	 * Getting the DEFAULT returns a false ASN1Boolean when no value present
	 * which saves the bother of a null check
	 */

	StringBuilder sb = new StringBuilder();

	BasicConstraints basicConstraints = BasicConstraints.getInstance(value);

	boolean ca = basicConstraints.isCA();
	BigInteger pathLenConstraint = basicConstraints.getPathLenConstraint();

	if (ca) {
		sb.append(res.getString("SubjectIsCa"));
		sb.append(NEWLINE);
	} else {
		sb.append(res.getString("SubjectIsNotCa"));
		sb.append(NEWLINE);
	}

	if (pathLenConstraint != null) {
		sb.append(MessageFormat.format(res.getString("PathLengthConstraint"), pathLenConstraint
				.intValue()));
		sb.append(NEWLINE);
	} else {
		sb.append(res.getString("NoPathLengthConstraint"));
		sb.append(NEWLINE);
	}

	return sb.toString();
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:42,代码来源:X509Ext.java


注:本文中的org.bouncycastle.asn1.x509.BasicConstraints.isCA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。