001/*
002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     bstefanescu
018 */
019package org.nuxeo.common.utils;
020
021import java.io.UnsupportedEncodingException;
022
023import org.apache.commons.logging.Log;
024import org.apache.commons.logging.LogFactory;
025
026/**
027 * Simple wrapper around codec library to preserve backward compatibility
028 *
029 * @author bstefanescu
030 * @deprecated Since 5.6. Use {@link org.apache.commons.codec.binary.Base64} instead.
031 */
032@Deprecated
033public class Base64 {
034
035    private static final Log log = LogFactory.getLog(Base64.class);
036
037    public final static String encodeBytes(byte[] source) {
038        try {
039            return new String(org.apache.commons.codec.binary.Base64.encodeBase64(source), "US-ASCII").trim();
040        } catch (UnsupportedEncodingException e) {
041            log.error(e);
042            return "";
043        }
044    }
045
046    public final static byte[] decode(String s) {
047        return org.apache.commons.codec.binary.Base64.decodeBase64(s);
048    }
049
050}