use of de.carne.certmgr.certs.security.KeyPairAlgorithm 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));
}
}
use of de.carne.certmgr.certs.security.KeyPairAlgorithm in project certmgr by hdecarne.
the class UserCertStoreTest method basicRequest.
private GenerateCertRequest basicRequest() {
KeyPairAlgorithm keyPairAlgorithm = Check.notNull(KeyPairAlgorithm.getDefaultSet(null, false).getDefault());
GenerateCertRequest request = new GenerateCertRequest(X500Names.fromString("CN=TestCert"), keyPairAlgorithm, Check.notNull(keyPairAlgorithm.getStandardKeySizes(null).getDefault()));
Date notBefore = new Date();
Date notAfter = new Date(notBefore.getTime() + 1000 * 60 * 24);
request.setNotBefore(notBefore);
request.setNotAfter(notAfter);
return request;
}
use of de.carne.certmgr.certs.security.KeyPairAlgorithm in project certmgr by hdecarne.
the class KeyPairAlgorithmTest method testGetDefaultSet.
/**
* Test the algorithm provisioning.
*/
@Test
public void testGetDefaultSet() {
Set<KeyPairAlgorithm> standardAlgorithms = KeyPairAlgorithm.getDefaultSet(null, false);
System.out.println("Standard algorithms:");
for (KeyPairAlgorithm standardAlgorithm : standardAlgorithms) {
System.out.println(standardAlgorithm);
}
Set<KeyPairAlgorithm> expertAlgorithms = KeyPairAlgorithm.getDefaultSet(null, true);
System.out.println("Expert algorithms:");
for (KeyPairAlgorithm expertAlgorithm : expertAlgorithms) {
System.out.println(expertAlgorithm);
}
// The standard ones should always be available
Assert.assertTrue(standardAlgorithms.size() == 3);
// The exact number of expert ones will vary, but should always be more
Assert.assertTrue(expertAlgorithms.size() > standardAlgorithms.size());
}
use of de.carne.certmgr.certs.security.KeyPairAlgorithm in project certmgr by hdecarne.
the class SignatureAlgorithmTest method testGetDefaultSet.
/**
* Test the algorithm provisioning.
*/
@Test
public void testGetDefaultSet() {
for (KeyPairAlgorithm keyPairAlgorithm : KeyPairAlgorithm.getDefaultSet(null, true)) {
Set<SignatureAlgorithm> expertAlgorithms = SignatureAlgorithm.getDefaultSet(keyPairAlgorithm.algorithm(), null, true);
System.out.println(keyPairAlgorithm.algorithm() + " expert algorithms:");
for (SignatureAlgorithm expertAlgorithm : expertAlgorithms) {
System.out.println(keyPairAlgorithm.algorithm() + "/" + expertAlgorithm);
}
}
for (KeyPairAlgorithm keyPairAlgorithm : KeyPairAlgorithm.getDefaultSet(null, false)) {
Set<SignatureAlgorithm> standardAlgorithms = SignatureAlgorithm.getDefaultSet(keyPairAlgorithm.algorithm(), null, false);
System.out.println(keyPairAlgorithm.algorithm() + " standard algorithms:");
for (SignatureAlgorithm standardAlgorithm : standardAlgorithms) {
System.out.println(keyPairAlgorithm.algorithm() + "/" + standardAlgorithm);
}
Assert.assertTrue(standardAlgorithms.size() > 0);
}
}
Aggregations