List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:at.gv.egovernment.moa.id.auth.servlet.GetMISSessionIDServlet.java
/** * Gets the signer certificate from the InfoboxReadRequest and responds with * a new <code>CreateXMLSignatureRequest</code>. <br> * Request parameters:/*from w w w .j a v a 2 s. c o m*/ * <ul> * <li>MOASessionID: ID of associated authentication session</li> * <li>XMLResponse: <code><InfoboxReadResponse></code></li> * </ul> * * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest, * HttpServletResponse) */ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Logger.debug("POST GetMISSessionIDServlet"); Logger.warn(getClass().getName() + " is deprecated and should not be used any more."); resp.setHeader(MOAIDAuthConstants.HEADER_EXPIRES, MOAIDAuthConstants.HEADER_VALUE_EXPIRES); resp.setHeader(MOAIDAuthConstants.HEADER_PRAGMA, MOAIDAuthConstants.HEADER_VALUE_PRAGMA); resp.setHeader(MOAIDAuthConstants.HEADER_CACHE_CONTROL, MOAIDAuthConstants.HEADER_VALUE_CACHE_CONTROL); resp.addHeader(MOAIDAuthConstants.HEADER_CACHE_CONTROL, MOAIDAuthConstants.HEADER_VALUE_CACHE_CONTROL_IE); // Map parameters; // try // { // parameters = getParameters(req); // } catch (FileUploadException e) // { // Logger.error("Parsing mulitpart/form-data request parameters failed: " // + e.getMessage()); // throw new IOException(e.getMessage()); // } String sessionID = req.getParameter(PARAM_SESSIONID); // escape parameter strings sessionID = StringEscapeUtils.escapeHtml(sessionID); AuthenticationSession session = null; String pendingRequestID = null; try { // check parameter if (!ParamValidatorUtils.isValidSessionID(sessionID)) throw new WrongParametersException("VerifyCertificate", PARAM_SESSIONID, "auth.12"); pendingRequestID = AuthenticationSessionStoreage.getPendingRequestID(sessionID); session = AuthenticationServer.getSession(sessionID); //change MOASessionID sessionID = AuthenticationSessionStoreage.changeSessionID(session); String misSessionID = session.getMISSessionID(); AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); ConnectionParameter connectionParameters = authConf.getOnlineMandatesConnectionParameter(); SSLSocketFactory sslFactory = SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters); List<MISMandate> list = MISSimpleClient.sendGetMandatesRequest(connectionParameters.getUrl(), misSessionID, sslFactory); if (list == null || list.size() == 0) { Logger.error("Keine Vollmacht gefunden."); throw new AuthenticationException("auth.15", null); } // for now: list contains only one element MISMandate mandate = (MISMandate) list.get(0); // TODO[tlenz]: UTF-8 ? String sMandate = new String(mandate.getMandate()); if (sMandate == null || sMandate.compareToIgnoreCase("") == 0) { Logger.error("Mandate is empty."); throw new AuthenticationException("auth.15", new Object[] { GET_MIS_SESSIONID }); } //check if it is a parsable XML byte[] byteMandate = mandate.getMandate(); // TODO[tlenz]: UTF-8 ? String stringMandate = new String(byteMandate); DOMUtils.parseDocument(stringMandate, false, null, null).getDocumentElement(); // extract RepresentationType AuthenticationServer.getInstance().verifyMandate(session, mandate); session.setMISMandate(mandate); session.setAuthenticatedUsed(false); session.setAuthenticated(true); //set QAA Level four in case of card authentifcation session.setQAALevel(PVPConstants.STORK_QAA_1_4); String oldsessionID = session.getSessionID(); //Session is implicite stored in changeSessionID!!! String newMOASessionID = AuthenticationSessionStoreage.changeSessionID(session); Logger.info("Changed MOASession " + oldsessionID + " to Session " + newMOASessionID); Logger.info("Daten angelegt zu MOASession " + newMOASessionID); String redirectURL = new DataURLBuilder().buildDataURL(session.getAuthURL(), ModulUtils.buildAuthURL(session.getModul(), session.getAction(), pendingRequestID), newMOASessionID); redirectURL = resp.encodeRedirectURL(redirectURL); resp.setContentType("text/html"); resp.setStatus(302); resp.addHeader("Location", redirectURL); Logger.debug("REDIRECT TO: " + redirectURL); } catch (MOAIDException ex) { handleError(null, ex, req, resp, pendingRequestID); } catch (GeneralSecurityException ex) { handleError(null, ex, req, resp, pendingRequestID); } catch (PKIException e) { handleError(null, e, req, resp, pendingRequestID); } catch (SAXException e) { handleError(null, e, req, resp, pendingRequestID); } catch (ParserConfigurationException e) { handleError(null, e, req, resp, pendingRequestID); } catch (Exception e) { Logger.error("MISMandateValidation has an interal Error.", e); } finally { ConfigurationDBUtils.closeSession(); } }
From source file:edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils.java
public static String getSessionAttributes(HttpServletRequest req) { String val = "<table>"; Enumeration names = req.getSession().getAttributeNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); val += "\n\t<tr><td><h3>" + name + "</h3><td><pre>"; String value = null;/*ww w. j a v a 2 s .co m*/ try { Object obj = req.getSession().getAttribute(name); value = (obj instanceof Model || obj instanceof ModelCom) ? "[Jena model object]" : (obj == null) ? "[null]" : StringEscapeUtils.escapeHtml(obj.toString()); } catch (Exception ex) { value = "unable to get value"; } catch (Error er) { value = "unable to get value"; } catch (Throwable th) { value = "unable to get value"; } val += value + "</pre></td></tr>\n"; } return val + "</table>"; }
From source file:elaborate.editor.export.tei.TeiMaker.java
private Element interp(String type, String value) { Element interp = tei.createElement("interp"); interp.setAttribute("type", SolrUtils.normalize(type)); interp.setAttribute("value", StringEscapeUtils.escapeHtml(value)); return interp; }
From source file:com.bst.tags.JavascriptHref.java
/** * Adds all the parameters contained in the map to the Href. The value in the given Map will be escaped before * added. Parameters in the original href are kept and not overridden. * @param parametersMap Map containing parameters *//*from ww w .jav a 2 s . c o m*/ public void addParameterMap(Map parametersMap) { // handle nulls if (parametersMap == null) { return; } // copy value, escaping html Iterator mapIterator = parametersMap.entrySet().iterator(); while (mapIterator.hasNext()) { Map.Entry entry = (Map.Entry) mapIterator.next(); String key = StringEscapeUtils.escapeHtml((String) entry.getKey()); // don't overwrite parameters if (!this.parameters.containsKey(key)) { Object value = entry.getValue(); if (value != null) { if (value.getClass().isArray()) { String[] values = (String[]) value; for (int i = 0; i < values.length; i++) { values[i] = StringEscapeUtils.escapeHtml(values[i]); } } else { value = StringEscapeUtils.escapeHtml(value.toString()); } } this.parameters.put(key, value); } } }
From source file:com.fluidops.iwb.widget.CodeExecutionWidget.java
@CallableFromWidget public static void testMe3(String value) { System.out.println("Clicked on " + StringEscapeUtils.escapeHtml(value)); }
From source file:com.redhat.rhn.frontend.taglibs.list.ListTagHelper.java
/** * returns the value that the list is being filtered upon. (null if not being filtered) * @param request the request to look in * @param uniqueName the unique (hashed) name for the list * @return the filter value//from w w w.j av a 2s . c o m */ public static String getFilterValue(ServletRequest request, String uniqueName) { String newValue = request.getParameter(ListTagUtil.makeFilterValueByLabel(uniqueName)); String oldValue = request.getParameter(ListTagUtil.makeOldFilterValueByLabel(uniqueName)); String clicked = request.getParameter(ListTagUtil.makeFilterNameByLabel(uniqueName)); if (clicked == null) { if (oldValue != null && !oldValue.equals("null")) { return StringEscapeUtils.escapeHtml(oldValue); } return ""; } return StringEscapeUtils.escapeHtml(newValue); }
From source file:eu.earthobservatory.org.StrabonEndpoint.BrowseBean.java
/** * Processes the request made from the HTML visual interface of Strabon * Endpoint./* ww w. j a va 2 s . c o m*/ * * @param request * @param response * @throws ServletException * @throws IOException */ private void processVIEWRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher dispatcher; String query = URLDecoder.decode(request.getParameter("query"), "UTF-8"); String format = request.getParameter("format"); // get stSPARQLQueryResultFormat from given format name TupleQueryResultFormat queryResultFormat = stSPARQLQueryResultFormat.valueOf(format); if (query == null || format == null || queryResultFormat == null) { dispatcher = request.getRequestDispatcher("browse.jsp"); request.setAttribute(ERROR, PARAM_ERROR); dispatcher.forward(request, response); } else { dispatcher = request.getRequestDispatcher("browse.jsp"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); request.setAttribute("resource", request.getParameter("resource")); try { strabonWrapper.query(query, format, bos); if (format.equals(Common.getHTMLFormat())) { request.setAttribute(RESPONSE, bos.toString()); } else { request.setAttribute(RESPONSE, StringEscapeUtils.escapeHtml(bos.toString())); } } catch (Exception e) { logger.error("[StrabonEndpoint.BrowseBean] Error during querying.", e); request.setAttribute(ERROR, e.getMessage()); } finally { dispatcher.forward(request, response); } } }
From source file:com.connexience.server.model.ServerObject.java
@JsonIgnore public String getDisplayName() { String n = StringEscapeUtils.escapeHtml(this.getName()); return n; }
From source file:io.github.tavernaextras.biocatalogue.model.Tag.java
/** * This method is used to generate the tooltip to be shown over the tag * in the tagcloud. Shown text will contain the full tag name, namespace * and frequency.//from w ww .j a va 2 s. co m * * @return HTML encoded string ready to be put into the tooltip. */ public String getTagCloudTooltip() { StringBuilder tooltip = new StringBuilder("<html>"); tooltip.append(" <b>" + (this.fullTagName.length() > this.tagDisplayName.length() ? "Full tag" : "Tag") + ": </b>" + StringEscapeUtils.escapeHtml(this.fullTagName)); if (this.tagNamespace != null && this.tagNamespace.length() > 0) { tooltip.append("<br> <b>Namespace: </b>" + StringEscapeUtils.escapeHtml(this.tagNamespace)); } tooltip.append("<br> <b>Frequency: </b>" + this.itemCount); tooltip.append("</html>"); return tooltip.toString(); }
From source file:au.edu.anu.portal.portlets.rss.SimpleRSSPortlet.java
/** * Process any portlet actions. //from w ww . ja va 2 s .c om */ public void processAction(ActionRequest request, ActionResponse response) throws PortletModeException { log.debug("Simple RSS processAction()"); //this handles both EDIT and CONFIG modes in exactly the same way. //if we need to split, check PortletMode. boolean success = true; //get prefs and submitted values PortletPreferences prefs = request.getPreferences(); String portletTitle = StringEscapeUtils.escapeHtml(StringUtils.trim(request.getParameter("portletTitle"))); String maxItems = StringUtils.trim(request.getParameter("maxItems")); String feedUrl = StringUtils.trim(request.getParameter("feedUrl")); //portlet title could be blank, set to default if (StringUtils.isBlank(portletTitle)) { portletTitle = Constants.PORTLET_TITLE_DEFAULT; } boolean feedUrlIsLocked = isPrefLocked(request, PREF_FEED_URL); boolean portletTitleIsLocked = isPrefLocked(request, PREF_PORTLET_TITLE); //check not readonly try { //only do this if we know its not locked, ie this is not a preconfigured portlet if (!portletTitleIsLocked) { prefs.setValue(PREF_PORTLET_TITLE, portletTitle); } //only do this if we know its not locked, ie this is not a preconfigured portlet if (!feedUrlIsLocked) { prefs.setValue(PREF_FEED_URL, feedUrl); } prefs.setValue(PREF_MAX_ITEMS, maxItems); } catch (ReadOnlyException e) { success = false; response.setRenderParameter("errorMessage", Messages.getString("error.form.readonly.error")); log.error(e.getMessage()); } //validate and save if (success) { try { prefs.store(); response.setPortletMode(PortletMode.VIEW); } catch (ValidatorException e) { //PORT-672 present entered data on the form again response.setRenderParameter("errorMessage", e.getMessage()); response.setRenderParameter("portletTitle", portletTitle); response.setRenderParameter("maxItems", maxItems); //this will be null if locked so don't set it, we dont need it if (!feedUrlIsLocked) { response.setRenderParameter("feedUrl", feedUrl); } log.error(e.getMessage()); } catch (IOException e) { response.setRenderParameter("errorMessage", Messages.getString("error.form.save.error")); log.error(e.getMessage()); } catch (PortletModeException e) { log.error(e.getMessage(), e); } } }