View Javadoc
1   /*
2    * GordianKnot: Security Suite
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.gordianknot.api.zip;
18  
19  import io.github.tonywasher.joceanus.gordianknot.api.base.GordianException;
20  import io.github.tonywasher.joceanus.gordianknot.api.keypair.GordianKeyPair;
21  import io.github.tonywasher.joceanus.gordianknot.api.lock.GordianLock;
22  import io.github.tonywasher.joceanus.gordianknot.api.lock.spec.GordianPasswordLockSpec;
23  
24  import java.io.File;
25  import java.io.InputStream;
26  import java.io.OutputStream;
27  
28  /**
29   * GordianKnot Zip Factory API.
30   */
31  public interface GordianZipFactory {
32      /**
33       * Create a keySetLock.
34       *
35       * @param pPassword the password
36       * @return the zipLock
37       * @throws GordianException on error
38       */
39      GordianZipLock keySetZipLock(char[] pPassword) throws GordianException;
40  
41      /**
42       * Create a keySetLock.
43       *
44       * @param pLockSpec the lockSpec
45       * @param pPassword the password
46       * @return the zipLock
47       * @throws GordianException on error
48       */
49      GordianZipLock keySetZipLock(GordianPasswordLockSpec pLockSpec,
50                                   char[] pPassword) throws GordianException;
51  
52      /**
53       * Create a factoryLock.
54       *
55       * @param pPassword the password
56       * @return the zipLock
57       * @throws GordianException on error
58       */
59      GordianZipLock factoryZipLock(char[] pPassword) throws GordianException;
60  
61      /**
62       * Create a factoryLock.
63       *
64       * @param pLockSpec the lockSpec
65       * @param pPassword the password
66       * @return the zipLock
67       * @throws GordianException on error
68       */
69      GordianZipLock factoryZipLock(GordianPasswordLockSpec pLockSpec,
70                                    char[] pPassword) throws GordianException;
71  
72      /**
73       * Create a keyPairZipLock.
74       *
75       * @param pKeyPair  the keyPair
76       * @param pPassword the password
77       * @return the zipLock
78       * @throws GordianException on error
79       */
80      GordianZipLock keyPairZipLock(GordianKeyPair pKeyPair,
81                                    char[] pPassword) throws GordianException;
82  
83      /**
84       * Create a keyPairZipLock.
85       *
86       * @param pLockSpec the lockSpec
87       * @param pKeyPair  the keyPair
88       * @param pPassword the password
89       * @return the zipLock
90       * @throws GordianException on error
91       */
92      GordianZipLock keyPairZipLock(GordianPasswordLockSpec pLockSpec,
93                                    GordianKeyPair pKeyPair,
94                                    char[] pPassword) throws GordianException;
95  
96      /**
97       * Create a zipLock.
98       *
99       * @param pLock the keyPairLock
100      * @return the zipLock
101      * @throws GordianException on error
102      */
103     GordianZipLock zipLock(GordianLock<?> pLock) throws GordianException;
104 
105     /**
106      * Create a secure zipFile.
107      *
108      * @param pZipLock the zipLock to use
109      * @param pFile    the file details for the new zip file
110      * @return the zipFile
111      * @throws GordianException on error
112      */
113     GordianZipWriteFile createZipFile(GordianZipLock pZipLock,
114                                       File pFile) throws GordianException;
115 
116     /**
117      * Create a secure zipFile.
118      *
119      * @param pZipLock      the zipLock to use
120      * @param pOutputStream the output stream to write to
121      * @return the zipFile
122      * @throws GordianException on error
123      */
124     GordianZipWriteFile createZipFile(GordianZipLock pZipLock,
125                                       OutputStream pOutputStream) throws GordianException;
126 
127     /**
128      * Create a standard zipFile with no security.
129      *
130      * @param pFile the file details for the new zip file
131      * @return the zipFile
132      * @throws GordianException on error
133      */
134     GordianZipWriteFile createZipFile(File pFile) throws GordianException;
135 
136     /**
137      * Create a standard zipFile with no security.
138      *
139      * @param pOutputStream the output stream to write to
140      * @return the zipFile
141      */
142     GordianZipWriteFile createZipFile(OutputStream pOutputStream);
143 
144     /**
145      * Open an existing zipFile.
146      *
147      * @param pFile the file to read
148      * @return the zipFile
149      * @throws GordianException on error
150      */
151     GordianZipReadFile openZipFile(File pFile) throws GordianException;
152 
153     /**
154      * Open an existing zipFile.
155      *
156      * @param pInputStream the input stream to read from
157      * @return the zipFile
158      * @throws GordianException on error
159      */
160     GordianZipReadFile openZipFile(InputStream pInputStream) throws GordianException;
161 }