本文整理汇总了Java中org.apache.axis.encoding.Base64.encode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.encode方法的具体用法?Java Base64.encode怎么用?Java Base64.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis.encoding.Base64
的用法示例。
在下文中一共展示了Base64.encode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeToString
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
public static String encodeToString (byte[] in, int width) throws Exception {
// return Base64.encode(in);
String raw = Base64.encode(in);
if (width > 0) {
StringBuffer buf = new StringBuffer();
for (int i=0;i<raw.length();i++) {
buf.append(raw.charAt(i));
if (i > 0 && (i % 72 == 0))
buf.append ("=\n");
}
return buf.toString();
}
else {
return raw;
}
}
示例2: getConnection
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
private HttpURLConnection getConnection(URL url, int retries) throws IOException{
HttpURLConnection res = null;
for(int i=0;i<retries;i++){
try{
res = (HttpURLConnection)url.openConnection();
String val = user + ":" + password;
String encoding = Base64.encode(val.getBytes());
res.setRequestProperty ("Authorization", "Basic " + encoding);
break;
}catch(IOException e){
log.warn("Connect failed to: "+url+" - retrying...",e);
if(i==retries-1){
throw e;
}
}
}
return res;
}
示例3: signHeader
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
/**
* Sign the current header with the correct private key for this connection.
*
* @param header - the header string ( canonical )
* @return - the Base64 signed encoding for the header
* @throws Exception
*/
private String signHeader( String _header ) throws Exception
{
Signature signature = null;
try {
signature = Signature.getInstance( "SHA1withRSA" );
signature.initSign( getPrivateKeyObject() );
/* IMPORTANT!
* The header specified by :
*
* POST <request_url>\n
* \n
* \n
* x-nsdl-date : <date>\n
*
*/
_header = "POST " + getConnection() + "\n\n\n" + _header + "\n";
signature.update( _header.getBytes("UTF-8") );
// System.out.println ( "header to be signed : [" + _header + "]" );
return
Base64.encode( signature.sign() );
} catch ( Exception e ) {
return
""; // NOTE : we'll let the NDR server reject the connection w/ no handle
}
}
示例4: encode
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
public static String encode(String text)
{
if(text == null)
return text;
try {
return Base64.encode(text.getBytes());
}
catch (Throwable e) {
return null;
}
}
示例5: sign
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
/**
* Creates a signature based on the given parameters.
*
* @param toSign A string to sign
* @return A signature
*/
public String sign(String toSign) {
// compute the hmac on input data bytes
byte[] rawHmac = mac.doFinal(toSign.getBytes());
// base64-encode the hmac
return Base64.encode(rawHmac);
}
示例6: getCacheFolderName
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
private String getCacheFolderName()
{
SessionIF session = Session.getCurrentSession();
String sessionId = session.getId();
return Base64.encode(sessionId.getBytes());
}
示例7: encode
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
public static String encode(byte[] bs){
return Base64.encode(bs);
}
示例8: getSaveInfo
import org.apache.axis.encoding.Base64; //导入方法依赖的package包/类
@Override
public String getSaveInfo(File f, String name,
HashMap<String, String> params, boolean minified) throws WsSrvException {
return "{\"base64\":\"" + new String(Base64.encode(
GenericUtils.readFile(f))) + "\"}";
}