当前位置: 首页>>代码示例>>Java>>正文


Java Base64.encode方法代码示例

本文整理汇总了Java中com.squareup.okhttp.internal.Base64.encode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.encode方法的具体用法?Java Base64.encode怎么用?Java Base64.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.okhttp.internal.Base64的用法示例。


在下文中一共展示了Base64.encode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeCertArray

import com.squareup.okhttp.internal.Base64; //导入方法依赖的package包/类
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:17,代码来源:HttpResponseCache.java

示例2: writeCertArray

import com.squareup.okhttp.internal.Base64; //导入方法依赖的package包/类
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e);
  }
}
 
开发者ID:nadavelyashiv,项目名称:metal-finder-new,代码行数:17,代码来源:HttpResponseCache.java

示例3: basic

import com.squareup.okhttp.internal.Base64; //导入方法依赖的package包/类
/** Returns an auth credential for the Basic scheme. */
public static Credential basic(String userName, String password) {
  try {
    String usernameAndPassword = userName + ":" + password;
    byte[] bytes = usernameAndPassword.getBytes("ISO-8859-1");
    String encoded = Base64.encode(bytes);
    return new Credential("Basic " + encoded);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError();
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:12,代码来源:OkAuthenticator.java

示例4: getCredentials

import com.squareup.okhttp.internal.Base64; //导入方法依赖的package包/类
/**
 * Returns the authorization credentials that may satisfy the challenge.
 * Returns null if a challenge header was not provided or if credentials
 * were not available.
 */
private static String getCredentials(RawHeaders responseHeaders, String challengeHeader,
    Proxy proxy, URL url) throws IOException {
  List<Challenge> challenges = parseChallenges(responseHeaders, challengeHeader);
  if (challenges.isEmpty()) {
    return null;
  }

  for (Challenge challenge : challenges) {
    // Use the global authenticator to get the password.
    PasswordAuthentication auth;
    if (responseHeaders.getResponseCode() == HTTP_PROXY_AUTH) {
      InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
      auth = Authenticator.requestPasswordAuthentication(proxyAddress.getHostName(),
          getConnectToInetAddress(proxy, url), proxyAddress.getPort(), url.getProtocol(),
          challenge.realm, challenge.scheme, url, Authenticator.RequestorType.PROXY);
    } else {
      auth = Authenticator.requestPasswordAuthentication(url.getHost(),
          getConnectToInetAddress(proxy, url), url.getPort(), url.getProtocol(), challenge.realm,
          challenge.scheme, url, Authenticator.RequestorType.SERVER);
    }
    if (auth == null) {
      continue;
    }

    // Use base64 to encode the username and password.
    String usernameAndPassword = auth.getUserName() + ":" + new String(auth.getPassword());
    byte[] bytes = usernameAndPassword.getBytes("ISO-8859-1");
    String encoded = Base64.encode(bytes);
    return challenge.scheme + " " + encoded;
  }

  return null;
}
 
开发者ID:sinnwerkstatt,项目名称:economy-common-good-mobile,代码行数:39,代码来源:HttpAuthenticator.java


注:本文中的com.squareup.okhttp.internal.Base64.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。