本文整理汇总了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);
}
}
}
}
示例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;
}
示例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;
}
示例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");
}
}
示例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();
}
示例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");
}
}
示例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();
}