KickJava   Java API By Example, From Geeks To Geeks.

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


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

17 /**
18   * this class is default implementation of license key support, that does nothing.
19   */

20 public class TestLicenseKeySupport extends LicenseKeySupport
21 {
22   String JavaDoc key;
23   /** @return true if license key query step need to be performed
24     */

25   public boolean needsLicenseKey()
26   {
27     return true;
28   }
29   /** @return uri of page that contains registration page,
30     * if such uri is not null, then it will be shown
31     * to user and launch browser button will be displayed
32     * depending on ui and platform.
33     */

34
35   public String JavaDoc getRegistrationPage()
36   {
37     return null;
38   }
39
40   /** get field info for this installer
41     * @return array of field info.
42     */

43   public FieldInfo[] getFieldInfo()
44   {
45     return new FieldInfo[]{new FieldInfo("serial key", 9, "code")};
46   }
47   /** set field values, this method coudl be called any number of times.
48     * implementation of this class should keep last passed values.
49     * @param values array of strings where each element correspond field
50     * info returned from get field info.
51     */

52   public void setFieldValues(String JavaDoc values[])
53   {
54     key = values[0];
55   }
56   /** @return true, if license key is valid, this method should be called only
57     * after set field values were called.
58     */

59   public boolean isLicenseKeyValid()
60   {
61     if("vainstall".equals(key) ) return true;
62     return false;
63   }
64   /** encode archive.zip stream with key supplied as string in
65     * configuration file, this fucntion is called during building install
66     * package
67     * @param is input steam to encode
68     * @param key key supplied in configuration file
69     * @return encrypted stream
70     */

71   public OutputStream JavaDoc encodeStream(OutputStream JavaDoc is, String JavaDoc key)
72   {
73     return is;
74   }
75   /** decode archive.zip stream using infromation supplied in fieldValues
76     * @param is input steam to decode
77     * @return decrypted stream
78     */

79   public InputStream JavaDoc decodeStream(InputStream JavaDoc is)
80   {
81     return is;
82   }
83 }
Popular Tags