Search in sources :

Example 11 with CommunityUser

use of org.apache.airavata.credential.store.credential.CommunityUser in project airavata by apache.

the class CommunityUserDAOTest method testDeleteCommunityUser.

@Test
public void testDeleteCommunityUser() throws Exception {
    Connection connection = getConnection();
    try {
        CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
        communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
        CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
        Assert.assertNotNull(user);
        communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
        communityUserDAO.deleteCommunityUser(communityUser, connection);
        user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
        Assert.assertNull(user);
    } finally {
        connection.close();
    }
}
Also used : CommunityUser(org.apache.airavata.credential.store.credential.CommunityUser) Connection(java.sql.Connection)

Example 12 with CommunityUser

use of org.apache.airavata.credential.store.credential.CommunityUser in project airavata by apache.

the class CommunityUserDAOTest method testDeleteCommunityUserByToken.

@Test
public void testDeleteCommunityUserByToken() throws Exception {
    Connection connection = getConnection();
    try {
        CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
        communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
        CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
        Assert.assertNotNull(user);
        communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
        communityUserDAO.deleteCommunityUserByToken(communityUser, "Token1", connection);
        user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
        Assert.assertNull(user);
    } finally {
        connection.close();
    }
}
Also used : CommunityUser(org.apache.airavata.credential.store.credential.CommunityUser) Connection(java.sql.Connection)

Example 13 with CommunityUser

use of org.apache.airavata.credential.store.credential.CommunityUser in project airavata by apache.

the class CommunityUserDAOTest method testGetCommunityUsers.

@Test
public void testGetCommunityUsers() throws Exception {
    Connection connection = getConnection();
    try {
        CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
        communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
        CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
        Assert.assertNotNull(user);
        Assert.assertEquals("ogce@sciencegateway.org", user.getUserEmail());
    } finally {
        connection.close();
    }
}
Also used : CommunityUser(org.apache.airavata.credential.store.credential.CommunityUser) Connection(java.sql.Connection)

Example 14 with CommunityUser

use of org.apache.airavata.credential.store.credential.CommunityUser in project airavata by apache.

the class CredentialsDAOTest method testUpdateCredentials.

@Test
public void testUpdateCredentials() throws Exception {
    addTestCredentials();
    Connection connection = getConnection();
    try {
        CommunityUser communityUser = getCommunityUser("gw1", "tom");
        CertificateCredential certificateCredential = new CertificateCredential();
        certificateCredential.setToken("tom");
        certificateCredential.setCommunityUser(communityUser);
        certificateCredential.setCertificates(x509Certificates);
        // certificateCredential.setPrivateKey(privateKey);
        certificateCredential.setPortalUserName("test2");
        certificateCredential.setLifeTime(50);
        certificateCredential.setNotBefore("15 OCT 2012 5:34:23");
        certificateCredential.setNotAfter("16 OCT 2012 5:34:23");
        certificateCredential.setCredentialOwnerType(CredentialOwnerType.USER);
        credentialsDAO.updateCredentials(communityUser.getGatewayName(), certificateCredential, connection);
        certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
        Assert.assertEquals("CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US", certificateCredential.getCertificates()[0].getIssuerDN().toString());
        // Assert.assertNotNull(certificateCredential.getPrivateKey());
        Assert.assertEquals("test2", certificateCredential.getPortalUserName());
        Assert.assertEquals(CredentialOwnerType.USER, certificateCredential.getCredentialOwnerType());
    } finally {
        connection.close();
    }
}
Also used : CertificateCredential(org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential) CommunityUser(org.apache.airavata.credential.store.credential.CommunityUser) Connection(java.sql.Connection) Test(org.junit.Test)

Aggregations

CommunityUser (org.apache.airavata.credential.store.credential.CommunityUser)14 Connection (java.sql.Connection)7 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)6 SQLException (java.sql.SQLException)4 CertificateCredential (org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 X509Certificate (java.security.cert.X509Certificate)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 Credential (org.apache.airavata.credential.store.credential.Credential)2 org.apache.airavata.model.credential.store (org.apache.airavata.model.credential.store)2 AssetResponse (edu.uiuc.ncsa.myproxy.oa4mp.client.AssetResponse)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 PrivateKey (java.security.PrivateKey)1 CertificateFactory (java.security.cert.CertificateFactory)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 CertificateAuditInfo (org.apache.airavata.credential.store.credential.impl.certificate.CertificateAuditInfo)1