Search in sources :

Example 1 with ExtendedKeyUsageExtensionData

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

the class ExtendedKeyUsageController method init.

/**
 * Initialize the dialog with existing extension data.
 *
 * @param data The extension data to use.
 * @param expertMode Whether to run in expert mode ({@code true}) or not ({@code false}).
 * @return This controller.
 */
public ExtendedKeyUsageController init(ExtendedKeyUsageExtensionData data, boolean expertMode) {
    init(expertMode);
    this.ctlCritical.setSelected(data.getCritical());
    if (data.hasUsage(ExtendedKeyUsage.ANY)) {
        this.ctlAnyUsage.setSelected(true);
    } else {
        for (ExtendedKeyUsage usage : data) {
            this.ctlUsages.getSelectionModel().select(usage);
        }
    }
    return this;
}
Also used : ExtendedKeyUsage(de.carne.certmgr.certs.x509.ExtendedKeyUsage)

Example 2 with ExtendedKeyUsageExtensionData

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

the class CertOptionsController method onCmdEditExtendedKeyUsage.

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

Example 3 with ExtendedKeyUsageExtensionData

use of de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData 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 4 with ExtendedKeyUsageExtensionData

use of de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData 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 5 with ExtendedKeyUsageExtensionData

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

the class ExtendedKeyUsageController method onApply.

@SuppressWarnings("unused")
private void onApply(ActionEvent evt) {
    boolean critical = this.ctlCritical.isSelected();
    Set<ExtendedKeyUsage> usages = new HashSet<>();
    if (this.ctlAnyUsage.isSelected()) {
        usages.add(ExtendedKeyUsage.ANY);
    } else {
        for (ExtendedKeyUsage usage : this.ctlUsages.getSelectionModel().getSelectedItems()) {
            usages.add(usage);
        }
    }
    this.extensionDataResult = new ExtendedKeyUsageExtensionData(critical, usages);
}
Also used : ExtendedKeyUsageExtensionData(de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData) ExtendedKeyUsage(de.carne.certmgr.certs.x509.ExtendedKeyUsage) HashSet(java.util.HashSet)

Aggregations

ExtendedKeyUsageExtensionData (de.carne.certmgr.certs.x509.ExtendedKeyUsageExtensionData)4 BasicConstraintsExtensionData (de.carne.certmgr.certs.x509.BasicConstraintsExtensionData)2 CRLDistributionPointsExtensionData (de.carne.certmgr.certs.x509.CRLDistributionPointsExtensionData)2 ExtendedKeyUsage (de.carne.certmgr.certs.x509.ExtendedKeyUsage)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 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1