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


Java DatatypeConverter.parseBase64Binary方法代码示例

本文整理汇总了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;
}
 
开发者ID:JensN4,项目名称:png_to_jpg_in_svg,代码行数:24,代码来源:PNG_to_JPG_in_SVG.java

示例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);
}
 
开发者ID:xunkutech,项目名称:jetbrainslicenseserver4j,代码行数:17,代码来源:JetbrainsLicenseServer.java

示例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");
	}
	
}
 
开发者ID:Will30,项目名称:MonitorYourLAN,代码行数:20,代码来源:EquipmentTest.java

示例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;
}
 
开发者ID:gunjank,项目名称:springboot-asymmetric-cryptography,代码行数:14,代码来源:GenerateKeys.java

示例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;
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:20,代码来源:SigningService.java

示例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=="));
}
 
开发者ID:yuexine,项目名称:loafer,代码行数:8,代码来源:TokenAuthenticationServiceImpl.java

示例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");
    } 
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:14,代码来源:AbstractRPCChannelHandler.java

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

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

示例10: toBytes

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private byte[] toBytes(String base64Str) {
    return DatatypeConverter.parseBase64Binary(base64Str);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:4,代码来源:ScramMessagesTest.java

示例11: fromBase64

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static byte[] fromBase64(String hex)
		throws IllegalArgumentException {
	return DatatypeConverter.parseBase64Binary(hex);
}
 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:5,代码来源:PasswordStorage.java

示例12: stringToBytes

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static byte[] stringToBytes(String v) {
    if (v.equals("")) {
        return null;
    }
    return DatatypeConverter.parseBase64Binary(v);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:CheckExampleVectors.java

示例13: fromBase64

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static byte[] fromBase64(String hex)
    throws IllegalArgumentException
{
    return DatatypeConverter.parseBase64Binary(hex);
}
 
开发者ID:javathought,项目名称:devoxx-2017,代码行数:6,代码来源:PasswordStorage.java

示例14: getStringAsKey

import javax.xml.bind.DatatypeConverter; //导入方法依赖的package包/类
private static ByteArray getStringAsKey(String keyStr) 
        throws UnsupportedEncodingException {
    return new ByteArray(DatatypeConverter.parseBase64Binary(keyStr));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:5,代码来源:JavaDBStorageEngine.java

示例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);
}
 
开发者ID:grantleymorrison,项目名称:FlashBoard,代码行数:11,代码来源:TokenService.java


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