use of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential in project airavata by apache.
the class CredentialsDAOTest method testDeleteCredentials.
@Test
public void testDeleteCredentials() throws Exception {
addTestCredentials();
Connection connection = getConnection();
try {
CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
Assert.assertNotNull(certificateCredential);
credentialsDAO.deleteCredentials("gw1", "tom", connection);
certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
Assert.assertNull(certificateCredential);
} finally {
connection.close();
}
}
use of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential in project airavata by apache.
the class CredentialsDAOTest method testAddCredentials.
@Test
public void testAddCredentials() throws Exception {
addTestCredentials();
Connection connection = getConnection();
try {
CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
// Test get gateway name
String gateway = credentialsDAO.getGatewayID("tom", connection);
Assert.assertNotNull(certificateCredential);
Assert.assertEquals("jerry", certificateCredential.getPortalUserName());
Assert.assertEquals("gw1", gateway);
checkEquality(x509Certificates, certificateCredential.getCertificates());
Assert.assertEquals(privateKey.getFormat(), certificateCredential.getPrivateKey().getFormat());
} finally {
connection.close();
}
}
use of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential in project airavata by apache.
the class CredentialsDAOTest method addTestCredentials.
private void addTestCredentials() throws Exception {
Connection connection = getConnection();
try {
CertificateCredential certificateCredential = getTestCredentialObject();
credentialsDAO.addCredentials(certificateCredential.getCommunityUser().getGatewayName(), certificateCredential, connection);
} finally {
connection.close();
}
}
use of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential in project airavata by apache.
the class CredentialsDAOTest method testSerializationWithEncryption.
@Test
public void testSerializationWithEncryption() throws CredentialStoreException {
URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
String secretKeyAlias = "mykey";
assert url != null;
CertificateCredential certificateCredential = getTestCredentialObject();
CredentialsDAO credentialsDAO1 = new CredentialsDAO(url.getPath(), secretKeyAlias, new TestACSKeyStoreCallback());
byte[] array = credentialsDAO1.convertObjectToByteArray(certificateCredential);
CertificateCredential readCertificateCredential = (CertificateCredential) credentialsDAO1.convertByteArrayToObject(array);
checkEquality(certificateCredential.getCertificates(), readCertificateCredential.getCertificates());
Assert.assertEquals(certificateCredential.getCertificateRequestedTime(), readCertificateCredential.getCertificateRequestedTime());
Assert.assertEquals(certificateCredential.getCommunityUser().getGatewayName(), readCertificateCredential.getCommunityUser().getGatewayName());
Assert.assertEquals(certificateCredential.getCommunityUser().getUserEmail(), readCertificateCredential.getCommunityUser().getUserEmail());
Assert.assertEquals(certificateCredential.getCommunityUser().getUserName(), readCertificateCredential.getCommunityUser().getUserName());
Assert.assertEquals(certificateCredential.getLifeTime(), readCertificateCredential.getLifeTime());
Assert.assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter());
Assert.assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore());
Assert.assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName());
Assert.assertEquals(certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType());
PrivateKey newKey = readCertificateCredential.getPrivateKey();
Assert.assertNotNull(newKey);
Assert.assertEquals(privateKey.getClass(), newKey.getClass());
Assert.assertEquals(privateKey.getFormat(), newKey.getFormat());
Assert.assertEquals(privateKey.getAlgorithm(), newKey.getAlgorithm());
Assert.assertTrue(Arrays.equals(privateKey.getEncoded(), newKey.getEncoded()));
}
use of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential in project airavata by apache.
the class CredentialsDAOTest method getTestCredentialObject.
public CertificateCredential getTestCredentialObject() {
CertificateCredential certificateCredential = new CertificateCredential();
certificateCredential.setToken("tom");
certificateCredential.setCertificates(x509Certificates);
certificateCredential.setPrivateKey(privateKey);
certificateCredential.setCommunityUser(getCommunityUser("gw1", "tom"));
certificateCredential.setLifeTime(1000);
certificateCredential.setPortalUserName("jerry");
certificateCredential.setNotBefore("13 OCT 2012 5:34:23");
certificateCredential.setNotAfter("14 OCT 2012 5:34:23");
certificateCredential.setCredentialOwnerType(CredentialOwnerType.GATEWAY);
return certificateCredential;
}
Aggregations