public static String urlEncode(String url, boolean keepPathSlash) { String encoded = URLEncodeUtils.encodeUtf8(url); if (keepPathSlash) { encoded = encoded.replace("%2F", "/"); } return encoded; } }
protected String getIdpLogoutUrl() { String idpBaseURL = webAuthConfig.getIdpBaseURL(); if (!idpBaseURL.endsWith("/")) { idpBaseURL += "/"; } String idpRedirectUrl = idpBaseURL + "logout?sp=" + URLEncodeUtils.encodeUtf8(getWebAppUrl()); return idpRedirectUrl; }
protected String getIdpRedirectUrl() { String idpBaseURL = webAuthConfig.getIdpBaseURL(); if (!idpBaseURL.endsWith("/")) { idpBaseURL += "/"; } String idpRedirectUrl = idpBaseURL + "?sp=" + URLEncodeUtils.encodeUtf8(getWebAppUrl()); return idpRedirectUrl; }
/** * Serializes the given {@code id} to string representation. * <p> * String, Integer, Long and UUID ids are only supported. * * @param id id to serialize * @return serialized string representation of id * @throws IllegalArgumentException if null id is passed or it has an unsupported type */ @Nonnull public static String serializeId(Object id) { checkNotNullArgument(id, "Id cannot be null"); String serialized; Class<?> idClass = id.getClass(); if (String.class == idClass || Integer.class == idClass || Long.class == idClass) { serialized = URLEncodeUtils.encodeUtf8(id.toString()); } else if (UUID.class == idClass) { serialized = CrockfordUuidEncoder.encode(((UUID) id)); } else { throw new IllegalArgumentException( String.format("Unable to serialize id '%s' of type '%s'", id, idClass)); } return serialized; }
@PostMapping(value = "/run/{entityId}") public void runReport(@PathVariable String entityId, @RequestBody(required = false) String body, HttpServletResponse response) { if (Strings.isNullOrEmpty(body)) { throw new RestAPIException("Run report error", "Required request body is missing", HttpStatus.BAD_REQUEST); } ReportRestResult result = controllerManager.runReport(entityId, body); try { String fileName = URLEncodeUtils.encodeUtf8(result.getDocumentName()); response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache"); response.setHeader(HttpHeaders.PRAGMA, "no-cache"); response.setDateHeader(HttpHeaders.EXPIRES, 0); response.setHeader(HttpHeaders.CONTENT_TYPE, getContentType(result.getReportOutputType())); response.setHeader(HttpHeaders.CONTENT_DISPOSITION, (BooleanUtils.isTrue(result.attachment) ? "attachment" : "inline") + "; filename=\"" + fileName + "\""); ServletOutputStream os = response.getOutputStream(); IOUtils.copy(new ByteArrayInputStream(result.getContent()), os); os.flush(); } catch (IOException e) { log.error("Error on downloading the report {}", entityId, e); throw new RestAPIException("Error on downloading the report", "", HttpStatus.INTERNAL_SERVER_ERROR); } }
return "redirect:login.html" + "?response_type=" + ResponseType.CLIENT_TICKET.getCode() + "&sp=" + URLEncodeUtils.encodeUtf8(serviceProviderUrl); return "redirect:login.html?sp=" + URLEncodeUtils.encodeUtf8(serviceProviderUrl);
String url = selectedUrl + fileDownloadContext + "?s=" + userSessionSource.getUserSession().getId() + "&p=" + URLEncodeUtils.encodeUtf8(filePath);
return "redirect:login.html" + "?response_type=" + ResponseType.CLIENT_TICKET.getCode() + "&sp=" + URLEncodeUtils.encodeUtf8(serviceProviderUrl); return "redirect:login.html?sp=" + URLEncodeUtils.encodeUtf8(serviceProviderUrl);
|| value instanceof Boolean) { sb.append(",").append(param.getKey()).append(":") .append(URLEncodeUtils.encodeUtf8(value.toString()));
String encodedFilePath = URLEncodeUtils.encodeUtf8(file.getPath()); sb.append(encodedFilePath).append("\n"); } else {
@Override public String getLogFileLink(String fileName) throws LogControlException { // check log file exists logControl.getLogFile(fileName); Configuration configuration = AppBeans.get(Configuration.NAME); GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class); String encodedFileName = URLEncodeUtils.encodeUtf8(fileName); return globalConfig.getDispatcherBaseUrl() + "/log/" + encodedFileName; }
String fileName = URLEncodeUtils.encodeUtf8(fd.getName());
String fileName = URLEncodeUtils.encodeUtf8(fd.getName());
protected void setRememberMeCookies() { if (connection.isAuthenticated()) { if (webConfig.getRememberMeEnabled()) { if (Boolean.TRUE.equals(rememberMeCheckBox.getValue())) { if (!loginByRememberMe) { app.addCookie(COOKIE_REMEMBER_ME, Boolean.TRUE.toString()); String login = loginField.getValue(); String encodedLogin = URLEncodeUtils.encodeUtf8(login); app.addCookie(COOKIE_LOGIN, StringEscapeUtils.escapeJava(encodedLogin)); UserSession session = connection.getSession(); if (session == null) { throw new IllegalStateException("Unable to get session after login"); } User user = session.getUser(); String rememberMeToken = userManagementService.generateRememberMeToken(user.getId()); app.addCookie(COOKIE_PASSWORD, rememberMeToken); } } else { app.removeCookie(COOKIE_REMEMBER_ME); app.removeCookie(COOKIE_LOGIN); app.removeCookie(COOKIE_PASSWORD); } } } }