Пример #1
0
 public static HttpRequestBase buildHeaders(
     HttpRequestBase httpRequestBase, Map<String, String> headers) {
   for (Entry<String, String> header : headers.entrySet()) {
     httpRequestBase.setHeader(header.getKey(), header.getValue());
   }
   return httpRequestBase;
 }
Пример #2
0
  public synchronized Enumeration<String> entryNames(JarFile jar, final CodeSource[] cs) {
    final Map map = signerMap();
    final Iterator itor = map.entrySet().iterator();
    boolean matchUnsigned = false;

    /*
     * Grab a single copy of the CodeSigner arrays. Check
     * to see if we can optimize CodeSigner equality test.
     */
    List req = new ArrayList(cs.length);
    for (int i = 0; i < cs.length; i++) {
      CodeSigner[] match = findMatchingSigners(cs[i]);
      if (match != null) {
        if (match.length > 0) {
          req.add(match);
        } else {
          matchUnsigned = true;
        }
      } else {
        matchUnsigned = true;
      }
    }

    final List signersReq = req;
    final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;

    return new Enumeration<String>() {

      String name;

      public boolean hasMoreElements() {
        if (name != null) {
          return true;
        }

        while (itor.hasNext()) {
          Map.Entry e = (Map.Entry) itor.next();
          if (signersReq.contains((CodeSigner[]) e.getValue())) {
            name = (String) e.getKey();
            return true;
          }
        }
        while (enum2.hasMoreElements()) {
          name = (String) enum2.nextElement();
          return true;
        }
        return false;
      }

      public String nextElement() {
        if (hasMoreElements()) {
          String value = name;
          name = null;
          return value;
        }
        throw new NoSuchElementException();
      }
    };
  }
Пример #3
0
 public static HttpRequestBase buildHeaders(
     HttpRequestBase httpRequestBase, Map<String, String> headers, HTTP_METHODS httpMethod) {
   Iterator<Entry<String, String>> iterator = headers.entrySet().iterator();
   while (iterator.hasNext()) {
     Entry<String, String> header = iterator.next();
     httpRequestBase.setHeader(header.getKey(), header.getValue());
   }
   return httpRequestBase;
 }
Пример #4
0
  public static String buildPayload(Map<String, String> params) {
    StringBuilder bodyBuilder = new StringBuilder();
    Iterator<Entry<String, String>> iterator = params.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<String, String> param = iterator.next();
      bodyBuilder.append(param.getKey()).append('=').append(param.getValue());
      if (iterator.hasNext()) {
        bodyBuilder.append('&');
      }
    }

    return bodyBuilder.toString();
  }