List of usage examples for org.springframework.web.util HtmlUtils htmlUnescape
public static String htmlUnescape(String input)
From source file:permafrost.tundra.html.HTMLHelper.java
/** * HTML decodes the given string.//w ww. j av a 2 s .co m * * @param input The string to be decoded. * @return The decoded string. */ public static String decode(String input) { if (input == null) return null; return HtmlUtils.htmlUnescape(input); }
From source file:com.webfileanalyzer.domain.FileStatistic.java
public FileStatistic(String line, Long maxWord, Long minWord, Long lengthLine, Double avgWord) { this.line = HtmlUtils.htmlUnescape(line); this.maxWord = maxWord; this.minWord = minWord; this.lengthLine = lengthLine; this.avgWord = avgWord; }
From source file:com.fileanalyzer.analitics.StatisticCalculatorTest.java
@Test public void test2() { FileStatistic canonic = new LineStatisticCalculator( "# Pattern to output the caller's file name and line number.").getFileStatistic(); log.info(canonic);//from w ww . j a v a2 s . c om FileStatistic notCanonic = new LineStatisticCalculator( HtmlUtils.htmlUnescape("# Pattern to output the caller's file name and line number.")) .getFileStatistic(); log.info(notCanonic); assertEquals(canonic, notCanonic); }
From source file:ch.silviowangler.dox.web.HomeController.java
@RequestMapping(method = GET, value = "/") public ModelAndView homeScreen(@RequestParam(value = "q", defaultValue = "", required = false) String query) { Map<String, Object> model = newHashMapWithExpectedSize(1); model.put("query", HtmlUtils.htmlUnescape(query)); return new ModelAndView("base.definition.angularjs", model); }
From source file:com.webfileanalyzer.domain.FileStatistic.java
public void setLine(String line) { this.line = HtmlUtils.htmlUnescape(line); }
From source file:org.cloudfoundry.identity.uaa.login.test.TestClient.java
public String extractLink(String messageBody) { Pattern linkPattern = Pattern.compile("<a href=\"(.*?)\">.*?</a>"); Matcher matcher = linkPattern.matcher(messageBody); matcher.find();/*from w ww.j a v a 2 s . co m*/ String encodedLink = matcher.group(1); return HtmlUtils.htmlUnescape(encodedLink); }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractAuthenticationController.java
@RequestMapping({ "/login", "/portal", "/" }) public String login(HttpServletRequest request, ModelMap map, HttpSession session) { logger.debug("###Entering in login(req,map,session) method"); boolean loginFailed = request.getParameter(LOGIN_FAILED_PARAM) != null; if (!loginFailed && request.getUserPrincipal() != null) { map.clear();/*w w w.j av a 2 s . c o m*/ return "redirect:/portal/home"; } if (session.getAttribute("email_verified") != null) { map.addAttribute("email_verified", session.getAttribute("email_verified")); session.removeAttribute("email_verified"); } String showSuffixControl = "false"; String suffixControlType = "textbox"; List<String> suffixList = null; if (config.getValue(Names.com_citrix_cpbm_username_duplicate_allowed).equals("true")) { showSuffixControl = "true"; if (config.getValue(Names.com_citrix_cpbm_login_screen_tenant_suffix_dropdown_enabled).equals("true")) { suffixControlType = "dropdown"; suffixList = tenantService.getSuffixList(); } } map.addAttribute("showSuffixControl", showSuffixControl); map.addAttribute("suffixControlType", suffixControlType); map.addAttribute("suffixList", suffixList); if (config.getBooleanValue(Configuration.Names.com_citrix_cpbm_portal_directory_service_enabled) && config.getValue(Names.com_citrix_cpbm_directory_mode).equals("pull")) { map.addAttribute("directoryServiceAuthenticationEnabled", "true"); } if (config.getValue(Names.com_citrix_cpbm_public_catalog_display).equals("true") && channelService.getDefaultServiceProviderChannel() != null) { map.addAttribute("showAnonymousCatalogBrowsing", "true"); } map.addAttribute("showLanguageSelection", "true"); map.addAttribute("supportedLocaleList", this.getLocaleDisplayName(listSupportedLocales())); map.addAttribute("selected_language", request.getParameter("lang")); String redirect = null; boolean loggedOut = request.getParameter(LOGOUT_PARAM) != null; final Throwable ex = (Throwable) session.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); // capture previous CAPTCHA position Boolean captchaRequiredSessionObj = (Boolean) session .getAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED); // Get last user String username = (String) session .getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY); // this as spring does a text-escape when it saves this attribute final String uUsername = HtmlUtils.htmlUnescape(username); if (loginFailed) { String error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); try { User user = privilegeService.runAsPortal(new PrivilegedAction<User>() { @Override public User run() { User user = userService.getUserByParam("username", uUsername, false); // All user writes here. // Every time there is a login failure but not invalid CAPTCHA, // we update failed login attempts for the user if (!(ex instanceof CaptchaValidationException) && !(ex instanceof LockedException) && !(ex instanceof IpRangeValidationException)) { user.setFailedLoginAttempts(user.getFailedLoginAttempts() + 1); } int attempts = user.getFailedLoginAttempts(); // Also locking the root user and quite easily too. Clearly this // needs an eye! if (attempts >= config.getIntValue( Names.com_citrix_cpbm_accountManagement_security_logins_lockThreshold)) { user.setEnabled(false); } return user; } }); int attempts = user.getFailedLoginAttempts(); if (attempts >= config .getIntValue(Names.com_citrix_cpbm_accountManagement_security_logins_captchaThreshold)) { session.setAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED, true); } } catch (NoSuchUserException e) { // map.addAttribute("showCaptcha", true); } captchaRequiredSessionObj = (Boolean) session .getAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED); map.addAttribute("loginFailed", loginFailed); String lastUsername = uUsername; if (config.getValue(Names.com_citrix_cpbm_username_duplicate_allowed).equals("true")) { if (!lastUsername.equals("root") && !lastUsername.equals("")) { lastUsername = lastUsername.substring(0, lastUsername.lastIndexOf('@')); } } map.addAttribute("lastUser", lastUsername); // Compose error string if (ex instanceof DisabledException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else if (ex instanceof CaptchaValidationException) { error = " " + messageSource.getMessage("error.auth.captcha.invalid", null, request.getLocale()); } else if (ex instanceof IpRangeValidationException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else if (ex instanceof LockedException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else if (ex instanceof BadCredentialsException) { if (ex.getMessage() != null && ex.getMessage().length() > 0) { // error = " " + ex.getMessage(); error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } } else if (ex instanceof AuthenticationException) { error = " " + messageSource.getMessage("error.auth.username.password.invalid", null, request.getLocale()); } else { logger.error("Error occurred in authentication", ex); error = " " + messageSource.getMessage("error.auth.unknown", null, request.getLocale()); } if (captchaRequiredSessionObj != null && captchaRequiredSessionObj == true && !(ex instanceof CaptchaValidationException) && !(ex instanceof LockedException)) { error += " " + messageSource.getMessage("error.auth.account.may.locked", null, request.getLocale()); } map.addAttribute("error", error); } if (loggedOut) { map.addAttribute("logout", loggedOut); } // This could come from session or from user if (captchaRequiredSessionObj != null && captchaRequiredSessionObj.booleanValue() && !Boolean.valueOf(config.getValue(Names.com_citrix_cpbm_use_intranet_only))) { map.addAttribute("showCaptcha", true); map.addAttribute("recaptchaPublicKey", config.getRecaptchaPublicKey()); } map.addAttribute(TIME_OUT, request.getParameter(TIME_OUT) != null); map.addAttribute(VERIFY, request.getParameter(VERIFY) != null); logger.debug("###Exiting login(req,map,session) method"); if (config.getAuthenticationService().compareToIgnoreCase(CAS) == 0) { try { redirect = StringUtils.isEmpty(config.getCasLoginUrl()) ? null : config.getCasLoginUrl() + "?service=" + URLEncoder.encode(config.getCasServiceUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Exception encoding: " + redirect, e); } if (redirect == null) { throw new InternalError("CAS authentication required, but login url not set"); } } return redirect == null ? "auth.login" : "redirect:" + redirect; }
From source file:gr.abiss.calipso.wicket.components.formfields.MultipleValuesTextField.java
/** * Read the List<String> backing the the fields, concat the values, * append them to the hidden field's model and refresh the display of the * input thas far// w w w . jav a2 s . co m * @param form */ private void updateModelAndRepaint(Form<?> form) { // logger.info("updateModelAndRepaint rowToEditIndex: " + // rowToEditIndex); // get the new subvalues boolean foundNonBlankValue = false; StringBuffer values = new StringBuffer(); if (CollectionUtils.isNotEmpty(newSubFieldValues)) { // obtain and clear sub-values for (int i = 0; i < newSubFieldValues.size(); i++) { // paralel form later in document order // submits the first in the page // for some reason, unless it's own submit is used // e.g. instead of pressing enter in a field if (StringUtils.isNotBlank(newSubFieldValues.get(i) + "")) { foundNonBlankValue = true; } values.append(XmlUtils.escapeHTML(HtmlUtils.htmlUnescape(newSubFieldValues.get(i) + ""))); if (i + 1 < newSubFieldValues.size()) { values.append(SEPARATOR_LINE_SUBVALUE); } } } if (foundNonBlankValue) { String newSubValue = values.toString(); // update model if (StringUtils.isNotBlank(newSubValue)) { String existingValues = valuesField.getModelObject(); if (StringUtils.isNotBlank(existingValues)) { String[] existingValuesArr = existingValues.split("\\r?\\n"); StringBuffer newValues = new StringBuffer(); for (int i = 0; i < existingValuesArr.length; i++) { if (rowToEditIndex == i) { newValues.append(newSubValue).append("\n"); } else { newValues.append(existingValuesArr[i]).append("\n"); } } if (rowToEditIndex == -1) { newValues.append(newSubValue).append("\n"); } valuesField.setModelObject(newValues.toString()); } else { valuesField.setModelObject(newSubValue); } rowToEditIndex = -1; // subValuesString = (String) valuesField.getModelObject(); } // update new subvalue's model for (int i = 0; i < newSubFieldValues.size(); i++) { newSubFieldValues.set(i, ""); } } // update subvalues table paintSubValuesTable(form); }
From source file:com.fota.pushMgt.controller.PushFotaCTR.java
/** * ? ? push ? ? // w w w . j a v a2s. c o m * MenuMgtInterceptor ? ? * PushFotaHistDetailCTR.java ?? * @param vo * @param model * @return * @throws Exception */ @RequestMapping("/pushFotaHistDetailDev") @ResponseBody public ModelAndView pushHistDetailDev(HttpServletRequest request, @ModelAttribute("pushResBasVO") PushResBasVO vo, ModelMap model) throws Exception { // validation check vo.setDevId(VoV.valid(vo.getDevId(), 30, 4)); //------------------- // ? ? DevSearchVO devVO = new DevSearchVO(); devVO.setDevId(vo.getDevId()); devVO = devSVC.getDevInfo(devVO); devVO.setClientNm(HtmlUtils.htmlUnescape(devVO.getClientNm())); devVO.setDealerNm(HtmlUtils.htmlUnescape(devVO.getDealerNm())); model.addAttribute("devInfo", devVO); // ? ? model.addAttribute("gridData", mySVC.pushHistDetailDev(vo)); return new ModelAndView(ajaxMainView, model); }