Search in sources :

Example 1 with QaPolicyConstraints

use of org.xipki.ca.qa.internal.QaPolicyConstraints in project xipki by xipki.

the class ExtensionsChecker method checkExtensionPolicyConstraints.

// method checkExtensionNameConstraintsSubtrees
private void checkExtensionPolicyConstraints(StringBuilder failureMsg, byte[] extensionValue, Extensions requestedExtensions, ExtensionControl extControl) {
    QaPolicyConstraints conf = policyConstraints;
    if (conf == null) {
        byte[] expected = getExpectedExtValue(Extension.policyConstraints, requestedExtensions, extControl);
        if (!Arrays.equals(expected, extensionValue)) {
            addViolation(failureMsg, "extension values", hex(extensionValue), (expected == null) ? "not present" : hex(expected));
        }
        return;
    }
    org.bouncycastle.asn1.x509.PolicyConstraints isPolicyConstraints = org.bouncycastle.asn1.x509.PolicyConstraints.getInstance(extensionValue);
    Integer expRequireExplicitPolicy = conf.getRequireExplicitPolicy();
    BigInteger bigInt = isPolicyConstraints.getRequireExplicitPolicyMapping();
    Integer isRequireExplicitPolicy = (bigInt == null) ? null : bigInt.intValue();
    boolean match = true;
    if (expRequireExplicitPolicy == null) {
        if (isRequireExplicitPolicy != null) {
            match = false;
        }
    } else if (!expRequireExplicitPolicy.equals(isRequireExplicitPolicy)) {
        match = false;
    }
    if (!match) {
        addViolation(failureMsg, "requireExplicitPolicy", isRequireExplicitPolicy, expRequireExplicitPolicy);
    }
    Integer expInhibitPolicyMapping = conf.getInhibitPolicyMapping();
    bigInt = isPolicyConstraints.getInhibitPolicyMapping();
    Integer isInhibitPolicyMapping = (bigInt == null) ? null : bigInt.intValue();
    match = true;
    if (expInhibitPolicyMapping == null) {
        if (isInhibitPolicyMapping != null) {
            match = false;
        }
    } else if (!expInhibitPolicyMapping.equals(isInhibitPolicyMapping)) {
        match = false;
    }
    if (!match) {
        addViolation(failureMsg, "inhibitPolicyMapping", isInhibitPolicyMapping, expInhibitPolicyMapping);
    }
}
Also used : QaPolicyConstraints(org.xipki.ca.qa.internal.QaPolicyConstraints) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)1 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)1 QaPolicyConstraints (org.xipki.ca.qa.internal.QaPolicyConstraints)1