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


Java Base64Decoder类代码示例

本文整理汇总了Java中com.mysql.jdbc.util.Base64Decoder的典型用法代码示例。如果您正苦于以下问题:Java Base64Decoder类的具体用法?Java Base64Decoder怎么用?Java Base64Decoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Base64Decoder类属于com.mysql.jdbc.util包,在下文中一共展示了Base64Decoder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeRSAPublicKey

import com.mysql.jdbc.util.Base64Decoder; //导入依赖的package包/类
public static RSAPublicKey decodeRSAPublicKey(String key, ExceptionInterceptor interceptor) throws SQLException {

        try {
            if (key == null) {
                throw new SQLException("key parameter is null");
            }

            int offset = key.indexOf("\n") + 1;
            int len = key.indexOf("-----END PUBLIC KEY-----") - offset;

            // TODO: use standard decoders with Java 6+
            byte[] certificateData = Base64Decoder.decode(key.getBytes(), offset, len);

            X509EncodedKeySpec spec = new X509EncodedKeySpec(certificateData);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            return (RSAPublicKey) kf.generatePublic(spec);
        } catch (Exception ex) {
            throw SQLError.createSQLException("Unable to decode public key", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, ex, interceptor);
        }
    }
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:21,代码来源:ExportControlled.java

示例2: decodeRSAPublicKey

import com.mysql.jdbc.util.Base64Decoder; //导入依赖的package包/类
public static RSAPublicKey decodeRSAPublicKey(String key, ExceptionInterceptor interceptor) throws SQLException {
	
	try {
		if (key == null) throw new SQLException("key parameter is null");
		
		int offset = key.indexOf("\n")+1;
		int len = key.indexOf("-----END PUBLIC KEY-----") - offset;
		
		// TODO: use standard decoders with Java 6+
		byte[] certificateData = Base64Decoder.decode(key.getBytes(), offset, len);
		
		X509EncodedKeySpec spec = new X509EncodedKeySpec(certificateData);
		KeyFactory kf = KeyFactory.getInstance("RSA");
		return (RSAPublicKey) kf.generatePublic(spec);
	} catch (Exception ex) {
		throw SQLError.createSQLException("Unable to decode public key", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, ex, interceptor);
	}
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:19,代码来源:ExportControlled.java

示例3: testBase64DecoderItem

import com.mysql.jdbc.util.Base64Decoder; //导入依赖的package包/类
private void testBase64DecoderItem(String source, String expected) throws Exception {
    assertEquals(expected, new String(Base64Decoder.decode(source.getBytes(), 0, source.length())));
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:4,代码来源:StringRegressionTest.java

示例4: testBase64DecoderItem

import com.mysql.jdbc.util.Base64Decoder; //导入依赖的package包/类
private void testBase64DecoderItem(String source, String expected) throws Exception {
	assertEquals(expected, new String(Base64Decoder.decode(source.getBytes(), 0, source.length())));
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:4,代码来源:StringRegressionTest.java


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