import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
-import org.cacert.gigi.Certificate.CSRType;
-import org.cacert.gigi.Certificate.CertificateStatus;
-import org.cacert.gigi.Certificate.SANType;
-import org.cacert.gigi.Certificate.SubjectAlternateName;
+import org.cacert.gigi.dbObjects.Certificate;
+import org.cacert.gigi.dbObjects.Certificate.CSRType;
+import org.cacert.gigi.dbObjects.Certificate.CertificateStatus;
+import org.cacert.gigi.dbObjects.Certificate.SANType;
+import org.cacert.gigi.dbObjects.Certificate.SubjectAlternateName;
+import org.cacert.gigi.dbObjects.CertificateProfile;
- public void testClientCertLoginStates() throws IOException, GeneralSecurityException, SQLException, InterruptedException {
+ public void testClientCertLoginStates() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
KeyPair kp = generateKeypair();
String key1 = generatePEMCSR(kp, "CN=testmail@example.com");
Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key1, CSRType.CSR, CertificateProfile.getById(1));
final PrivateKey pk = kp.getPrivate();
KeyPair kp = generateKeypair();
String key1 = generatePEMCSR(kp, "CN=testmail@example.com");
Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key1, CSRType.CSR, CertificateProfile.getById(1));
final PrivateKey pk = kp.getPrivate();
final X509Certificate ce = c.cert();
assertNotNull(login(pk, ce));
}
@Test
final X509Certificate ce = c.cert();
assertNotNull(login(pk, ce));
}
@Test
- public void testSANs() throws IOException, GeneralSecurityException, SQLException, InterruptedException {
+ public void testSANs() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
KeyPair kp = generateKeypair();
String key = generatePEMCSR(kp, "CN=testmail@example.com");
Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key, CSRType.CSR, CertificateProfile.getById(1),//
new SubjectAlternateName(SANType.EMAIL, "testmail@example.com"), new SubjectAlternateName(SANType.DNS, "testmail.example.com"));
testFails(CertificateStatus.DRAFT, c);
KeyPair kp = generateKeypair();
String key = generatePEMCSR(kp, "CN=testmail@example.com");
Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key, CSRType.CSR, CertificateProfile.getById(1),//
new SubjectAlternateName(SANType.EMAIL, "testmail@example.com"), new SubjectAlternateName(SANType.DNS, "testmail.example.com"));
testFails(CertificateStatus.DRAFT, c);
X509Certificate cert = c.cert();
Collection<List<?>> sans = cert.getSubjectAlternativeNames();
assertEquals(2, sans.size());
X509Certificate cert = c.cert();
Collection<List<?>> sans = cert.getSubjectAlternativeNames();
assertEquals(2, sans.size());
- public void testCertLifeCycle() throws IOException, GeneralSecurityException, SQLException, InterruptedException {
+ public void testCertLifeCycle() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
KeyPair kp = generateKeypair();
String key = generatePEMCSR(kp, "CN=testmail@example.com");
Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key, CSRType.CSR, CertificateProfile.getById(1));
final PrivateKey pk = kp.getPrivate();
testFails(CertificateStatus.DRAFT, c);
KeyPair kp = generateKeypair();
String key = generatePEMCSR(kp, "CN=testmail@example.com");
Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key, CSRType.CSR, CertificateProfile.getById(1));
final PrivateKey pk = kp.getPrivate();
testFails(CertificateStatus.DRAFT, c);
testFails(CertificateStatus.ISSUED, c);
X509Certificate cert = c.cert();
testFails(CertificateStatus.ISSUED, c);
X509Certificate cert = c.cert();
- private void testFails(CertificateStatus status, Certificate c) throws IOException, GeneralSecurityException, SQLException {
+ private void testFails(CertificateStatus status, Certificate c) throws IOException, GeneralSecurityException, SQLException, GigiApiException {
assertEquals(status, c.getStatus());
if (status != CertificateStatus.ISSUED) {
try {
assertEquals(status, c.getStatus());
if (status != CertificateStatus.ISSUED) {
try {