1 /**
2 * Copyright 2005-2016 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.core.impl.encryption;
17
18 import javax.crypto.SecretKey;
19 import java.security.GeneralSecurityException;
20
21 /**
22 * Contract for an encryption strategy.
23 *
24 * Specifies what Cipher transformation to use for encryption (in the form algorithm/mode/padding), as well as being
25 * able to load a SecretKey.
26 */
27 public interface EncryptionStrategy {
28
29 /**
30 * Return a String value representing the transformation to use for encryption in the form "algorithm/mode/padding".
31 *
32 * @return the transformation to use for encryption
33 */
34 String getTransformation();
35
36 /**
37 * Loads the given raw key bytes into a {@link SecretKey} which is valid for the algorithm used by this encryption
38 * strategy.
39 *
40 * @param key the raw key to load
41 * @return the SecretKey object that was loaded from the given key
42 */
43 SecretKey loadSecretKey(byte[] key) throws GeneralSecurityException;
44
45 }