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.property.processor; 017 018import java.util.List; 019import java.util.Properties; 020 021import org.jasypt.util.text.TextEncryptor; 022import org.kuali.common.util.PropertyUtils; 023import org.springframework.util.Assert; 024 025/** 026 * @deprecated Use ContextDecryptingProcessor instead 027 */ 028@Deprecated 029public class DecryptProcessor implements PropertyProcessor { 030 031 TextEncryptor encryptor; 032 033 public DecryptProcessor() { 034 this(null); 035 } 036 037 public DecryptProcessor(TextEncryptor encryptor) { 038 super(); 039 this.encryptor = encryptor; 040 } 041 042 @Override 043 public void process(Properties properties) { 044 Assert.notNull(encryptor, "encryptor is null"); 045 List<String> keys = PropertyUtils.getSortedKeys(properties); 046 for (String key : keys) { 047 String encryptedValue = properties.getProperty(key); 048 String decryptedValue = encryptor.decrypt(encryptedValue); 049 properties.setProperty(key, decryptedValue); 050 } 051 } 052 053 public TextEncryptor getEncryptor() { 054 return encryptor; 055 } 056 057 public void setEncryptor(TextEncryptor encryptor) { 058 this.encryptor = encryptor; 059 } 060 061}