Search in sources :

Example 6 with UserCerts

use of io.hops.hopsworks.persistence.entity.certificates.UserCerts in project hopsworks by logicalclocks.

the class CertsFacade method removeUserProjectCerts.

public void removeUserProjectCerts(String projectname, String username) {
    UserCerts item = findUserCert(projectname, username);
    if (item != null) {
        UserCerts tmp = em.merge(item);
        remove(tmp);
    }
}
Also used : UserCerts(io.hops.hopsworks.persistence.entity.certificates.UserCerts)

Example 7 with UserCerts

use of io.hops.hopsworks.persistence.entity.certificates.UserCerts in project hopsworks by logicalclocks.

the class CertsFacade method removeAllCertsOfAUser.

public void removeAllCertsOfAUser(String username) {
    List<UserCerts> items = findUserCertsByUid(username);
    if (items != null) {
        for (UserCerts uc : items) {
            UserCerts tmp = em.merge(uc);
            remove(tmp);
        }
    }
}
Also used : UserCerts(io.hops.hopsworks.persistence.entity.certificates.UserCerts)

Example 8 with UserCerts

use of io.hops.hopsworks.persistence.entity.certificates.UserCerts in project hopsworks by logicalclocks.

the class CertsFacade method putUserCerts.

public UserCerts putUserCerts(String projectname, String username, byte[] kStoreBlob, byte[] tStoreBlob, String userKeyPwd) {
    UserCerts uc = new UserCerts(projectname, username);
    uc.setUserKey(kStoreBlob);
    uc.setUserCert(tStoreBlob);
    uc.setUserKeyPwd(userKeyPwd);
    em.persist(uc);
    em.flush();
    return uc;
}
Also used : UserCerts(io.hops.hopsworks.persistence.entity.certificates.UserCerts)

Example 9 with UserCerts

use of io.hops.hopsworks.persistence.entity.certificates.UserCerts in project hopsworks by logicalclocks.

the class CertsFacade method findUserCert.

public UserCerts findUserCert(String projectName, String username) {
    TypedQuery<UserCerts> query = em.createNamedQuery("UserCerts.findUserProjectCert", UserCerts.class);
    query.setParameter("projectname", projectName);
    query.setParameter("username", username);
    try {
        UserCerts res = query.getSingleResult();
        return res;
    } catch (NoResultException e) {
        Logger.getLogger(CertsFacade.class.getName()).log(Level.SEVERE, null, e);
    }
    return new UserCerts();
}
Also used : UserCerts(io.hops.hopsworks.persistence.entity.certificates.UserCerts) NoResultException(javax.persistence.NoResultException)

Example 10 with UserCerts

use of io.hops.hopsworks.persistence.entity.certificates.UserCerts in project hopsworks by logicalclocks.

the class KafkaController method getKafkaCertPaths.

public String getKafkaCertPaths(Project project) {
    UserCerts userCert = userCerts.findUserCert(project.getName(), project.getOwner().getUsername());
    // Check if the user certificate was actually retrieved
    if (userCert.getUserCert() != null && userCert.getUserCert().length > 0 && userCert.getUserKey() != null && userCert.getUserKey().length > 0) {
        File certDir = new File(settings.getHopsworksTrueTempCertDir() + "/" + project.getName());
        if (!certDir.exists()) {
            try {
                certDir.mkdirs();
            } catch (Exception ex) {
            }
        }
        try {
            FileOutputStream fos;
            fos = new FileOutputStream(certDir.getAbsolutePath() + "/keystore.jks");
            fos.write(userCert.getUserKey());
            fos.close();
            fos = new FileOutputStream(certDir.getAbsolutePath() + "/truststore.jks");
            fos.write(userCert.getUserCert());
            fos.close();
        } catch (Exception e) {
        }
        return certDir.getAbsolutePath();
    } else {
        return null;
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) UserCerts(io.hops.hopsworks.persistence.entity.certificates.UserCerts) File(java.io.File) TimeoutException(java.util.concurrent.TimeoutException) ProjectException(io.hops.hopsworks.exceptions.ProjectException) KafkaException(io.hops.hopsworks.exceptions.KafkaException) KeeperException(org.apache.zookeeper.KeeperException) SchemaException(io.hops.hopsworks.exceptions.SchemaException) IOException(java.io.IOException) UserException(io.hops.hopsworks.exceptions.UserException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

UserCerts (io.hops.hopsworks.persistence.entity.certificates.UserCerts)11 HashMap (java.util.HashMap)3 Map (java.util.Map)3 UserException (io.hops.hopsworks.exceptions.UserException)2 File (java.io.File)2 IOException (java.io.IOException)2 CertificateMaterializer (io.hops.hopsworks.common.security.CertificateMaterializer)1 CryptoPasswordNotFoundException (io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException)1 EncryptionMasterPasswordException (io.hops.hopsworks.exceptions.EncryptionMasterPasswordException)1 KafkaException (io.hops.hopsworks.exceptions.KafkaException)1 ProjectException (io.hops.hopsworks.exceptions.ProjectException)1 SchemaException (io.hops.hopsworks.exceptions.SchemaException)1 LocalResourceDTO (io.hops.hopsworks.persistence.entity.jobs.configuration.yarn.LocalResourceDTO)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1 Users (io.hops.hopsworks.persistence.entity.user.Users)1 FileOutputStream (java.io.FileOutputStream)1 ByteBuffer (java.nio.ByteBuffer)1 InvalidKeyException (java.security.InvalidKeyException)1 KeyStore (java.security.KeyStore)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1