當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。