KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > jef > JecFile


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 package org.jahia.services.jef;
14
15 import org.jahia.exceptions.JahiaException;
16 import org.jahia.security.license.LicenseConstants;
17
18 import java.io.IOException JavaDoc;
19
20
21 /**
22  * Load and extract data from a JEC file
23  *
24  * @author Khue Nguyen
25  * @version 1.0
26  */

27 public final class JecFile extends JefFile {
28
29     private static org.apache.log4j.Logger logger =
30             org.apache.log4j.Logger.getLogger (JecFile.class);
31
32     //-------------------------------------------------------------------------
33
/**
34      * Construct a jef file object by extracting encrypted
35      * information out of the specified jef file.
36      *
37      * @param String the full path to the file
38      *
39      * @throws InvalidJefException Throws this exception when the specified jef file is
40      * not valid.
41      */

42     public JecFile (String JavaDoc path)
43             throws IOException JavaDoc, JahiaException, InvalidJefFileException {
44         super (path);
45     }
46
47
48     //-------------------------------------------------------------------------
49
/**
50      * Return the license type
51      *
52      * @return int the license type
53      */

54     public int getLicenseType ()
55             throws JefFileKeyNotFoundException, JefFileInvalidKeyValueException {
56
57         String JavaDoc val = getKey (LicenseConstants.LICENSE_TYPE_OPTION);
58         if (val == null) {
59             throw new JefFileKeyNotFoundException (LicenseConstants.LICENSE_TYPE_OPTION);
60         }
61
62         logger.debug (" getLicenseType val=" + val);
63
64         try {
65             return Integer.parseInt (val);
66         } catch (Throwable JavaDoc t) {
67             throw new JefFileInvalidKeyValueException (LicenseConstants.LICENSE_TYPE_OPTION);
68         }
69     }
70
71
72     //-------------------------------------------------------------------------
73
/**
74      * Return the license type relational comparator
75      *
76      * @return int the license type Relational Comparator
77      *
78      * @see LicenseConstants
79      */

80     public int getLicenseTypeRelComp ()
81             throws JefFileKeyNotFoundException, JefFileInvalidKeyValueException {
82
83         String JavaDoc val = getKey (LicenseConstants.LICENSE_TYPE_RELCOMP_OPTION);
84         if (val == null) {
85             throw new JefFileKeyNotFoundException (
86                     LicenseConstants.LICENSE_TYPE_RELCOMP_OPTION);
87         }
88
89         logger.debug (" getLicenseTypeRelComp val=" + val);
90
91         try {
92             return Integer.parseInt (val);
93         } catch (Throwable JavaDoc t) {
94             throw new JefFileInvalidKeyValueException (
95                     LicenseConstants.LICENSE_TYPE_RELCOMP_OPTION);
96         }
97     }
98
99 }
100
101
Popular Tags