001/*
002 * Copyright (c) 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 */
012package org.nuxeo.common.utils;
013
014import java.io.UnsupportedEncodingException;
015
016import org.apache.commons.logging.Log;
017import org.apache.commons.logging.LogFactory;
018
019/**
020 * Simple wrapper around codec library to preserve backward compatibility
021 *
022 * @author bstefanescu
023 * @deprecated Since 5.6. Use {@link org.apache.commons.codec.binary.Base64} instead.
024 */
025@Deprecated
026public class Base64 {
027
028    private static final Log log = LogFactory.getLog(Base64.class);
029
030    public final static String encodeBytes(byte[] source) {
031        try {
032            return new String(org.apache.commons.codec.binary.Base64.encodeBase64(source), "US-ASCII").trim();
033        } catch (UnsupportedEncodingException e) {
034            log.error(e);
035            return "";
036        }
037    }
038
039    public final static byte[] decode(String s) {
040        return org.apache.commons.codec.binary.Base64.decodeBase64(s);
041    }
042
043}