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


Java Base64类代码示例

本文整理汇总了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;
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:18,代码来源:ContentUtils.java

示例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;
	}
}
 
开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:17,代码来源:ContentUtils.java

示例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;
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:21,代码来源:OMSUploadUtil.java

示例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
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:39,代码来源:NDRConnection.java

示例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);
    }
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:10,代码来源:X509Utils.java

示例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 +"\"}")};
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:9,代码来源:PdTestFileUtils.java

示例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;
}
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:12,代码来源:Base64Codex.java

示例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;
}
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:13,代码来源:Base64Codex.java

示例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);
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:14,代码来源:HMACSigner.java

示例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;
}
 
开发者ID:laverca,项目名称:laverca,代码行数:18,代码来源:DTBS.java

示例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);
  }
}
 
开发者ID:terraframe,项目名称:geoprism,代码行数:33,代码来源:CacheDocumentManager.java

示例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());
}
 
开发者ID:terraframe,项目名称:geoprism,代码行数:8,代码来源:ReportItem.java

示例13: decodeString

import org.apache.axis.encoding.Base64; //导入依赖的package包/类
public static byte[] decodeString (String in) {
	return Base64.getDecoder().decode (in);
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:4,代码来源:ContentUtils.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:58,代码来源:TleDefaultSocketFactory.java

示例15: encode

import org.apache.axis.encoding.Base64; //导入依赖的package包/类
public static String encode(byte[] bs){
    return Base64.encode(bs);
}
 
开发者ID:1991wangliang,项目名称:lorne_core,代码行数:4,代码来源:Base64Utils.java


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