summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/dynamicFrame/api/IDynamicFrame.java
blob: 1e8a0ff04e66ef6910ff857645c452c11c53911c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package org.uic.barcode.dynamicFrame.api;

import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import org.uic.barcode.dynamicContent.api.IUicDynamicContent;
import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.ticket.EncodingFormatException;


/**
 * The DynamicHeader for bar codes 
 * 
 */
public interface IDynamicFrame{
	

	
	/**
	 * Gets the format.
	 *
	 * @return the format
	 */
	public String getFormat();
	

	/**
	 * Sets the format.
	 *
	 * @param format the new format
	 */
	public void setFormat(String format);

	/**
	 * Gets the level 2 signed data.
	 *
	 * @return the level 2 signed data
	 */
	public ILevel2Data getLevel2Data();

	/**
	 * Sets the level 2 signed data.
	 *
	 * @param level2SignedData the new level 2 signed data
	 */
	public void setLevel2Data(ILevel2Data level2Data);


	/**
	 * Gets the level 2 signature.
	 *
	 * @return the level 2 signature
	 */
	public byte[] getLevel2Signature();
	

	/**
	 * Sets the level 2 signature.
	 *
	 * @param level2Signature the new level 2 signature
	 */
	public void setLevel2Signature(byte[] level2Signature);
	

	/**
	 * Encode.
	 * 
	 * Encode the header as ASN.1 PER UNALIGNED byte array
	 *
	 * @return the byte[]
	 * @throws EncodingFormatException 
	 */
	public byte[] encode() throws EncodingFormatException;
	
	/**
	 * Decode.
	 *
	 * Decode the header from an ASN.1 PER UNALIGNED encoded byte array
	 *
	 * @param bytes the bytes
	 * @return the dynamic header
	 */
	public void decode(byte[] bytes);
	

	
	/**
	 * Verify the level 2 signature
	 * 
	 * Note:  an appropriate security provider (e.g. BC) must be registered before 
	 *
	 * @param data the data content
	 * @return the return error code
	 * @throws EncodingFormatException 
	 */	
	public int validateLevel2(byte[] data) throws EncodingFormatException;
	
	/**
	 * Verify the level 2 signature
	 * 
	 * Note:  an appropriate security provider (e.g. BC) must be registered before 
	 *
	 * @param prov the registered security provider
     * @param data the data content
	 * @return the return error code
	 * @throws EncodingFormatException 
	 */	
	public int validateLevel2(Provider prov, byte[] data) throws EncodingFormatException;

	/**
	 * Verify the level 1 signature
	 * 
	 * Note:  an appropriate security provider (e.g. BC) must be registered before 
	 *
	 * @param key the key
	 * @param data the data content
	 * @return the return error code
	 * @throws EncodingFormatException 
	 */
	public int validateLevel1(PublicKey key, byte[] data) throws EncodingFormatException;
	
	/**
	 * Verify the level 1 signature
	 * 
	 * Note:  an appropriate security provider (e.g. BC) must be registered before 
	 *
	 * @param key the key
	 * @param prov the registered security provider 
	 * @param the data content
	 * @return the return error code
	 * @throws EncodingFormatException 
	 */
	public int validateLevel1(PublicKey key, Provider prov,  byte[] data) throws EncodingFormatException;
 
	
	/**
	 * Sign level 2 data without a specific security provider.
	 *
	 * @param key the key
	 * @throws Exception the exception
	 */
	public void signLevel2(PrivateKey key) throws Exception;


	/**
	 * Sign level 2 data.
	 *
	 * @param key the key
	 * @param prov the security Provider
	 * @throws Exception the exception
	 */
	public void signLevel2(PrivateKey key, Provider prov) throws Exception;
	
	
	/**
	 * Adds the dynamic content and encodes it. (API level)
	 *
	 * @param content the dynamic content
	 * @throws EncodingFormatException the encoding format exception
	 */
	public void addDynamicContent(IUicDynamicContent content) throws EncodingFormatException;
	
	
	/**
	 * Adds the level 2 dynamic data. (ASN level)
	 *
	 * @param dynamicData the dynamic data
	 */
	public void addLevel2DynamicData(UicDynamicContentDataFDC1 dynamicData);
	
	/**
	 * Gets the dynamic content.
	 *
	 * @return the dynamic content
	 */
	public IUicDynamicContent getDynamicContent();
	
	
	/**
	 * Sign the contained data block.
	 * 
	 * Note:  an appropriate security provider (e.g. BC) must be registered before 
	 *
	 * @param key the key
	 * @return 
	 * @return the byte[]
	 * @throws Exception 
	 */
	public void signLevel1(PrivateKey key) throws Exception;
	
	/**
	 * Sign the contained data block.
	 * 
	 * Note:  an appropriate security provider (e.g. BC) must be registered before 
	 *
	 * @param key the key
	 * @param security provider - security provider that must be sued to create the signature
	 * @return 
	 * @return the byte[]
	 * @throws Exception 
	 */
	public void signLevel1(PrivateKey key, Provider prov) throws Exception;
	
	
	
}