28 | * Constant names of the parameters that can be used by a jasypt's 29 | * Hibernate connection provider. 30 | *
31 | * 32 | * @since 1.4 33 | * 34 | * @author Daniel Fernández 35 | * 36 | * @deprecated Will be removed in 1.11. Package org.jasypt.hibernate.connectionprovider 37 | * has been renamed as org.jasypt.hibernate3.connectionprovider. 38 | * 39 | */ 40 | public final class ParameterNaming { 41 | 42 | 43 | /** 44 | * Property in hibernate.cfg.xml or 45 | * hibernate.properties which contains the registered name 46 | * (in {@link HibernatePBEEncryptorRegistry}) of the encryptor which 47 | * will be used to decrypt the datasource parameters. 48 | */ 49 | public static final String ENCRYPTOR_REGISTERED_NAME = 50 | "hibernate.connection.encryptor_registered_name"; 51 | 52 | 53 | private ParameterNaming() { 54 | super(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /jasypt-hibernate3/src/main/java/org/jasypt/hibernate3/connectionprovider/ParameterNaming.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.hibernate3.connectionprovider; 21 | 22 | import org.jasypt.hibernate3.encryptor.HibernatePBEEncryptorRegistry; 23 | 24 | 25 | 26 | /** 27 | *28 | * Constant names of the parameters that can be used by a jasypt's 29 | * Hibernate connection provider. 30 | *
31 | * 32 | * @since 1.9.0 (class existed in package 33 | * org.jasypt.hibernate.connectionprovider since 1.4) 34 | * 35 | * @author Daniel Fernández 36 | * 37 | */ 38 | public final class ParameterNaming { 39 | 40 | 41 | /** 42 | * Property in hibernate.cfg.xml or 43 | * hibernate.properties which contains the registered name 44 | * (in {@link HibernatePBEEncryptorRegistry}) of the encryptor which 45 | * will be used to decrypt the datasource parameters. 46 | */ 47 | public static final String ENCRYPTOR_REGISTERED_NAME = 48 | "hibernate.connection.encryptor_registered_name"; 49 | 50 | 51 | private ParameterNaming() { 52 | super(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /jasypt-hibernate3/src/test/java/org/jasypt/hibernate3/model/user/User.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 |28 | * Constant names of the parameters that can be used by a jasypt's 29 | * Hibernate connection provider. 30 | *
31 | * 32 | * @since 1.9.0 33 | * 34 | * @author Daniel Fernández 35 | * 36 | */ 37 | public final class ParameterNaming { 38 | 39 | 40 | /** 41 | * Property in hibernate.cfg.xml or 42 | * hibernate.properties which contains the registered name 43 | * (in {@link HibernatePBEEncryptorRegistry}) of the encryptor which 44 | * will be used to decrypt the datasource parameters. 45 | */ 46 | public static final String ENCRYPTOR_REGISTERED_NAME = 47 | "hibernate.connection.encryptor_registered_name"; 48 | 49 | 50 | private ParameterNaming() { 51 | super(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jasypt-hibernate4/src/test/java/org/jasypt/hibernate4/model/user/User.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 |Provides the highest level of abstraction for Encoders. 27 | * This is the sister interface of {@link Decoder}. Every implementation of 28 | * Encoder provides this common generic interface whic allows a user to pass a 29 | * generic Object to any Encoder implementation in the codec package.
30 | * 31 | * @author Apache Software Foundation 32 | */ 33 | public interface Encoder { 34 | 35 | /** 36 | * Encodes an "Object" and returns the encoded content 37 | * as an Object. The Objects here may just bebyte[]
38 | * or String
s depending on the implementation used.
39 | *
40 | * @param pObject An object ot encode
41 | *
42 | * @return An "encoded" Object
43 | *
44 | * @throws EncoderException an encoder exception is
45 | * thrown if the encoder experiences a failure
46 | * condition during the encoding process.
47 | */
48 | Object encode(Object pObject) throws EncoderException;
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/jasypt/src/main/java/org/jasypt/contrib/org/apache/commons/codec_1_3/EncoderException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001-2004 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 | /*
17 | * IMPORTANT NOTE: This class has been included into Jasypt's source tree from
18 | * Apache Commons-Codec version 1.3 [see http://commons.apache.org/codec],
19 | * licensed under Apache License 2.0 [see http://www.apache.org/licenses/LICENSE-2.0].
20 | * No modifications have been made to the code of this class except the package name.
21 | */
22 |
23 | package org.jasypt.contrib.org.apache.commons.codec_1_3;
24 |
25 | /**
26 | * Thrown when there is a failure condition during the encoding process. This
27 | * exception is thrown when an Encoder encounters a encoding specific exception
28 | * such as invalid data, inability to calculate a checksum, characters outside of the
29 | * expected range.
30 | *
31 | * @author Apache Software Foundation
32 | */
33 | public class EncoderException extends Exception {
34 |
35 | /**
36 | * Creates a new instance of this exception with an useful message.
37 | *
38 | * @param pMessage a useful message relating to the encoder specific error.
39 | */
40 | public EncoderException(String pMessage) {
41 | super(pMessage);
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/jasypt/src/main/java/org/jasypt/digest/ByteDigester.java:
--------------------------------------------------------------------------------
1 | /*
2 | * =============================================================================
3 | *
4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org)
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * =============================================================================
19 | */
20 | package org.jasypt.digest;
21 |
22 | /**
23 | * 24 | * Common interface for all digesters which receive a byte array message and 25 | * return a byte array digest. 26 | *
27 | *28 | * For a default implementation, see {@link StandardByteDigester}. 29 | *
30 | * 31 | * @since 1.0 32 | * 33 | * @author Daniel Fernández 34 | * 35 | */ 36 | public interface ByteDigester { 37 | 38 | 39 | /** 40 | *41 | * Create a digest of the input message. 42 | *
43 | * 44 | * @param message the message to be digested 45 | * @return the digest 46 | */ 47 | public byte[] digest(byte[] message); 48 | 49 | 50 | /** 51 | *52 | * Check whether a message matches a digest, managing aspects like 53 | * salt, hashing iterations, etc. (if applicable). 54 | *
55 | * 56 | * @param message the message to check 57 | * @param digest the digest to check 58 | * @return TRUE if the message matches the digest, FALSE if not. 59 | */ 60 | public boolean matches(byte[] message, byte[] digest); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/digest/StringDigester.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.digest; 21 | 22 | /** 23 | *24 | * Common interface for all digesters which receive a String message and 25 | * return a String digest. 26 | *
27 | *28 | * For a default implementation, see {@link StandardStringDigester}. 29 | *
30 | * 31 | * @since 1.0 32 | * 33 | * @author Daniel Fernández 34 | * 35 | */ 36 | public interface StringDigester { 37 | 38 | /** 39 | *40 | * Create a digest of the input message. 41 | *
42 | * 43 | * @param message the message to be digested 44 | * @return the digest 45 | */ 46 | public String digest(String message); 47 | 48 | 49 | /** 50 | *51 | * Check whether a message matches a digest, managing aspects like 52 | * salt, hashing iterations, etc. (if applicable). 53 | *
54 | * 55 | * @param message the message to check 56 | * @param digest the digest to check 57 | * @return TRUE if the message matches the digest, FALSE if not. 58 | */ 59 | public boolean matches(String message, String digest); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/BigDecimalEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption; 21 | 22 | import java.math.BigDecimal; 23 | 24 | 25 | 26 | /** 27 | *28 | * Common interface for all Encryptors which receive a 29 | * BigDecimal (arbitrary precision) message and return a BigDecimal result. 30 | *
31 | *32 | * Important: The size of the result of encrypting a number, depending 33 | * on the algorithm, may be much bigger (in bytes) than the size of the 34 | * encrypted number itself. For example, encrypting a 4-byte integer can 35 | * result in an encrypted 16-byte number. This can lead the user into 36 | * problems if the encrypted values are to be stored and not enough room 37 | * has been provided. 38 | *
39 | * 40 | * @since 1.2 41 | * 42 | * @author Daniel Fernández 43 | * 44 | */ 45 | public interface BigDecimalEncryptor { 46 | 47 | 48 | /** 49 | * Encrypt the input message 50 | * 51 | * @param message the message to be encrypted 52 | * @return the result of encryption 53 | */ 54 | public BigDecimal encrypt(BigDecimal message); 55 | 56 | 57 | /** 58 | * Decrypt an encrypted message 59 | * 60 | * @param encryptedMessage the encrypted message to be decrypted 61 | * @return the result of decryption 62 | */ 63 | public BigDecimal decrypt(BigDecimal encryptedMessage); 64 | 65 | } 66 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/BigIntegerEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption; 21 | 22 | import java.math.BigInteger; 23 | 24 | 25 | /** 26 | *27 | * Common interface for all Encryptors which receive a 28 | * BigInteger (arbitrary precision) message and return a BigInteger result. 29 | *
30 | *31 | * Important: The size of the result of encrypting a number, depending 32 | * on the algorithm, may be much bigger (in bytes) than the size of the 33 | * encrypted number itself. For example, encrypting a 4-byte integer can 34 | * result in an encrypted 16-byte number. This can lead the user into 35 | * problems if the encrypted values are to be stored and not enough room 36 | * has been provided. 37 | *
38 | * 39 | * @since 1.2 40 | * 41 | * @author Daniel Fernández 42 | * 43 | */ 44 | public interface BigIntegerEncryptor { 45 | 46 | 47 | /** 48 | * Encrypt the input message 49 | * 50 | * @param message the message to be encrypted 51 | * @return the result of encryption 52 | */ 53 | public BigInteger encrypt(BigInteger message); 54 | 55 | 56 | /** 57 | * Decrypt an encrypted message 58 | * 59 | * @param encryptedMessage the encrypted message to be decrypted 60 | * @return the result of decryption 61 | */ 62 | public BigInteger decrypt(BigInteger encryptedMessage); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/ByteEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption; 21 | 22 | /** 23 | *24 | * Common interface for all Encryptors which receive a 25 | * byte array message and return a byte array result. 26 | *
27 | * 28 | * @since 1.0 29 | * 30 | * @author Daniel Fernández 31 | * 32 | */ 33 | public interface ByteEncryptor { 34 | 35 | 36 | /** 37 | * Encrypt the input message 38 | * 39 | * @param message the message to be encrypted 40 | * @return the result of encryption 41 | */ 42 | public byte[] encrypt(byte[] message); 43 | 44 | /** 45 | * Decrypt an encrypted message 46 | * 47 | * @param encryptedMessage the encrypted message to be decrypted 48 | * @return the result of decryption 49 | */ 50 | public byte[] decrypt(byte[] encryptedMessage); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/StringEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption; 21 | 22 | 23 | /** 24 | *25 | * Common interface for all Encryptors which receive a 26 | * String message and return a String result. 27 | *
28 | * 29 | * @since 1.0 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public interface StringEncryptor { 35 | 36 | 37 | /** 38 | * Encrypt the input message 39 | * 40 | * @param message the message to be encrypted 41 | * @return the result of encryption 42 | */ 43 | public String encrypt(String message); 44 | 45 | 46 | /** 47 | * Decrypt an encrypted message 48 | * 49 | * @param encryptedMessage the encrypted message to be decrypted 50 | * @return the result of decryption 51 | */ 52 | public String decrypt(String encryptedMessage); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/CleanablePasswordBased.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | /** 23 | *24 | * Common interface for all entities which can be set a password in char[] shape, 25 | * which can be cleaned once the encryptor is initialized so that no immutable 26 | * Strings containing the password are left in memory. 27 | *
28 | * 29 | * @since 1.8 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public interface CleanablePasswordBased extends PasswordBased { 35 | 36 | /** 37 | *38 | * Sets a password to be used by the encryptor, as a (cleanable) char[]. 39 | *
40 | * 41 | * @since 1.8 42 | * 43 | * @param password the password to be used. 44 | */ 45 | public void setPasswordCharArray(char[] password); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEBigDecimalCleanablePasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | /** 24 | *25 | * Common interface for all Password Based Encryptors which receive a 26 | * BigDecimal message and return a BigDecimal result, and provide means 27 | * to set passwords as cleanable char[] objects (instead of 28 | * immutable Strings). 29 | *
30 | *31 | * Important: The size of the result of encrypting a number, depending 32 | * on the algorithm, may be much bigger (in bytes) than the size of the 33 | * encrypted number itself. For example, encrypting a 4-byte integer can 34 | * result in an encrypted 16-byte number. This can lead the user into 35 | * problems if the encrypted values are to be stored and not enough room 36 | * has been provided. 37 | *
38 | *39 | * For a default implementation, see {@link StandardPBEBigDecimalEncryptor}. 40 | *
41 | * 42 | * @since 1.8 43 | * 44 | * @author Daniel Fernández 45 | * 46 | */ 47 | public interface PBEBigDecimalCleanablePasswordEncryptor 48 | extends PBEBigDecimalEncryptor, CleanablePasswordBased { 49 | 50 | // aggregator interface 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEBigDecimalEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.jasypt.encryption.BigDecimalEncryptor; 23 | 24 | /** 25 | *26 | * Common interface for all Password Based Encryptors which receive a 27 | * BigDecimal message and return a BigDecimal result. 28 | *
29 | *30 | * Important: The size of the result of encrypting a number, depending 31 | * on the algorithm, may be much bigger (in bytes) than the size of the 32 | * encrypted number itself. For example, encrypting a 4-byte integer can 33 | * result in an encrypted 16-byte number. This can lead the user into 34 | * problems if the encrypted values are to be stored and not enough room 35 | * has been provided. 36 | *
37 | *38 | * For a default implementation, see {@link StandardPBEBigDecimalEncryptor}. 39 | *
40 | * 41 | * @since 1.2 42 | * 43 | * @author Daniel Fernández 44 | * 45 | */ 46 | public interface PBEBigDecimalEncryptor 47 | extends BigDecimalEncryptor, PasswordBased { 48 | 49 | // aggregator interface 50 | 51 | } 52 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEBigIntegerCleanablePasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | /** 24 | *25 | * Common interface for all Password Based Encryptors which receive a BigInteger 26 | * message and return a BigInteger result, and provide means 27 | * to set passwords as cleanable char[] objects (instead of 28 | * immutable Strings). 29 | *
30 | *31 | * Important: The size of the result of encrypting a number, depending 32 | * on the algorithm, may be much bigger (in bytes) than the size of the 33 | * encrypted number itself. For example, encrypting a 4-byte integer can result 34 | * in an encrypted 16-byte number. This can lead the user into problems if the 35 | * encrypted values are to be stored and not enough room has been provided. 36 | *
37 | *38 | * For a default implementation, see {@link StandardPBEBigIntegerEncryptor}. 39 | *
40 | * 41 | * @since 1.8 42 | * 43 | * @author Daniel Fernández 44 | * 45 | */ 46 | public interface PBEBigIntegerCleanablePasswordEncryptor 47 | extends PBEBigIntegerEncryptor, CleanablePasswordBased { 48 | 49 | // aggregator interface 50 | 51 | } 52 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEBigIntegerEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.jasypt.encryption.BigIntegerEncryptor; 23 | 24 | /** 25 | *26 | * Common interface for all Password Based Encryptors which receive a BigInteger 27 | * message and return a BigInteger result. 28 | *
29 | *30 | * Important: The size of the result of encrypting a number, depending 31 | * on the algorithm, may be much bigger (in bytes) than the size of the 32 | * encrypted number itself. For example, encrypting a 4-byte integer can result 33 | * in an encrypted 16-byte number. This can lead the user into problems if the 34 | * encrypted values are to be stored and not enough room has been provided. 35 | *
36 | *37 | * For a default implementation, see {@link StandardPBEBigIntegerEncryptor}. 38 | *
39 | * 40 | * @since 1.2 41 | * 42 | * @author Daniel Fernández 43 | * 44 | */ 45 | public interface PBEBigIntegerEncryptor 46 | extends BigIntegerEncryptor, PasswordBased { 47 | 48 | // aggregator interface 49 | 50 | } 51 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEByteCleanablePasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | /** 24 | *25 | * Common interface for all Password Based Encryptors which receive a 26 | * byte array message and return a byte array result, and provide means 27 | * to set passwords as cleanable char[] objects (instead of 28 | * immutable Strings). 29 | *
30 | *31 | * For a default implementation, see {@link StandardPBEByteEncryptor}. 32 | *
33 | * 34 | * @since 1.8 35 | * 36 | * @author Daniel Fernández 37 | * 38 | */ 39 | public interface PBEByteCleanablePasswordEncryptor extends PBEByteEncryptor, CleanablePasswordBased { 40 | 41 | // aggregator interface 42 | 43 | } 44 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEByteEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.jasypt.encryption.ByteEncryptor; 23 | 24 | /** 25 | *26 | * Common interface for all Password Based Encryptors which receive a 27 | * byte array message and return a byte array result. 28 | *
29 | *30 | * For a default implementation, see {@link StandardPBEByteEncryptor}. 31 | *
32 | * 33 | * @since 1.0 34 | * 35 | * @author Daniel Fernández 36 | * 37 | */ 38 | public interface PBEByteEncryptor extends ByteEncryptor, PasswordBased { 39 | 40 | // aggregator interface 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEStringCleanablePasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | /** 24 | *25 | * Common interface for all Password Based Encryptors which receive a 26 | * String message and return a String result, and provide means 27 | * to set passwords as cleanable char[] objects (instead of 28 | * immutable Strings). 29 | *
30 | * For a default implementation, see {@link StandardPBEStringEncryptor}. 31 | *
32 | * 33 | * @since 1.8 34 | * 35 | * @author Daniel Fernández 36 | * 37 | */ 38 | public interface PBEStringCleanablePasswordEncryptor extends PBEStringEncryptor, CleanablePasswordBased { 39 | 40 | // aggregator interface 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PBEStringEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.jasypt.encryption.StringEncryptor; 23 | 24 | /** 25 | *26 | * Common interface for all Password Based Encryptors which receive a 27 | * String message and return a String result. 28 | *
29 | *30 | * For a default implementation, see {@link StandardPBEStringEncryptor}. 31 | *
32 | * 33 | * @since 1.0 34 | * 35 | * @author Daniel Fernández 36 | * 37 | */ 38 | public interface PBEStringEncryptor extends StringEncryptor, PasswordBased { 39 | 40 | // aggregator interface 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/PasswordBased.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | /** 23 | *24 | * Common interface for all entities which can be set a password. 25 | *
26 | * 27 | * @since 1.3 28 | * 29 | * @author Daniel Fernández 30 | * 31 | */ 32 | public interface PasswordBased { 33 | 34 | /** 35 | *36 | * Sets a password to be used by the encryptor. 37 | *
38 | * 39 | * @param password the password to be used. 40 | */ 41 | public void setPassword(String password); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/encryption/pbe/config/PBECleanablePasswordConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe.config; 21 | 22 | 23 | 24 | /** 25 | *26 | * Common interface for all PBEConfig implementations that store passwords as char[] instead 27 | * of String and also allow this passwords to be set as char[] instead of Strings. 28 | *
29 | * 30 | * @since 1.8 31 | * 32 | * @author Daniel Fernández 33 | * 34 | */ 35 | public interface PBECleanablePasswordConfig { 36 | 37 | 38 | /** 39 | *40 | * Return the password set, as a char array. 41 | *
42 | *43 | * Important: the returned array MUST BE A COPY of the one 44 | * stored in the configuration object. The caller of 45 | * this method is therefore be responsible for cleaning this 46 | * resulting char[]. 47 | *
48 | * 49 | * @since 1.8 50 | * 51 | */ 52 | public char[] getPasswordCharArray(); 53 | 54 | /** 55 | *56 | * Clean the password stored in this configuration object. 57 | *
58 | *59 | * A common implementation of this cleaning operation consists of 60 | * iterating the array of chars and setting each of its positions to (char)0. 61 | *
62 | * 63 | * @since 1.8 64 | * 65 | */ 66 | public void cleanPassword(); 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/exceptions/AlreadyInitializedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.exceptions; 21 | 22 | 23 | /** 24 | * Exception thrown when an attempt is made to change the configuration 25 | * of an entity once it has been initialized. 26 | * 27 | * 28 | * @since 1.0 29 | * 30 | * @author Daniel Fernández 31 | * 32 | */ 33 | public final class AlreadyInitializedException extends RuntimeException { 34 | 35 | private static final long serialVersionUID = 4592515503937873874L; 36 | 37 | public AlreadyInitializedException() { 38 | super("Encryption entity already initialized"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/exceptions/EncryptionInitializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.exceptions; 21 | 22 | /** 23 | * Exception thrown when an error is raised during initialization of 24 | * an entity. 25 | * 26 | * @since 1.0 27 | * 28 | * @author Daniel Fernández 29 | * 30 | */ 31 | public final class EncryptionInitializationException extends RuntimeException { 32 | 33 | private static final long serialVersionUID = 8929638240023639778L; 34 | 35 | public EncryptionInitializationException() { 36 | super(); 37 | } 38 | 39 | public EncryptionInitializationException(final Throwable t) { 40 | super(t); 41 | } 42 | 43 | public EncryptionInitializationException(final String msg, final Throwable t) { 44 | super(msg, t); 45 | } 46 | 47 | public EncryptionInitializationException(final String msg) { 48 | super(msg); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/exceptions/EncryptionOperationNotPossibleException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.exceptions; 21 | 22 | 23 | /** 24 | *25 | * General exception thrown when any errors are raised during encryption, 26 | * digesting, etc. 27 | *
28 | *29 | * It is intended to provide very little information (if any) of the error 30 | * causes, so that encryption internals are not revealed through error 31 | * messages. 32 | *
33 | * 34 | * @since 1.0 35 | * 36 | * @author Daniel Fernández 37 | * 38 | */ 39 | public final class EncryptionOperationNotPossibleException extends RuntimeException { 40 | 41 | private static final long serialVersionUID = 6304674109588715145L; 42 | 43 | public EncryptionOperationNotPossibleException() { 44 | super(); 45 | } 46 | 47 | public EncryptionOperationNotPossibleException(final Throwable t) { 48 | super(t); 49 | } 50 | 51 | public EncryptionOperationNotPossibleException(final String message) { 52 | super(message); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/exceptions/PasswordAlreadyCleanedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.exceptions; 21 | 22 | 23 | /** 24 | * Exception thrown when an attempt is made to access the configured 25 | * password of an encryptor when this password has already been 26 | * cleaned (so that it appears no more as an immutable String in memory). 27 | * 28 | * 29 | * @since 1.8 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public final class PasswordAlreadyCleanedException extends RuntimeException { 35 | 36 | private static final long serialVersionUID = 7988484935273871733L; 37 | 38 | public PasswordAlreadyCleanedException() { 39 | super("Password already cleaned: The encryptor that uses this password has " + 40 | "already been initialized and therefore this password has been cleaned so "+ 41 | "that it is no more present in memory. An exception has been raised when accessing " + 42 | "this property in order to avoid inconsistencies. A possible reason for this error " + 43 | "is that you are using the same PBEConfig object to configure two different " + 44 | "PBE encryptor instances."); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/intf/cli/AlgorithmRegistryCLI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.intf.cli; 21 | 22 | import java.util.Set; 23 | 24 | import org.jasypt.registry.AlgorithmRegistry; 25 | 26 | 27 | /** 28 | *29 | * This class supports the CLI "listAlgorithms" operation. 30 | *
31 | *32 | * It should NEVER be used inside your code, only from the supplied 33 | * command-line tools. 34 | *
35 | * 36 | * @since 1.7 37 | * 38 | * @author Daniel Fernández 39 | * 40 | */ 41 | public final class AlgorithmRegistryCLI { 42 | 43 | 44 | /** 45 | *46 | * CLI execution method. 47 | *
48 | * 49 | * @param args the command execution arguments 50 | */ 51 | public static void main(final String[] args) { 52 | 53 | try { 54 | 55 | final Set digestAlgos = AlgorithmRegistry.getAllDigestAlgorithms(); 56 | final Set pbeAlgos = AlgorithmRegistry.getAllPBEAlgorithms(); 57 | 58 | System.out.println(); 59 | System.out.println("DIGEST ALGORITHMS: " + digestAlgos); 60 | System.out.println(); 61 | System.out.println("PBE ALGORITHMS: " + pbeAlgos); 62 | System.out.println(); 63 | 64 | } catch (Throwable t) { 65 | t.printStackTrace(System.err); 66 | } 67 | 68 | } 69 | 70 | 71 | 72 | /* 73 | * Instantiation is forbidden. 74 | */ 75 | private AlgorithmRegistryCLI() { 76 | super(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/salt/FixedSaltGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.salt; 21 | 22 | 23 | /** 24 | *25 | * Marker interface for all implementations of {@link SaltGenerator} that 26 | * will always return the same salt (for the same amount of bytes asked). 27 | *
28 | *29 | * Use of this interface in salt generators enables encryptors to perform 30 | * some performance optimizations whenever they are used. 31 | *
32 | * 33 | * @since 1.9.2 34 | * 35 | * @author Daniel Fernández 36 | * 37 | */ 38 | public interface FixedSaltGenerator extends SaltGenerator { 39 | 40 | // Marker interface - no methods added 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/salt/ZeroSaltGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.salt; 21 | 22 | import java.util.Arrays; 23 | 24 | 25 | /** 26 | *27 | * This implementation of {@link SaltGenerator} always returns a salt 28 | * of the required length, filled with zero bytes. 29 | *
30 | *31 | * This class is thread-safe. 32 | *
33 | * 34 | * @since 1.4 35 | * 36 | * @author Daniel Fernández 37 | * 38 | */ 39 | public class ZeroSaltGenerator implements SaltGenerator { 40 | 41 | /** 42 | * Creates a new instance of ZeroSaltGenerator 43 | * 44 | */ 45 | public ZeroSaltGenerator() { 46 | super(); 47 | } 48 | 49 | 50 | /** 51 | * Return salt with the specified byte length. This will return 52 | * an array of zero bytes, with the specified length. 53 | * 54 | * @param lengthBytes length in bytes. 55 | * @return the generated salt. 56 | */ 57 | public byte[] generateSalt(final int lengthBytes) { 58 | final byte[] result = new byte[lengthBytes]; 59 | Arrays.fill(result, (byte)0); 60 | return result; 61 | } 62 | 63 | 64 | /** 65 | * As this salt generator provides a predictable salt, its inclusion 66 | * unencrypted in encryption results 67 | * is not necessary, and in fact not desirable (so that it remains hidden). 68 | * 69 | * @return false 70 | */ 71 | public boolean includePlainSaltInEncryptionResults() { 72 | return false; 73 | } 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/util/binary/BinaryEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.binary; 21 | 22 | 23 | 24 | /** 25 | *26 | * Common interface for all util classes aimed at binary encryption 27 | *
28 | * 29 | * @since 1.2 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public interface BinaryEncryptor { 35 | 36 | 37 | /** 38 | * Encrypts a byte array 39 | * 40 | * @param binary the byte array to be encrypted. 41 | */ 42 | public byte[] encrypt(byte[] binary); 43 | 44 | 45 | /** 46 | * Decrypts a byte array. 47 | * 48 | * @param encryptedBinary the byte array to be decrypted. 49 | */ 50 | public byte[] decrypt(byte[] encryptedBinary); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/util/numeric/DecimalNumberEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.numeric; 21 | 22 | import java.math.BigDecimal; 23 | 24 | /** 25 | *26 | * Common interface for all util classes aimed at decimal number encryption. 27 | *
28 | * 29 | * @since 1.2 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public interface DecimalNumberEncryptor { 35 | 36 | 37 | /** 38 | * Encrypts a BigDecimal 39 | * 40 | * @param number the number to be encrypted. 41 | */ 42 | public BigDecimal encrypt(BigDecimal number); 43 | 44 | 45 | /** 46 | * Decrypts a BigDecimal. 47 | * 48 | * @param encryptedNumber the number to be decrypted. 49 | */ 50 | public BigDecimal decrypt(BigDecimal encryptedNumber); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/util/numeric/IntegerNumberEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.numeric; 21 | 22 | import java.math.BigInteger; 23 | 24 | /** 25 | *26 | * Common interface for all util classes aimed at integer number encryption. 27 | *
28 | * 29 | * @since 1.2 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public interface IntegerNumberEncryptor { 35 | 36 | 37 | /** 38 | * Encrypts a BigInteger 39 | * 40 | * @param number the number to be encrypted. 41 | */ 42 | public BigInteger encrypt(BigInteger number); 43 | 44 | 45 | /** 46 | * Decrypts a BigInteger. 47 | * 48 | * @param encryptedNumber the number to be decrypted. 49 | */ 50 | public BigInteger decrypt(BigInteger encryptedNumber); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/util/password/PasswordEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.password; 21 | 22 | 23 | 24 | 25 | /** 26 | *27 | * Common interface for all util classes aimed at password encryption. 28 | *
29 | * 30 | * @since 1.2 31 | * 32 | * @author Daniel Fernández 33 | * 34 | */ 35 | public interface PasswordEncryptor { 36 | 37 | 38 | /** 39 | * Encrypts (digests) a password. 40 | * 41 | * @param password the password to be encrypted. 42 | * @return the resulting digest. 43 | */ 44 | public String encryptPassword(String password); 45 | 46 | 47 | /** 48 | * Checks an unencrypted (plain) password against an encrypted one 49 | * (a digest) to see if they match. 50 | * 51 | * @param plainPassword the plain password to check. 52 | * @param encryptedPassword the digest against which to check the password. 53 | * @return true if passwords match, false if not. 54 | */ 55 | public boolean checkPassword(String plainPassword, 56 | String encryptedPassword); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /jasypt/src/main/java/org/jasypt/util/text/TextEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.text; 21 | 22 | 23 | 24 | /** 25 | *26 | * Common interface for all util classes aimed at text encryption 27 | *
28 | * 29 | * @since 1.2 30 | * 31 | * @author Daniel Fernández 32 | * 33 | */ 34 | public interface TextEncryptor { 35 | 36 | 37 | /** 38 | * Encrypts a message. 39 | * 40 | * @param message the message to be encrypted. 41 | */ 42 | public String encrypt(String message); 43 | 44 | 45 | /** 46 | * Decrypts a message. 47 | * 48 | * @param encryptedMessage the message to be decrypted. 49 | */ 50 | public String decrypt(String encryptedMessage); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderBigDecimalEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 23 | 24 | 25 | public class BouncyCastleByProviderBigDecimalEncryptorTest 26 | extends AbstractPBEBigDecimalEncryptorTest { 27 | 28 | 29 | protected PBEBigDecimalEncryptor createPBEDecimalEncryptor() { 30 | StandardPBEBigDecimalEncryptor encryptor = new StandardPBEBigDecimalEncryptor(); 31 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 32 | encryptor.setProvider(new BouncyCastleProvider()); 33 | return encryptor; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderBigIntegerEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 23 | 24 | 25 | public class BouncyCastleByProviderBigIntegerEncryptorTest 26 | extends AbstractPBEBigIntegerEncryptorTest { 27 | 28 | 29 | protected PBEBigIntegerEncryptor createPBEIntegerEncryptor() { 30 | StandardPBEBigIntegerEncryptor encryptor = new StandardPBEBigIntegerEncryptor(); 31 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 32 | encryptor.setProvider(new BouncyCastleProvider()); 33 | return encryptor; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderByteEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 23 | 24 | 25 | public class BouncyCastleByProviderByteEncryptorTest 26 | extends AbstractPBEByteEncryptorTest { 27 | 28 | 29 | protected StandardPBEByteEncryptor createPBEByteEncryptor() { 30 | StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); 31 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 32 | encryptor.setProvider(new BouncyCastleProvider()); 33 | return encryptor; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderNameBigDecimalEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import java.security.Security; 23 | 24 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 25 | 26 | 27 | public class BouncyCastleByProviderNameBigDecimalEncryptorTest 28 | extends AbstractPBEBigDecimalEncryptorTest { 29 | 30 | protected void setUp() throws Exception { 31 | super.setUp(); 32 | Security.addProvider(new BouncyCastleProvider()); 33 | } 34 | 35 | protected PBEBigDecimalEncryptor createPBEDecimalEncryptor() { 36 | StandardPBEBigDecimalEncryptor encryptor = new StandardPBEBigDecimalEncryptor(); 37 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 38 | encryptor.setProviderName("BC"); 39 | return encryptor; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderNameBigIntegerEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import java.security.Security; 23 | 24 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 25 | 26 | 27 | public class BouncyCastleByProviderNameBigIntegerEncryptorTest 28 | extends AbstractPBEBigIntegerEncryptorTest { 29 | 30 | protected void setUp() throws Exception { 31 | super.setUp(); 32 | Security.addProvider(new BouncyCastleProvider()); 33 | } 34 | 35 | protected PBEBigIntegerEncryptor createPBEIntegerEncryptor() { 36 | StandardPBEBigIntegerEncryptor encryptor = new StandardPBEBigIntegerEncryptor(); 37 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 38 | encryptor.setProviderName("BC"); 39 | return encryptor; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderNameByteEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import java.security.Security; 23 | 24 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 25 | 26 | 27 | public class BouncyCastleByProviderNameByteEncryptorTest 28 | extends AbstractPBEByteEncryptorTest { 29 | 30 | protected void setUp() throws Exception { 31 | super.setUp(); 32 | Security.addProvider(new BouncyCastleProvider()); 33 | } 34 | 35 | protected StandardPBEByteEncryptor createPBEByteEncryptor() { 36 | StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); 37 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 38 | encryptor.setProviderName("BC"); 39 | return encryptor; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderNameStringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import java.security.Security; 23 | 24 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 25 | 26 | 27 | public class BouncyCastleByProviderNameStringEncryptorTest 28 | extends AbstractPBEStringEncryptorTest { 29 | 30 | protected void setUp() throws Exception { 31 | super.setUp(); 32 | Security.addProvider(new BouncyCastleProvider()); 33 | } 34 | 35 | protected PBEStringEncryptor createPBEStringEncryptor() { 36 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 37 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 38 | encryptor.setProviderName("BC"); 39 | return encryptor; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/BouncyCastleByProviderStringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | import org.bouncycastle.jce.provider.BouncyCastleProvider; 23 | 24 | 25 | public class BouncyCastleByProviderStringEncryptorTest 26 | extends AbstractPBEStringEncryptorTest { 27 | 28 | 29 | protected PBEStringEncryptor createPBEStringEncryptor() { 30 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 31 | encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC"); 32 | encryptor.setProvider(new BouncyCastleProvider()); 33 | return encryptor; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/HexadecimalPBEWithMD5AndDESStringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class HexadecimalPBEWithMD5AndDESStringEncryptorTest 25 | extends AbstractPBEStringEncryptorTest { 26 | 27 | protected PBEStringEncryptor createPBEStringEncryptor() { 28 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndDES"); 30 | encryptor.setStringOutputType("hex"); 31 | return encryptor; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndDESBigDecimalEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndDESBigDecimalEncryptorTest 25 | extends AbstractPBEBigDecimalEncryptorTest { 26 | 27 | protected PBEBigDecimalEncryptor createPBEDecimalEncryptor() { 28 | StandardPBEBigDecimalEncryptor encryptor = new StandardPBEBigDecimalEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndDES"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndDESBigIntegerEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndDESBigIntegerEncryptorTest 25 | extends AbstractPBEBigIntegerEncryptorTest { 26 | 27 | protected PBEBigIntegerEncryptor createPBEIntegerEncryptor() { 28 | StandardPBEBigIntegerEncryptor encryptor = new StandardPBEBigIntegerEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndDES"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndDESByteEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | public class PBEWithMD5AndDESByteEncryptorTest 24 | extends AbstractPBEByteEncryptorTest { 25 | 26 | protected StandardPBEByteEncryptor createPBEByteEncryptor() { 27 | StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); 28 | encryptor.setAlgorithm("PBEWithMD5AndDES"); 29 | return encryptor; 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndDESStringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndDESStringEncryptorTest 25 | extends AbstractPBEStringEncryptorTest { 26 | 27 | protected PBEStringEncryptor createPBEStringEncryptor() { 28 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndDES"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndDESStringEncryptorThreadedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | 25 | public class PBEWithMD5AndDESStringEncryptorThreadedTest 26 | extends AbstractPBEStringEncryptorThreadedTest { 27 | 28 | protected PBEStringEncryptor createEncryptor() { 29 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 30 | encryptor.setAlgorithm("PBEWithMD5AndDES"); 31 | return encryptor; 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndTripleDESBigDecimalEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndTripleDESBigDecimalEncryptorTest 25 | extends AbstractPBEBigDecimalEncryptorTest { 26 | 27 | protected PBEBigDecimalEncryptor createPBEDecimalEncryptor() { 28 | StandardPBEBigDecimalEncryptor encryptor = new StandardPBEBigDecimalEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndTripleDESBigIntegerEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndTripleDESBigIntegerEncryptorTest 25 | extends AbstractPBEBigIntegerEncryptorTest { 26 | 27 | protected PBEBigIntegerEncryptor createPBEIntegerEncryptor() { 28 | StandardPBEBigIntegerEncryptor encryptor = new StandardPBEBigIntegerEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndTripleDESByteEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndTripleDESByteEncryptorTest 25 | extends AbstractPBEByteEncryptorTest { 26 | 27 | protected StandardPBEByteEncryptor createPBEByteEncryptor() { 28 | StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithMD5AndTripleDESStringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithMD5AndTripleDESStringEncryptorTest 25 | extends AbstractPBEStringEncryptorTest { 26 | 27 | protected PBEStringEncryptor createPBEStringEncryptor() { 28 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 29 | encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); 30 | return encryptor; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndDESedeBigDecimalEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndDESedeBigDecimalEncryptorTest 25 | extends AbstractPBEBigDecimalEncryptorTest { 26 | 27 | protected PBEBigDecimalEncryptor createPBEDecimalEncryptor() { 28 | StandardPBEBigDecimalEncryptor encryptor = new StandardPBEBigDecimalEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndDESede"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndDESedeBigIntegerEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndDESedeBigIntegerEncryptorTest 25 | extends AbstractPBEBigIntegerEncryptorTest { 26 | 27 | protected PBEBigIntegerEncryptor createPBEIntegerEncryptor() { 28 | StandardPBEBigIntegerEncryptor encryptor = new StandardPBEBigIntegerEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndDESede"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndDESedeByteEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndDESedeByteEncryptorTest 25 | extends AbstractPBEByteEncryptorTest { 26 | 27 | protected StandardPBEByteEncryptor createPBEByteEncryptor() { 28 | StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndDESede"); 30 | return encryptor; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndDESedeStringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndDESedeStringEncryptorTest 25 | extends AbstractPBEStringEncryptorTest { 26 | 27 | protected PBEStringEncryptor createPBEStringEncryptor() { 28 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndDESede"); 30 | return encryptor; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndRC2_40BigDecimalEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndRC2_40BigDecimalEncryptorTest 25 | extends AbstractPBEBigDecimalEncryptorTest { 26 | 27 | protected PBEBigDecimalEncryptor createPBEDecimalEncryptor() { 28 | StandardPBEBigDecimalEncryptor encryptor = new StandardPBEBigDecimalEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndRC2_40"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndRC2_40BigIntegerEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndRC2_40BigIntegerEncryptorTest 25 | extends AbstractPBEBigIntegerEncryptorTest { 26 | 27 | protected PBEBigIntegerEncryptor createPBEIntegerEncryptor() { 28 | StandardPBEBigIntegerEncryptor encryptor = new StandardPBEBigIntegerEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndRC2_40"); 30 | return encryptor; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndRC2_40ByteEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndRC2_40ByteEncryptorTest 25 | extends AbstractPBEByteEncryptorTest { 26 | 27 | protected StandardPBEByteEncryptor createPBEByteEncryptor() { 28 | StandardPBEByteEncryptor encryptor = new StandardPBEByteEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndRC2_40"); 30 | return encryptor; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/encryption/pbe/PBEWithSHA1AndRC2_40StringEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.encryption.pbe; 21 | 22 | 23 | 24 | public class PBEWithSHA1AndRC2_40StringEncryptorTest 25 | extends AbstractPBEStringEncryptorTest { 26 | 27 | protected PBEStringEncryptor createPBEStringEncryptor() { 28 | StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); 29 | encryptor.setAlgorithm("PBEWithSHA1AndRC2_40"); 30 | return encryptor; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/normalization/NormalizationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.normalization; 21 | 22 | import junit.framework.Assert; 23 | import junit.framework.TestCase; 24 | 25 | public class NormalizationTest extends TestCase { 26 | 27 | 28 | public void testNormalizationEquivalence() throws Exception { 29 | 30 | org.jasypt.normalization.Normalizer.initializeIcu4j(); 31 | 32 | boolean executeJavaTextNorm = true; 33 | try { 34 | // Tests might not be executed in Java >= 6 35 | org.jasypt.normalization.Normalizer.initializeJavaTextNormalizer(); 36 | } catch (final Exception e) { 37 | executeJavaTextNorm = false; 38 | } 39 | 40 | 41 | final String msg = "ÁÉÍÓÚÀÈÌÒÙÄËÏÖÜÂÊÎÔÛÑÇÆÅßÐáéíóúàèìòùäëïöüâêîôûnçæåÞØÕÃāăþőŏœűŁňć"; 42 | final char[] msgCharArray = msg.toCharArray(); 43 | 44 | String norm1 = com.ibm.icu.text.Normalizer.normalize(msg, com.ibm.icu.text.Normalizer.NFC); 45 | String norm2 = new String(org.jasypt.normalization.Normalizer.normalizeWithIcu4j(msgCharArray)); 46 | String norm3 = (executeJavaTextNorm? new String(org.jasypt.normalization.Normalizer.normalizeWithJavaNormalizer(msgCharArray)) : null); 47 | 48 | Assert.assertEquals(norm1, norm2); 49 | if (executeJavaTextNorm) { 50 | Assert.assertEquals(norm2, norm3); 51 | } 52 | 53 | } 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/util/binary/BasicBinaryEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.binary; 21 | 22 | 23 | import java.util.Arrays; 24 | 25 | import junit.framework.TestCase; 26 | 27 | public class BasicBinaryEncryptorTest extends TestCase { 28 | 29 | 30 | 31 | public void testEncrypt() throws Exception { 32 | 33 | byte[] message = "This is a Message".getBytes(); 34 | String password = "APASSWORD"; 35 | 36 | BasicBinaryEncryptor textEncryptor = new BasicBinaryEncryptor(); 37 | textEncryptor.setPassword(password); 38 | 39 | for (int i = 0; i < 100; i++) { 40 | byte[] encryptedMessage = textEncryptor.encrypt(message); 41 | assertTrue(Arrays.equals(textEncryptor.decrypt(encryptedMessage), message)); 42 | } 43 | 44 | BasicBinaryEncryptor textEncryptor2 = new BasicBinaryEncryptor(); 45 | textEncryptor2.setPassword(password); 46 | for (int i = 0; i < 100; i++) { 47 | byte[] encryptedMessage = textEncryptor.encrypt(message); 48 | assertTrue(Arrays.equals(textEncryptor2.decrypt(encryptedMessage), message)); 49 | } 50 | 51 | for (int i = 0; i < 100; i++) { 52 | assertFalse(Arrays.equals( 53 | textEncryptor.encrypt(message), 54 | textEncryptor.encrypt(message))); 55 | } 56 | 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/util/binary/StrongBinaryEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.binary; 21 | 22 | 23 | import java.util.Arrays; 24 | 25 | import junit.framework.TestCase; 26 | 27 | public class StrongBinaryEncryptorTest extends TestCase { 28 | 29 | 30 | 31 | public void testEncrypt() throws Exception { 32 | 33 | byte[] message = "This is a Message".getBytes(); 34 | String password = "APASSWORD"; 35 | 36 | StrongBinaryEncryptor textEncryptor = new StrongBinaryEncryptor(); 37 | textEncryptor.setPassword(password); 38 | 39 | for (int i = 0; i < 100; i++) { 40 | byte[] encryptedMessage = textEncryptor.encrypt(message); 41 | assertTrue(Arrays.equals(textEncryptor.decrypt(encryptedMessage), message)); 42 | } 43 | 44 | StrongBinaryEncryptor textEncryptor2 = new StrongBinaryEncryptor(); 45 | textEncryptor2.setPassword(password); 46 | for (int i = 0; i < 100; i++) { 47 | byte[] encryptedMessage = textEncryptor.encrypt(message); 48 | assertTrue(Arrays.equals(textEncryptor2.decrypt(encryptedMessage), message)); 49 | } 50 | 51 | for (int i = 0; i < 100; i++) { 52 | assertFalse(Arrays.equals( 53 | textEncryptor.encrypt(message), 54 | textEncryptor.encrypt(message))); 55 | } 56 | 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/util/numeric/BasicDecimalNumberEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.numeric; 21 | 22 | 23 | import java.math.BigDecimal; 24 | 25 | import junit.framework.TestCase; 26 | 27 | public class BasicDecimalNumberEncryptorTest extends TestCase { 28 | 29 | 30 | 31 | public void testEncrypt() throws Exception { 32 | 33 | BigDecimal message = BigDecimal.valueOf(-12321318473812923.2131928700009987123); 34 | String password = "A PASSWORD1234"; 35 | 36 | BasicDecimalNumberEncryptor encryptor = new BasicDecimalNumberEncryptor(); 37 | encryptor.setPassword(password); 38 | 39 | for (int i = 0; i < 100; i++) { 40 | BigDecimal encryptedMessage = encryptor.encrypt(message); 41 | assertTrue(encryptor.decrypt(encryptedMessage).equals(message)); 42 | } 43 | 44 | BasicDecimalNumberEncryptor textEncryptor2 = new BasicDecimalNumberEncryptor(); 45 | textEncryptor2.setPassword(password); 46 | for (int i = 0; i < 100; i++) { 47 | BigDecimal encryptedMessage = encryptor.encrypt(message); 48 | assertTrue(textEncryptor2.decrypt(encryptedMessage).equals(message)); 49 | } 50 | 51 | for (int i = 0; i < 100; i++) { 52 | assertFalse(encryptor.encrypt(message).equals( 53 | encryptor.encrypt(message))); 54 | } 55 | 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/util/numeric/BasicIntegerNumberEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.numeric; 21 | 22 | 23 | import java.math.BigInteger; 24 | 25 | import junit.framework.TestCase; 26 | 27 | public class BasicIntegerNumberEncryptorTest extends TestCase { 28 | 29 | 30 | 31 | public void testEncrypt() throws Exception { 32 | 33 | BigInteger message = BigInteger.valueOf(-12321318473812923L); 34 | String password = "A PASSWORD1234"; 35 | 36 | BasicIntegerNumberEncryptor encryptor = new BasicIntegerNumberEncryptor(); 37 | encryptor.setPassword(password); 38 | 39 | for (int i = 0; i < 100; i++) { 40 | BigInteger encryptedMessage = encryptor.encrypt(message); 41 | assertTrue(encryptor.decrypt(encryptedMessage).equals(message)); 42 | } 43 | 44 | BasicIntegerNumberEncryptor textEncryptor2 = new BasicIntegerNumberEncryptor(); 45 | textEncryptor2.setPassword(password); 46 | for (int i = 0; i < 100; i++) { 47 | BigInteger encryptedMessage = encryptor.encrypt(message); 48 | assertTrue(textEncryptor2.decrypt(encryptedMessage).equals(message)); 49 | } 50 | 51 | for (int i = 0; i < 100; i++) { 52 | assertFalse(encryptor.encrypt(message).equals( 53 | encryptor.encrypt(message))); 54 | } 55 | 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/util/numeric/StrongDecimalNumberEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.numeric; 21 | 22 | 23 | import java.math.BigDecimal; 24 | 25 | import junit.framework.TestCase; 26 | 27 | public class StrongDecimalNumberEncryptorTest extends TestCase { 28 | 29 | 30 | 31 | public void testEncrypt() throws Exception { 32 | 33 | BigDecimal message = BigDecimal.valueOf(-12321318473812923.2131928700009987123); 34 | String password = "A PASSWORD1234"; 35 | 36 | StrongDecimalNumberEncryptor encryptor = new StrongDecimalNumberEncryptor(); 37 | encryptor.setPassword(password); 38 | 39 | for (int i = 0; i < 100; i++) { 40 | BigDecimal encryptedMessage = encryptor.encrypt(message); 41 | assertTrue(encryptor.decrypt(encryptedMessage).equals(message)); 42 | } 43 | 44 | StrongDecimalNumberEncryptor textEncryptor2 = new StrongDecimalNumberEncryptor(); 45 | textEncryptor2.setPassword(password); 46 | for (int i = 0; i < 100; i++) { 47 | BigDecimal encryptedMessage = encryptor.encrypt(message); 48 | assertTrue(textEncryptor2.decrypt(encryptedMessage).equals(message)); 49 | } 50 | 51 | for (int i = 0; i < 100; i++) { 52 | assertFalse(encryptor.encrypt(message).equals( 53 | encryptor.encrypt(message))); 54 | } 55 | 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jasypt/src/test/java/org/jasypt/util/numeric/StrongIntegerNumberEncryptorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ============================================================================= 3 | * 4 | * Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ============================================================================= 19 | */ 20 | package org.jasypt.util.numeric; 21 | 22 | 23 | import java.math.BigInteger; 24 | 25 | import junit.framework.TestCase; 26 | 27 | public class StrongIntegerNumberEncryptorTest extends TestCase { 28 | 29 | 30 | 31 | public void testEncrypt() throws Exception { 32 | 33 | BigInteger message = BigInteger.valueOf(-12321318473812923L); 34 | String password = "A PASSWORD1234"; 35 | 36 | StrongIntegerNumberEncryptor encryptor = new StrongIntegerNumberEncryptor(); 37 | encryptor.setPassword(password); 38 | 39 | for (int i = 0; i < 100; i++) { 40 | BigInteger encryptedMessage = encryptor.encrypt(message); 41 | assertTrue(encryptor.decrypt(encryptedMessage).equals(message)); 42 | } 43 | 44 | StrongIntegerNumberEncryptor textEncryptor2 = new StrongIntegerNumberEncryptor(); 45 | textEncryptor2.setPassword(password); 46 | for (int i = 0; i < 100; i++) { 47 | BigInteger encryptedMessage = encryptor.encrypt(message); 48 | assertTrue(textEncryptor2.decrypt(encryptedMessage).equals(message)); 49 | } 50 | 51 | for (int i = 0; i < 100; i++) { 52 | assertFalse(encryptor.encrypt(message).equals( 53 | encryptor.encrypt(message))); 54 | } 55 | 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /jasypt/src/test/resources/props.properties: -------------------------------------------------------------------------------- 1 | location.enc=ENC(v0z0uGQRucwfBau0e+gB6A\=\=) 2 | location.plain=Spain 3 | --------------------------------------------------------------------------------