private void init() { synchronized (FacesElWeblet.class) { if (_delegate == null) { Class instantiation = ServiceLoader.loadService(FacesElWeblet.class.getName()); try { _delegate = (FacesElWeblet) instantiation.newInstance(); } catch (InstantiationException e) { throw new WebletException("Error instantiating FacesElWeblet", e); } catch (IllegalAccessException e) { throw new WebletException("Error instantiating FacesElWeblet", e); } } } }
static IFacesWebletUtils getInstance() throws WebletException { synchronized (FacesWebletUtils.class) { if (instance == null) { Class instantiation = ServiceLoader.loadService(FacesWebletUtils.class.getName()); try { instance = (IFacesWebletUtils) instantiation.newInstance(); } catch (InstantiationException e) { throw new WebletException("Error instantiating IJSFWebletsUtils", e); } catch (IllegalAccessException e) { throw new WebletException("Error instantiating IJSFWebletsUtils", e); } } } return instance; } }
static IWebletUtils getInstance() throws WebletException { synchronized (FacesWebletUtils.class) { if (instance == null) { Class instantiation = ServiceLoader.loadService(WebletUtils.class.getName()); try { instance = (IWebletUtils) instantiation.newInstance(); } catch (InstantiationException e) { throw new WebletException("Error instantiating WebletsUtil", e); } catch (IllegalAccessException e) { throw new WebletException("Error instantiating WebletsUtil", e); } } } return instance; } }
public Weblet getWeblet(String webletName) { Weblet weblet = (Weblet) _weblets.get(webletName); if (weblet == null) { try { WebletConfigImpl config = (WebletConfigImpl) _webletConfigs.get(webletName); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class webletClass = loader.loadClass(config.getWebletClass()); weblet = (Weblet) webletClass.newInstance(); weblet.init(config); _weblets.put(webletName, weblet); } catch (ClassNotFoundException e) { throw new WebletException(e); } catch (InstantiationException e) { throw new WebletException(e); } catch (IllegalAccessException e) { throw new WebletException(e); } } return weblet; }
public Weblet getWeblet(String webletName) { Weblet weblet = (Weblet) _weblets.get(webletName); if (weblet == null) { try { WebletConfigImpl config = (WebletConfigImpl) _webletConfigs.get(webletName); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class webletClass = loader.loadClass(config.getWebletClass()); weblet = (Weblet) webletClass.newInstance(); weblet.init(config); _weblets.put(webletName, weblet); } catch (ClassNotFoundException e) { throw new WebletException(e); } catch (InstantiationException e) { throw new WebletException(e); } catch (IllegalAccessException e) { throw new WebletException(e); } } return weblet; }
return loader.loadClass(serviceClassName); } catch (IOException e) { throw new WebletException("Error reading Weblet Service " + "service information " + serviceRef, e); } catch (ClassNotFoundException e) { throw new WebletException("Unable to load Weblet Service " + "implementation class " + serviceRef, e); } finally { if (reader != null) reader.close(); } catch (IOException e) { throw new WebletException("Unable to load Weblet Service " + serviceRef, e);
return loader.loadClass(serviceClassName); } catch (IOException e) { throw new WebletException("Error reading Weblet Service " + "service information " + serviceRef, e); } catch (ClassNotFoundException e) { throw new WebletException("Unable to load Weblet Service " + "implementation class " + serviceRef, e); } finally { if (reader != null) reader.close(); } catch (IOException e) { throw new WebletException("Unable to load Weblet Service " + serviceRef, e);
public String getResourceUri( String webletName, String pathInfo) throws WebletException { WebletConfig config = (WebletConfig) _webletConfigs.get(webletName); if (config == null) throw new WebletException("Missing Weblet configuration for '" + webletName + "'"); String webletPath = (String) _webletPaths.get(webletName); if (webletPath == null) throw new WebletException("Missing Weblet mapping for '" + webletName + "'"); String webletVersion = config.getWebletVersion(); // URL-syntax /webletPath[$version]/pathInfo StringBuffer buffer = new StringBuffer(); buffer.append(webletPath); if (webletVersion != null) { buffer.append('$'); buffer.append(webletVersion); } if (pathInfo != null) { buffer.append(pathInfo); } String webletURL = buffer.toString(); if (_webletURLFormat != null) webletURL = _webletURLFormat.format(new Object[]{webletURL}); return webletURL; }
public String getResourceUri( String webletName, String pathInfo) throws WebletException { WebletConfig config = (WebletConfig) _webletConfigs.get(webletName); if (config == null) throw new WebletException("Missing Weblet configuration for '" + webletName + "'"); String webletPath = (String) _webletPaths.get(webletName); if (webletPath == null) throw new WebletException("Missing Weblet mapping for '" + webletName + "'"); String webletVersion = config.getWebletVersion(); // URL-syntax /webletPath[$version]/pathInfo StringBuffer buffer = new StringBuffer(); buffer.append(webletPath); if (webletVersion != null) { buffer.append('$'); buffer.append(webletVersion); } if (pathInfo != null) { buffer.append(pathInfo); } String webletURL = buffer.toString(); if (_webletURLFormat != null) webletURL = _webletURLFormat.format(new Object[]{webletURL}); return webletURL; }
WebletConfig webletConfig = (WebletConfig) _webletConfigs.get(webletName); if (webletConfig == null) throw new WebletException("Weblet configuration not found: " + webletName); Matcher matcher = _WEBLET_PATH_PATTERN.matcher(urlPattern); if (matcher.matches()) {
throw new WebletException("Weblet configuration not found: " + webletName);
public void init(WebletConfig config) { super.init(config); String httpAddress = config.getInitParameter("rootaddress"); if (httpAddress == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } _resourceRoot = httpAddress; }
throw new WebletException(e);
/** * init method which is called by default to process the parameters * * @param config * the webletconfig to be processed */ public void init(WebletConfig config) { super.init(config); _resourceRoot = config.getInitParameter("resourceRoot"); // init param missing, lets throw an error if (_resourceRoot == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } }
/** * init method which is called by default to process the parameters * * @param config the webletconfig to be processed */ public void init(WebletConfig config) { super.init(config); // fetch the weblets init param _packageName = config.getInitParameter("package"); // fetch the resource root param /*auto fix path according to the specs the root must begin with a leading /*/ _resourceRoot = config.getInitParameter("resourceRoot"); if (StringUtils.isBlank(_resourceRoot)) _resourceRoot = "/"; _resourceRoot = _resourceRoot.trim(); if (!_resourceRoot.startsWith("/") && !_resourceRoot.startsWith("\\")) _resourceRoot = "/" + _resourceRoot; // init param missing, lets throw an error if (_packageName == null && _resourceRoot == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } // the init was successful we now have all we need _resourceRoot = (_packageName != null) ? _packageName.replace('.', '/') : _resourceRoot; }
/** * init method which is called by default to process the parameters * * @param config the webletconfig to be processed */ public void init(WebletConfig config) { super.init(config); // fetch the weblets init param String packageName = config.getInitParameter("package"); // fetch the resource root param String resourceRoot = config.getInitParameter("resourceRoot"); // String cacheTimeout = config.getInitParameter("cachecontrol-timeout"); // init param missing, lets throw an error if (packageName == null && resourceRoot == null) { throw new WebletException("Missing either init parameter \"package\" or " + " or init parameter \"resourceRoot\" for " + " Weblet \"" + config.getWebletName() + "\""); } // the init was successful we now have all we need _resourceRoot = (packageName != null) ? packageName.replace('.', '/') : resourceRoot; // optional init param }
public void service( WebletRequest request, WebletResponse response) throws IOException, WebletException { Weblet weblet = getWeblet(request); String pathInfo = request.getPathInfo(); //enhanced security check if (pathInfo != null && SandboxGuard.isJailBreak(pathInfo)) { throw new WebletException("Security Exception, the " + pathInfo + " breaks out of the resource jail, no resource is served!"); } WebletConfig webConfig = weblet.getWebletConfig(); String mimeType = null; if(!StringUtils.isBlank(pathInfo)) { mimeType = webConfig.getMimeType(pathInfo); } if(mimeType == null) { mimeType = response.getDefaultContentType(); } response.setContentType(mimeType); Set allowedResources = webConfig.getAllowedResources(); if (allowedResources != null) { String filetype = StringUtils.getExtension(pathInfo); if (!allowedResources.contains(filetype.toLowerCase())) { throw new WebletException("Security Exception, the " + pathInfo + " resource cannot be served!"); /* not allowed no content delivered */ } } weblet.service(request, response); }
throw new WebletException("Security Exception, the " + pathInfo + " breaks out of the resource jail, no resource is served!"); String filetype = StringUtils.getExtension(pathInfo); if (!allowedResources.contains(filetype.toLowerCase())) { throw new WebletException("Security Exception, the " + pathInfo + " resource cannot be served!");
throw new WebletException(e); throw new WebletException(e);
throw new WebletException(e); throw new WebletException(e);