All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jasypt.wicket.JasyptCryptFactory Maven / Gradle / Ivy

/*
 * =============================================================================
 * 
 *   Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org)
 * 
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * 
 * =============================================================================
 */
package org.jasypt.wicket;

import org.apache.wicket.util.crypt.ICrypt;
import org.apache.wicket.util.crypt.ICryptFactory;
import org.jasypt.encryption.pbe.PBEByteEncryptor;
import org.jasypt.encryption.pbe.PBEStringEncryptor;
import org.slf4j.LoggerFactory;


/**
 * 

* Implementation of the Apache Wicket {@link ICryptFactory} interface * which returns {@link JasyptCrypt} instances. *

*

* Requires a {@link PBEByteEncryptor} as a constructor argument, which can * be created or retrieved from any part of the jasypt encryption configuration * infrastructure. *

*

* *

*

* This class is thread-safe. *

* * @since 1.4 * @author Daniel Fernández * @deprecated Package renamed to org.jasypt.wicket13. This class * will be removed in 1.11. Use {@link org.jasypt.wicket13.JasyptCrypt} * instead. * */ public final class JasyptCryptFactory implements ICryptFactory { // Encryptor doesn't need to be instanced each time. We hold a reference. private final JasyptCrypt jasyptCrypt; /** *

* Creates a new instance of JasyptCryptFactory. *

*

* This factory uses an instance of {@link PBEByteEncryptor} instead of * a {@link PBEStringEncryptor} (as could be expected) because Wicket * requires a specific type of String encoding (URL and file safe * BASE64), which is managed by a wicket internal class, and which * expectes byte[] input. *

* * @param encryptor the PBEByteEncryptor to be used. */ public JasyptCryptFactory(final PBEByteEncryptor encryptor) { this.jasyptCrypt = new JasyptCrypt(encryptor); LoggerFactory.getLogger(JasyptCryptFactory.class).warn( "The org.jasypt.wicket.JasyptCryptFactory and " + "org.jasypt.wicket.JasyptCrypt classes from the " + "jasypt-wicket13 package class have been moved to package " + "org.jasypt.wicket13. The old class names have been " + "DEPRECATED. Please update your package names before " + "these classes are deleted in future versions"); } /** *

* Return a new encryptor object. *

*

* This method returns always the same JasyptCrypt object, instead * of creating a new one. *

*/ public ICrypt newCrypt() { return this.jasyptCrypt; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy