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