Package org.jvnet.staxex

Examples of org.jvnet.staxex.Base64Data


    Base64Data data;
    String base64EncodedString;
   
    /** Creates a new instance of Base64Test */
    public Base64Test() {
        data = new Base64Data();
        data.set(bytes, null);
        base64EncodedString = data.toString();
    }
View Full Code Here


        verifyTag(reader,null,"foo");

        assertEquals(XMLStreamConstants.CHARACTERS,reader.next());
        CharSequence c = reader.getPCDATA();
        assertEquals(true, c instanceof Base64Data);
        Base64Data d = (Base64Data)c;
        byte[] b = d.getExact();
        assertEquals(bytes.length, b.length);
        for (int i = 0; i < bytes.length; i++) {
            assertEquals(bytes[i], b[i]);
        }
View Full Code Here

        @Override
        public void writePCDATA(CharSequence data) throws XMLStreamException {
            if(data == null)
                return;
            if(data instanceof Base64Data){
                Base64Data binaryData = (Base64Data)data;
                writeBinary(binaryData.getDataHandler());
                return;
            }
            writeCharacters(data.toString());
        }
View Full Code Here

                    if(att != null){
                        DataHandler dh = att.asDataHandler();
                        if (dh instanceof StreamingDataHandler) {
                            ((StreamingDataHandler)dh).setHrefCid(att.getContentId());
                        }
                        base64AttData = new Base64Data();
                        base64AttData.set(dh);
                    }
                    xopReferencePresent = true;
                } catch (IOException e) {
                    throw new WebServiceException(e);
View Full Code Here

                            reader.next();
                            StringBuffer sb = null;
                            while(reader.getEventType() == reader.CHARACTERS && reader.getEventType() != reader.END_ELEMENT){
                                CharSequence charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                                if(charSeq instanceof Base64Data){
                                    Base64Data bd = (Base64Data) ((XMLStreamReaderEx)reader).getPCDATA();
                                    signatureValue = bd.getExact();
                                    canonWriter.writeCharacters(Base64.encode(signatureValue));
                                } else{
                                    if(sb == null){
                                        sb = new StringBuffer();
                                    }
View Full Code Here

    private void processReferences(XMLStreamReader reader)throws XWSSecurityException{
        try{
            String dm = "";
            final String uri=reader.getAttributeValue(null,"URI");           
            String digestValue ="";
            Base64Data bd = null;
            ArrayList tList = null;
            while(reader.hasNext() && !StreamUtil._break(reader,"Reference",MessageConstants.DSIG_NS)){
                reader.next();
                int referenceEvent = getReferenceEventType(reader);
                switch(referenceEvent){
                case TRANSFORMS_EVENT :{
                    tList = processTransforms(reader,uri);
                    break;
                }
                case DIGEST_METHOD_EVENT :{                   
                    dm = reader.getAttributeValue(null,"Algorithm");
                    break;
                }
                case DIGEST_VALUE_EVENT :{                   
                    if(reader instanceof XMLStreamReaderEx){
                        reader.next();
                        CharSequence charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                        String dv = null;
                        if(charSeq instanceof Base64Data){
                            bd = (Base64Data)charSeq;
                            dv = Base64.encode(bd.getExact());
                        } else{
                            dv = StreamUtil.getCV(reader);  
                        }
                        digestValue = dv;                       
                        //reader.next();
                    }else{
                        digestValue = StreamUtil.getCV(reader);                       
                    }
                    break;
                }
                default :{
                    //no - op
                }
                }
            }
           
            ReferenceType rt = new Reference();
            DigestMethod digestMethod = new DigestMethod();
            digestMethod.setAlgorithm(dm);
            rt.setDigestMethod(digestMethod);
            if(bd != null){
                rt.setDigestValue(bd.getExact());
            }else{
                try{
                    rt.setDigestValue(Base64.decode(digestValue));
                }catch(Base64DecodingException dec){
                    logger.log(Level.SEVERE, LogStringsMessages.WSS_1719_ERROR_DIGESTVAL_REFERENCE(uri),dec);
View Full Code Here

        }
        if(reader.getEventType() == XMLStreamReader.CHARACTERS){
            if(reader instanceof XMLStreamReaderEx){
                CharSequence data = ((XMLStreamReaderEx)reader).getPCDATA();
                if(data instanceof Base64Data){
                    Base64Data binaryData = (Base64Data)data;
                    bstValue = binaryData.getExact();
                    return;
                }
            }
            try {
                bstValue = Base64.decode(StreamUtil.getCV(reader));
View Full Code Here

                    if (reader.getEventType() == XMLStreamReader.CHARACTERS) {

                        if (reader instanceof XMLStreamReaderEx) {
                            CharSequence data = ((XMLStreamReaderEx) reader).getPCDATA();
                            if (data instanceof Base64Data) {
                                Base64Data binaryData = (Base64Data) data;
                                bstValue = binaryData.getExact();
                                return bstValue;
                            }
                        }
                        try {
                            bstValue = Base64.decode(StreamUtil.getCV(reader));
View Full Code Here

        if(reader.getEventType() == XMLStreamReader.CHARACTERS){
            if(reader instanceof XMLStreamReaderEx){
                try{
                    CharSequence data = ((XMLStreamReaderEx)reader).getPCDATA();
                    if(data instanceof Base64Data){
                        Base64Data binaryData = (Base64Data)data;
                        //bstValue = binaryData.getExact();
                        buildCertificate(binaryData.getInputStream());
                        return;
                    }
                }catch(XMLStreamException ex){
                    logger.log(Level.SEVERE, LogStringsMessages.WSS_1603_ERROR_READING_STREAM(ex));
                    throw new XWSSecurityRuntimeException(LogStringsMessages.WSS_1603_ERROR_READING_STREAM(ex));
View Full Code Here

                    reader.next();
                    StringBuffer sb = null;
                    byte [] value = null;
                    CharSequence charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                    if(charSeq instanceof Base64Data){
                        Base64Data bd = (Base64Data) ((XMLStreamReaderEx)reader).getPCDATA();
                        value = bd.getExact();
                        modulus = new BigInteger(1,value);
                        if(canonWriter != null){
                            String ev = Base64.encode(value);
                            canonWriter.writeCharacters(ev);
                        }
                    }else {
                        sb = new StringBuffer();
                       
                       
                        while(reader.getEventType() == reader.CHARACTERS && reader.getEventType() != reader.END_ELEMENT){
                            charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                            for(int i=0;i<charSeq.length();i++){
                                if(charSeq.charAt(i)== '\n'){
                                    continue;
                                }
                                sb.append(charSeq.charAt(i));
                            }
                            reader.next();
                        }
                        String dv = sb.toString();
                        if(canonWriter != null){
                            canonWriter.writeCharacters(dv);
                        }
                        try{
                            value = Base64.decode(dv);
                        }catch(Base64DecodingException dec){
                            logger.log(Level.SEVERE, LogStringsMessages.WSS_1606_ERROR_RSAKEYINFO_BASE_64_DECODING("EXPONENT"),dec);
                            throw new XWSSecurityException(LogStringsMessages.WSS_1606_ERROR_RSAKEYINFO_BASE_64_DECODING("EXPONENT"));
                        }
                        modulus = new BigInteger(1,value);
                       
                    }
                    break;
                }
                case EXPONENT_ELEMENT :{
                    if(canonWriter != null){
                        StreamUtil.writeCurrentEvent(reader,canonWriter);
                    }
                    reader.next();
                    StringBuffer sb = null;
                    byte [] value = null;
                    CharSequence charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                    if(charSeq instanceof Base64Data){
                        Base64Data bd = (Base64Data) ((XMLStreamReaderEx)reader).getPCDATA();
                        value = bd.getExact();
                        exponent = new BigInteger(1,value);
                        if(canonWriter != null){
                            String ev = Base64.encode(value);
                            canonWriter.writeCharacters(ev);
                        }
View Full Code Here

TOP

Related Classes of org.jvnet.staxex.Base64Data

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.