View Javadoc
1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.property.processor;
17  
18  import java.util.Properties;
19  
20  import org.jasypt.util.text.TextEncryptor;
21  import org.kuali.common.util.Assert;
22  import org.kuali.common.util.PropertyUtils;
23  import org.kuali.common.util.enc.EncStrength;
24  import org.kuali.common.util.enc.EncUtils;
25  
26  /**
27   * @deprecated
28   */
29  @Deprecated
30  public final class ContextDecryptingProcessor implements PropertyProcessor {
31  
32  	public ContextDecryptingProcessor() {
33  		this(org.kuali.common.util.enc.EncryptionContext.DEFAULT);
34  	}
35  
36  	public ContextDecryptingProcessor(org.kuali.common.util.enc.EncryptionContext context) {
37  		Assert.noNulls(context);
38  		this.context = context;
39  	}
40  
41  	private final org.kuali.common.util.enc.EncryptionContext context;
42  
43  	@Override
44  	public void process(Properties properties) {
45  		Assert.noNulls(properties);
46  		if (!context.isEnabled()) {
47  			return;
48  		}
49  		String password = context.getPassword().get();
50  		EncStrength strength = context.getStrength();
51  		TextEncryptor encryptor = EncUtils.getTextEncryptor(password, strength);
52  		PropertyUtils.decrypt(properties, encryptor);
53  	}
54  
55  	public org.kuali.common.util.enc.EncryptionContext getContext() {
56  		return context;
57  	}
58  
59  }