1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.core.impl.encryption;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.encryption.EncryptionService;
20
21 import java.security.GeneralSecurityException;
22
23 /**
24 * Implementation of encryption service for demonstration.
25 *
26 *
27 */
28 public class NoEncryptionEncryptionServiceImpl implements EncryptionService {
29
30 /**
31 * @see org.kuali.rice.ksb.security.EncryptionService#isEnabled()
32 */
33 public boolean isEnabled() {
34 return false;
35 }
36
37 public String encrypt(Object valueToHide) throws GeneralSecurityException {
38 if (valueToHide == null) {
39 return "";
40 }
41
42 return valueToHide.toString();
43 }
44
45 public String decrypt(String ciphertext) throws GeneralSecurityException {
46 if (StringUtils.isBlank(ciphertext)) {
47 return "";
48 }
49
50 return new String(ciphertext);
51 }
52
53 public String hash(Object valueToHide) throws GeneralSecurityException {
54 if ( valueToHide == null || StringUtils.isEmpty( valueToHide.toString() ) ) {
55 return "";
56 }
57 return valueToHide.toString();
58 }
59
60 /**
61 * This overridden method ...
62 *
63 * @see org.kuali.rice.core.api.encryption.EncryptionService#decryptBytes(byte[])
64 */
65 public byte[] decryptBytes(byte[] ciphertext)
66 throws GeneralSecurityException {
67 return ciphertext;
68 }
69
70 /**
71 * This overridden method ...
72 *
73 * @see org.kuali.rice.core.api.encryption.EncryptionService#encryptBytes(byte[])
74 */
75 public byte[] encryptBytes(byte[] valueToHide)
76 throws GeneralSecurityException {
77 return valueToHide;
78 }
79 }