Package org.wiztools.restclient

Examples of org.wiztools.restclient.Base64Exception


        return Base64.encodeBase64String(arr);
    }
   
    public static byte[] base64decodeByteArray(String base64Str) throws Base64Exception {
        if(!Base64.isBase64(base64Str)) {
            throw new Base64Exception("Provided string is not Base64 encoded");
        }
        byte[] out = Base64.decodeBase64(base64Str);
        return out;
    }
View Full Code Here


        return out;
    }
   
    public static String base64decode(String base64Str) throws Base64Exception {
        if(!Base64.isBase64(base64Str)) {
            throw new Base64Exception("Provided string is not Base64 encoded");
        }
        byte[] out = base64decodeByteArray(base64Str);
        CharsetDecoder decoder = Charsets.UTF_8.newDecoder();
        try {
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
            CharBuffer buffer = decoder.decode(
                    ByteBuffer.wrap(Arrays.copyOf(out, out.length)));
            return buffer.toString();
        }
        catch(MalformedInputException ex) {
            throw new Base64Exception("Input is malformed", ex);
        }
        catch(UnmappableCharacterException ex) {
            throw new Base64Exception("Unmappable characters found", ex);
        }
        catch(CharacterCodingException ex) {
            throw new Base64Exception(ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.wiztools.restclient.Base64Exception

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.