01: /*
02: * BEGIN_HEADER - DO NOT EDIT
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
17: * If applicable add the following below this CDDL HEADER,
18: * with the fields enclosed by brackets "[]" replaced with
19: * your own identifying information: Portions Copyright
20: * [year] [name of copyright owner]
21: */
22:
23: /*
24: * @(#)KeyStoreUtil.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package com.sun.jbi.security;
30:
31: import java.security.KeyStoreException;
32:
33: /**
34: * KeyStoreUtil provides helper methods for encrypting and decrypting
35: * Strings and/or byte arrays. An implementation is generally
36: * expected to provide at least one default key for use in encrypting
37: * and decrypting. The algorithm used for encrypting and decrypting
38: * messages is chosen by the implementation; keys must match the
39: * algorithm used by the implementation, so it's important that the
40: * implementation also be the generator of the keys! The current
41: * interface purposely tries to limit flexibility by not allowing the
42: * user to use any key or any algorithm when invoking the encrypt and
43: * decrypt methods.
44: *
45: * @version $Revision: 1.4 $
46: *
47: */
48: public interface KeyStoreUtil {
49:
50: /**
51: * Encrypts a message using a default key.
52: *
53: * @param clearText the byte array that will be encrypted
54: * @return the encrypted byte array
55: * @exception KeyStoreException if any error occurs retrieving the
56: * key to be used
57: */
58: public byte[] encrypt(byte[] clearText) throws KeyStoreException;
59:
60: /**
61: * Decrypts a message using a default key
62: *
63: * @param cipherText the byte array with the encrypted data
64: * @return the unencrypted byte array
65: * @exception KeyStoreException if any error occurs retrieving the
66: * key to be used
67: */
68: public byte[] decrypt(byte[] cipherText) throws KeyStoreException;
69:
70: /**
71: * Encrypts a message using a default key. The result
72: * is a Base64-encoded string.
73: *
74: * @param clearText a String representing the message to be encrypted
75: * @return a Base64-encoded string representing the encrypted message
76: * @exception KeyStoreException if any error occurs retrieving the
77: * key to be used
78: */
79: public String encrypt(String clearText) throws KeyStoreException;
80:
81: /**
82: * Decrypts a message using the key identified by keyName. The second
83: * argument must be a Base-64 encoded string
84: *
85: * @param base64EncodedCipherText a Base-64 Encoded string
86: * @return the decrypted message as a String
87: * @exception KeyStoreException if any error occurs retrieving the
88: * key to be used
89: */
90: public String decrypt(String base64EncodedCipherText)
91: throws KeyStoreException;
92: }
|