Package org.apache.airavata.credential.store.credential.impl.certificate

Examples of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential


            if (credential instanceof CertificateCredential) {

                log.info("Successfully found credentials for token id - " + getRequestData().getTokenId() +
                        " gateway id - " + getRequestData().getGatewayId());

                CertificateCredential certificateCredential = (CertificateCredential) credential;

                X509Certificate[] certificates = certificateCredential.getCertificates();
                X509Credential newCredential = new X509Credential(certificateCredential.getPrivateKey(), certificates);

                GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(newCredential, GSSCredential.INITIATE_AND_ACCEPT);
                System.out.print(cred.export(ExtendedGSSCredential.IMPEXP_OPAQUE));
                return cred;
                //return new GlobusGSSCredentialImpl(newCredential,
View Full Code Here


    private void addTestCredentials() throws Exception {

        Connection connection = getConnection();

        try {
            CertificateCredential certificateCredential = getTestCredentialObject();
            credentialsDAO.addCredentials(certificateCredential.getCommunityUser().getGatewayName(),
                    certificateCredential, connection);

        } finally {
            connection.close();
        }
View Full Code Here

        }
    }

    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");

        return certificateCredential;

    }
View Full Code Here

    }

    @Test
    public void testSerialization() throws IOException, ClassNotFoundException {

        CertificateCredential certificateCredential = getTestCredentialObject();

        byte[] array = CredentialsDAO.convertObjectToByteArray(certificateCredential);
        CertificateCredential readCertificateCredential = (CertificateCredential) CredentialsDAO
                .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());

        PrivateKey newKey = readCertificateCredential.getPrivateKey();

        Assert.assertNotNull(newKey);
        Assert.assertEquals(privateKey.getClass(), newKey.getClass());

        Assert.assertEquals(privateKey.getFormat(), newKey.getFormat());
View Full Code Here

        addTestCredentials();

        Connection connection = getConnection();

        try {
            CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1",
                    "tom", connection);
            Assert.assertNotNull(certificateCredential);
            Assert.assertEquals("jerry", certificateCredential.getPortalUserName());
            checkEquality(x509Certificates, certificateCredential.getCertificates());
            Assert.assertEquals(privateKey.getFormat(), certificateCredential.getPrivateKey().getFormat());
        } finally {
            connection.close();
        }
    }
View Full Code Here

        addTestCredentials();

        Connection connection = getConnection();

        try {
            CertificateCredential certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1",
                    "tom", connection);
            Assert.assertNotNull(certificateCredential);

            credentialsDAO.deleteCredentials("gw1", "tom", connection);
View Full Code Here

        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");

            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());

        } finally {
            connection.close();
        }
View Full Code Here

        Connection connection = getConnection();

        try {

            CertificateCredential 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());

        } finally {
            connection.close();
        }
View Full Code Here

        communityUserDAO = new CommunityUserDAO();
    }

    public void writeCredentials(Credential credential) throws CredentialStoreException {

        CertificateCredential certificateCredential = (CertificateCredential) credential;

        Connection connection = null;

        try {

            connection = dbUtil.getConnection();
            // Write community user
            writeCommunityUser(certificateCredential.getCommunityUser(), credential.getToken(), connection);
            // First delete existing credentials
            credentialsDAO.deleteCredentials(certificateCredential.getCommunityUser().getGatewayName(),
                    certificateCredential.getToken(), connection);
            // Add the new certificate
            credentialsDAO.addCredentials(certificateCredential.getCommunityUser().getGatewayName(), credential,
                    connection);

        } catch (SQLException e) {
            throw new CredentialStoreException("Unable to retrieve database connection.", e);
        } finally {
View Full Code Here

            JSPUtil.fwd(request, response, ERROR_PAGE);
            return;
        }
        info("2.b. Done! Displaying success page.");

        CertificateCredential certificateCredential = new CertificateCredential();

        certificateCredential.setNotBefore(Utility.convertDateToString(cert.getNotBefore()));
        certificateCredential.setNotAfter(Utility.convertDateToString(cert.getNotAfter()));
        certificateCredential.setCertificate(cert);
        certificateCredential.setPrivateKey(oa4MPResponse.getPrivateKey());
        certificateCredential
                .setCommunityUser(new CommunityUser(gatewayName, assetResponse.getUsername(), contactEmail));
        certificateCredential.setPortalUserName(portalUserName);
        certificateCredential.setLifeTime(duration);
        certificateCredential.setToken(portalTokenId);

        certificateCredentialWriter.writeCredentials(certificateCredential);

        StringBuilder stringBuilder = new StringBuilder("Certificate for community user ");
        stringBuilder.append(assetResponse.getUsername()).append(" successfully persisted.");
View Full Code Here

TOP

Related Classes of org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.