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();
}
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();
}
}
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);
}
}
}
}
}
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);
}
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;
}
Aggregations