View Javadoc

1   package org.apache.fulcrum.jce.crypto;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.IOException;
23  import java.io.InputStream;
24  import java.io.OutputStream;
25  import java.security.GeneralSecurityException;
26  
27  /**
28   * Interface for creating encrypting/decrypting streams.
29   *
30   * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl </a>
31   */
32  
33  public interface CryptoStreamFactory
34  {
35      /**
36       * Creates a decrypting input stream.
37       *
38       * @param is the input stream to be wrapped
39       * @return an decrypting input stream
40       * @throws GeneralSecurityException creating the input stream failed
41       * @throws IOException creating the input stream failed
42       */
43      InputStream getInputStream(InputStream is)
44          throws GeneralSecurityException, IOException;
45  
46      /**
47       * Creates an decrypting input stream
48       *
49       * @param is the input stream to be wrapped
50       * @param password the password to be used
51       * @return an decrypting input stream
52       * @throws GeneralSecurityException creating the input stream failed
53       * @throws IOException creating the input stream failed
54       */
55      InputStream getInputStream(InputStream is, char[] password)
56          throws GeneralSecurityException, IOException;
57  
58      /**
59       * Creates a smart decrypting input stream.
60       *
61       * @param is the input stream to be wrapped
62       * @return an decrypting input stream
63       * @throws GeneralSecurityException creating the input stream failed
64       * @throws IOException creating the input stream failed
65       */
66      InputStream getSmartInputStream(InputStream is)
67          throws GeneralSecurityException, IOException;
68  
69      /**
70       * Creates an decrypting input stream
71       *
72       * @param is the input stream to be wrapped
73       * @param password the password to be used
74       * @return an decrypting input stream
75       * @throws GeneralSecurityException creating the input stream failed
76       * @throws IOException creating the input stream failed
77       */
78      InputStream getSmartInputStream(InputStream is, char[] password)
79          throws GeneralSecurityException, IOException;
80  
81  
82      /**
83       * Creates an encrypting output stream
84       *
85       * @param os the output stream to be wrapped
86       * @param password the password to be used
87       * @return an decrypting input stream
88       * @throws GeneralSecurityException creating the ouptut stream failed
89       * @throws IOException creating the ouptut stream failed
90       */
91      OutputStream getOutputStream(OutputStream os, char[] password)
92          throws GeneralSecurityException, IOException;
93  }