Search in sources :

Example 21 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project keystore-explorer by kaikramer.

the class DNameConstraints method okPressed.

private void okPressed() {
    List<GeneralSubtree> permittedSubtrees = jgsPermittedSubtrees.getGeneralSubtrees().getGeneralSubtrees();
    List<GeneralSubtree> excludedSubtrees = jgsExcludedSubtrees.getGeneralSubtrees().getGeneralSubtrees();
    GeneralSubtree[] permittedSubtreesArray = permittedSubtrees.toArray(new GeneralSubtree[permittedSubtrees.size()]);
    GeneralSubtree[] excludedSubtreesArray = excludedSubtrees.toArray(new GeneralSubtree[excludedSubtrees.size()]);
    NameConstraints nameConstraints = new NameConstraints(permittedSubtreesArray, excludedSubtreesArray);
    try {
        value = nameConstraints.getEncoded(ASN1Encoding.DER);
    } catch (IOException e) {
        DError.displayError(this, e);
        return;
    }
    closeDialog();
}
Also used : NameConstraints(org.bouncycastle.asn1.x509.NameConstraints) GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree) IOException(java.io.IOException)

Example 22 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project keystore-explorer by kaikramer.

the class JGeneralSubtrees method removeSelectedGeneralSubtree.

private void removeSelectedGeneralSubtree() {
    int selectedRow = jtGeneralSubtrees.getSelectedRow();
    if (selectedRow != -1) {
        GeneralSubtree generalSubtree = (GeneralSubtree) jtGeneralSubtrees.getValueAt(selectedRow, 0);
        generalSubtrees.getGeneralSubtrees().remove(generalSubtree);
        reloadGeneralSubtreesTable();
        selectFirstGeneralSubtreeInTable();
        updateButtonControls();
    }
}
Also used : GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree) Point(java.awt.Point)

Example 23 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project LinLong-Java by zhenwei1108.

the class RFC3280CertPathUtilities method prepareNextCertG.

protected static void prepareNextCertG(CertPath certPath, int index, PKIXNameConstraintValidator nameConstraintValidator) throws CertPathValidatorException {
    List certs = certPath.getCertificates();
    X509Certificate cert = (X509Certificate) certs.get(index);
    // 
    // (g) handle the name constraints extension
    // 
    NameConstraints nc = null;
    try {
        ASN1Sequence ncSeq = ASN1Sequence.getInstance(CertPathValidatorUtilities.getExtensionValue(cert, RFC3280CertPathUtilities.NAME_CONSTRAINTS));
        if (ncSeq != null) {
            nc = NameConstraints.getInstance(ncSeq);
        }
    } catch (Exception e) {
        throw new ExtCertPathValidatorException("Name constraints extension could not be decoded.", e, certPath, index);
    }
    if (nc != null) {
        // 
        // (g) (1) permitted subtrees
        // 
        GeneralSubtree[] permitted = nc.getPermittedSubtrees();
        if (permitted != null) {
            try {
                nameConstraintValidator.intersectPermittedSubtree(permitted);
            } catch (Exception ex) {
                throw new ExtCertPathValidatorException("Permitted subtrees cannot be build from name constraints extension.", ex, certPath, index);
            }
        }
        // 
        // (g) (2) excluded subtrees
        // 
        GeneralSubtree[] excluded = nc.getExcludedSubtrees();
        if (excluded != null) {
            for (int i = 0; i != excluded.length; i++) {
                try {
                    nameConstraintValidator.addExcludedSubtree(excluded[i]);
                } catch (Exception ex) {
                    throw new ExtCertPathValidatorException("Excluded subtrees cannot be build from name constraints extension.", ex, certPath, index);
                }
            }
        }
    }
}
Also used : NameConstraints(com.github.zhenwei.core.asn1.x509.NameConstraints) ASN1Sequence(com.github.zhenwei.core.asn1.ASN1Sequence) ExtCertPathValidatorException(com.github.zhenwei.provider.jce.exception.ExtCertPathValidatorException) List(java.util.List) ArrayList(java.util.ArrayList) GeneralSubtree(com.github.zhenwei.core.asn1.x509.GeneralSubtree) X509Certificate(java.security.cert.X509Certificate) CertificateExpiredException(java.security.cert.CertificateExpiredException) GeneralSecurityException(java.security.GeneralSecurityException) CertPathValidatorException(java.security.cert.CertPathValidatorException) ExtCertPathValidatorException(com.github.zhenwei.provider.jce.exception.ExtCertPathValidatorException) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertPathBuilderException(java.security.cert.CertPathBuilderException) IOException(java.io.IOException) IssuingDistributionPoint(com.github.zhenwei.core.asn1.x509.IssuingDistributionPoint) CRLDistPoint(com.github.zhenwei.core.asn1.x509.CRLDistPoint) DistributionPoint(com.github.zhenwei.core.asn1.x509.DistributionPoint)

Example 24 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project LinLong-Java by zhenwei1108.

the class GeneralSubtree method toASN1Primitive.

/**
 * Produce an object suitable for an ASN1OutputStream.
 * <p>
 * Returns:
 *
 * <pre>
 *       GeneralSubtree ::= SEQUENCE
 *       {
 *         base                    GeneralName,
 *         minimum         [0]     BaseDistance DEFAULT 0,
 *         maximum         [1]     BaseDistance OPTIONAL
 *       }
 * </pre>
 *
 * @return a ASN1Primitive
 */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector(3);
    v.add(base);
    if (minimum != null && !minimum.hasValue(0)) {
        v.add(new DERTaggedObject(false, 0, minimum));
    }
    if (maximum != null) {
        v.add(new DERTaggedObject(false, 1, maximum));
    }
    return new DERSequence(v);
}
Also used : DERSequence(com.github.zhenwei.core.asn1.DERSequence) DERTaggedObject(com.github.zhenwei.core.asn1.DERTaggedObject) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector)

Example 25 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project LinLong-Java by zhenwei1108.

the class PKIXNameConstraintValidator method intersectURI.

private Set intersectURI(Set permitted, Set uris) {
    Set intersect = new HashSet();
    for (Iterator it = uris.iterator(); it.hasNext(); ) {
        String uri = extractNameAsString(((GeneralSubtree) it.next()).getBase());
        if (permitted == null) {
            if (uri != null) {
                intersect.add(uri);
            }
        } else {
            Iterator _iter = permitted.iterator();
            while (_iter.hasNext()) {
                String _permitted = (String) _iter.next();
                intersectURI(_permitted, uri, intersect);
            }
        }
    }
    return intersect;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) ASN1IA5String(com.github.zhenwei.core.asn1.ASN1IA5String) ASN1OctetString(com.github.zhenwei.core.asn1.ASN1OctetString) HashSet(java.util.HashSet)

Aggregations

GeneralSubtree (org.bouncycastle.asn1.x509.GeneralSubtree)18 BigInteger (java.math.BigInteger)7 GeneralName (org.bouncycastle.asn1.x509.GeneralName)6 NameConstraints (org.bouncycastle.asn1.x509.NameConstraints)6 IOException (java.io.IOException)5 X509Certificate (java.security.cert.X509Certificate)5 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 X500Name (org.bouncycastle.asn1.x500.X500Name)4 GeneralSecurityException (java.security.GeneralSecurityException)3 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)3 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)3 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)3 ASN1IA5String (com.github.zhenwei.core.asn1.ASN1IA5String)2 ASN1OctetString (com.github.zhenwei.core.asn1.ASN1OctetString)2 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)2 CRLDistPoint (com.github.zhenwei.core.asn1.x509.CRLDistPoint)2 DistributionPoint (com.github.zhenwei.core.asn1.x509.DistributionPoint)2 GeneralSubtree (com.github.zhenwei.core.asn1.x509.GeneralSubtree)2