protected void sendRedirect(HttpServletRequest request, HttpServletResponse response, String redirectURI, Map<String, String> params) throws IOException { if (redirectURI == null) { response.sendError(SC_BAD_REQUEST, "No redirect URI"); return; } String url = URIUtils.addParametersToURIQuery(redirectURI, params); response.sendRedirect(url); } }
protected String resolveUrlWithTimestamp(UIComponent component, String url) { boolean doIncludeTimestamp = true; Object includeTimestamp = component.getAttributes().get("includeTimestamp"); if (includeTimestamp instanceof String) { if (!StringUtils.isBlank((String) includeTimestamp)) { doIncludeTimestamp = Boolean.parseBoolean((String) includeTimestamp); } } if (doIncludeTimestamp) { Long timestamp = Framework.getService(WebResourceManager.class).getLastModified(); if (timestamp != null) { return URIUtils.addParametersToURIQuery(url, Collections.singletonMap("ts", String.valueOf(timestamp))); } } return url; }
/** * @since 10.3 */ protected String getLogoutRedirectURL(String callbackURL, String baseURL, Map<String, String> parameters) { if (isCallbackURLValid(callbackURL, baseURL)) { return callbackURL; } String url = baseURL + LoginScreenHelper.getStartupPagePath(); return URIUtils.addParametersToURIQuery(url, parameters); }
@Override public String getLoginURL(HttpServletRequest request) { PluggableAuthenticationService authService = (PluggableAuthenticationService) Framework.getRuntime() .getComponent( PluggableAuthenticationService.NAME); Map<String, String> urlParameters = new HashMap<>(); urlParameters.put(SECURITY_ERROR, "true"); urlParameters.put(FORCE_ANONYMOUS_LOGIN, "true"); if (request.getAttribute(REQUESTED_URL) != null) { urlParameters.put(REQUESTED_URL, (String) request.getAttribute(REQUESTED_URL)); } else { urlParameters.put(REQUESTED_URL, NuxeoAuthenticationFilter.getRequestedUrl(request)); } String baseURL = authService.getBaseURL(request) + LOGOUT_PAGE; return URIUtils.addParametersToURIQuery(baseURL, urlParameters); }
redirectUrl = URIUtils.addParametersToURIQuery(redirectUrl, parameters); httpResponse.sendRedirect(redirectUrl); } catch (IOException e) {
@Override public String getUrlFromDocumentView(DocumentView docView) { DocumentLocation docLoc = docView.getDocumentLocation(); String filepath = docView.getParameter(FILE_PROPERTY_PATH_KEY); String filename = docView.getParameter(FILENAME_KEY); if (docLoc != null && filepath != null && filename != null) { StringBuilder buf = new StringBuilder(); buf.append(getPrefix()); buf.append("/"); buf.append(docLoc.getServerName()); buf.append("/"); buf.append(docLoc.getDocRef().toString()); buf.append("/"); buf.append(filepath); buf.append("/"); buf.append(URIUtils.quoteURIPathToken(filename)); String uri = buf.toString(); Map<String, String> requestParams = new HashMap<>(docView.getParameters()); requestParams.remove(FILE_PROPERTY_PATH_KEY); requestParams.remove(FILENAME_KEY); return URIUtils.addParametersToURIQuery(uri, requestParams); } return null; }
@Override public String getUrlFromDocumentView(DocumentView docView) { DocumentLocation docLoc = docView.getDocumentLocation(); if (docLoc != null) { List<String> items = new ArrayList<String>(); items.add(getPrefix()); IdRef docRef = docLoc.getIdRef(); if (docRef == null) { return null; } items.add(docRef.toString()); String uri = Joiner.on("/").join(items); return URIUtils.addParametersToURIQuery(uri, docView.getParameters()); } return null; }
/** * Get the url from a DocumentView for a user or a group. */ public String getUrlFromDocumentViewAndID(DocumentView docView, String paramName) { String id = docView.getParameter(paramName); if (id != null) { docView.removeParameter(paramName); List<String> items = new ArrayList<>(); items.add(getPrefix()); items.add(URIUtils.quoteURIPathComponent(id, true, false)); String viewId = docView.getViewId(); if (viewId != null) { items.add(viewId); } String uri = String.join("/", items); Map<String, String> parameters = docView.getParameters(); if (parameters == null) { parameters = new HashMap<>(); } return URIUtils.addParametersToURIQuery(uri, parameters); } return null; }
/** * Logs the user out. Invalidates the HTTP session so that it cannot be used anymore. * * @return the next page that is going to be displayed */ public static String logout() throws IOException { Map<String, String> parameters = new HashMap<String, String>(); FacesContext context = FacesContext.getCurrentInstance(); ExternalContext eContext = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) eContext.getRequest(); HttpServletResponse response = (HttpServletResponse) eContext.getResponse(); Principal principal = request.getUserPrincipal(); if (principal instanceof NuxeoPrincipal) { NuxeoPrincipal nuxeoPrincipal = (NuxeoPrincipal) principal; if (nuxeoPrincipal.isAnonymous()) { parameters.put(FORCE_ANONYMOUS_LOGIN, "true"); } } if (response != null && !context.getResponseComplete()) { String baseURL = BaseURL.getBaseURL(request) + LOGOUT_PAGE; request.setAttribute(DISABLE_REDIRECT_REQUEST_KEY, true); baseURL = URIUtils.addParametersToURIQuery(baseURL, parameters); response.sendRedirect(baseURL); context.responseComplete(); } return null; }
@Override public String getUrlFromDocumentView(DocumentView docView) { DocumentLocation docLoc = docView.getDocumentLocation(); if (docLoc != null) { List<String> items = new ArrayList<>(); items.add(getPrefix()); items.add(docLoc.getServerName()); IdRef docRef = docLoc.getIdRef(); if (docRef == null) { return null; } items.add(docRef.toString()); String viewId = docView.getViewId(); if (viewId != null) { items.add(viewId); } String uri = String.join("/", items); return URIUtils.addParametersToURIQuery(uri, docView.getParameters()); } return null; }
params.put(OAUTH_TOKEN, rToken.getToken()); params.put(OAUTH_VERIFIER, rToken.getVerifier()); String targetUrl = URIUtils.addParametersToURIQuery(callbackUrl, params); response.sendRedirect(targetUrl);
String uriWithParam = URIUtils.addParametersToURIQuery(uri, docView.getParameters());