Package org.springframework.web.util

Examples of org.springframework.web.util.UriComponents$FullPathComponent


  public String getIdentifier(UserInfo userInfo, ClientDetailsEntity client) {

    String sectorIdentifier = null;

    if (!Strings.isNullOrEmpty(client.getSectorIdentifierUri())) {
      UriComponents uri = UriComponentsBuilder.fromUriString(client.getSectorIdentifierUri()).build();
      sectorIdentifier = uri.getHost(); // calculate based on the host component only
    } else {
      Set<String> redirectUris = client.getRedirectUris();
      UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build();
      sectorIdentifier = uri.getHost(); // calculate based on the host of the only redirect URI
    }

    if (sectorIdentifier != null) {
      // if there's a sector identifier, use that for the lookup
      PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier);
View Full Code Here


    targetUrl = updateTargetUrl(targetUrl, model, request, response);
   
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    if (!CollectionUtils.isEmpty(flashMap)) {
      UriComponents uriComponents = UriComponentsBuilder.fromUriString(targetUrl).build();
      flashMap.setTargetRequestPath(uriComponents.getPath());
      flashMap.addTargetRequestParams(uriComponents.getQueryParams());
    }
   
    sendRedirect(request, response, targetUrl.toString(), this.http10Compatible);
  }
View Full Code Here

    String targetUrl = createTargetUrl(model, request);
    targetUrl = updateTargetUrl(targetUrl, model, request, response);
   
    FlashMap flashMap = RequestContextUtils.getOutputFlashMap(request);
    if (!CollectionUtils.isEmpty(flashMap)) {
      UriComponents uriComponents = UriComponentsBuilder.fromUriString(targetUrl).build();
      flashMap.setTargetRequestPath(uriComponents.getPath());
      flashMap.addTargetRequestParams(uriComponents.getQueryParams());
    }

    FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request);
    flashMapManager.saveOutputFlashMap(flashMap, request, response);
View Full Code Here

        ChannelFuture writeFuture = ctx.write(new ChunkedStream(contentStream));
        writeFuture.addListener(ChannelFutureListener.CLOSE);
    }

  private MockHttpServletRequest createServletRequest(HttpRequest httpRequest) {
        UriComponents uriComponents = UriComponentsBuilder.fromUriString(httpRequest.getUri()).build();

    MockHttpServletRequest servletRequest = new MockHttpServletRequest(this.servletContext);
    servletRequest.setRequestURI(uriComponents.getPath());
    servletRequest.setPathInfo(uriComponents.getPath());
    servletRequest.setMethod(httpRequest.getMethod().getName());

    if (uriComponents.getScheme() != null) {
      servletRequest.setScheme(uriComponents.getScheme());
    }
    if (uriComponents.getHost() != null) {
      servletRequest.setServerName(uriComponents.getHost());
    }
    if (uriComponents.getPort() != -1) {
      servletRequest.setServerPort(uriComponents.getPort());
    }

    for (String name : httpRequest.getHeaderNames()) {
      for (String value : httpRequest.getHeaders(name)) {
        servletRequest.addHeader(name, value);
      }
    }

    servletRequest.setContent(httpRequest.getContent().array());

    try {
      if (uriComponents.getQuery() != null) {
        String query = UriUtils.decode(uriComponents.getQuery(), "UTF-8");
        servletRequest.setQueryString(query);
      }

      for (Entry<String, List<String>> entry : uriComponents.getQueryParams().entrySet()) {
        for (String value : entry.getValue()) {
          servletRequest.addParameter(
              UriUtils.decode(entry.getKey(), "UTF-8"),
              UriUtils.decode(value, "UTF-8"));
        }
View Full Code Here

    String uri = super.getResourceURL(context, path);
    int facesResourceIndex = (uri == null ? -1 : uri.indexOf(FACES_RESOURCE));
    if (facesResourceIndex == -1) {
      return uri;
    }
    UriComponents components = UriComponentsBuilder.fromUriString(uri.substring(facesResourceIndex + FACES_RESOURCE.length() + 1)).build();
    MimeResponse response = (MimeResponse) context.getExternalContext().getResponse();
    ResourceURL resourceURL = response.createResourceURL();
    for (Map.Entry<String, List<String>> entry : components.getQueryParams().entrySet()) {
      String name = entry.getKey();
      List<String> value = entry.getValue();
      resourceURL.setParameter(name, value.toArray(new String[value.size()]));
    }
    resourceURL.setParameter(FACES_RESOURCE, components.getPath());
    return resourceURL.toString();
  }
View Full Code Here

        // doesn't match the pattern, throw it out
        logger.warn("Parser couldn't match input: " + identifier);
        return null;
      }

      UriComponents n = builder.build();

      if (Strings.isNullOrEmpty(n.getScheme())) {
        if (!Strings.isNullOrEmpty(n.getUserInfo())
            && Strings.isNullOrEmpty(n.getPath())
            && Strings.isNullOrEmpty(n.getQuery())
            && n.getPort() < 0) {

          // scheme empty, userinfo is not empty, path/query/port are empty
          // set to "acct" (rule 2)
          builder.scheme("acct");
View Full Code Here

  @Test
  public void normalizeResource_novTest() {
    for (String input : inputToNormalized.keySet()) {

      UriComponents actualNormalized = WebfingerURLNormalizer.normalizeResource(input);

      String expectedNormalized = inputToNormalized.get(input);

      assertEquals("Identifer/Normalized failed.", expectedNormalized, WebfingerURLNormalizer.serializeURL(actualNormalized));
    }
View Full Code Here

    FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request);
    if (flashMapManager == null) {
      return;
    }

    UriComponents uriComponents = UriComponentsBuilder.fromUriString(location).build();
    FlashMap flashMap = new FlashMap();
    flashMap.setTargetRequestPath(uriComponents.getPath());
    flashMap.addTargetRequestParams(uriComponents.getQueryParams());
    flashMap.putAll(output.asMap());
    flashMapManager.saveOutputFlashMap(flashMap, request, response);
  }
View Full Code Here

    String queryString = request.getQueryString();
    boolean legalSpaces = queryString != null && queryString.contains("+");
    if (legalSpaces) {
      builder.replaceQuery(queryString.replace("+", "%20"));
    }
    UriComponents uri = null;
        try {
        uri = builder.replaceQueryParam("code").build(true);
        } catch (IllegalArgumentException ex) {
            // ignore failures to parse the url (including query string). does't make sense
            // for redirection purposes anyway.
            return null;
        }
    String query = uri.getQuery();
    if (legalSpaces) {
      query = query.replace("%20", "+");
    }
    return ServletUriComponentsBuilder.fromUri(uri.toUri()).replaceQuery(query).build().toString();
  }
View Full Code Here

     * @return a UriComponentsBuilder instance
     */
    public static UriComponentsBuilder fromMethod(Method method, Object... argumentValues) {

        UriComponentsBuilder builder = ServletUriComponentsBuilder.newInstance().path(getMethodRequestMapping(method));
        UriComponents uriComponents = applyContributors(builder, method, argumentValues);

        String typePath = getTypeRequestMapping(method.getDeclaringClass());
        String methodPath = uriComponents.getPath();
        String path = pathMatcher.combine(typePath, methodPath);

        return ServletUriComponentsBuilder.fromCurrentServletMapping().path(
                path).queryParams(uriComponents.getQueryParams());
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.util.UriComponents$FullPathComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.