本文整理汇总了Java中javax.xml.bind.DatatypeConverter.parseBase64Binary方法的典型用法代码示例。如果您正苦于以下问题:Java DatatypeConverter.parseBase64Binary方法的具体用法?Java DatatypeConverter.parseBase64Binary怎么用?Java DatatypeConverter.parseBase64Binary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.DatatypeConverter
的用法示例。
在下文中一共展示了DatatypeConverter.parseBase64Binary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertPngToJpeg
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private String convertPngToJpeg(String pngBase64) throws IOException {
byte[] pngBinary = DatatypeConverter.parseBase64Binary(pngBase64);
InputStream in = new ByteArrayInputStream(pngBinary);
BufferedImage pngImage = ImageIO.read(in);
int width = pngImage.getWidth(), height = pngImage.getHeight();
BufferedImage jpgImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = jpgImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setBackground(Color.WHITE);
g.clearRect(0, 0, width, height);
g.drawImage(pngImage, 0, 0, width, height, null);
g.dispose();
final ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.setOutput(ImageIO.createImageOutputStream(baos));
writer.write(null, new IIOImage(jpgImage, null, null), JPEG_PARAMS);
String jpgBase64 = DatatypeConverter.printBase64Binary(baos.toByteArray());
return jpgBase64;
}
示例2: getPrivateKey
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
static PrivateKey getPrivateKey() throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
byte[] pkcs1Key = DatatypeConverter.parseBase64Binary(PRIVATE_KEY.replaceAll("(-+BEGIN RSA PRIVATE KEY-+\\r?\\n|-+END RSA PRIVATE KEY-+\\r?\\n?)", ""));
DerInputStream dis = new DerInputStream(pkcs1Key);
DerValue[] disSequence = dis.getSequence(0);
BigInteger modulus = disSequence[1].getBigInteger();
BigInteger publicExp = disSequence[2].getBigInteger();
BigInteger privateExp = disSequence[3].getBigInteger();
BigInteger prime1 = disSequence[4].getBigInteger();
BigInteger prime2 = disSequence[5].getBigInteger();
BigInteger exp1 = disSequence[6].getBigInteger();
BigInteger exp2 = disSequence[7].getBigInteger();
BigInteger crtCoef = disSequence[8].getBigInteger();
RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec(modulus, publicExp, privateExp, prime1, prime2, exp1, exp2, crtCoef);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
return keyFactory.generatePrivate(keySpec);
}
示例3: testconvertImageToBase64
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Test
public void testconvertImageToBase64()
{
System.out.println("\n testconvertImageToBase64()");
String encodedImage = null;
Equipment TempEquipment = new Equipment ();
encodedImage = TempEquipment.convertImageToBase64("Desktop");
try
{
DatatypeConverter.parseBase64Binary(encodedImage);
}
catch(IllegalArgumentException e)
{
fail("string parameter does not conform to lexical value --> Datatypes for xsd:base64Binary");
}
}
示例4: readPrivateKey
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public PrivateKey readPrivateKey(String appId)
throws IOException, GeneralSecurityException {
PrivateKey key;
String fileString = this.jdbcInMemory.getPrivateKeyForAppId(appId);
fileString = fileString.replace(
"-----BEGIN RSA PRIVATE KEY-----\n", "")
.replace("-----END RSA PRIVATE KEY-----", "");
byte[] keyBytes = DatatypeConverter.parseBase64Binary(fileString);
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory kf = KeyFactory.getInstance("RSA");
key = kf.generatePrivate(spec);
return key;
}
示例5: signDocument
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public DSSDocument signDocument(SignatureMultipleDocumentsForm form) {
logger.info("Start signDocument with multiple documents");
MultipleDocumentsSignatureService service = getASiCSignatureService(form.getSignatureForm());
AbstractSignatureParameters parameters = fillParameters(form);
DSSDocument signedDocument = null;
try {
List<DSSDocument> toSignDocuments = WebAppUtils.toDSSDocuments(form.getDocumentsToSign());
SignatureAlgorithm sigAlgorithm = SignatureAlgorithm.getAlgorithm(form.getEncryptionAlgorithm(), form.getDigestAlgorithm());
SignatureValue signatureValue = new SignatureValue(sigAlgorithm, DatatypeConverter.parseBase64Binary(form.getBase64SignatureValue()));
signedDocument = service.signDocument(toSignDocuments, parameters, signatureValue);
} catch (Exception e) {
logger.error("Unable to execute signDocument : " + e.getMessage(), e);
}
logger.info("End signDocument with multiple documents");
return signedDocument;
}
示例6: TokenAuthenticationServiceImpl
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
public TokenAuthenticationServiceImpl(UserRepository userRepository,
StringRedisTemplate stringRedisTemplate) {
this.userRepository = userRepository;
this.stringRedisTemplate = stringRedisTemplate;
// TODO: parse this as a property
tokenHandler = new TokenHandler(DatatypeConverter.parseBase64Binary("9SyECk96oDsTmXfogIfgdjhdsgvagHJLKNLvfdsfR8cbXTvoPjX+Pq/T/b1PqpHX0lYm0oCBjXWICA=="));
}
示例7: authenticateResponse
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private void authenticateResponse(String challenge,
String response) throws AuthException {
String expected = generateResponse(challenge);
if (expected == null) return;
byte[] expectedBytes = DatatypeConverter.parseBase64Binary(expected);
byte[] reponseBytes = DatatypeConverter.parseBase64Binary(response);
if (!Arrays.equals(expectedBytes, reponseBytes)) {
throw new AuthException("Challenge response does not match " +
"expected response");
}
}
示例8: deserialize
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
@Override
public byte[] deserialize(
final VPackSlice parent,
final VPackSlice vpack,
final VPackDeserializationContext context) throws VPackException {
return DatatypeConverter.parseBase64Binary(vpack.getAsString());
}
示例9: decodeToImage
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
* Converter String Base64 em imagem
*
* @param imageString string com a imagem no formato base64
* @return imagem
* @throws java.lang.Exception
*/
public static BufferedImage decodeToImage(String imageString) throws Exception {
BufferedImage image;
byte[] imageByte = DatatypeConverter.parseBase64Binary(imageString);
ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
image = ImageIO.read(bis);
bis.close();
return image;
}
示例10: toBytes
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private byte[] toBytes(String base64Str) {
return DatatypeConverter.parseBase64Binary(base64Str);
}
示例11: fromBase64
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static byte[] fromBase64(String hex)
throws IllegalArgumentException {
return DatatypeConverter.parseBase64Binary(hex);
}
示例12: stringToBytes
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static byte[] stringToBytes(String v) {
if (v.equals("")) {
return null;
}
return DatatypeConverter.parseBase64Binary(v);
}
示例13: fromBase64
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static byte[] fromBase64(String hex)
throws IllegalArgumentException
{
return DatatypeConverter.parseBase64Binary(hex);
}
示例14: getStringAsKey
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static ByteArray getStringAsKey(String keyStr)
throws UnsupportedEncodingException {
return new ByteArray(DatatypeConverter.parseBase64Binary(keyStr));
}
示例15: getSecret
import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
/**
* Creates the secret key from a static string
*
* @return byte[] conversion of secretKey
*/
private static byte[] getSecret() {
String base64Key = DatatypeConverter.printBase64Binary(secretKey.getBytes());
return DatatypeConverter.parseBase64Binary(base64Key);
}