KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > LicenseKeySupport


1 package com.memoire.vainstall;
2 import java.io.IOException JavaDoc;
3 import java.io.InputStream JavaDoc;
4 import java.io.OutputStream JavaDoc;
5 /*
6  * I suggest to license this file under LGPL license so anyone
7  * could extend this class with own license key validators w/o need
8  * to release source code of validator. I suggest to no to license
9  * this file under GPL2 and stick with LGPL as otherwise it will put
10  * very much of burden on the users of vainstall w/o obvious value
11  * to other user as different company polices could require different
12  * fields to be supplied and this will be likely only difference in different
13  * validators.
14  *
15  * copyrights are completly transfered to VAInstall team without any
16  * restriction.
17  */

18 /** this class integrate functionality that is needed to support
19   * license keys. It is not generic enough now, but possibly could
20   * be extended. Subclasses of this class will be created by user.
21   */

22 public abstract class LicenseKeySupport
23 {
24   /** field info class, this class */
25   public final class FieldInfo
26   {
27     /** constructor for field info */
28     public FieldInfo(String JavaDoc nm, int sz, String JavaDoc txt)
29     {
30       name = nm;
31       size = sz;
32       text = txt;
33     }
34     /** localized name of field */
35     final public String JavaDoc 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 JavaDoc text;
40     public String JavaDoc toString()
41     {
42       return "FieldInfo[name="+name+",size="+size+",text="+text+"]";
43     }
44   }
45   /** @return true if license key query step need to be performed
46     */

47   public abstract boolean needsLicenseKey();
48   /** @return uri of page that contains registration page,
49     * if such uri is not null, then it will be shown
50     * to user and launch browser button will be displayed
51     * depending on ui and platform.
52     */

53   public abstract String JavaDoc getRegistrationPage();
54
55   /** get field info for this installer
56     * @return array of field info.
57     */

58   public abstract FieldInfo[] getFieldInfo();
59   /** set field values, this method coudl be called any number of times.
60     * implementation of this class should keep last passed values.
61     * @param values array of strings where each element correspond field
62     * info returned from get field info.
63     */

64   public abstract void setFieldValues(String JavaDoc values[]);
65   /** @return true, if license key is valid, this method should be called only
66     * after set field values were called.
67     */

68   public abstract boolean isLicenseKeyValid();
69   /** encode archive.zip stream with key supplied as string in
70     * configuration file, this function is called during building install
71     * package
72     * @param is input steam to encode
73     * @param key key supplied in configuration file
74     * @return encrypted stream
75     */

76   public abstract OutputStream JavaDoc encodeStream(OutputStream JavaDoc is, String JavaDoc key) throws IOException JavaDoc;
77   /** decode archive.zip stream using infromation supplied in fieldValues
78     * @param is input steam to decode
79     * @return decrypted stream
80     */

81   public abstract InputStream JavaDoc decodeStream(InputStream JavaDoc is) throws IOException JavaDoc;
82 }
Popular Tags