org.eclipse.jgit.util.Base64.encodeBytes()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(103)

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

Base64.encodeBytes介绍

[英]Encodes a byte array into Base64 notation.
[中]将字节数组编码为Base64表示法。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Encodes a byte array into Base64 notation.
 *
 * @param source
 *            The data to convert
 * @return encoded base64 representation of source.
 */
public static String encodeBytes(byte[] source) {
  return encodeBytes(source, 0, source.length);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

Digest(String hdr) {
  super(Type.DIGEST);
  params = parse(hdr);
  final String qop = params.get("qop"); //$NON-NLS-1$
  if ("auth".equals(qop)) { //$NON-NLS-1$
    final byte[] bin = new byte[8];
    PRNG.nextBytes(bin);
    params.put("cnonce", Base64.encodeBytes(bin)); //$NON-NLS-1$
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Override
  void configureRequest(HttpConnection conn) throws IOException {
    String ident = user + ":" + pass; //$NON-NLS-1$
    String enc = Base64.encodeBytes(ident.getBytes(UTF_8));
    conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
        + " " + enc); //$NON-NLS-1$
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

final Mac m = Mac.getInstance(HMAC);
  m.init(privateKey);
  sec = Base64.encodeBytes(m.doFinal(s.toString().getBytes(UTF_8)));
} catch (NoSuchAlgorithmException e) {
  throw new IOException(MessageFormat.format(JGitText.get().noHMACsupport, HMAC, e.getMessage()));

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Override
OutputStream encrypt(OutputStream output) throws IOException {
  try {
    Cipher cipher = InsecureCipherFactory.create(cipherAlgo);
    cipher.init(Cipher.ENCRYPT_MODE, secretKey);
    AlgorithmParameters params = cipher.getParameters();
    if (params == null) {
      context = EMPTY;
    } else {
      context = Base64.encodeBytes(params.getEncoded());
    }
    return new CipherOutputStream(output, cipher);
  } catch (Exception e) {
    throw error(e);
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

final String md5str = Base64.encodeBytes(newMD5().digest(data));
final String lenstr = String.valueOf(data.length);
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Override
  void configureRequest(HttpConnection conn) throws IOException {
    GSSManager gssManager = GSS_MANAGER_FACTORY.newInstance(conn
        .getURL());
    String host = conn.getURL().getHost();
    String peerName = "HTTP@" + host.toLowerCase(Locale.ROOT); //$NON-NLS-1$
    try {
      GSSName gssName = gssManager.createName(peerName,
          GSSName.NT_HOSTBASED_SERVICE);
      GSSContext context = gssManager.createContext(gssName, OID,
          null, GSSContext.DEFAULT_LIFETIME);
      // Respect delegation policy in HTTP/SPNEGO.
      context.requestCredDeleg(true);
      byte[] token = context.initSecContext(prevToken, 0,
          prevToken.length);
      conn.setRequestProperty(HDR_AUTHORIZATION, getType().getSchemeName()
          + " " + Base64.encodeBytes(token)); //$NON-NLS-1$
    } catch (GSSException e) {
      throw new IOException(e);
    }
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

monitorTask = MessageFormat.format(JGitText.get().progressMonUploading, key);
final String md5str = Base64.encodeBytes(csum);
final long len = buf.length();
for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Encodes a byte array into Base64 notation.
 *
 * @param source
 *            The data to convert
 * @return encoded base64 representation of source.
 */
public static String encodeBytes(byte[] source) {
  return encodeBytes(source, 0, source.length);
}

代码示例来源:origin: berlam/github-bucket

/**
 * Encodes a byte array into Base64 notation.
 *
 * @param source
 *            The data to convert
 * @return encoded base64 representation of source.
 */
public static String encodeBytes(byte[] source) {
  return encodeBytes(source, 0, source.length);
}

代码示例来源:origin: com.heroku.sdk/heroku-deploy

private String encodeApiKey(String apiKey) throws IOException {
  return Base64.encodeBytes((":" + apiKey).getBytes());
 }
}

代码示例来源:origin: heroku/heroku-maven-plugin

private String encodeApiKey(String apiKey) throws IOException {
  return Base64.encodeBytes((":" + apiKey).getBytes());
 }
}

代码示例来源:origin: berlam/github-bucket

Digest(String hdr) {
  super(Type.DIGEST);
  params = parse(hdr);
  final String qop = params.get("qop"); //$NON-NLS-1$
  if ("auth".equals(qop)) { //$NON-NLS-1$
    final byte[] bin = new byte[8];
    PRNG.nextBytes(bin);
    params.put("cnonce", Base64.encodeBytes(bin)); //$NON-NLS-1$
  }
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

Digest(String hdr) {
  super(Type.DIGEST);
  params = parse(hdr);
  final String qop = params.get("qop"); //$NON-NLS-1$
  if ("auth".equals(qop)) { //$NON-NLS-1$
    final byte[] bin = new byte[8];
    PRNG.nextBytes(bin);
    params.put("cnonce", Base64.encodeBytes(bin)); //$NON-NLS-1$
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit.ssh.apache

@Override
public String getToken() throws Exception {
  return getName() + ' ' + Base64.encodeBytes(token);
}

代码示例来源:origin: com.meltmedia.cadmium/cadmium-core

private static void setupBasicAuth(String username, String password, HttpMessage message) {
 message.addHeader("Authorization", "Basic "+Base64.encodeBytes(new String(username+":"+password).getBytes()));
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

@Override
  void configureRequest(final HttpConnection conn) throws IOException {
    String ident = user + ":" + pass; //$NON-NLS-1$
    String enc = Base64.encodeBytes(ident.getBytes("UTF-8")); //$NON-NLS-1$
    conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
        + " " + enc); //$NON-NLS-1$
  }
}

代码示例来源:origin: berlam/github-bucket

@Override
  void configureRequest(HttpConnection conn) throws IOException {
    String ident = user + ":" + pass; //$NON-NLS-1$
    String enc = Base64.encodeBytes(ident.getBytes(UTF_8));
    conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
        + " " + enc); //$NON-NLS-1$
  }
}

代码示例来源:origin: jenkinsci/bitbucket-build-status-notifier-plugin

private String getHttpBasicAuthHeaderValue() {
  String authStr = config.getApiKey() + ":" + config.getApiSecret();
  return "Basic " + Base64.encodeBytes(authStr.getBytes());
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

@Override
OutputStream encrypt(OutputStream output) throws IOException {
  try {
    Cipher cipher = Cipher.getInstance(cipherAlgo);
    cipher.init(Cipher.ENCRYPT_MODE, secretKey);
    AlgorithmParameters params = cipher.getParameters();
    if (params == null) {
      context = EMPTY;
    } else {
      context = Base64.encodeBytes(params.getEncoded());
    }
    return new CipherOutputStream(output, cipher);
  } catch (Exception e) {
    throw error(e);
  }
}

相关文章

微信公众号

最新文章

更多