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.enc.spring; 017 018import org.jasypt.util.text.TextEncryptor; 019import org.kuali.common.util.enc.DefaultEncryptionService; 020import org.kuali.common.util.enc.EncContext; 021import org.kuali.common.util.enc.EncryptionService; 022import org.kuali.common.util.enc.NoOpEncryptionService; 023import org.kuali.common.util.spring.env.EnvironmentService; 024import org.kuali.common.util.spring.service.SpringServiceConfig; 025import org.springframework.beans.factory.annotation.Autowired; 026import org.springframework.context.annotation.Bean; 027import org.springframework.context.annotation.Configuration; 028import org.springframework.context.annotation.Import; 029 030import com.google.common.base.Optional; 031 032/** 033 * @deprecated 034 */ 035@Deprecated 036@Configuration 037@Import({ SpringServiceConfig.class }) 038public class DefaultEncryptionServiceConfig implements EncryptionServiceConfig { 039 040 @Autowired 041 EnvironmentService env; 042 043 @Override 044 @Bean 045 public EncryptionService encryptionService() { 046 EncContext context = new EncContext.Builder(env).build(); 047 Optional<TextEncryptor> optional = context.getTextEncryptor(); 048 if (optional.isPresent()) { 049 return new DefaultEncryptionService(optional.get()); 050 } else { 051 return NoOpEncryptionService.INSTANCE; 052 } 053 } 054}