01: package com.memoire.vainstall;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05: import java.io.OutputStream;
06:
07: /*
08: * I suggest to license this file under LGPL license so anyone
09: * could extend this class with own license key validators w/o need
10: * to release source code of validator. I suggest to no to license
11: * this file under GPL2 and stick with LGPL as otherwise it will put
12: * very much of burden on the users of vainstall w/o obvious value
13: * to other user as different company polices could require different
14: * fields to be supplied and this will be likely only difference in different
15: * validators.
16: *
17: * copyrights are completly transfered to VAInstall team without any
18: * restriction.
19: */
20: /** this class integrate functionality that is needed to support
21: * license keys. It is not generic enough now, but possibly could
22: * be extended. Subclasses of this class will be created by user.
23: */
24: public abstract class LicenseKeySupport {
25: /** field info class, this class */
26: public final class FieldInfo {
27: /** constructor for field info */
28: public FieldInfo(String nm, int sz, String txt) {
29: name = nm;
30: size = sz;
31: text = txt;
32: }
33:
34: /** localized name of field */
35: final public String name;
36: /** size of field, this is used to resize text field control */
37: final public int size;
38: /** start text for field */
39: final public String text;
40:
41: public String toString() {
42: return "FieldInfo[name=" + name + ",size=" + size
43: + ",text=" + text + "]";
44: }
45: }
46:
47: /** @return true if license key query step need to be performed
48: */
49: public abstract boolean needsLicenseKey();
50:
51: /** @return uri of page that contains registration page,
52: * if such uri is not null, then it will be shown
53: * to user and launch browser button will be displayed
54: * depending on ui and platform.
55: */
56: public abstract String getRegistrationPage();
57:
58: /** get field info for this installer
59: * @return array of field info.
60: */
61: public abstract FieldInfo[] getFieldInfo();
62:
63: /** set field values, this method coudl be called any number of times.
64: * implementation of this class should keep last passed values.
65: * @param values array of strings where each element correspond field
66: * info returned from get field info.
67: */
68: public abstract void setFieldValues(String values[]);
69:
70: /** @return true, if license key is valid, this method should be called only
71: * after set field values were called.
72: */
73: public abstract boolean isLicenseKeyValid();
74:
75: /** encode archive.zip stream with key supplied as string in
76: * configuration file, this function is called during building install
77: * package
78: * @param is input steam to encode
79: * @param key key supplied in configuration file
80: * @return encrypted stream
81: */
82: public abstract OutputStream encodeStream(OutputStream is,
83: String key) throws IOException;
84:
85: /** decode archive.zip stream using infromation supplied in fieldValues
86: * @param is input steam to decode
87: * @return decrypted stream
88: */
89: public abstract InputStream decodeStream(InputStream is)
90: throws IOException;
91: }
|