当前位置: 首页>>代码示例>>Java>>正文


Java XSSAPI类代码示例

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


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


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