use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.
the class ClownfishLoginServlet method processRequest.
protected void processRequest(HttpServletRequest request, HttpServletResponse response) {
String inst_klasse;
String inst_identifier;
String inst_passwordField;
String salt;
String inst_clearTextPw;
String inst_identifierField;
boolean success = false;
Map<String, String[]> parameters = request.getParameterMap();
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("class") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
klasse = values[0];
});
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("clearPw") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
clearPw = values[0];
});
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("idField") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
id_field = values[0];
});
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("id") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
id = values[0];
});
parameters.keySet().stream().filter((paramname) -> (paramname.compareToIgnoreCase("pwField") == 0)).map((paramname) -> parameters.get(paramname)).forEach((values) -> {
pw_field = values[0];
});
inst_klasse = klasse;
inst_identifier = id;
inst_passwordField = pw_field;
inst_identifierField = id_field;
inst_clearTextPw = clearPw;
CfClass cfclass = cfclassService.findByName(inst_klasse);
List<CfClasscontent> classcontentList = cfclasscontentService.findByClassref(cfclass);
CfAttribut attributField = cfattributService.findByNameAndClassref(inst_identifierField, cfclass);
CfAttribut attributPassword = cfattributService.findByNameAndClassref(inst_passwordField, cfclass);
for (CfClasscontent classcontent : classcontentList) {
CfAttributcontent attributContent = cfattributcontentService.findByAttributrefAndClasscontentref(attributField, classcontent);
if (attributContent.getContentString().equals(inst_identifier)) {
long cref = attributContent.getClasscontentref().getId();
for (CfClasscontent classcontent1 : classcontentList) {
CfAttributcontent attributContent1 = cfattributcontentService.findByAttributrefAndClasscontentref(attributPassword, classcontent1);
salt = attributContent1.getSalt();
if (null != salt) {
String test = PasswordUtil.generateSecurePassword(inst_clearTextPw, salt);
if ((attributContent1.getContentString().compareTo(test) == 0) && (attributContent1.getClasscontentref().getId() == cref)) {
success = PasswordUtil.verifyUserPassword(inst_clearTextPw, PasswordUtil.generateSecurePassword(inst_clearTextPw, salt), salt);
if (success) {
break;
}
}
}
}
}
}
try (PrintWriter out = response.getWriter()) {
out.print(success);
} catch (IOException ex) {
// LOGGER.error(ex.getMessage());
}
}
use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.
the class Searcher method addClasscontentMap.
private void addClasscontentMap(long classcontentref, HashMap searchclasscontentmap) {
// Search in classes and put it via template to the output
try {
CfClasscontent findclasscontent = cfclasscontentservice.findById(classcontentref);
CfClass findclass = cfclassservice.findById(findclasscontent.getClassref().getId());
if (findclass.isSearchrelevant()) {
Map attributmap = classutil.getattributmap(findclasscontent);
if (searchclasscontentmap.containsKey(findclass.getName())) {
ArrayList searchclassarray = (ArrayList) searchclasscontentmap.get(findclass.getName());
if (!searchclassarray.contains(attributmap)) {
searchclassarray.add(attributmap);
searchclasscontentmap.put(findclass.getName(), searchclassarray);
}
} else {
ArrayList searchclassarray = new ArrayList<>();
searchclassarray.add(attributmap);
searchclasscontentmap.put(findclass.getName(), searchclassarray);
}
}
} catch (Exception ex) {
LOGGER.warn("LUCENE SEARCHER CONTENT NOT FOUND: " + classcontentref);
}
}
use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.
the class RestContent method updateContent.
private RestContentParameter updateContent(RestContentParameter ucp) {
try {
String token = ucp.getToken();
if (authtokenlist.checkValidToken(token)) {
String apikey = ucp.getApikey();
if (apikeyutil.checkApiKey(apikey, "RestService")) {
CfClass clazz = cfclassService.findByName(ucp.getClassname());
try {
CfClasscontent classcontent = cfclasscontentService.findByName(ucp.getContentname());
List<CfAttributcontent> attributcontentlist = cfattributcontentService.findByClasscontentref(classcontent);
for (CfAttributcontent attributcontent : attributcontentlist) {
CfAttribut attribut = attributcontent.getAttributref();
// Check, if attribut exists in attributmap
if (ucp.getAttributmap().containsKey(attribut.getName())) {
contentUtil.setAttributValue(attributcontent, ucp.getAttributmap().get(attribut.getName()));
cfattributcontentService.edit(attributcontent);
if (ucp.isIndexing()) {
contentUtil.indexContent();
}
ucp.setReturncode("OK");
}
}
hibernateUtil.updateContent(classcontent);
} catch (javax.persistence.NoResultException ex) {
ucp.setReturncode("Classcontent not found");
}
} else {
ucp.setReturncode("Wrong API KEY");
}
} else {
ucp.setReturncode("Invalid token");
}
} catch (javax.persistence.NoResultException ex) {
ucp.setReturncode("NoResultException");
}
return ucp;
}
use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.
the class RestListcontent method insertListcontent.
private RestListcontentParameter insertListcontent(RestListcontentParameter ilcp) {
try {
String token = ilcp.getToken();
if (authtokenlist.checkValidToken(token)) {
String apikey = ilcp.getApikey();
if (apikeyutil.checkApiKey(apikey, "RestService")) {
try {
CfList list = cflistService.findByName(ilcp.getListname());
CfClasscontent classcontent = cfclasscontentService.findByName(ilcp.getClasscontentname());
CfListcontent listcontent = new CfListcontent();
CfListcontentPK cfListcontentPK = new CfListcontentPK();
cfListcontentPK.setListref(list.getId());
cfListcontentPK.setClasscontentref(classcontent.getId());
listcontent.setCfListcontentPK(cfListcontentPK);
cflistcontentService.create(listcontent);
hibernateutil.updateRelation(list);
ilcp.setReturncode("OK");
} catch (Exception ex) {
ilcp.setReturncode("Exception");
}
} else {
ilcp.setReturncode("Wrong API KEY");
}
} else {
ilcp.setReturncode("Invalid token");
}
} catch (javax.persistence.NoResultException ex) {
ilcp.setReturncode("NoResultException");
}
return ilcp;
}
use of io.clownfish.clownfish.dbentities.CfClasscontent in project Clownfish by rawdog71.
the class RestListcontent method deleteListcontent.
private RestListcontentParameter deleteListcontent(RestListcontentParameter ilcp) {
try {
String token = ilcp.getToken();
if (authtokenlist.checkValidToken(token)) {
String apikey = ilcp.getApikey();
if (apikeyutil.checkApiKey(apikey, "RestService")) {
try {
ilcp.setReturncode("");
CfList list = cflistService.findByName(ilcp.getListname());
CfClasscontent classcontent = cfclasscontentService.findByName(ilcp.getClasscontentname());
List<CfListcontent> listcontentList = cflistcontentService.findByListref(list.getId());
for (CfListcontent listcontent : listcontentList) {
if (listcontent.getCfListcontentPK().getClasscontentref() == classcontent.getId()) {
cflistcontentService.delete(listcontent);
ilcp.setReturncode("OK");
}
}
} catch (javax.persistence.EntityExistsException ex) {
ilcp.setReturncode("EntityExistsException");
}
} else {
ilcp.setReturncode("Wrong API KEY");
}
} else {
ilcp.setReturncode("Invalid token");
}
} catch (javax.persistence.NoResultException ex) {
ilcp.setReturncode("NoResultException");
}
return ilcp;
}
Aggregations