本文整理汇总了Java中org.apache.axis.encoding.Base64类的典型用法代码示例。如果您正苦于以下问题:Java Base64类的具体用法?Java Base64怎么用?Java Base64使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Base64类属于org.apache.axis.encoding包,在下文中一共展示了Base64类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.getEncoder().encode(in).toString();
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: 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;
}
}
示例3: 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;
}
示例4: 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
}
}
示例5: toX509Certificate
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
public static X509Certificate toX509Certificate(String encodedCertificate) {
try {
return (X509Certificate) CertificateFactory.getInstance("X.509")
.generateCertificate(new ByteArrayInputStream(Base64.decode(encodedCertificate
.replaceAll(BEGIN_CERT, "").replaceAll(END_CERT, ""))));
} catch (CertificateException e) {
throw new RuntimeException(e);
}
}
示例6: getExtFileTestSet
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
@Override
public TestFileItem[] getExtFileTestSet(String resName, String fileExt) {
String img = TEST_ICON_SET.get(fileExt);
return new TestFileItem[] {
new TestFileItem(Base64.decode(img),
"{\"base64\":\"" + img +"\"}")};
}
示例7: 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;
}
}
示例8: decode
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
public static String decode(String base64)
{
if(base64 == null)
return null;
try {
return new String(Base64.decode(base64), UTF8);
}
catch (Throwable e) {
return null;
}
}
示例9: 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);
}
示例10: toDataToBeSigned
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
/**
* Convert to a DataToBeSigned object.
* @return this object as org.etsi.uri.TS102204.v1_1_2.DataToBeSigned
*/
public DataType toDataToBeSigned() {
DataType rv = new DataType();
rv.setEncoding(this.encoding);
rv.setMimeType(this.mimeType);
if(this.text == null) {
rv.setValue(Base64.encode(this.data));
} else {
rv.setValue(this.text);
}
return rv;
}
示例11: run
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
@Override
public void run()
{
try
{
String[] directories = new String[] { BirtConstants.CACHE_DIR, BirtConstants.IMGS_DIR };
for (String dir : directories)
{
File directory = new File(dir);
File[] files = directory.listFiles();
if (files != null)
{
for (File file : files)
{
String sessionId = new String(Base64.decode(file.getName()));
if (!SessionFacade.containsSession(sessionId))
{
FileIO.deleteDirectory(file);
}
}
}
}
}
catch (Exception e)
{
log.error(e);
}
}
示例12: getCacheFolderName
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
private String getCacheFolderName()
{
SessionIF session = Session.getCurrentSession();
String sessionId = session.getId();
return Base64.encode(sessionId.getBytes());
}
示例13: decodeString
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
public static byte[] decodeString (String in) {
return Base64.getDecoder().decode (in);
}
示例14: create
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
/**
* Creates a socket.
*
* @param host
* @param port
* @param otherHeaders
* @param useFullURL
* @return Socket
* @throws Exception
*/
@Override
public Socket create(String host, int port, StringBuffer otherHeaders, BooleanHolder useFullURL) throws Exception
{
int timeout = 0;
if( attributes != null )
{
String value = (String) attributes.get(CONNECT_TIMEOUT);
timeout = (value != null) ? Integer.parseInt(value) : 0;
}
TransportClientProperties tcp = TleTransportClientPropertiesFactory.create("http"); //$NON-NLS-1$
Socket sock = null;
boolean hostInNonProxyList = isHostInNonProxyList(host, tcp.getNonProxyHosts());
if( tcp.getProxyUser().length() != 0 )
{
StringBuilder tmpBuf = new StringBuilder();
tmpBuf.append(tcp.getProxyUser()).append(":").append(tcp.getProxyPassword());
otherHeaders.append(HTTPConstants.HEADER_PROXY_AUTHORIZATION).append(": Basic ")
.append(Base64.encode(tmpBuf.toString().getBytes())).append("\r\n");
}
if( port == -1 )
{
port = 80;
}
if( (tcp.getProxyHost().length() == 0) || (tcp.getProxyPort().length() == 0) || hostInNonProxyList )
{
sock = create(host, port, timeout);
if( log.isDebugEnabled() )
{
log.debug(Messages.getMessage("createdHTTP00"));
}
}
else
{
sock = create(tcp.getProxyHost(), new Integer(tcp.getProxyPort()).intValue(), timeout);
if( log.isDebugEnabled() )
{
log.debug(Messages.getMessage("createdHTTP01", tcp.getProxyHost(), tcp.getProxyPort()));
}
useFullURL.value = true;
}
return sock;
}
示例15: encode
import org.apache.axis.encoding.Base64; //导入依赖的package包/类
public static String encode(byte[] bs){
return Base64.encode(bs);
}