public String doIclubLogin() { LOGGER.info("Class :: " + this.getClass() + " :: Method :: doIclubLogin"); if (!validateLogin()) { try { WebClient client = IclubWebHelper.createCustomClient( BASE_URL + "person/login/" + bean.getLName() + "/" + Base64.encodeBase64URLSafeString(DigestUtils.md5(bean.getLPasswd()))); ResponseModel response = client.accept(MediaType.APPLICATION_JSON).get(ResponseModel.class); client.close(); if (response.getStatusCode() == 0) { setTheme(); IclubWebHelper.addMessage("Person Logged-In successfully", FacesMessage.SEVERITY_INFO); WebClient loginClient = IclubWebHelper.createCustomClient(BASE_URL + "person/" + bean.getLName()); IclubLoginModel model = loginClient.accept(MediaType.APPLICATION_JSON).get(IclubLoginModel.class); loginClient.close(); if (model != null && model.getLId() != null) { IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.user.id"), model.getIclubPersonBByLPersonId()); IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.user.scname"), bean.getLName()); WebClient personClient = IclubWebHelper.createCustomClient( U_BASE_URL + "get/" + model.getIclubPersonBByLPersonId()); IclubPersonModel personModel = personClient.accept(MediaType.APPLICATION_JSON).get(IclubPersonModel.class); personClient.close(); IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.user.name"), personModel.getPFName() + (personModel.getPLName() == null ? "" : personModel.getPLName() + " ")); IclubWebHelper.addObjectIntoSession( BUNDLE.getString("logged.in.role.id"), model.getIclubRoleType()); return "/pages/dashboard/user/main.xhtml?faces-redirect=true"; } else { IclubWebHelper.addMessage( "Person Profile Fetch Error - Contact Admin", FacesMessage.SEVERITY_ERROR); return ""; } } else { IclubWebHelper.addMessage( "Login error :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); return ""; } } catch (Exception e) { LOGGER.error(e, e); IclubWebHelper.addMessage("Login error :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); return ""; } } else { return ""; } }
public IclubPersonBean getBean() { if (bean == null) { bean = new IclubPersonBean(); } if (!loadBean) { if (IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.user.id")) != null) { WebClient client = IclubWebHelper.createCustomClient(BASE_URL + "get/" + getSessionUserId()); IclubPersonModel model = (IclubPersonModel) (client.accept(MediaType.APPLICATION_JSON).get(IclubPersonModel.class)); client.close(); bean = IclubPersonTrans.fromWStoUI(model); if (IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.login.id")) != null) { client = IclubWebHelper.createCustomClient( LOG_BASE_URL + "get/" + IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.login.id")) .toString()); } else { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "person/" + bean.getPFName()); } IclubLoginModel loginModel = (IclubLoginModel) (client.accept(MediaType.APPLICATION_JSON).get(IclubLoginModel.class)); if (loginModel != null && loginModel.getLId() != null) { updateLogin = true; loginBean = IclubLoginTrans.fromWStoUI(loginModel); } else { updateLogin = false; loginBean = new IclubLoginBean(); } } } return bean; }
public String updateLogin() { try { if (validateLoginForm(!updateLogin)) { IclubLoginModel model = new IclubLoginModel(); WebClient client = null; if (loginBean.getLId() != null) { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "mod"); model.setLId(loginBean.getLId()); } else { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "add"); model.setLId(UUID.randomUUID().toString()); } model.setLCrtdDt(new Date(System.currentTimeMillis())); model = IclubLoginTrans.fromUItoWS(loginBean); model.setLPasswd(Base64.encodeBase64URLSafeString(DigestUtils.md5(loginBean.getLPasswd()))); model.setIclubPersonAByLCrtdBy(bean.getPId()); model.setIclubPersonBByLPersonId(getSessionUserId()); model.setIclubRoleType(2l); ResponseModel response = null; if (updateLogin) { response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); } else { response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); } if (response.getStatusCode() == 0) { IclubWebHelper.addObjectIntoSession("social_update_profile", null); IclubWebHelper.addMessage( "Personal Details Updated Successfully", FacesMessage.SEVERITY_INFO); loadBean = false; return "userDashboard"; } else { IclubWebHelper.addMessage( "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } return null; }
public void updatePassword() { try { if (validateLoginForm(!updateLogin)) { IclubLoginModel model = new IclubLoginModel(); WebClient client = null; if (loginBean.getLId() != null) { client = IclubWebHelper.createCustomClient(BASE_URL + "mod"); model.setLId(loginBean.getLId()); } else { client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "add"); model.setLId(UUID.randomUUID().toString()); } model.setLCrtdDt(new Date(System.currentTimeMillis())); model.setLLastDate(loginBean.getLLastDate()); model.setLName(loginBean.getLName()); model.setLPasswd(Base64.encodeBase64URLSafeString(DigestUtils.md5(loginBean.getLPasswd()))); model.setLSecAns(loginBean.getLSecAns()); model.setIclubPersonAByLCrtdBy(bean.getPId()); model.setIclubPersonBByLPersonId(getSessionUserId()); model.setIclubRoleType(2l); model.setIclubSecurityQuestion(loginBean.getIclubSecurityQuestion()); ResponseModel response = null; if (updateLogin) { response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class); } else { response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class); } if (response.getStatusCode() == 0) { IclubWebHelper.addMessage( "Personal Details Updated Successfully", FacesMessage.SEVERITY_INFO); } else { IclubWebHelper.addMessage( "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR); } } } catch (Exception e) { IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR); } }