001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 */
016package org.kuali.common.util;
017
018import org.jasypt.util.text.BasicTextEncryptor;
019import org.jasypt.util.text.StrongTextEncryptor;
020import org.jasypt.util.text.TextEncryptor;
021
022/**
023 * @deprecated
024 */
025@Deprecated
026public class EncUtils {
027
028        /**
029         * Returns a <code>BasicTextEncryptor</code> that uses <code>password</code> to encrypt/decrypt.
030         */
031        public static final TextEncryptor getTextEncryptor(String password) {
032                return getTextEncryptor(EncryptionStrength.BASIC, password);
033        }
034
035        /**
036         * Return a <code>BasicTextEncryptor</code> or <code>StrongTextEncryptor</code> depending on what <code>strength</code> is set to
037         * 
038         * @deprecated
039         */
040        @Deprecated
041        public static final TextEncryptor getTextEncryptor(EncryptionStrength strength, String password) {
042                switch (strength) {
043                case BASIC:
044                        BasicTextEncryptor basic = new BasicTextEncryptor();
045                        basic.setPassword(password);
046                        return basic;
047                case STRONG:
048                        StrongTextEncryptor strong = new StrongTextEncryptor();
049                        strong.setPassword(password);
050                        return strong;
051                default:
052                        throw new IllegalArgumentException("Encryption strength [" + strength + "] is unknown");
053                }
054        }
055}