本文整理汇总了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);
}
}
示例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);
}
}
示例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())));
}
示例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())));
}