net.oauth.OAuth.percentEncode()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(140)

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

OAuth.percentEncode介绍

[英]Construct a &-separated list of the given values, percentEncoded.
[中]构建一个以&-分隔的给定值列表,百分比编码。

代码示例

代码示例来源:origin: org.apache.shindig/shindig-gadgets

static String getAuthorizationHeader(List<Map.Entry<String, String>> oauthParams) {
 StringBuilder result = new StringBuilder("OAuth ");
 boolean first = true;
 for (Map.Entry<String, String> parameter : oauthParams) {
  if (!first) {
   result.append(", ");
  } else {
   first = false;
  }
  result.append(OAuth.percentEncode(parameter.getKey()))
     .append("=\"")
     .append(OAuth.percentEncode(parameter.getValue()))
     .append('"');
 }
 return result.toString();
}

代码示例来源:origin: org.gatein.shindig/shindig-gadgets

static String getAuthorizationHeader(List<Map.Entry<String, String>> oauthParams) {
 StringBuilder result = new StringBuilder("OAuth ");
 boolean first = true;
 for (Map.Entry<String, String> parameter : oauthParams) {
  if (!first) {
   result.append(", ");
  } else {
   first = false;
  }
  result.append(OAuth.percentEncode(parameter.getKey()))
     .append("=\"")
     .append(OAuth.percentEncode(parameter.getValue()))
     .append('"');
 }
 return result.toString();
}

代码示例来源:origin: net.oauth.core/oauth

/** Construct a &-separated list of the given values, percentEncoded. */
public static String percentEncode(Iterable values) {
  StringBuilder p = new StringBuilder();
  for (Object v : values) {
    if (p.length() > 0) {
      p.append("&");
    }
    p.append(OAuth.percentEncode(toString(v)));
  }
  return p.toString();
}

代码示例来源:origin: net.oauth.core/oauth

private synchronized String getSignature() {
  if (signature == null) {
    signature = OAuth.percentEncode(getConsumerSecret()) + '&'
        + OAuth.percentEncode(getTokenSecret());
  }
  return signature;
}

代码示例来源:origin: sakaiproject/sakai

@SuppressWarnings("rawtypes")
ComparableParameter(Map.Entry value) {
  this.value = value;
  String n = toString(value.getKey());
  String v = toString(value.getValue());
  this.key = OAuth.percentEncode(n) + ' ' + OAuth.percentEncode(v);
  // ' ' is used because it comes before any character
  // that can appear in a percentEncoded string.
}

代码示例来源:origin: sakaiproject/sakai

private synchronized String getSignature() {
  if (signature == null) {
    signature = OAuth.percentEncode(getConsumerSecret()) + '&'
        + OAuth.percentEncode(getTokenSecret());
  }
  return signature;
}

代码示例来源:origin: sakaiproject/sakai

/** Construct a &-separated list of the given values, percentEncoded. */
public static String percentEncode(Iterable<?> values) {
  StringBuilder p = new StringBuilder();
  for (Object v : values) {
    if (p.length() > 0) {
      p.append("&");
    }
    p.append(OAuth.percentEncode(toString(v)));
  }
  return p.toString();
}

代码示例来源:origin: net.oauth.core/oauth

@Override
public String toString() {
  return percentEncode(getKey()) + '=' + percentEncode(getValue());
}

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

static String getAuthorizationHeader(List<Map.Entry<String, String>> oauthParams) {
 StringBuilder result = new StringBuilder("OAuth ");
 boolean first = true;
 for (Map.Entry<String, String> parameter : oauthParams) {
  if (!first) {
   result.append(", ");
  } else {
   first = false;
  }
  result.append(OAuth.percentEncode(parameter.getKey()))
     .append("=\"")
     .append(OAuth.percentEncode(parameter.getValue()))
     .append('"');
 }
 return result.toString();
}

代码示例来源:origin: sakaiproject/sakai

@Override
public String toString() {
  return percentEncode(getKey()) + '=' + percentEncode(getValue());
}

代码示例来源:origin: net.oauth.core/oauth

ComparableParameter(Map.Entry value) {
  this.value = value;
  String n = toString(value.getKey());
  String v = toString(value.getValue());
  this.key = OAuth.percentEncode(n) + ' ' + OAuth.percentEncode(v);
  // ' ' is used because it comes before any character
  // that can appear in a percentEncoded string.
}

代码示例来源:origin: net.oauth.core/oauth

private byte[] computeSignature(String baseString)
    throws GeneralSecurityException, UnsupportedEncodingException {
  SecretKey key = null;
  synchronized (this) {
    if (this.key == null) {
      String keyString = OAuth.percentEncode(getConsumerSecret())
          + '&' + OAuth.percentEncode(getTokenSecret());
      byte[] keyBytes = keyString.getBytes(ENCODING);
      this.key = new SecretKeySpec(keyBytes, MAC_NAME);
    }
    key = this.key;
  }
  Mac mac = Mac.getInstance(MAC_NAME);
  mac.init(key);
  byte[] text = baseString.getBytes(ENCODING);
  return mac.doFinal(text);
}

代码示例来源:origin: sakaiproject/sakai

private byte[] computeSignature(String baseString)
    throws GeneralSecurityException, UnsupportedEncodingException {
  SecretKey key = null;
  synchronized (this) {
    if (this.key == null) {
      String keyString = OAuth.percentEncode(getConsumerSecret())
          + '&' + OAuth.percentEncode(getTokenSecret());
      byte[] keyBytes = keyString.getBytes(ENCODING);
      this.key = new SecretKeySpec(keyBytes, MAC_NAME);
    }
    key = this.key;
  }
  Mac mac = Mac.getInstance(MAC_NAME);
  mac.init(key);
  byte[] text = baseString.getBytes(ENCODING);
  return mac.doFinal(text);
}

代码示例来源:origin: sakaiproject/sakai

private byte[] computeSignature(String baseString)
    throws GeneralSecurityException, UnsupportedEncodingException {
  SecretKey key = null;
  synchronized (this) {
    if (this.key == null) {
      String keyString = OAuth.percentEncode(getConsumerSecret())
          + '&' + OAuth.percentEncode(getTokenSecret());
      byte[] keyBytes = keyString.getBytes(ENCODING);
      this.key = new SecretKeySpec(keyBytes, MAC_NAME);
    }
    key = this.key;
  }
  Mac mac = Mac.getInstance(MAC_NAME);
  mac.init(key);
  byte[] text = baseString.getBytes(ENCODING);
  return mac.doFinal(text);
}

代码示例来源:origin: apache/cxf

private static String doGetAuthorizationHeader(OAuthAccessor accessor,
    String method, String requestURI, Map<String, String> parameters) {
  try {
    OAuthMessage msg = accessor.newRequestMessage(method, requestURI, parameters.entrySet());
    StringBuilder sb = new StringBuilder();
    sb.append(msg.getAuthorizationHeader(null));
    for (Map.Entry<String, String> entry : parameters.entrySet()) {
      if (!entry.getKey().startsWith("oauth_")) {
        sb.append(", ");
        sb.append(OAuth.percentEncode(entry.getKey())).append("=\"");
        sb.append(OAuth.percentEncode(entry.getValue())).append('"');
      }
    }
    return sb.toString();
  } catch (Exception ex) {
    throw new ProcessingException(ex);
  }
}

代码示例来源:origin: net.oauth.core/oauth

public static String getBaseString(OAuthMessage message)
    throws IOException, URISyntaxException {
  List<Map.Entry<String, String>> parameters;
  String url = message.URL;
  int q = url.indexOf('?');
  if (q < 0) {
    parameters = message.getParameters();
  } else {
    // Combine the URL query string with the other parameters:
    parameters = new ArrayList<Map.Entry<String, String>>();
    parameters.addAll(OAuth.decodeForm(message.URL.substring(q + 1)));
    parameters.addAll(message.getParameters());
    url = url.substring(0, q);
  }
  return OAuth.percentEncode(message.method.toUpperCase()) + '&'
      + OAuth.percentEncode(normalizeUrl(url)) + '&'
      + OAuth.percentEncode(normalizeParameters(parameters));
}

代码示例来源:origin: sakaiproject/sakai

public static String getBaseString(OAuthMessage message)
    throws IOException, URISyntaxException {
  List<Map.Entry<String, String>> parameters;
  String url = message.URL;
  int q = url.indexOf('?');
  if (q < 0) {
    parameters = message.getParameters();
  } else {
    // Combine the URL query string with the other parameters:
    parameters = new ArrayList<Map.Entry<String, String>>();
    parameters.addAll(OAuth.decodeForm(message.URL.substring(q + 1)));
    parameters.addAll(message.getParameters());
    url = url.substring(0, q);
  }
  return OAuth.percentEncode(message.method.toUpperCase()) + '&'
      + OAuth.percentEncode(normalizeUrl(url)) + '&'
      + OAuth.percentEncode(normalizeParameters(parameters));
}

代码示例来源:origin: org.apache.shindig/shindig-social-api

private static String getAuthorizationHeader(List<Map.Entry<String, String>> oauthParams) {
 StringBuilder result = new StringBuilder("OAuth ");
 boolean first = true;
 for (Map.Entry<String, String> parameter : oauthParams) {
  if (!first) {
   result.append(", ");
  } else {
   first = false;
  }
  result.append(OAuth.percentEncode(parameter.getKey()))
    .append("=\"")
    .append(OAuth.percentEncode(parameter.getValue()))
    .append('"');
 }
 return result.toString();
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-social-api

private static String getAuthorizationHeader(List<Map.Entry<String, String>> oauthParams) {
 StringBuilder result = new StringBuilder("OAuth ");
 boolean first = true;
 for (Map.Entry<String, String> parameter : oauthParams) {
  if (!first) {
   result.append(", ");
  } else {
   first = false;
  }
  result.append(OAuth.percentEncode(parameter.getKey()))
    .append("=\"")
    .append(OAuth.percentEncode(parameter.getValue()))
    .append('"');
 }
 return result.toString();
}

代码示例来源:origin: com.lmco.shindig/shindig-social-api

private static String getAuthorizationHeader(List<Map.Entry<String, String>> oauthParams) {
 StringBuilder result = new StringBuilder("OAuth ");
 boolean first = true;
 for (Map.Entry<String, String> parameter : oauthParams) {
  if (!first) {
   result.append(", ");
  } else {
   first = false;
  }
  result.append(OAuth.percentEncode(parameter.getKey()))
    .append("=\"")
    .append(OAuth.percentEncode(parameter.getValue()))
    .append('"');
 }
 return result.toString();
}

相关文章