/** * Is the Gadget to be rendered sanitized? * @return true if sanitization will be enabled */ public static boolean isSanitizedRenderingRequest(Gadget gadget) { return "1".equals(gadget.getContext().getParameter("sanitize")); }
/** * Is the Gadget to be rendered sanitized? * @return true if sanitization will be enabled */ public static boolean isSanitizedRenderingRequest(Gadget gadget) { return "1".equals(gadget.getContext().getParameter("sanitize")); }
/** * Is the Gadget to be rendered sanitized? * @return true if sanitization will be enabled */ public static boolean isSanitizedRenderingRequest(Gadget gadget) { return "1".equals(gadget.getContext().getParameter("sanitize")); }
public VisitStatus visit(Gadget gadget, Node node) throws RewritingException { if (node.getNodeType() == Node.ELEMENT_NODE && "style".equalsIgnoreCase(node.getNodeName())) { cssSanitizer.sanitize((Element) node, gadget.getSpec().getUrl(), gadget.getContext(), cssImportRewriter, imageRewriter); return VisitStatus.MODIFY; } return VisitStatus.BYPASS; }
public VisitStatus visit(Gadget gadget, Node node) throws RewritingException { if (node.getNodeType() == Node.ELEMENT_NODE && "style".equalsIgnoreCase(node.getNodeName())) { cssSanitizer.sanitize((Element) node, gadget.getSpec().getUrl(), gadget.getContext(), cssImportRewriter, imageRewriter); return VisitStatus.MODIFY; } return VisitStatus.BYPASS; }
protected String generateSecurityToken(Gadget gadget) { // Find a security token in the context try { SecurityToken token = gadget.getContext().getToken(); if (securityTokenCodec != null && token != null) { return securityTokenCodec.encodeToken(token); } } catch (SecurityTokenException e) { // ignore -- no security token } return null; }
/** * Returns true iff the gadget opts into the caja or the container forces caja by flag */ private boolean requiresCaja(Gadget gadget) { return gadget.getSpec().getModulePrefs().getFeatures().containsKey("caja") || "1".equals(gadget.getContext().getParameter("caja")); }
public boolean revisit(Gadget gadget, List<Node> nodes) throws RewritingException { Uri contentBase = gadget.getSpec().getUrl(); for (Node node: nodes) { Element elem = (Element) node; cssRewriter.rewrite( elem, contentBase, CssResponseRewriter.uriMaker(proxyUriManager, config), false, gadget.getContext()); } return !nodes.isEmpty(); } }
public boolean revisit(Gadget gadget, List<Node> nodes) throws RewritingException { Uri contentBase = gadget.getSpec().getUrl(); for (Node node: nodes) { Element elem = (Element) node; cssRewriter.rewrite( elem, contentBase, CssResponseRewriter.uriMaker(proxyUriManager, config), false, gadget.getContext()); } return !nodes.isEmpty(); } }
/** {@inheritDoc} */ public void contribute(Map<String, Object> config, Gadget gadget) { GadgetContext ctx = gadget.getContext(); addServicesConfig(config, ctx.getContainer(), ctx.getHost()); }
public Collection<Callable<PreloadedData>> createPreloadTasks(Gadget gadget) { List<Callable<PreloadedData>> preloads = Lists.newArrayList(); GadgetContext context = gadget.getContext(); for (Preload preload : gadget.getSpec().getModulePrefs().getPreloads()) { Set<String> preloadViews = preload.getViews(); if (preloadViews.isEmpty() || preloadViews.contains(context.getView())) { preloads.add(new PreloadTask(context, preload, preload.getHref().toString())); } } return preloads; }
public Collection<Callable<PreloadedData>> createPreloadTasks(Gadget gadget) { List<Callable<PreloadedData>> preloads = Lists.newArrayList(); GadgetContext context = gadget.getContext(); for (Preload preload : gadget.getSpec().getModulePrefs().getPreloads()) { Set<String> preloadViews = preload.getViews(); if (preloadViews.isEmpty() || preloadViews.contains(context.getView())) { preloads.add(new PreloadTask(context, preload, preload.getHref().toString())); } } return preloads; }
public Collection<Callable<PreloadedData>> createPreloadTasks(Gadget gadget) { List<Callable<PreloadedData>> preloads = Lists.newArrayList(); GadgetContext context = gadget.getContext(); for (Preload preload : gadget.getSpec().getModulePrefs().getPreloads()) { Set<String> preloadViews = preload.getViews(); if (preloadViews.isEmpty() || preloadViews.contains(context.getView())) { preloads.add(new PreloadTask(context, preload, preload.getHref().toString())); } } return preloads; }
/** * Should the gadget content be sanitized on output * @return */ public boolean sanitizeOutput() { return (getCurrentView() != null && getCurrentView().getType() == View.ContentType.HTML_SANITIZED) || "1".equals(getContext().getParameter(UriCommon.Param.SANITIZE.getKey())); } }
/** * Should the gadget content be sanitized on output * @return */ public boolean sanitizeOutput() { return (getCurrentView() != null && getCurrentView().getType() == View.ContentType.HTML_SANITIZED) || "1".equals(getContext().getParameter(UriCommon.Param.SANITIZE.getKey())); }
/** * Should the gadget content be sanitized on output * @return */ public boolean sanitizeOutput() { return (getCurrentView() != null && getCurrentView().getType() == View.ContentType.HTML_SANITIZED) || "1".equals(getContext().getParameter(UriCommon.Param.SANITIZE.getKey())); } }
private void mockGadget(List<Feature> allFeatures, String container, String gadgetUrl) { mockGadgetContext(container); mockGadgetSpec(allFeatures, gadgetUrl); EasyMock.expect(mockGadget.getContext()).andReturn(mockContext).anyTimes(); EasyMock.expect(mockGadget.getSpec()).andReturn(mockSpec).anyTimes(); }
private void mockGadget(List<Feature> allFeatures, String container, String gadgetUrl) { mockGadgetContext(container); mockGadgetSpec(allFeatures, gadgetUrl); EasyMock.expect(mockGadget.getContext()).andReturn(mockContext).anyTimes(); EasyMock.expect(mockGadget.getSpec()).andReturn(mockSpec).anyTimes(); }
private void mockGadget(List<Feature> allFeatures, String container, String gadgetUrl) { mockGadgetContext(container); mockGadgetSpec(allFeatures, gadgetUrl); EasyMock.expect(mockGadget.getContext()).andReturn(mockContext).anyTimes(); EasyMock.expect(mockGadget.getSpec()).andReturn(mockSpec).anyTimes(); }
private Gadget makeGadget() throws GadgetException { Gadget gadget = EasyMock.createNiceMock(Gadget.class); GadgetContext context = EasyMock.createNiceMock(GadgetContext.class); expect(context.getUrl()).andReturn(Uri.parse("http://example.com/gadget.xml")).anyTimes(); expect(context.getContainer()).andReturn("cajaContainer").anyTimes(); expect(context.getDebug()).andReturn(false).anyTimes(); expect(gadget.getContext()).andReturn(context).anyTimes(); expect(gadget.getAllFeatures()).andReturn(ImmutableList.of("caja")).anyTimes(); expect(gadget.requiresCaja()).andReturn(true).anyTimes(); replay(context, gadget); return gadget; }