• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XSSAPI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.adobe.granite.xss.XSSAPI的典型用法代码示例。如果您正苦于以下问题:Java XSSAPI类的具体用法?Java XSSAPI怎么用?Java XSSAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XSSAPI类属于com.adobe.granite.xss包,在下文中一共展示了XSSAPI类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Before
public void setUp() {
  when(this.request.getResource()).thenReturn(this.resource);
  when(this.request.getResourceResolver()).thenReturn(this.resourceResolver);
  when(this.request.getAttribute(ComponentContext.CONTEXT_ATTR_NAME)).thenReturn(this.componentContext);
  when(this.request.getAttribute(WCMMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(WCMMode.PREVIEW);
  when(this.request.adaptTo(XSSAPI.class)).thenReturn(this.xssApi);
  when(this.resource.getResourceResolver()).thenReturn(this.resourceResolver);
  when(this.resourceResolver.adaptTo(PageManager.class)).thenReturn(this.pageManager);
  when(this.resourceResolver.adaptTo(Designer.class)).thenReturn(this.designer);
  when(this.componentContext.getPage()).thenReturn(this.currentPage);
  when(this.componentContext.getCell()).thenReturn(this.cell);
  when(this.pageManager.getContainingPage(this.resource)).thenReturn(this.resourcePage);
  when(this.designer.getDesign(any(Page.class))).thenReturn(this.design);
  when(this.design.getStyle(this.cell)).thenReturn(this.style);
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:17,代码来源:AemObjectInjectorRequestTest.java


示例2: getRedirect

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Set and return redirect given a path
 * 
 * @param path
 * @return xss scrubbed URL or null
 */
private String getRedirect(final String path) {
    // immediately return previously acquired target or blank path
    if (null != redirectPath || StringUtils.isBlank(path)) return redirectPath;
    
    String target = null;
    XSSAPI xssApi = getSlingScriptHelper().getService(XSSAPI.class);

    // consider relative paths
    if (StringUtils.startsWith(path, WCMConstants.DELIMITER_PATH)) {
        Page page = WCMUtil.getPage(getRequest(), path);
        if (null != page) {
            if (!page.isValid()) {
                // empty target for invalid page
                return redirectPath;
            }
            // attempt to get URL of valid Page
            target = WCMUtil.getPageURL(getRequest(), path);
        } else if (null != getResourceResolver().resolve(path)) {
            // may be a valid resource but not a page
            target = path;
        }
        // path is not a valid, visible resource per request
    } 
    // external location or possibly fully qualified URL
    target = path;
    redirectPath = xssApi.getValidHref(target);
    return redirectPath;
}
 
开发者ID:steeleforge,项目名称:ironsites,代码行数:35,代码来源:RedirectUse.java


示例3: doTag

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Override
public void doTag() throws JspException, IOException {

    ResourceResolver resourceResolver = request.getResourceResolver();
    XSSAPI xssAPI = resourceResolver.adaptTo(XSSAPI.class);
    String q = xssAPI.encodeForHTML(this.q);
    String appName= "", apikey = "", contextNumber = "";

    if (currentPage != null) {
        Page rootPage = currentPage.getAbsoluteParent(1);

        ValueMap properties = rootPage.getProperties();
        String[] cloudServices = properties.get("cq:cloudserviceconfigs", new String[0]);
        for (String cloudService : cloudServices) {
            if (cloudService.contains("/etc/cloudservices/googlecustomsearch")) {
                Resource searchConfigResource = resourceResolver.getResource(cloudService);
                Page searchConfigPage = (searchConfigResource != null) ? searchConfigResource.adaptTo(Page.class) : null;

                if (searchConfigPage!= null) {
                    ValueMap searchConfigProperties = searchConfigPage.getContentResource().adaptTo(ValueMap.class);

                    appName = searchConfigProperties.get("appname", "");
                    apikey = searchConfigProperties.get("apikey", "");
                    contextNumber = searchConfigProperties.get("cx", "");
                }
            }
        }
    }

    if (!"".equals(appName) && !"".equals(apikey) && !"".equals(contextNumber) &&
            this.q.length() > 0 && this.currentTab.length() > 0 && this.numberOfResults > 0 && this.numberOfPages > 0) {

        ResultList resultList = new GoogleSearchService(apikey, appName, contextNumber)
                .getResults(q, currentTab, numberOfResults, numberOfPages);

        LinkedList<ResultItem> resultItems = resultList.getResultItems();

        getJspContext().setAttribute("resultList", resultList);
        getJspContext().setAttribute("resultItems", resultItems);
    }
}
 
开发者ID:infielddigital,项目名称:aem-id-googlesearch,代码行数:42,代码来源:GoogleSearchTag.java


示例4: getValue

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Override
public Object getValue(final Object adaptable, final String name, final Type type, final AnnotatedElement element,
    final DisposalCallbackRegistry callbackRegistry) {

  // only class types are supported
  if (!(type instanceof Class<?>)) {
    return null;
  }
  Class<?> requestedClass = (Class<?>)type;

  if (adaptable instanceof SlingHttpServletRequest) {
    SlingHttpServletRequest request = (SlingHttpServletRequest)adaptable;
    if (requestedClass.equals(WCMMode.class)) {
      return getWcmMode(request);
    }
    if (requestedClass.equals(ComponentContext.class)) {
      return getComponentContext(request);
    }
    if (requestedClass.equals(Style.class)) {
      return getStyle(request);
    }
    if (requestedClass.equals(XSSAPI.class)) {
      return getXssApi(request);
    }
  }

  if (requestedClass.equals(PageManager.class)) {
    return getPageManager(adaptable);
  }
  else if (requestedClass.equals(Page.class)) {
    if (StringUtils.equals(name, RESOURCE_PAGE)) {
      return getResourcePage(adaptable);
    }
    else {
      return getCurrentPage(adaptable);
    }
  }
  else if (requestedClass.equals(Designer.class)) {
    return getDesigner(adaptable);
  }
  else if (requestedClass.equals(Design.class)) {
    return getCurrentDesign(adaptable);
  }

  return null;
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:47,代码来源:AemObjectInjector.java


示例5: getXssApi

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
private XSSAPI getXssApi(final SlingHttpServletRequest request) {
  return request.adaptTo(XSSAPI.class);
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:4,代码来源:AemObjectInjector.java


示例6: testXssApi

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Test
public void testXssApi() {
  Object result = this.injector.getValue(this.request, null, XSSAPI.class, this.annotatedElement, null);
  assertSame(this.xssApi, result);
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:6,代码来源:AemObjectInjectorRequestTest.java


示例7: testXssApi

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Test
public void testXssApi() {
  Object result = this.injector.getValue(this.resource, null, XSSAPI.class, this.annotatedElement, null);
  assertNull(result);
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:6,代码来源:AemObjectInjectorResourceTest.java


示例8: testXssApi

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Test
public void testXssApi() {
  Object result = this.injector.getValue(this.resourceResolver, null, XSSAPI.class, this.annotatedElement, null);
  assertNull(result);
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:6,代码来源:AemObjectInjectorResourceResolverTest.java


示例9: getXssApi

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
public XSSAPI getXssApi() {
    return xssApi;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:4,代码来源:AemObjectInjectorTest.java


示例10: getXssAPI

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
@Override
public XSSAPI getXssAPI() {
	return this.get(XSS_API, XSSAPI.class);
}
 
开发者ID:SixDimensions,项目名称:Component-Bindings-Provider,代码行数:5,代码来源:CQVariablesImpl.java


示例11: encodeForHTML

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Encode a string for HTML.
 * 
 * @param xssAPI the XSSAPI
 * @param source the source string
 * @return the encoded string
 */
@Function
public static CharSequence encodeForHTML(XSSAPI xssAPI, String source) {
    return xssAPI.encodeForHTML(source);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:12,代码来源:XSSFunctions.java


示例12: encodeForHTMLAttr

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Encode a string for an HTML attribute.
 * 
 * @param xssAPI the XSSAPI
 * @param source the source string
 * @return the encoded string
 */
@Function
public static CharSequence encodeForHTMLAttr(XSSAPI xssAPI, String source) {
    return xssAPI.encodeForHTMLAttr(source);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:12,代码来源:XSSFunctions.java


示例13: encodeForJSString

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Encode a string for an JavaScript string.
 * 
 * @param xssAPI the XSSAPI
 * @param source the source string
 * @return the encoded string
 */
@Function
public static CharSequence encodeForJSString(XSSAPI xssAPI, String source) {
    return xssAPI.encodeForJSString(source);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:12,代码来源:XSSFunctions.java


示例14: filterHTML

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Filter a string for HTML.
 * 
 * @param xssAPI the XSSAPI
 * @param source the source string
 * @return the encoded string
 */
@Function
public static CharSequence filterHTML(XSSAPI xssAPI, String source) {
    return xssAPI.filterHTML(source);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:12,代码来源:XSSFunctions.java


示例15: getValidHref

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Get a valid href. This does not use the standard XSS API due to a bug
 * impacting CQ 5.6.1 (and earlier). Internal bug reference: GRANITE-4193
 * 
 * @param xssAPI the XSSAPI
 * @param source the source string
 * @return the encoded string
 */
@Function
public static CharSequence getValidHref(XSSAPI xssAPI, String source) {
    return xssAPI.getValidHref(source);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:13,代码来源:XSSFunctions.java


示例16: getValidDimension

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Validate a string which should contain a dimension, returning a default value if the source is
 * empty, can't be parsed, or contains XSS risks.  Allows integer dimensions and the keyword "auto".
 *
 * @param xssAPI the XSSAPI
 * @param dimension the source dimension
 * @param defaultValue a default value if the source can't be used
 * @return a sanitized dimension
 */
@Function
public static String getValidDimension(XSSAPI xssAPI, String dimension, String defaultValue) {
    return xssAPI.getValidDimension(dimension, defaultValue);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:XSSFunctions.java


示例17: getValidInteger

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Validate a string which should contain an integer, returning a default value if the source is
 * empty, can't be parsed, or contains XSS risks.
 *
 * @param xssAPI the XSSAPI
 * @param integer the source integer
 * @param defaultValue a default value if the source can't be used
 * @return a sanitized integer
 */
@Function
public static Integer getValidInteger(XSSAPI xssAPI, String integer, int defaultValue) {
    return xssAPI.getValidInteger(integer, defaultValue);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:XSSFunctions.java


示例18: getValidJSToken

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Validate a Javascript token.  The value must be either a single identifier, a literal number,
 * or a literal string.
 *
 * @param xssAPI the XSSAPI
 * @param token the source token
 * @param defaultValue a default value to use if the source doesn't meet validity constraints.
 * @return a string containing a single identifier, a literal number, or a literal string token
 */
@Function
public static String getValidJSToken(XSSAPI xssAPI, String token, String defaultValue) {
    return xssAPI.getValidJSToken(token, defaultValue);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:14,代码来源:XSSFunctions.java


示例19: getXssAPI

import com.adobe.granite.xss.XSSAPI; //导入依赖的package包/类
/**
 * Returns the XSS API for the current request.
 * 
 * @return the XSS API instance
 */
XSSAPI getXssAPI();
 
开发者ID:SixDimensions,项目名称:Component-Bindings-Provider,代码行数:7,代码来源:CQVariables.java



注:本文中的com.adobe.granite.xss.XSSAPI类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PersistenceHelper类代码示例发布时间:2022-05-22
下一篇:
Java KeyColumnValueStoreManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap