Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Base64


     * @throws IOException if an data I/O error occurs
     */
    public static Object decode(String string)
            throws ClassNotFoundException, IOException {

        Base64 base64 = new Base64();
        byte[] byteData = null;

        try {
            byteData = base64.decode(string.getBytes());

        } catch (Throwable t) {
            String message =
                "error occured Base64 decoding: " + string + " : " + t;
            throw new IOException(message);
View Full Code Here


        String challenge = buffer.substringTrimmed(beginIndex, endIndex);
        if (log.isDebugEnabled()) {
            log.debug("Received challenge '" + challenge + "' from the auth server");
        }
        if (state == State.UNINITIATED) {
            token = new Base64().decode(challenge.getBytes());
            state = State.CHALLENGE_RECEIVED;
        } else {
            log.debug("Authentication already attempted");
            state = State.FAILED;
        }
View Full Code Here

        }
    }

    public static final byte[] encode(byte[] bytes)
    {
        return new Base64().encode(bytes);
    }
View Full Code Here

        }
    }

    public static final byte[] decode(byte[] bytes)
    {
        return new Base64().decode(bytes);
    }
View Full Code Here

           ObjectOutputStream oos = new ObjectOutputStream(zos);
           oos.writeObject(obj);
           oos.close();
           zos.close();
           baos.close();
           Base64 base64Codec = new Base64();
           return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
       }
       catch (IOException e)
       {
           log.fatal("Cannot encode Object with Base64", e);
           throw new FacesException(e);
View Full Code Here

            _algorithmParams = DEFAULT_ALGORITHM_PARAMS;
        }

        testConfiguration(_algorithmParams, _iv);

        Base64 base64 = new Base64();
        // TODO find a way to avoid decoding each time, maybe context listener

        byte[] iv = null;

        if (_iv != null)
            iv = base64.decode(_iv.getBytes());

        if(_cache != null && "false".equals(_cache)){
           
            // secret will have to be decoded and SecretKey will have to
            // be generated
           
            byte[] secret = base64.decode(_secret.getBytes());
           
            return symmetric(data, secret, _algorithm, _algorithmParams, iv, mode);
           
        }else{
           
View Full Code Here

        if(_secret == null)
            throw new NullPointerException("_secret String - '"
                    + INIT_SECRET_KEY_CACHE + "' has been enabled, "
                    + "but there is no '" + INIT_SECRET + "'");
       
        byte[] secret = new Base64().decode(_secret.getBytes());
       
        // you want to do this as few times as possible
        SecretKey secretKey = new SecretKeySpec(secret, _algorithm);
       
        if (log.isDebugEnabled())
View Full Code Here

            }
            String authscheme = auth.substring(0, i);
            if (authscheme.equalsIgnoreCase("basic")) {
                String s = auth.substring(i + 1).trim();
                byte[] credsRaw = s.getBytes(HTTP.ASCII);
                BinaryDecoder codec = new Base64();
                try {
                    String creds = new String(codec.decode(credsRaw), HTTP.ASCII);
                    context.setAttribute("creds", creds);
                } catch (DecoderException ex) {
                    throw new ProtocolException("Malformed BASIC credentials");
                }
            }
View Full Code Here

        }
    }

    public static final byte[] encode(byte[] bytes)
    {
          return new Base64().encode(bytes);
    }
View Full Code Here

        }
    }

    public static final byte[] decode(byte[] bytes)
    {
          return new Base64().decode(bytes);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.binary.Base64

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.