www in docker support

This commit is contained in:
MaddoScientisto 2026-04-22 18:41:37 +02:00
commit c227fce036
2145 changed files with 399596 additions and 58 deletions

View file

@ -0,0 +1,131 @@
package it.acxent.human;
import it.acxent.db.ApplParmFull;
import it.acxent.db.DBAdapter;
import it.acxent.util.PasswordPolicy;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Random;
public class Challenge {
private String hid;
private String hokpage;
private long httl;
private String theChallenge;
private LinkedHashSet<Integer> theQuestion;
public static final String _HC = "_HC_";
private ApplParmFull apFull;
public Challenge(ApplParmFull apFull) {
this.apFull = apFull;
}
public Challenge() {}
public Challenge(ApplParmFull apFull, int sizeChallenge, int sizeQuestion) {
this.apFull = apFull;
setTheChallenge(PasswordPolicy.getRandomPassword(sizeChallenge, false));
Random random = new Random();
while (getTheQuestion().size() < sizeQuestion) {
int numeroCasuale = random.nextInt(sizeChallenge) + 1;
if (!getTheQuestion().contains(Integer.valueOf(numeroCasuale)))
getTheQuestion().add(Integer.valueOf(numeroCasuale));
}
}
public String getQuestion() {
return getQuestion("it");
}
public String getQuestion(String lang) {
StringBuilder sb = new StringBuilder(getApFull().translate("Inserisci l'elemento delle posizioni", lang) + " ");
int i = 0;
for (Iterator<Integer> iterator = getTheQuestion().iterator(); iterator.hasNext(); ) {
int elemento = iterator.next();
i++;
sb.append(getApFull().translate(DBAdapter.numberToString((double)elemento, false), lang));
if (i < getTheQuestion().size())
sb.append(", ");
}
return sb.toString();
}
public boolean checkAnswer(String answer) {
StringBuilder correctAnswer = new StringBuilder();
for (Iterator<Integer> iterator = getTheQuestion().iterator(); iterator.hasNext(); ) {
int elemento = iterator.next();
correctAnswer.append(getTheChallenge().charAt(elemento - 1));
}
if (correctAnswer.toString().equals(answer))
return true;
return false;
}
public String getTheChallenge() {
return (this.theChallenge == null) ? "" : this.theChallenge.trim();
}
public void setTheChallenge(String theChallenge) {
this.theChallenge = theChallenge;
}
public LinkedHashSet<Integer> getTheQuestion() {
if (this.theQuestion == null)
this.theQuestion = new LinkedHashSet<>();
return this.theQuestion;
}
public void setTheQuestion(LinkedHashSet<Integer> theQuestion) {
this.theQuestion = theQuestion;
}
public String getHtmlChallenge() {
StringBuilder sb = new StringBuilder("<div class=\"human-boxed-text\">");
for (int i = 0; i < getTheChallenge().length(); i++) {
char carattere = getTheChallenge().charAt(i);
sb.append("<span>");
sb.append(carattere);
sb.append("</span>");
}
sb.append("</div>");
return sb.toString();
}
public String getHid() {
return this.hid;
}
public void setHid(String hid) {
this.hid = hid;
}
public String getHokpage() {
return this.hokpage;
}
public void setHokpage(String hokpage) {
this.hokpage = hokpage;
}
public long getHttl() {
return this.httl;
}
public void setHttl(long httl) {
this.httl = httl;
}
public ApplParmFull getApFull() {
return this.apFull;
}
public void setApFull(ApplParmFull apFull) {
this.apFull = apFull;
}
}

View file

@ -0,0 +1 @@
package it.acxent.human;

View file

@ -0,0 +1,72 @@
package it.acxent.human.servlet;
import it.acxent.cc.Attivita;
import it.acxent.db.ApplParmFull;
import it.acxent.db.CRAdapter;
import it.acxent.db.DBAdapter;
import it.acxent.human.Challenge;
import it.acxent.servlet.AblServletSvlt;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
@WebServlet(urlPatterns = {"/HumanCeck.abl"})
public class HumanCeckSvlt extends AblServletSvlt {
private static final String _SESSION_CHALLENGE = "_challenge";
private static final long serialVersionUID = 476646217816287146L;
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {}
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {}
protected DBAdapter getBean(HttpServletRequest req) {
return null;
}
protected CRAdapter getBeanCR(HttpServletRequest req) {
return null;
}
protected boolean isSecureServlet(HttpServletRequest req) {
return false;
}
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
_sendChallenge(req, res);
}
public void _checkChallenge(HttpServletRequest req, HttpServletResponse res) {
ApplParmFull apFull = getApFull(req);
Challenge ch = (Challenge)req.getSession().getAttribute("_challenge");
String ans = getRequestParameter(req, "h_answer");
JSONObject jo = new JSONObject();
if (ch.checkAnswer(ans)) {
long endTime = DBAdapter.getNow().getTime() + ch.getHttl() * 1000L;
req.getSession().setAttribute("_HC_" + ch.getHid(), Long.valueOf(endTime));
jo.put("res", "true");
Attivita attivita = Attivita.getDefaultInstance(apFull);
jo.put("page", attivita.getWwwAddress() + attivita.getWwwAddress());
} else {
jo.put("res", "false");
}
sendHtmlMsgResponse(req, res, jo.toString());
}
protected void search(HttpServletRequest req, HttpServletResponse res) {
_sendChallenge(req, res);
}
protected String getBeanPageName(HttpServletRequest req) {
return "_inc_human_check.jsp";
}
public void _sendChallenge(HttpServletRequest req, HttpServletResponse res) {
Challenge ch = new Challenge(getApFull(req), 10, 3);
fillObject(req, ch);
req.getSession().setAttribute("_challenge", ch);
setJspPage("/_inc_human_check_challenge.jsp", req);
callJsp(req, res);
}
}

View file

@ -0,0 +1 @@
package it.acxent.human.servlet;

View file

@ -0,0 +1,70 @@
package it.acxent.human.taglib;
import it.acxent.taglib.AbstractDbTag;
import java.io.IOException;
import java.io.Writer;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
public class ElseHumanTag extends AbstractDbTag {
private static final long serialVersionUID = 6183519243825318138L;
public static final String BEAN_ID = "hid";
public static final String BEAN_TTL = "httl";
public static final String BEAN_PAGE = "hokpage";
private String hid;
private String hokpage;
private long httl;
public int doAfterBody() throws JspException {
try {
this.bodyContent.writeOut((Writer)this.bodyContent.getEnclosingWriter());
return 0;
} catch (IOException ioexception) {
throw new JspTagException(ioexception.toString());
}
}
public int doStartTag() throws JspException {
if (getWhereCondition())
return 0;
this.pageContext.setAttribute("hid", getHid());
this.pageContext.setAttribute("hokpage", getHokpage());
this.pageContext.setAttribute("httl", String.valueOf(getHttl()));
return 2;
}
private boolean getWhereCondition() throws JspException {
String wc = "_WC_HC";
return (Boolean)this.pageContext.getAttribute(wc);
}
public String getHid() {
return (this.hid == null) ? "" : this.hid.trim();
}
public void setHid(String id) {
this.hid = id;
}
public String getHokpage() {
return (this.hokpage == null) ? "" : this.hokpage.trim();
}
public void setHokpage(String page) {
this.hokpage = page;
}
public long getHttl() {
return this.httl;
}
public void setHttl(long ttl) {
this.httl = ttl;
}
}

View file

@ -0,0 +1,11 @@
package it.acxent.human.taglib;
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
public class ElseHumanTagExtraInfo extends TagExtraInfo {
public VariableInfo[] getVariableInfo(TagData tagdata) {
return new VariableInfo[] { new VariableInfo("hid", "java.lang.String", true, 0), new VariableInfo("hokpage", "java.lang.String", true, 0), new VariableInfo("httl", "java.lang.String", true, 0) };
}
}

View file

@ -0,0 +1,127 @@
package it.acxent.human.taglib;
import it.acxent.common.Users;
import it.acxent.taglib.AbstractDbTag;
import java.io.IOException;
import java.io.Writer;
import java.util.Calendar;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
public class IfHumanTag extends AbstractDbTag {
private static final long serialVersionUID = -8243492975234898706L;
private String hid;
private boolean uselogonok = false;
protected Users utente;
protected boolean logonOk = false;
protected static final String _WC = "_WC_HC";
protected static final String _NESTVAL = "_WC_HC_NESTVAL";
public int doAfterBody() throws JspException {
try {
this.bodyContent.writeOut((Writer)this.bodyContent.getEnclosingWriter());
return 0;
} catch (IOException ex) {
throw new JspTagException(ex.toString());
}
}
public int doStartTag() {
this.pageContext.setAttribute("_WC_HC", Boolean.valueOf(getWherecondition()));
if (getWherecondition())
return 2;
return 0;
}
private boolean getWherecondition() {
if (this.uselogonok && isUserLogged())
return true;
Object obj = getReq().getSession().getAttribute(getSessionId());
if (obj == null)
return false;
long tsMils = (Long)obj;
System.out.println(tsMils - Calendar.getInstance().getTimeInMillis());
if (tsMils > Calendar.getInstance().getTimeInMillis())
return true;
return false;
}
private String getSessionId() {
return "_HC_" + getHid();
}
public String getHid() {
return (this.hid == null) ? "" : this.hid.trim();
}
public void setHid(String id) {
this.hid = id;
}
public boolean isUselogonok() {
return this.uselogonok;
}
public void setUselogonok(boolean logonok) {
this.uselogonok = logonok;
}
private boolean isUserLogged() {
if (getLoginUserId(getReq()) != null && checkLoginProfile(getReq())) {
this.logonOk = true;
return true;
}
this.logonOk = false;
getReq().getSession().removeAttribute("utenteLogon");
return false;
}
protected Users getLoginUser(HttpServletRequest req) {
HttpSession session = req.getSession(true);
if (session.getAttribute("loginUser_id") != null) {
if (this.utente == null) {
Long l_id_utente = (Long)session.getAttribute("loginUser_id");
Users utente = getUtente();
utente.findByPrimaryKey(l_id_utente);
}
} else {
this.utente = null;
}
return this.utente;
}
protected Long getLoginUserId(HttpServletRequest req) {
HttpSession session = req.getSession(true);
if (session.getAttribute("loginUser_id") != null)
return (Long)session.getAttribute("loginUser_id");
return null;
}
protected Users getUtente() {
return new Users(getApFull());
}
protected boolean isUseLogonCookie() {
String ulc = "false";
if (this.pageContext.getServletContext().getInitParameter("useLogonCookie") != null)
ulc = this.pageContext.getServletContext().getInitParameter("useLogonCookie");
return ulc.equals("true");
}
protected boolean checkLoginProfile(HttpServletRequest req) {
try {
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}

View file

@ -0,0 +1 @@
package it.acxent.human.taglib;