001: /**
002: * JavaGuard -- an obfuscation package for Java classfiles.
003: *
004: * Copyright (c) 2002 Thorsten Heit (theit@gmx.de)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * The author may be contacted at theit@gmx.de.
021: *
022: *
023: * $Id: ScriptConstants.java,v 1.3 2002/04/23 22:58:45 glurk Exp $
024: */package net.sf.javaguard;
025:
026: /** This interface contains all possible constants that may be used inside
027: * the script file.
028: */
029: public interface ScriptConstants {
030: /** Script file directive for additional obfuscator attributes. */
031: public static final String DIRECTIVE_ATTRIBUTE = ".attribute";
032: /** The <code>int</code> value representing the <code>.attribute</code> directive. */
033: public static final int TYPE_ATTRIBUTE = 0;
034:
035: /** Script file directive for additional obfuscator attributes. */
036: public static final String DIRECTIVE_RENAME = ".rename";
037: /** The <code>int</code> value representing the <code>.rename</code> directive. */
038: public static final int TYPE_RENAME = 1;
039:
040: /** Script file directive for additional obfuscator attributes. */
041: public static final String DIRECTIVE_PRESERVE = ".preserve";
042: /** The <code>int</code> value representing the <code>.rename</code> directive. */
043: public static final int TYPE_PRESERVE = 2;
044:
045: /** Script file directive for retaining packages. */
046: public static final String DIRECTIVE_PACKAGE = ".package";
047: /** The <code>int</code> value representing the <code>.package</code> directive. */
048: public static final int TYPE_PACKAGE = 10;
049:
050: /** Script file directive for package mapping. */
051: public static final String DIRECTIVE_PACKAGE_MAP = ".package_map";
052: /** The <code>int</code> value representing the <code>.package_map</code> directive. */
053: public static final int TYPE_PACKAGE_MAP = 11;
054:
055: /** Script file directive for retaining classes. */
056: public static final String DIRECTIVE_CLASS = ".class";
057: /** The <code>int</code> value representing the <code>.class</code> directive. */
058: public static final int TYPE_CLASS = 20;
059:
060: /** Script file directive for class mapping. */
061: public static final String DIRECTIVE_CLASS_MAP = ".class_map";
062: /** The <code>int</code> value representing the <code>.class_map</code> directive. */
063: public static final int TYPE_CLASS_MAP = 21;
064:
065: /** Script file directive for retaining methods. */
066: public static final String DIRECTIVE_METHOD = ".method";
067: /** The <code>int</code> value representing the <code>.method</code> directive. */
068: public static final int TYPE_METHOD = 30;
069:
070: /** Script file directive for method mapping. */
071: public static final String DIRECTIVE_METHOD_MAP = ".method_map";
072: /** The <code>int</code> value representing the <code>.method_map</code> directive. */
073: public static final int TYPE_METHOD_MAP = 31;
074:
075: /** Script file directive for retaining fields. */
076: public static final String DIRECTIVE_FIELD = ".field";
077: /** The <code>int</code> value representing the <code>.field</code> directive. */
078: public static final int TYPE_FIELD = 40;
079:
080: /** Script file directive for field mapping. */
081: public static final String DIRECTIVE_FIELD_MAP = ".field_map";
082: /** The <code>int</code> value representing the <code>.field_map</code> directive. */
083: public static final int TYPE_FIELD_MAP = 41;
084:
085: /** Script file directive for default ignore patterns. */
086: public static final String DIRECTIVE_IGNORE = ".ignore";
087: /** The <code>int</code> value representing the <code>.ignore</code> directive. */
088: public static final int TYPE_IGNORE = 50;
089:
090: /** Script file directive for package ignore patterns. */
091: public static final String DIRECTIVE_IGNORE_PACKAGE = ".ignore_package";
092: /** The <code>int</code> value representing the <code>.ignore_package</code> directive. */
093: public static final int TYPE_IGNORE_PACKAGE = 51;
094:
095: /** Script file directive for class ignore patterns. */
096: public static final String DIRECTIVE_IGNORE_CLASS = ".ignore_class";
097: /** The <code>int</code> value representing the <code>.ignore_class</code> directive. */
098: public static final int TYPE_IGNORE_CLASS = 52;
099:
100: /** Script file directive for method ignore patterns. */
101: public static final String DIRECTIVE_IGNORE_METHOD = ".ignore_method";
102: /** The <code>int</code> value representing the <code>.ignore_method</code> directive. */
103: public static final int TYPE_IGNORE_METHOD = 53;
104:
105: /** Script file directive for field ignore patterns. */
106: public static final String DIRECTIVE_IGNORE_FIELD = ".ignore_field";
107: /** The <code>int</code> value representing the <code>.ignore_field</code> directive. */
108: public static final int TYPE_IGNORE_FIELD = 54;
109:
110: /** Script file directive for default obfuscation patterns. */
111: public static final String DIRECTIVE_OBFUSCATE = ".obfuscate";
112: /** The <code>int</code> value representing the <code>.obfuscate</code> directive. */
113: public static final int TYPE_OBFUSCATE = 60;
114:
115: /** Script file directive for package obfuscation patterns. */
116: public static final String DIRECTIVE_OBFUSCATE_PACKAGE = ".obfuscate_package";
117: /** The <code>int</code> value representing the <code>.obfuscate_package</code> directive. */
118: public static final int TYPE_OBFUSCATE_PACKAGE = 61;
119:
120: /** Script file directive for class obfuscation patterns. */
121: public static final String DIRECTIVE_OBFUSCATE_CLASS = ".obfuscate_class";
122: /** The <code>int</code> value representing the <code>.obfuscate_class</code> directive. */
123: public static final int TYPE_OBFUSCATE_CLASS = 62;
124:
125: /** Script file directive for method obfuscation patterns. */
126: public static final String DIRECTIVE_OBFUSCATE_METHOD = ".obfuscate_method";
127: /** The <code>int</code> value representing the <code>.obfuscate_method</code> directive. */
128: public static final int TYPE_OBFUSCATE_METHOD = 63;
129:
130: /** Script file directive for field obfuscation patterns. */
131: public static final String DIRECTIVE_OBFUSCATE_FIELD = ".obfuscate_field";
132: /** The <code>int</code> value representing the <code>.obfuscate_field</code> directive. */
133: public static final int TYPE_OBFUSCATE_FIELD = 64;
134:
135: /** Holds the array with all possible script file directives. */
136: public static final String[] directives = { DIRECTIVE_ATTRIBUTE,
137: DIRECTIVE_RENAME, DIRECTIVE_PRESERVE, DIRECTIVE_PACKAGE,
138: DIRECTIVE_PACKAGE_MAP, DIRECTIVE_CLASS,
139: DIRECTIVE_CLASS_MAP, DIRECTIVE_METHOD,
140: DIRECTIVE_METHOD_MAP, DIRECTIVE_FIELD, DIRECTIVE_FIELD_MAP,
141: DIRECTIVE_IGNORE, DIRECTIVE_IGNORE_PACKAGE,
142: DIRECTIVE_IGNORE_CLASS, DIRECTIVE_IGNORE_METHOD,
143: DIRECTIVE_IGNORE_FIELD, DIRECTIVE_OBFUSCATE,
144: DIRECTIVE_OBFUSCATE_PACKAGE, DIRECTIVE_OBFUSCATE_CLASS,
145: DIRECTIVE_OBFUSCATE_METHOD, DIRECTIVE_OBFUSCATE_FIELD };
146:
147: /** Holds the array with all possible <code>int</code> values representing
148: * the script file directives.
149: */
150: public static final int[] directiveTypes = { TYPE_ATTRIBUTE,
151: TYPE_RENAME, TYPE_PRESERVE, TYPE_PACKAGE, TYPE_PACKAGE_MAP,
152: TYPE_CLASS, TYPE_CLASS_MAP, TYPE_METHOD, TYPE_METHOD_MAP,
153: TYPE_FIELD, TYPE_FIELD_MAP, TYPE_IGNORE,
154: TYPE_IGNORE_PACKAGE, TYPE_IGNORE_CLASS, TYPE_IGNORE_METHOD,
155: TYPE_IGNORE_FIELD, TYPE_OBFUSCATE, TYPE_OBFUSCATE_PACKAGE,
156: TYPE_OBFUSCATE_CLASS, TYPE_OBFUSCATE_METHOD,
157: TYPE_OBFUSCATE_FIELD, };
158:
159: /** Optional parameter for the <code>.class</code> directive to not obfuscate
160: * public elements.
161: */
162: public static final String OPTION_PUBLIC = "public";
163: /** The <code>int</code> value representing the <code>public</code> option. */
164: public static final int OPTION_TYPE_PUBLIC = 1000;
165:
166: /** Optional parameter for the <code>.class</code> directive to not obfuscate
167: * protected elements.
168: */
169: public static final String OPTION_PROTECTED = "protected";
170: /** The <code>int</code> value representing the <code>protected</code> option. */
171: public static final int OPTION_TYPE_PROTECTED = 1001;
172:
173: /** Optional parameter for the <code>.class</code> directive to not obfuscate
174: * methods.
175: */
176: public static final String OPTION_METHOD = "method";
177: /** The <code>int</code> value representing the <code>method</code> option. */
178: public static final int OPTION_TYPE_METHOD = 1002;
179:
180: /** Optional parameter for the <code>.class</code> directive to not obfuscate
181: * fields.
182: */
183: public static final String OPTION_FIELD = "field";
184: /** The <code>int</code> value representing the <code>field</code> option. */
185: public static final int OPTION_TYPE_FIELD = 1003;
186:
187: /** Holds an array with additional options possible for the <code>.class</code>
188: * directive.
189: */
190: public static final String[] options = { OPTION_PUBLIC,
191: OPTION_PROTECTED, OPTION_METHOD, OPTION_FIELD };
192:
193: /** Holds the array with all possible <code>int</code> values representing
194: * the additional options for the <code>.class</code> directive.
195: */
196: public static final int[] optionTypes = { OPTION_TYPE_PUBLIC,
197: OPTION_TYPE_PROTECTED, OPTION_TYPE_METHOD,
198: OPTION_TYPE_FIELD };
199:
200: // additional attributes for the obfuscator:
201:
202: /** Specifies how the obfuscator should work. */
203: public static final String ATTR_Unknown = "Unknown";
204: /** Specifies how the obfuscator should work. */
205: public static final String ATTR_Code = "Code";
206: /** Specifies how the obfuscator should work. */
207: public static final String ATTR_ConstantValue = "ConstantValue";
208: /** Specifies how the obfuscator should work. */
209: public static final String ATTR_Exceptions = "Exceptions";
210: /** Specifies how the obfuscator should work. */
211: public static final String ATTR_LineNumberTable = "LineNumberTable";
212: /** Specifies how the obfuscator should work. */
213: public static final String ATTR_SourceFile = "SourceFile";
214: /** Specifies how the obfuscator should work. */
215: public static final String ATTR_LocalVariableTable = "LocalVariableTable";
216: /** Specifies how the obfuscator should work. */
217: public static final String ATTR_InnerClasses = "InnerClasses";
218: /** Specifies how the obfuscator should work. */
219: public static final String ATTR_Synthetic = "Synthetic";
220:
221: /** An array that contains all valid options for the <code>.attribute</code>
222: * directive.
223: */
224: public static String[] validAttrs = { ATTR_Unknown, ATTR_Code,
225: ATTR_ConstantValue, ATTR_Exceptions, ATTR_LineNumberTable,
226: ATTR_SourceFile, ATTR_LocalVariableTable,
227: ATTR_InnerClasses, ATTR_Synthetic };
228:
229: /** Attribute for the obfuscator to treat RMIC-generated classes in a special
230: * way.
231: */
232: public static final String RENAME_RMIC = "rmic";
233: /** Attribute for the obfuscator to rename resource files according to their
234: * class files.
235: */
236: public static final String RENAME_RESOURCES = "resources";
237:
238: /** An array that contains all valid options for the <code>.rename</code>
239: * directive.
240: */
241: public static String[] renameAttrs = { RENAME_RMIC,
242: RENAME_RESOURCES };
243:
244: /** Attribute for the obfuscator to prevent classes that are used in
245: * hardcoded references from being assigned obfuscated names.
246: */
247: public static final String PRESERVE_REFERENCES = "hardcodedreferences";
248:
249: /** An array that contains all valid options for the <code>.preserve</code>
250: * directive.
251: */
252: public static String[] preserveAttrs = { PRESERVE_REFERENCES };
253: }
|