本文整理了Java中org.eclipse.jgit.util.Base64
类的一些代码示例,展示了Base64
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64
类的具体详情如下:
包路径:org.eclipse.jgit.util.Base64
类名称:Base64
[英]Encodes and decodes to and from Base64 notation.
I am placing this code in the Public Domain. Do with it as you will. This software comes with no guarantees or warranties but with plenty of well-wishing instead! Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.
[中]对Base64符号进行编码和解码。
我将此代码置于公共域中。你想怎么做就怎么做。这个软件没有任何保证或保证,但却有很多美好的愿望!请定期访问http://iharder.net/base64,检查更新或作出改进。
代码示例来源:origin: spring-cloud/spring-cloud-config
@Override
protected Session createSession(Host hc, String user, String host, int port, FS fs) throws JSchException {
if (sshKeysByHostname.containsKey(host)) {
JGitEnvironmentProperties sshUriProperties = sshKeysByHostname.get(host);
jSch.addIdentity(host, sshUriProperties.getPrivateKey().getBytes(), null, null);
if (sshUriProperties.getKnownHostsFile() != null) {
jSch.setKnownHosts(sshUriProperties.getKnownHostsFile());
}
if (sshUriProperties.getHostKey() != null) {
HostKey hostkey = new HostKey(host, Base64.decode(sshUriProperties.getHostKey()));
jSch.getHostKeyRepository().add(hostkey, null);
}
return jSch.getSession(user, host, port);
}
throw new JSchException("no keys configured for hostname " + host);
}
代码示例来源: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
b4[b4Posn++] = sbiCrop;
if (b4Posn > 3) {
outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn);
b4Posn = 0;
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Encodes a byte array into Base64 notation.
*
* @param source
* The data to convert
* @param off
* Offset in array where conversion should begin
* @param len
* Length of data to convert
* @return encoded base64 representation of source.
*/
public static String encodeBytes(byte[] source, int off, int len) {
final int len43 = len * 4 / 3;
byte[] outBuff = new byte[len43 + ((len % 3) > 0 ? 4 : 0)];
int d = 0;
int e = 0;
int len2 = len - 2;
for (; d < len2; d += 3, e += 4)
encode3to4(source, d + off, 3, outBuff, e);
if (d < len) {
encode3to4(source, d + off, len - d, outBuff, e);
e += 4;
}
return new String(outBuff, 0, e, UTF_8);
}
代码示例来源:origin: berlam/github-bucket
/**
* Encodes a byte array into Base64 notation.
*
* @param source
* The data to convert
* @param off
* Offset in array where conversion should begin
* @param len
* Length of data to convert
* @return encoded base64 representation of source.
*/
public static String encodeBytes(byte[] source, int off, int len) {
final int len43 = len * 4 / 3;
byte[] outBuff = new byte[len43 + ((len % 3) > 0 ? 4 : 0)];
int d = 0;
int e = 0;
int len2 = len - 2;
for (; d < len2; d += 3, e += 4)
encode3to4(source, d + off, 3, outBuff, e);
if (d < len) {
encode3to4(source, d + off, len - d, outBuff, e);
e += 4;
}
return new String(outBuff, 0, e, UTF_8);
}
代码示例来源: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
public Negotiate(String hdr) {
super(Type.NEGOTIATE);
prevToken = Base64.decode(hdr);
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
/**
* Encodes a byte array into Base64 notation.
*
* @param source
* The data to convert
* @param off
* Offset in array where conversion should begin
* @param len
* Length of data to convert
* @return encoded base64 representation of source.
*/
public static String encodeBytes(byte[] source, int off, int len) {
final int len43 = len * 4 / 3;
byte[] outBuff = new byte[len43 + ((len % 3) > 0 ? 4 : 0)];
int d = 0;
int e = 0;
int len2 = len - 2;
for (; d < len2; d += 3, e += 4)
encode3to4(source, d + off, 3, outBuff, e);
if (d < len) {
encode3to4(source, d + off, len - d, outBuff, e);
e += 4;
}
try {
return new String(outBuff, 0, e, UTF_8);
} catch (UnsupportedEncodingException uue) {
return new String(outBuff, 0, e);
}
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
b4[b4Posn++] = sbiCrop;
if (b4Posn > 3) {
outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn);
b4Posn = 0;
代码示例来源: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
/**
* Decodes data from Base64 notation.
*
* @param s
* the string to decode
* @return the decoded data
*/
public static byte[] decode(String s) {
byte[] bytes = s.getBytes(UTF_8);
return decode(bytes, 0, bytes.length);
}
}
代码示例来源:origin: berlam/github-bucket
b4[b4Posn++] = sbiCrop;
if (b4Posn > 3) {
outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn);
b4Posn = 0;
代码示例来源: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
AlgorithmParameters params = AlgorithmParameters
.getInstance(paramsAlgo);
params.init(Base64.decode(cont));
decryptCipher.init(Cipher.DECRYPT_MODE, secretKey, params);
代码示例来源: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: berlam/github-bucket
public Negotiate(String hdr) {
super(Type.NEGOTIATE);
prevToken = Base64.decode(hdr);
}
代码示例来源: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: sonia.jgit/org.eclipse.jgit
public Negotiate(String hdr) {
super(Type.NEGOTIATE);
prevToken = Base64.decode(hdr);
}
代码示例来源: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: berlam/github-bucket
/**
* Decodes data from Base64 notation.
*
* @param s
* the string to decode
* @return the decoded data
*/
public static byte[] decode(String s) {
byte[] bytes = s.getBytes(UTF_8);
return decode(bytes, 0, bytes.length);
}
}
内容来源于网络,如有侵权,请联系作者删除!