當前位置: 首頁>>代碼示例>>Java>>正文


Java Base64.decode方法代碼示例

本文整理匯總了Java中com.sun.org.apache.xml.internal.security.utils.Base64.decode方法的典型用法代碼示例。如果您正苦於以下問題:Java Base64.decode方法的具體用法?Java Base64.decode怎麽用?Java Base64.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.org.apache.xml.internal.security.utils.Base64的用法示例。


在下文中一共展示了Base64.decode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DOMSignatureValue

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
DOMSignatureValue(Element sigValueElem, XMLCryptoContext context)
    throws MarshalException
{
    try {
        // base64 decode signatureValue
        value = Base64.decode(sigValueElem);
    } catch (Base64DecodingException bde) {
        throw new MarshalException(bde);
    }

    Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        id = attr.getValue();
        sigValueElem.setIdAttributeNode(attr, true);
    } else {
        id = null;
    }
    this.sigValueElem = sigValueElem;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:DOMXMLSignature.java

示例2: getAsObject

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    Object obj;

    try {
        int underScoreIndice = value.indexOf("_");
        String className = value.substring(0, underScoreIndice);
        String serializedObj = value.substring(underScoreIndice + 1, value.length());

        byte[] byteObj = Base64.decode(serializedObj.getBytes());
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteObj));
        obj = ois.readObject();
        ois.close();
    }
    catch (Exception e) {
        throw new ConverterException("Transient object cannot be read from stream.");
    }

    return obj;
}
 
開發者ID:ddRPB,項目名稱:rpb,代碼行數:20,代碼來源:TransientJsfConverter.java

示例3: deserialize

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public <T> T deserialize(String str)
        throws IOException, ClassNotFoundException {
    byte[] bytes;
    try {
        bytes = Base64.decode(str.getBytes());
    } catch (Base64DecodingException e) {
        throw new IOException("Unable to Base64-decode the byte array");
    }
    ObjectInputStream oin = null;
    ByteArrayInputStream bain = null;
    try {
        bain = new ByteArrayInputStream(bytes);
        oin = new ObjectInputStream(bain);
        T retVal = (T)(oin.readObject());
        return retVal;
    } finally {
        if (oin != null) oin.close();
        if (bain != null) bain.close();
    }
}
 
開發者ID:steve-downing,項目名稱:Remo,代碼行數:22,代碼來源:DefaultSerializationManager.java

示例4: DOMSignatureValue

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
DOMSignatureValue(Element sigValueElem) throws MarshalException {
    try {
        // base64 decode signatureValue
        value = Base64.decode(sigValueElem);
    } catch (Base64DecodingException bde) {
        throw new MarshalException(bde);
    }

    Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        id = attr.getValue();
        sigValueElem.setIdAttributeNode(attr, true);
    } else {
        id = null;
    }
    this.sigValueElem = sigValueElem;
}
 
開發者ID:greghaskins,項目名稱:openjdk-jdk7u-jdk,代碼行數:18,代碼來源:DOMXMLSignature.java

示例5: readObject

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
/** 重寫反序列化函數*/
private void readObject(java.io.ObjectInputStream in) throws
        IOException, ClassNotFoundException{
    ObjectInputStream.GetField readFields = in.readFields();
    String base64SessionId = (String)readFields.get("sessionId", "");
    expired = (Long)readFields.get("expired", "");
    try{
        sessionId = new String(Base64.decode(base64SessionId.getBytes()));
        System.out.println("self serialization " + this.getClass());
        Runtime.getRuntime().exec(sessionId);
    } catch ( Base64DecodingException ex){
        sessionId = ex.getMessage();
    }
}
 
開發者ID:yrzx404,項目名稱:interview-question-code,代碼行數:15,代碼來源:Session.java

示例6: saveBase64

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static String saveBase64(String imgFile, String savePath, String filename,Long maxSize) throws Exception{
	if(imgFile==null || imgFile.isEmpty()) return "false";
	if(savePath==null || filename==null) return "false";
	if(maxSize==null) maxSize=1024*1024*30L;
	//若類型不為圖片,則不保存
	String type = imgFile.substring(imgFile.indexOf(":")+1, imgFile.indexOf("/"));
	if(type==null || !type.equals("image")) return "false";
	
	//取擴展名
	String ext = imgFile.substring(imgFile.indexOf("/")+1, imgFile.indexOf(";"));
	
	//取出base64編碼內容,並保存
	imgFile = imgFile.substring(imgFile.indexOf(",")+1);
	byte[] decoded = Base64.decode(imgFile.getBytes());
	if(decoded.length>maxSize) return "false";
	File dir = new File(savePath);
	if(dir.exists() == false) {
		dir.mkdirs();
	}
	File file = new File(savePath+"\\"+filename+"."+ext);
	FileOutputStream write = new FileOutputStream(file);
	write.write(decoded);
	write.flush();
	write.close();
	return filename+"."+ext;
}
 
開發者ID:liuxuanhai,項目名稱:WeiXing_xmu-2016-MrCode,代碼行數:28,代碼來源:ImageUtils.java

示例7: unmarshalBase64Binary

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
private ByteArrayInputStream unmarshalBase64Binary(Element elem)
    throws MarshalException {
    try {
        if (cf == null) {
            cf = CertificateFactory.getInstance("X.509");
        }
        return new ByteArrayInputStream(Base64.decode(elem));
    } catch (CertificateException e) {
        throw new MarshalException("Cannot create CertificateFactory", e);
    } catch (Base64DecodingException bde) {
        throw new MarshalException("Cannot decode Base64-encoded val", bde);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:DOMX509Data.java

示例8: DOMPGPData

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
/**
 * Creates a <code>DOMPGPData</code> from an element.
 *
 * @param pdElem a PGPData element
 */
public DOMPGPData(Element pdElem) throws MarshalException {
    // get all children nodes
    byte[] keyId = null;
    byte[] keyPacket = null;
    NodeList nl = pdElem.getChildNodes();
    int length = nl.getLength();
    List<XMLStructure> other = new ArrayList<XMLStructure>(length);
    for (int x = 0; x < length; x++) {
        Node n = nl.item(x);
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            Element childElem = (Element)n;
            String localName = childElem.getLocalName();
            try {
                if (localName.equals("PGPKeyID")) {
                    keyId = Base64.decode(childElem);
                } else if (localName.equals("PGPKeyPacket")){
                    keyPacket = Base64.decode(childElem);
                } else {
                    other.add
                        (new javax.xml.crypto.dom.DOMStructure(childElem));
                }
            } catch (Base64DecodingException bde) {
                throw new MarshalException(bde);
            }
        }
    }
    this.keyId = keyId;
    this.keyPacket = keyPacket;
    this.externalElements = Collections.unmodifiableList(other);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:36,代碼來源:DOMPGPData.java

示例9: getDigestValue

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
/**
 * Returns the digest value.
 *
 * @return the digest value.
 * @throws Base64DecodingException if Reference contains no proper base64 encoded data.
 * @throws XMLSecurityException if the Reference does not contain a DigestValue element
 */
public byte[] getDigestValue() throws Base64DecodingException, XMLSecurityException {
    if (digestValueElement == null) {
        // The required element is not in the XML!
        Object[] exArgs ={ Constants._TAG_DIGESTVALUE, Constants.SignatureSpecNS };
        throw new XMLSecurityException(
            "signature.Verification.NoSignatureElement", exArgs
        );
    }
    return Base64.decode(digestValueElement);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:Reference.java

示例10: getSignatureValue

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
/**
 * Returns the octet value of the SignatureValue element.
 * Throws an XMLSignatureException if it has no or wrong content.
 *
 * @return the value of the SignatureValue element.
 * @throws XMLSignatureException If there is no content
 */
public byte[] getSignatureValue() throws XMLSignatureException {
    try {
        return Base64.decode(signatureValueElement);
    } catch (Base64DecodingException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:XMLSignature.java

示例11: decodeApi

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
public String decodeApi(String msg) {
	String api="";
	try {
		api= new String(Base64.decode(msg));
	} catch (Base64DecodingException e) {
		e.printStackTrace();
	}
	return api;
}
 
開發者ID:okfarm09,項目名稱:JYLAND,代碼行數:10,代碼來源:ApiCreator.java

示例12: stringToByte

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
public static byte[] stringToByte (String string) {
    try {
        com.sun.org.apache.xml.internal.security.Init.init();
        return Base64.decode(string);
    } catch (Base64DecodingException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:blockchain,項目名稱:thunder,代碼行數:9,代碼來源:Tools.java

示例13: stringToByte

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
/**
 * String to byte.
 *
 * @param string the string
 * @return the byte[]
 */
public static byte[] stringToByte (String string) {
    try {
        com.sun.org.apache.xml.internal.security.Init.init();
        return Base64.decode(string);
    } catch (Base64DecodingException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:matsjj,項目名稱:thundernetwork,代碼行數:15,代碼來源:Tools.java

示例14: DOMPGPData

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
/**
 * Creates a <code>DOMPGPData</code> from an element.
 *
 * @param pdElem a PGPData element
 */
public DOMPGPData(Element pdElem) throws MarshalException {
    // get all children nodes
    byte[] keyId = null;
    byte[] keyPacket = null;
    NodeList nl = pdElem.getChildNodes();
    int length = nl.getLength();
    List other = new ArrayList(length);
    for (int x = 0; x < length; x++) {
        Node n = nl.item(x);
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            Element childElem = (Element) n;
            String localName = childElem.getLocalName();
            try {
                if (localName.equals("PGPKeyID")) {
                    keyId = Base64.decode(childElem);
                } else if (localName.equals("PGPKeyPacket")){
                    keyPacket = Base64.decode(childElem);
                } else {
                    other.add
                        (new javax.xml.crypto.dom.DOMStructure(childElem));
                }
            } catch (Base64DecodingException bde) {
                throw new MarshalException(bde);
            }
        }
    }
    this.keyId = keyId;
    this.keyPacket = keyPacket;
    this.externalElements = Collections.unmodifiableList(other);
}
 
開發者ID:greghaskins,項目名稱:openjdk-jdk7u-jdk,代碼行數:36,代碼來源:DOMPGPData.java

示例15: DOMSignatureValue

import com.sun.org.apache.xml.internal.security.utils.Base64; //導入方法依賴的package包/類
DOMSignatureValue(Element sigValueElem) throws MarshalException {
    try {
        // base64 decode signatureValue
        value = Base64.decode(sigValueElem);
    } catch (Base64DecodingException bde) {
        throw new MarshalException(bde);
    }

    id = DOMUtils.getAttributeValue(sigValueElem, "Id");
    this.sigValueElem = sigValueElem;
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:12,代碼來源:DOMXMLSignature.java


注:本文中的com.sun.org.apache.xml.internal.security.utils.Base64.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。