org.restlet.data.Reference.normalize()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.restlet.data.Reference.normalize方法的一些代码示例,展示了Reference.normalize的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.normalize方法的具体详情如下:
包路径:org.restlet.data.Reference
类名称:Reference
方法名:normalize

Reference.normalize介绍

[英]Normalizes the reference. Useful before comparison between references or when building a target reference from a base and a relative references.
[中]规范化引用。在比较引用之前,或从基引用和相对引用构建目标引用时,非常有用。

代码示例

代码示例来源:origin: com.noelios.restlet/com.noelios.restlet.ext.servlet

result.normalize();

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Prevent the client from accessing resources in upper directories
 */
public void preventUpperDirectoryAccess() {
  String targetUriPath = new Reference(Reference.decode(targetUri))
      .normalize()
      .toString();
  if (!targetUriPath.startsWith(directory.getRootRef().toString())) {
    throw new ResourceException(Status.CLIENT_ERROR_FORBIDDEN);
  }
}

代码示例来源:origin: apache/attic-polygene-java

public synchronized ContextResourceClient newClient( String relativePath )
{
  if( relativePath.startsWith( "http://" ) )
  {
    return contextResourceFactory.newClient( new Reference( relativePath ) );
  }
  Reference reference = this.reference.clone();
  if( relativePath.startsWith( "/" ) )
  {
    reference.setPath( relativePath );
  }
  else
  {
    reference.setPath( reference.getPath() + relativePath );
    reference = reference.normalize();
  }
  return contextResourceFactory.newClient( reference );
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Handles a call. Note that this implementation will systematically
 * normalize and URI-decode the resource reference.
 * 
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 */
@Override
public final void handle(Request request, Response response) {
  // Ensure that all ".." and "." are normalized into the path
  // to prevent unauthorized access to user directories.
  request.getResourceRef().normalize();
  // As the path may be percent-encoded, it has to be percent-decoded.
  // Then, all generated URIs must be encoded.
  String path = request.getResourceRef().getPath();
  String decodedPath = Reference.decode(path);
  if (decodedPath != null) {
    // Continue the local handling
    handleLocal(request, response, decodedPath);
  } else {
    getLogger().warning(
        "Unable to get the path of this local URI: "
            + request.getResourceRef());
  }
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

result.normalize();

代码示例来源:origin: org.restlet/org.restlet

result.normalize();

代码示例来源:origin: org.restlet.osgi/org.restlet

result.normalize();

代码示例来源:origin: org.restlet.osgi/org.restlet

.normalize()
    .toString(false, false);
if (!this.targetUri.startsWith(directory.getRootRef().toString())) {

相关文章

Reference类方法