Search in sources :

Example 1 with BasicConstraintsExtensionData

use of de.carne.certmgr.certs.x509.BasicConstraintsExtensionData in project certmgr by hdecarne.

the class CertOptionsController method onCmdDeleteExtension.

@SuppressWarnings("unused")
@FXML
void onCmdDeleteExtension(ActionEvent evt) {
    ExtensionDataModel extensionDataItem = this.ctlExtensionData.getSelectionModel().getSelectedItem();
    if (extensionDataItem != null) {
        X509ExtensionData extensionData = extensionDataItem.getExtensionData();
        if (extensionData instanceof BasicConstraintsExtensionData) {
            this.basicConstraintsExtension.set(null);
        } else if (extensionData instanceof KeyUsageExtensionData) {
            this.keyUsageExtension.set(null);
        } else if (extensionData instanceof ExtendedKeyUsageExtensionData) {
            this.extendedKeyUsageExtension.set(null);
        } else if (extensionData instanceof SubjectAlternativeNameExtensionData) {
            this.subjectAlternativeExtension.set(null);
        } else if (extensionData instanceof CRLDistributionPointsExtensionData) {
            this.crlDistributionPointsExtension.set(null);
        }
        this.ctlExtensionData.getItems().remove(extensionDataItem);
    }
}
Also used : X509ExtensionData(de.carne.certmgr.certs.x509.X509ExtensionData) ExtendedKeyUsageExtensionData(de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData) KeyUsageExtensionData(de.carne.certmgr.certs.x509.KeyUsageExtensionData) ExtendedKeyUsageExtensionData(de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData) SubjectAlternativeNameExtensionData(de.carne.certmgr.certs.x509.SubjectAlternativeNameExtensionData) BasicConstraintsExtensionData(de.carne.certmgr.certs.x509.BasicConstraintsExtensionData) CRLDistributionPointsExtensionData(de.carne.certmgr.certs.x509.CRLDistributionPointsExtensionData) FXML(javafx.fxml.FXML)

Example 2 with BasicConstraintsExtensionData

use of de.carne.certmgr.certs.x509.BasicConstraintsExtensionData in project certmgr by hdecarne.

the class CertOptionsController method applyPreset.

private void applyPreset(CertOptionsPreset preset) {
    this.ctlAliasInput.setText(preset.aliasInput());
    this.ctlDNInput.setText(preset.dnInput());
    KeyPairAlgorithm keyAlg = preset.getKeyAlg();
    if (keyAlg != null) {
        this.ctlKeyAlgOption.setValue(preset.getKeyAlg());
    }
    Integer keySize = preset.getKeySize();
    if (keySize != null) {
        this.ctlKeySizeOption.setValue(preset.getKeySize());
    }
    this.basicConstraintsExtension.set(null);
    this.keyUsageExtension.set(null);
    this.extendedKeyUsageExtension.set(null);
    this.subjectAlternativeExtension.set(null);
    this.crlDistributionPointsExtension.set(null);
    this.ctlExtensionData.getItems().clear();
    for (X509ExtensionData extensionData : preset.getExtensions()) {
        if (extensionData instanceof BasicConstraintsExtensionData) {
            this.basicConstraintsExtension.set((BasicConstraintsExtensionData) extensionData);
        } else if (extensionData instanceof KeyUsageExtensionData) {
            this.keyUsageExtension.set((KeyUsageExtensionData) extensionData);
        } else if (extensionData instanceof ExtendedKeyUsageExtensionData) {
            this.extendedKeyUsageExtension.set((ExtendedKeyUsageExtensionData) extensionData);
        } else if (extensionData instanceof SubjectAlternativeNameExtensionData) {
            this.subjectAlternativeExtension.set((SubjectAlternativeNameExtensionData) extensionData);
        } else if (extensionData instanceof CRLDistributionPointsExtensionData) {
            this.crlDistributionPointsExtension.set((CRLDistributionPointsExtensionData) extensionData);
        }
        this.ctlExtensionData.getItems().add(new ExtensionDataModel(extensionData));
    }
}
Also used : X509ExtensionData(de.carne.certmgr.certs.x509.X509ExtensionData) KeyPairAlgorithm(de.carne.certmgr.certs.security.KeyPairAlgorithm) ExtendedKeyUsageExtensionData(de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData) KeyUsageExtensionData(de.carne.certmgr.certs.x509.KeyUsageExtensionData) ExtendedKeyUsageExtensionData(de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData) SubjectAlternativeNameExtensionData(de.carne.certmgr.certs.x509.SubjectAlternativeNameExtensionData) BasicConstraintsExtensionData(de.carne.certmgr.certs.x509.BasicConstraintsExtensionData) CRLDistributionPointsExtensionData(de.carne.certmgr.certs.x509.CRLDistributionPointsExtensionData)

Example 3 with BasicConstraintsExtensionData

use of de.carne.certmgr.certs.x509.BasicConstraintsExtensionData in project certmgr by hdecarne.

the class CertOptionsController method onCmdEditBasicConstraints.

@SuppressWarnings("unused")
@FXML
void onCmdEditBasicConstraints(ActionEvent evt) {
    try {
        BasicConstraintsController extensionDialog = BasicConstraintsDialog.load(this);
        BasicConstraintsExtensionData extensionData = this.basicConstraintsExtension.get();
        if (extensionData != null) {
            extensionDialog.init(extensionData, this.expertModeParam);
        } else {
            extensionDialog.init(this.expertModeParam);
        }
        Optional<BasicConstraintsExtensionData> dialogResult = extensionDialog.showAndWait();
        if (dialogResult.isPresent()) {
            extensionData = dialogResult.get();
            setExtensionData(extensionData);
            this.basicConstraintsExtension.set(extensionData);
        }
    } catch (IOException e) {
        Alerts.unexpected(e).showAndWait();
    }
}
Also used : BasicConstraintsExtensionData(de.carne.certmgr.certs.x509.BasicConstraintsExtensionData) IOException(java.io.IOException) FXML(javafx.fxml.FXML)

Example 4 with BasicConstraintsExtensionData

use of de.carne.certmgr.certs.x509.BasicConstraintsExtensionData in project certmgr by hdecarne.

the class BasicConstraintsController method onApply.

private void onApply(ActionEvent evt) {
    try {
        boolean critical = this.ctlCritical.isSelected();
        boolean ca = this.ctlCA.isSelected();
        BigInteger pathLenConstraint = null;
        if (ca) {
            pathLenConstraint = valdiateAndGetPathLenConstraint();
        }
        this.extensionDataResult = new BasicConstraintsExtensionData(critical, ca, pathLenConstraint);
    } catch (ValidationException e) {
        ValidationAlerts.error(e).showAndWait();
        evt.consume();
    }
}
Also used : ValidationException(de.carne.jfx.util.validation.ValidationException) BasicConstraintsExtensionData(de.carne.certmgr.certs.x509.BasicConstraintsExtensionData) BigInteger(java.math.BigInteger)

Example 5 with BasicConstraintsExtensionData

use of de.carne.certmgr.certs.x509.BasicConstraintsExtensionData in project certmgr by hdecarne.

the class UserCertStoreTest method generateRequest.

private GenerateCertRequest generateRequest(UserCertStore store, CertGenerator generator, boolean ca) {
    GenerateCertRequest request = basicRequest();
    if (generator.hasFeature(CertGenerator.Feature.CUSTOM_ISSUER)) {
        request.setIssuer(generator.getIssuers(store, null).getDefault());
    }
    if (generator.hasFeature(CertGenerator.Feature.CUSTOM_SIGNATURE_ALGORITHM)) {
        request.setSignatureAlgorithm(Check.notNull(generator.getSignatureAlgorithms(request.getIssuer(), request.keyPairAlgorithm(), null, false).getDefault()));
    }
    request.addExtension(new BasicConstraintsExtensionData(false, ca, null));
    return request;
}
Also used : BasicConstraintsExtensionData(de.carne.certmgr.certs.x509.BasicConstraintsExtensionData) GenerateCertRequest(de.carne.certmgr.certs.x509.GenerateCertRequest)

Aggregations

BasicConstraintsExtensionData (de.carne.certmgr.certs.x509.BasicConstraintsExtensionData)5 CRLDistributionPointsExtensionData (de.carne.certmgr.certs.x509.CRLDistributionPointsExtensionData)2 ExtendedKeyUsageExtensionData (de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData)2 KeyUsageExtensionData (de.carne.certmgr.certs.x509.KeyUsageExtensionData)2 SubjectAlternativeNameExtensionData (de.carne.certmgr.certs.x509.SubjectAlternativeNameExtensionData)2 X509ExtensionData (de.carne.certmgr.certs.x509.X509ExtensionData)2 FXML (javafx.fxml.FXML)2 KeyPairAlgorithm (de.carne.certmgr.certs.security.KeyPairAlgorithm)1 GenerateCertRequest (de.carne.certmgr.certs.x509.GenerateCertRequest)1 ValidationException (de.carne.jfx.util.validation.ValidationException)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1