public static String getContextUrl(HttpServletRequest req) { String serverUrl = getServerUrl(req); return PathUtil.concat(serverUrl, req.getContextPath(), '/'); }
protected void redirectToJavaApp(HttpServletRequest req, HttpServletResponse resp, String authentication) throws ServletException, IOException { Context context = Context.get(); String url = (String)req.getParameter(REDIRECT_URL); if(authentication.equals(AUTH_DECLINED)){ if(url != null){ if(url.indexOf("showWrongCredsMessage=true") == -1){// don't add again if wrongCreds parameter is already added for declined Authentication if(url.indexOf('?')!= -1) url = PathUtil.concat(url,"showWrongCredsMessage=true", '&'); else url = PathUtil.concat(url,"showWrongCredsMessage=true", '?'); } } } context.sendRedirect(url); }
/** * Get the URL to the proxy. * * @param context * @return * @throws OAuthException */ public static String getProxyUrl(HttpServletRequest request) { String contextPath = request.getContextPath(); String proxyBaseUrl = UrlUtil.makeUrlAbsolute(request,PathUtil.concat(contextPath,ServiceServlet.getServletPath(),'/')); return proxyBaseUrl; }
@Override public String getCallbackUrl(Context context) throws OAuthException { Object _req = context.getHttpRequest(); if(_req instanceof HttpServletRequest) { HttpServletRequest request = (HttpServletRequest)_req; String proxyBaseUrl = PathUtil.concat(ServiceUtil.getProxyUrl(request),OA2Callback.URL_PATH,'/'); return proxyBaseUrl; } return null; }
public String getCallbackUrl(Context context) throws OAuthException { Object _req = context.getHttpRequest(); if (_req instanceof HttpServletRequest) { HttpServletRequest request = (HttpServletRequest) _req; String proxyBaseUrl = PathUtil.concat(ServiceUtil.getProxyUrl(request), OACallback.URL_PATH, '/'); return proxyBaseUrl; } return null; }
protected String getUrlPath(Args args) { String baseUrl = getBaseUrl(); String serviceUrl = args.getServiceUrl(); return PathUtil.concat(baseUrl, serviceUrl, '/'); }
@Override public String encodeUrl(String url) { return PathUtil.concat(UrlUtil.getBaseUrl(getHttpRequest()),url, '/'); }
private String composeRequestUrl(Args args, Map<String, String[]> parameters) throws ClientServicesException { // Compose the URL StringBuilder b = new StringBuilder(256); String baseUrl = endpoint.getUrl(); String serviceUrl = args.getServiceUrl(); String url = PathUtil.concat(baseUrl, serviceUrl, '/'); if (url.charAt(url.length() - 1) == '/') { url = url.substring(0, url.length() - 1); } b.append(url); if (parameters != null) { boolean first = true; for (Map.Entry<String, String[]> e : parameters.entrySet()) { String name = e.getKey(); if (StringUtil.isNotEmpty(name)) { String[] values = e.getValue(); for (String value : values) { first = addParameter(b, first, name, value); } } } } return b.toString(); }
String postToProxy = PathUtil.concat(baseUrl, servletPath, '/'); postToProxy = PathUtil.concat(postToProxy,basicProxyUrl, '/'); postToProxy = PathUtil.concat(postToProxy,endPointName, '/'); postToProxy = PathUtil.concat(postToProxy,"JavaApp", '/'); authPage = PathUtil.concat(authPage,"proxyPath",'&'); authPage = PathUtil.concat(authPage,postToProxy,'='); authPage = PathUtil.concat(authPage,"redirectURL",'&'); authPage = PathUtil.concat(authPage,redirectUrl,'='); context.sendRedirect(authPage);
protected String getUrlPath(Args args) { String baseUrl = getBaseUrl(); String serviceUrl = args.getServiceUrl(); serviceUrl = substituteServiceMapping(serviceUrl); return PathUtil.concat(baseUrl, serviceUrl, CH_SLASH); }
String postToProxy = PathUtil.concat(baseUrl, servletPath, '/'); postToProxy = PathUtil.concat(postToProxy,basicProxyUrl, '/'); postToProxy = PathUtil.concat(postToProxy,endPointName, '/'); postToProxy = PathUtil.concat(postToProxy,"JavaApp", '/'); authPage = PathUtil.concat(authPage,"proxyPath",'&'); authPage = PathUtil.concat(authPage,postToProxy,'='); authPage = PathUtil.concat(authPage,"redirectURL",'&'); authPage = PathUtil.concat(authPage,redirectUrl,'='); context.sendRedirect(authPage);
String postToProxy = PathUtil.concat(baseUrl, servletPath, '/'); postToProxy = PathUtil.concat(postToProxy,basicProxyUrl, '/'); postToProxy = PathUtil.concat(postToProxy,endPointName, '/'); postToProxy = PathUtil.concat(postToProxy,"JavaApp", '/'); authPage = PathUtil.concat(authPage,"proxyPath",'?'); authPage = PathUtil.concat(authPage,postToProxy,'='); authPage = PathUtil.concat(authPage,"redirectURL",'&'); authPage = PathUtil.concat(authPage,redirectUrl,'='); context.sendRedirect(authPage);
protected String getModuleUrl(LibraryRequest request, String modulePath, ModuleType type) { if (logger.isLoggable(Level.FINEST)) { logger.entering(sourceClass, "getModuleUrl", new Object[] { request, modulePath }); } String jsUrl = ""; String moduleUrl = ""; switch (type) { case SBT_MODULE: jsUrl = request.getToolkitJsUrl(); break; case SBTX_MODULE: jsUrl = request.getToolkitExtJsUrl(); break; case JS_LIBRARY: jsUrl = request.getJsLibraryUrl(); break; default: moduleUrl = modulePath; break; } moduleUrl = moduleUrl.isEmpty() ? PathUtil.concat(jsUrl, modulePath, '/') : moduleUrl; if (logger.isLoggable(Level.FINEST)) { logger.exiting(sourceClass, "getModuleUrl", moduleUrl); } return moduleUrl; } /**
if(StringUtil.isNotEmpty(requestUri)&& requestUri.indexOf("?")!=-1) requestUri = requestUri.substring(0, requestUri.indexOf("?")); requestUri = PathUtil.concat(baseUrl, requestUri, '/');
/** * Initialize with the default values */ public void initDefaults() { // default parameters Application application = Application.get(); String defaultToolkitUrl = getAppParameter(application, LibraryRequestParams.PARAM_TOOLKIT_URL, LibraryRequestParams.DEFAULT_TOOLKIT_URL); String defaultToolkitExtUrl = getAppParameter(application, LibraryRequestParams.PARAM_TOOLKIT_EXT_URL, LibraryRequestParams.DEFAULT_TOOLKIT_EXT_URL); String defaultJsLibraryUrl = getAppParameter(application, LibraryRequestParams.PARAM_JS_LIBRARY_URL, LibraryRequestParams.DEFAULT_JS_LIBRARY_URL); String defaultJavaScriptPath = getAppParameter(application, LibraryRequestParams.PARAM_JAVASCRIPT_PATH, LibraryRequestParams.DEFAULT_JAVASCRIPT_PATH); String defaultServiceUrl = getAppParameter(application, LibraryRequestParams.PARAM_SERVICE_URL, LibraryRequestParams.DEFAULT_SERVICE_URL); String defaultLibraryUrl = getAppParameter(application, LibraryRequestParams.PARAM_LIBRARY_URL, LibraryRequestParams.DEFAULT_LIBRARY_URL); String defaultIFramePath = getAppParameter(application, LibraryRequestParams.PARAM_IFRAME_PATH, LibraryRequestParams.DEFAULT_IFRAME_PATH); // load initialisation parameters setToolkitUrl(defaultToolkitUrl); setToolkitJsUrl(PathUtil.concat(getToolkitUrl(), defaultJavaScriptPath, '/')); setToolkitExtUrl(defaultToolkitExtUrl); setToolkitExtJsUrl(PathUtil.concat(getToolkitExtUrl(), defaultJavaScriptPath, '/')); setServiceUrl(defaultServiceUrl); setLibraryUrl(defaultLibraryUrl); setJsLibraryUrl(defaultJsLibraryUrl); setIframeUrl(PathUtil.concat(getToolkitUrl(), defaultIFramePath, '/')); // load initialization parameters SBTEnvironment environment = SBTEnvironmentFactory.get("defaultEnvironment"); setEnvironment(environment); }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); // default parameters Application application = Application.get(); String defaultToolkitUrl = getAppParameter(application, LibraryRequestParams.PARAM_TOOLKIT_URL, LibraryRequestParams.DEFAULT_TOOLKIT_URL); String defaultToolkitExtUrl = getAppParameter(application, LibraryRequestParams.PARAM_TOOLKIT_EXT_URL, LibraryRequestParams.DEFAULT_TOOLKIT_EXT_URL); String defaultJsLibraryUrl = getAppParameter(application, LibraryRequestParams.PARAM_JS_LIBRARY_URL, LibraryRequestParams.DEFAULT_JS_LIBRARY_URL); String defaultJavaScriptPath = getAppParameter(application, LibraryRequestParams.PARAM_JAVASCRIPT_PATH, LibraryRequestParams.DEFAULT_JAVASCRIPT_PATH); String defaultServiceUrl = getAppParameter(application, LibraryRequestParams.PARAM_SERVICE_URL, LibraryRequestParams.DEFAULT_SERVICE_URL); String defaultLibraryUrl = getAppParameter(application, LibraryRequestParams.PARAM_LIBRARY_URL, LibraryRequestParams.DEFAULT_LIBRARY_URL); String defaultIFramePath = getAppParameter(application, LibraryRequestParams.PARAM_IFRAME_PATH, LibraryRequestParams.DEFAULT_IFRAME_PATH); // load initialisation parameters defaultParams.setToolkitUrl(getInitParameter(config, LibraryRequestParams.PARAM_TOOLKIT_URL, defaultToolkitUrl)); defaultParams.setToolkitJsUrl(PathUtil.concat(defaultParams.getToolkitUrl(), getInitParameter(config, LibraryRequestParams.PARAM_JAVASCRIPT_PATH, defaultJavaScriptPath), '/')); defaultParams.setToolkitExtUrl(getInitParameter(config, LibraryRequestParams.PARAM_TOOLKIT_EXT_URL, defaultToolkitExtUrl)); defaultParams.setToolkitExtJsUrl(PathUtil.concat(defaultParams.getToolkitExtUrl(), getInitParameter(config, LibraryRequestParams.PARAM_JAVASCRIPT_PATH, defaultJavaScriptPath), '/')); defaultParams.setServiceUrl(getInitParameter(config, LibraryRequestParams.PARAM_SERVICE_URL, defaultServiceUrl)); defaultParams.setLibraryUrl(getInitParameter(config, LibraryRequestParams.PARAM_LIBRARY_URL, defaultLibraryUrl)); defaultParams.setJsLibraryUrl(getInitParameter(config, LibraryRequestParams.PARAM_JS_LIBRARY_URL, defaultJsLibraryUrl)); defaultParams.setIframeUrl(PathUtil.concat(defaultParams.getToolkitUrl(), getInitParameter(config, LibraryRequestParams.PARAM_IFRAME_PATH, defaultIFramePath), '/')); // create the libraries libraries = readLibraries(application); }
String proxyUrl = PathUtil.concat(request.getServiceUrl(), endpoint.getProxyHandlerPath(), '/'); proxyUrl = addMakeAbsoluteUrl(proxyUrl).getRef(); return new JsonReference("new Proxy({proxyUrl:" + proxyUrl + "})");