package it.acxent.pg.servlet; import it.acxent.anag.Clifor; import it.acxent.anag.Postazione; import it.acxent.db.ApplParmFull; import it.acxent.db.ResParm; import it.acxent.pg.Users; import java.net.InetAddress; import java.sql.Date; import java.util.Calendar; import javax.servlet.RequestDispatcher; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; public class CartSvlt extends it.acxent.www.servlet.CartSvlt { protected void socialLogin(HttpServletRequest req, HttpServletResponse res, long l_socialType, String l_socialId, String socialEmail, String l_nome, String l_cognome) { ApplParmFull apFull = getApFull(req); ResParm rp = new ResParm(true); String jspPage = getCal(req); try { Users utente = new Users(apFull); utente.findUsersBySocialId(l_socialId, l_socialType); if (utente.getId_users() == 0L) utente.findUsersByEmail(socialEmail); if (utente.getId_users() > 0L) { if (utente.getFlgValido().equals("S")) { boolean saveUtente = false; if (utente.getSocialId().isEmpty() || !utente.getSocialId().equals(l_socialId)) { utente.setSocialId(l_socialId); utente.setFlgSocialIdType(l_socialType); saveUtente = true; } if (saveUtente) rp = utente.save(); HttpSession session = req.getSession(); handleDebug("Ok. Recording loginuser_id in the session."); session.setAttribute("loginUser_id", new Long(utente.getId_users())); String ip = req.getRemoteHost(); InetAddress ia = InetAddress.getByName(ip); byte[] ipBytes = ia.getAddress(); ia = InetAddress.getByAddress(ipBytes); Postazione pos = new Postazione(getApFull(req)); if (!ia.getHostName().isEmpty()) pos.findByHostname(ia.getHostName()); if (pos.getDBState() != 1) pos.findByIp(ip); if (pos.getDBState() == 1) utente.setId_postazione(pos.getId_postazione()); System.out.println("socialLoginByEmail: LOGIN EFFETTUATO: user:" + utente.getLogin() + " ip:" + ip + " HOSTNAME:" + ia.getHostName() + " Postazione: " + utente.getPostazione().getDescrizione()); utente.setCurrentIp(ip); session.setAttribute("utenteLogon", utente); req.setAttribute("logon", "logonOk"); rp.setStatus(true); } } else { utente.setNome(l_nome); utente.setCognome(l_cognome); utente.setLogin(socialEmail); utente.setEMail(socialEmail); utente.setFlgValido("S"); utente.setId_userProfile(utente.getIdUserProfileWww()); utente.setSocialId(l_socialId); utente.setFlgSocialIdType(l_socialType); if (getParm("GG_VALIDITA").getNumeroInt() > 0) { Calendar cal = Calendar.getInstance(); cal.add(6, getParm("GG_VALIDITA").getNumeroInt()); utente.setDataScadenza(new Date(cal.getTimeInMillis())); } if (getParm("N_FOTO_MAX").getNumeroInt() > 0) utente.setNFotoMax(getParm("N_FOTO_MAX").getNumeroLong()); Clifor cliente = utente.getClifor(); cliente.setNome(l_nome); cliente.setCognome(l_cognome); cliente.setEMail(socialEmail); cliente.setFlgAzienda(0L); cliente.setFlgTipo("C"); rp = cliente.save(); if (rp.getStatus()) { utente.setId_clifor(cliente.getId_clifor()); rp.append(utente.save()); } if (!rp.getStatus()) { sendMessage(req, "Impossibile salvare: " + rp.getMsg()); rp.setStatus(false); rp.setMsg("Impossibile salvare: " + rp.getMsg()); } if (rp.getStatus()) { HttpSession session = req.getSession(); session.setAttribute("loginUser_id", new Long(utente.getId_users())); session.setAttribute("utenteLogon", utente); req.setAttribute("logon", "logonOk"); } } if (rp.getStatus()) { setJspPageRelative(jspPage, req); RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req)); try { rd.forward((ServletRequest)req, (ServletResponse)res); } catch (Exception e) {} } else { sendMessage(req, rp.getMsg()); setJspPageRelative(jspPage, req); RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req)); try { rd.forward((ServletRequest)req, (ServletResponse)res); } catch (Exception e) {} } } catch (Exception e) { e.printStackTrace(); sendMessage(req, e.getMessage()); setJspPageRelative(jspPage, req); RequestDispatcher rd = getServletContext().getRequestDispatcher(getJspPage(req)); try { rd.forward((ServletRequest)req, (ServletResponse)res); } catch (Exception exception) {} } } public void _googleSignIn(HttpServletRequest req, HttpServletResponse res) { super._googleSignIn(req, res); } public void _facebookSignIn(HttpServletRequest req, HttpServletResponse res) { super._facebookSignIn(req, res); } }