コード例 #1
0
 public IRequestHandler mapRequest(final Request request) {
   final Url url = this.decryptUrl(request, request.getUrl());
   if (url == null) {
     return this.wrappedMapper.mapRequest(request);
   }
   return this.wrappedMapper.mapRequest(request.cloneWithUrl(url));
 }
コード例 #2
0
ファイル: SortableList.java プロジェクト: emorency/onyx
 @Override
 protected void respond(AjaxRequestTarget target) {
   Request request = RequestCycle.get().getRequest();
   String items = request.getParameter("items");
   @SuppressWarnings("unchecked")
   List<T> modelList = (List<T>) SortableList.this.getDefaultModelObject();
   modelList.clear();
   for (String markupId : StringUtils.commaDelimitedListToStringArray(items)) {
     if (org.apache.commons.lang.StringUtils.isNotBlank(markupId))
       modelList.add(itemByMarkupId.get(markupId));
   }
 }
コード例 #3
0
 /**
  * Cache the requested protected resource pending successful authentication.
  *
  * @param pageClass
  */
 public void cacheRequest(Class<? extends Page> pageClass) {
   // build absolute url with correctly encoded parameters?!
   Request req = WebRequestCycle.get().getRequest();
   Map<String, ?> params = req.getRequestParameters().getParameters();
   PageParameters pageParams = new PageParameters(params);
   String relativeUrl = WebRequestCycle.get().urlFor(pageClass, pageParams).toString();
   requestUrl = RequestUtils.toAbsolutePath(relativeUrl);
   if (isTemporary()) {
     // we must bind the temporary session into the session store
     // so that we can re-use this session for reporting an error message
     // on the redirected page and continuing the request after
     // authentication.
     bind();
   }
 }
コード例 #4
0
 private Url decryptUrl(final Request request, final Url encryptedUrl) {
   if (encryptedUrl.getSegments().isEmpty()) {
     return encryptedUrl;
   }
   final List<String> encryptedSegments = (List<String>) encryptedUrl.getSegments();
   if (encryptedSegments.size() < 1) {
     return null;
   }
   Url url = new Url(request.getCharset());
   try {
     final String encryptedUrlString = (String) encryptedSegments.get(0);
     if (Strings.isEmpty((CharSequence) encryptedUrlString)) {
       return null;
     }
     final String decryptedUrl = this.getCrypt().decryptUrlSafe(encryptedUrlString);
     if (decryptedUrl == null) {
       return null;
     }
     final Url originalUrl = Url.parse(decryptedUrl, request.getCharset());
     final int originalNumberOfSegments = originalUrl.getSegments().size();
     final int encryptedNumberOfSegments = encryptedUrl.getSegments().size();
     final HashedSegmentGenerator generator = new HashedSegmentGenerator(encryptedUrlString);
     int segNo;
     for (segNo = 1; segNo < encryptedNumberOfSegments; ++segNo) {
       if (segNo > originalNumberOfSegments) {
         break;
       }
       final String next = generator.next();
       final String encryptedSegment = (String) encryptedSegments.get(segNo);
       if (!next.equals(encryptedSegment)) {
         break;
       }
       url.getSegments().add(originalUrl.getSegments().get(segNo - 1));
     }
     while (segNo < encryptedNumberOfSegments) {
       url.getSegments().add(encryptedUrl.getSegments().get(segNo));
       ++segNo;
     }
     url.getQueryParameters().addAll(originalUrl.getQueryParameters());
   } catch (Exception e) {
     CryptoMapper.log.error("Error decrypting URL", e);
     url = null;
   }
   return url;
 }