本文整理汇总了Java中org.bouncycastle.asn1.x509.BasicConstraints.getPathLenConstraint方法的典型用法代码示例。如果您正苦于以下问题:Java BasicConstraints.getPathLenConstraint方法的具体用法?Java BasicConstraints.getPathLenConstraint怎么用?Java BasicConstraints.getPathLenConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x509.BasicConstraints
的用法示例。
在下文中一共展示了BasicConstraints.getPathLenConstraint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBasicConstraintsStringValue
import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
/**
* Get Basic Constraints (2.5.29.19) extension value as a string.
*
* <pre>
* BasicConstraints ::= SEQUENCE {
* cA BOOLEAN DEFAULT FALSE,
* pathLenConstraint INTEGER (0..MAX) OPTIONAL }
* </pre>
*
* @param bValue The octet string value
* @return Extension value as a string
* @throws IOException If an I/O problem occurs
*/
private String getBasicConstraintsStringValue(byte[] bValue)
throws IOException
{
BasicConstraints bc = BasicConstraints.getInstance(bValue);
StringBuilder strBuff = new StringBuilder();
strBuff.append(RB.getString(bc.isCA() ? "SubjectIsCa" : "SubjectIsNotCa"));
strBuff.append("<br><br>");
BigInteger pathLen = bc.getPathLenConstraint();
if (pathLen != null)
{
strBuff.append(MessageFormat.format(RB.getString("PathLengthConstraint"), pathLen));
}
return strBuff.toString();
}
示例2: 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);
}
}
}
}
示例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: 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;
}
示例5: prepareNextCertM
import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
protected static int prepareNextCertM(
CertPath certPath,
int index,
int maxPathLength)
throws CertPathValidatorException
{
List certs = certPath.getCertificates();
X509Certificate cert = (X509Certificate)certs.get(index);
//
// (m)
//
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)
{
BigInteger _pathLengthConstraint = bc.getPathLenConstraint();
if (_pathLengthConstraint != null)
{
int _plc = _pathLengthConstraint.intValue();
if (_plc < maxPathLength)
{
return _plc;
}
}
}
return maxPathLength;
}
示例6: prepopulateWithValue
import org.bouncycastle.asn1.x509.BasicConstraints; //导入方法依赖的package包/类
private void prepopulateWithValue(byte[] value) throws IOException {
BasicConstraints basicConstraints = BasicConstraints.getInstance(value);
jcbSubjectIsCa.setSelected(basicConstraints.isCA());
if (basicConstraints.getPathLenConstraint() != null) {
jtfPathLengthConstraint.setText("" + basicConstraints.getPathLenConstraint().intValue());
jtfPathLengthConstraint.setCaretPosition(0);
}
}
示例7: 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");
}
}
示例8: 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();
}