001: package migration.modules.rules;
002:
003: import java.lang.*;
004: import java.util.*;
005: import java.io.*;
006: import com.iplanet.portalserver.parser.WebtopParser;
007: import migration.modules.ldap.Component;
008: import migration.modules.ldap.Element;
009: import migration.modules.ldap.Attribute;
010:
011: public class IDSDataSource implements DataSource {
012:
013: static Vector attrs;
014:
015: public IDSDataSource(String infile) {
016: try {
017: WebtopParser wp = new WebtopParser();
018: wp.register(Element.COMPONENT_E,
019: "migration.modules.ldap.Component");
020: wp.register(Element.ATT_E,
021: "migration.modules.ldap.Attribute");
022: wp.register(Element.PRIV_E,
023: "migration.modules.ldap.Privilege");
024: wp.register(Element.VALUELIST,
025: "migration.modules.ldap.List");
026: wp
027: .register(Element.DENYLIST,
028: "migration.modules.ldap.List");
029: wp.register(Element.ALLOWLIST,
030: "migration.modules.ldap.List");
031: wp.register(Element.CHOICEVALUE,
032: "migration.modules.ldap.List");
033: wp
034: .register(Element.READPERM,
035: "migration.modules.ldap.List");
036: wp.register(Element.WRITEPERM,
037: "migration.modules.ldap.List");
038: wp.register(Element.VALUELISTN,
039: "migration.modules.ldap.List");
040: wp.register(Element.DENYLISTN,
041: "migration.modules.ldap.List");
042: wp.register(Element.ALLOWLISTN,
043: "migration.modules.ldap.List");
044: wp.register(Element.CHOICEVALUEN,
045: "migration.modules.ldap.List");
046: wp.register(Element.READPERMN,
047: "migration.modules.ldap.List");
048: wp.register(Element.WRITEPERMN,
049: "migration.modules.ldap.List");
050: wp.register("Component",
051: "com.sun.portal.psadmin.AppComponent");
052: wp.register("Attributes",
053: "com.iplanet.portalserver.parser.GenericNode");
054: wp.register("Privileges",
055: "com.iplanet.portalserver.parser.GenericNode");
056: wp.register("Attribute",
057: "com.sun.portal.psadmin.AppAttribute");
058: wp.register("Privilege",
059: "com.sun.portal.psadmin.AppPrivilege");
060:
061: Component comp = (Component) wp.parse(new DataInputStream(
062: new FileInputStream(infile)));
063: String attrName = new String();
064: Vector attrVector;
065: int count;
066: /*System.out.println("Finished parse.....!!!"+comp.getCompName());
067: System.out.println("Number of attributes..."+(comp.getAttributes()).size());*/
068: attrs = comp.getAttributes();
069: for (int i = 0; i < attrs.size(); ++i) {
070:
071: attrName = ((Attribute) (attrs.elementAt(i))).name;
072: //System.out.println("value of attrName:"+attrName);
073: if (attrName.indexOf("AppletParamValues") >= 0) {
074: attrVector = (Vector) ((Attribute) (attrs
075: .elementAt(i))).vallist;
076: if (attrVector != null) {
077: count = attrVector.size();
078: APPLET_PARAM_ARRAY = new String[count];
079: for (int j = 0; j < count; ++j)
080: APPLET_PARAM_ARRAY[j] = (attrVector
081: .elementAt(j)).toString();
082: /* for(int j=0;j<count;++j)
083: System.out.println(APPLET_PARAM_ARRAY[j]); */
084: }
085: }
086: if (attrName.indexOf("-Tags") >= 0) {
087: attrVector = (Vector) ((Attribute) (attrs
088: .elementAt(i))).vallist;
089: if (attrVector != null) {
090: count = attrVector.size();
091: ATTRIBUTE_PARAM_ARRAY = new String[count];
092: for (int j = 0; j < count; ++j)
093: ATTRIBUTE_PARAM_ARRAY[j] = (attrVector
094: .elementAt(j)).toString();
095: /* for(int j=0;j<count;++j)
096: System.out.println(ATTRIBUTE_PARAM_ARRAY[j]); */
097: }
098: }
099: if (attrName.indexOf("-JavaScriptTags") >= 0) {
100: attrVector = (Vector) ((Attribute) (attrs
101: .elementAt(i))).vallist;
102: if (attrVector != null) {
103: count = attrVector.size();
104: JS_TOKEN_ARRAY = new String[count];
105: for (int j = 0; j < count; ++j)
106: JS_TOKEN_ARRAY[j] = (attrVector
107: .elementAt(j)).toString();
108: /* for(int j=0;j<count;++j)
109: System.out.println(JS_TOKEN_ARRAY[j]); */
110: }
111: }
112: if (attrName.indexOf("-JavaScriptVariables") >= 0) {
113: attrVector = (Vector) ((Attribute) (attrs
114: .elementAt(i))).vallist;
115: if (attrVector != null) {
116: count = attrVector.size();
117: JS_VARIABLES_SIMPLE = new String[count];
118: for (int j = 0; j < count; ++j)
119: JS_VARIABLES_SIMPLE[j] = (attrVector
120: .elementAt(j)).toString();
121: /*for(int j=0;j<count;++j)
122: System.out.println(JS_VARIABLES_SIMPLE[j]); */
123: }
124: }
125: if (attrName.indexOf("-JavaScriptVariableConvert") >= 0) {
126: attrVector = (Vector) ((Attribute) (attrs
127: .elementAt(i))).vallist;
128: if (attrVector != null) {
129: count = attrVector.size();
130: JS_EXPRESSION_VARIABLE_ARRAY = new String[count];
131: for (int j = 0; j < count; ++j)
132: JS_EXPRESSION_VARIABLE_ARRAY[j] = (attrVector
133: .elementAt(j)).toString();
134: /*for(int j=0;j<count;++j)
135: System.out.println(JS_EXPRESSION_VARIABLE_ARRAY[j]); */
136: }
137: }
138: if (attrName.indexOf("-JavaScriptHTMLVariables") >= 0) {
139: attrVector = (Vector) ((Attribute) (attrs
140: .elementAt(i))).vallist;
141: if (attrVector != null) {
142: count = attrVector.size();
143: JS_DHTML_VARIABLE_ARRAY = new String[count];
144: for (int j = 0; j < count; ++j)
145: JS_DHTML_VARIABLE_ARRAY[j] = (attrVector
146: .elementAt(j)).toString();
147: /*for(int j=0;j<count;++j)
148: System.out.println(JS_DHTML_VARIABLE_ARRAY[j]); */
149: }
150: }
151: if (attrName.indexOf("-JavaScriptHTML") >= 0
152: && attrName.indexOf("-JavaScriptHTMLVariables") < 0) {
153: attrVector = (Vector) ((Attribute) (attrs
154: .elementAt(i))).vallist;
155: if (attrVector != null) {
156: count = attrVector.size();
157: JS_DHTML_FUNCTION_ARRAY = new String[count];
158: for (int j = 0; j < count; ++j)
159: JS_DHTML_FUNCTION_ARRAY[j] = (attrVector
160: .elementAt(j)).toString();
161: /*for(int j=0;j<count;++j)
162: System.out.println(JS_DHTML_FUNCTION_ARRAY[j]); */
163: }
164: }
165: if (attrName
166: .indexOf("-JavaScriptFunctionParameterConvert") >= 0) {
167: attrVector = (Vector) ((Attribute) (attrs
168: .elementAt(i))).vallist;
169: if (attrVector != null) {
170: count = attrVector.size();
171:
172: JS_EXPRESSION_FUNCTION_ARRAY = new String[count];
173: for (int j = 0; j < count; ++j)
174: JS_EXPRESSION_FUNCTION_ARRAY[j] = (attrVector
175: .elementAt(j)).toString();
176: /*for(int j=0;j<count;++j)
177: System.out.println(JS_EXPRESSION_FUNCTION_ARRAY[j]); */
178: }
179: }
180: if (attrName.indexOf("-JavaScriptRewrite") >= 0) {
181: attrVector = (Vector) ((Attribute) (attrs
182: .elementAt(i))).vallist;
183: if (attrVector != null) {
184: count = attrVector.size();
185: JS_SIMPLE_FUNCTION_ARRAY = new String[count];
186: for (int j = 0; j < count; ++j)
187: JS_SIMPLE_FUNCTION_ARRAY[j] = (attrVector
188: .elementAt(j)).toString();
189: /*for(int j=0;j<count;++j)
190: System.out.println(JS_SIMPLE_FUNCTION_ARRAY[j]); */
191: }
192: }
193: if (attrName
194: .indexOf("-JavaScriptSystemVariableConvert") >= 0) {
195: attrVector = (Vector) ((Attribute) (attrs
196: .elementAt(i))).vallist;
197: if (attrVector != null) {
198: count = attrVector.size();
199: JS_SYSTEM_VARIABLE_ARRAY = new String[count];
200: for (int j = 0; j < count; ++j)
201: JS_SYSTEM_VARIABLE_ARRAY[j] = (attrVector
202: .elementAt(j)).toString();
203: }
204: }
205: if (attrName.indexOf("-FormInputValues") >= 0) {
206: attrVector = (Vector) ((Attribute) (attrs
207: .elementAt(i))).vallist;
208: if (attrVector != null) {
209: count = attrVector.size();
210: FORM_ARRAY = new String[count];
211: for (int j = 0; j < count; ++j)
212: FORM_ARRAY[j] = (attrVector.elementAt(j))
213: .toString();
214: /*for(int j=0;j<count;++j)
215: System.out.println(FORM_ARRAY[j]); */
216: }
217: }
218: if (attrName.indexOf("-XMLTextRewrite") >= 0) {
219: attrVector = (Vector) ((Attribute) (attrs
220: .elementAt(i))).vallist;
221: if (attrVector != null) {
222: count = attrVector.size();
223: XML_TEXT_ARRAY = new String[count];
224: for (int j = 0; j < count; ++j)
225: XML_TEXT_ARRAY[j] = (attrVector
226: .elementAt(j)).toString();
227: /*for(int j=0;j<count;++j)
228: System.out.println(XML_TEXT_ARRAY[j]); */
229: }
230: }
231: if (attrName.indexOf("-XMLAttributeRewrite") >= 0) {
232: attrVector = (Vector) ((Attribute) (attrs
233: .elementAt(i))).vallist;
234: if (attrVector != null) {
235: count = attrVector.size();
236: XML_ATTRIBUTE_ARRAY = new String[count];
237: for (int j = 0; j < count; ++j)
238: XML_ATTRIBUTE_ARRAY[j] = (attrVector
239: .elementAt(j)).toString();
240: /*for(int j=0;j<count;++j)
241: System.out.println(XML_ATTRIBUTE_ARRAY[j]); */
242: }
243: }
244:
245: if (attrName.indexOf("-JavaScriptVariableJavaScript") >= 0) {
246: attrVector = (Vector) ((Attribute) (attrs
247: .elementAt(i))).vallist;
248: if (attrVector != null) {
249: count = attrVector.size();
250: JS_DJS_VARIABLE_ARRAY = new String[count];
251: for (int j = 0; j < count; ++j)
252: JS_DJS_VARIABLE_ARRAY[j] = (attrVector
253: .elementAt(j)).toString();
254: /*for(int j=0;j<count;++j)
255: System.out.println(XML_ATTRIBUTE_ARRAY[j]); */
256: }
257: }
258:
259: if (attrName
260: .indexOf("-JavaScriptFunctionParameterJavaScript") >= 0) {
261: attrVector = (Vector) ((Attribute) (attrs
262: .elementAt(i))).vallist;
263: if (attrVector != null) {
264: count = attrVector.size();
265: JS_DJS_FUNCTION_ARRAY = new String[count];
266: for (int j = 0; j < count; ++j)
267: JS_DJS_FUNCTION_ARRAY[j] = (attrVector
268: .elementAt(j)).toString();
269: /*for(int j=0;j<count;++j)
270: System.out.println(XML_ATTRIBUTE_ARRAY[j]); */
271: }
272: }
273: }
274:
275: } catch (Exception e) {
276: e.printStackTrace();
277: System.out.println("Error reading rules");
278: }
279: }
280:
281: public static String[] APPLET_PARAM_ARRAY;
282:
283: public static String[] ATTRIBUTE_PARAM_ARRAY;
284:
285: public static String[] FORM_ARRAY;
286:
287: public static String[] JS_TOKEN_ARRAY;
288:
289: public static String[] JS_VARIABLES_SIMPLE;
290:
291: public static String[] JS_EXPRESSION_VARIABLE_ARRAY;
292:
293: public static String[] JS_DHTML_VARIABLE_ARRAY;
294:
295: public static String[] JS_DJS_VARIABLE_ARRAY;
296:
297: public static String[] JS_SIMPLE_FUNCTION_ARRAY;
298:
299: public static String[] JS_EXPRESSION_FUNCTION_ARRAY;
300:
301: public static String[] JS_DHTML_FUNCTION_ARRAY;
302:
303: public static String[] JS_DJS_FUNCTION_ARRAY;
304:
305: public static String[] JS_SYSTEM_VARIABLE_ARRAY;
306:
307: public static String[] XML_ATTRIBUTE_ARRAY;
308:
309: public static String[] XML_TEXT_ARRAY;
310:
311: public String[] getHTMLAppletData() {
312: return APPLET_PARAM_ARRAY;
313: }
314:
315: public String[] getHTMLFormData() {
316: return FORM_ARRAY;
317: }
318:
319: public String[] getHTMLAttributeData() {
320: // System.out.println("Entered attribute part...");
321: return ATTRIBUTE_PARAM_ARRAY;
322: }
323:
324: public String[] getXMLAttributeData() {
325: // System.out.println("Entered XML attribute part..."+SAMPLE_JS_TOKEN_ARRAY.toString());
326: return XML_ATTRIBUTE_ARRAY;
327: }
328:
329: public String[] getXMLTextStringData() {
330: //System.out.println("Entered XML textstring part...");
331: return XML_TEXT_ARRAY;
332: }
333:
334: public String[] getHTMLJSTokenData() {
335: return JS_TOKEN_ARRAY;
336: }
337:
338: public String[] getJSURLVariablesData() {
339: return JS_VARIABLES_SIMPLE;
340: }
341:
342: public String[] getJSExpressionVariablesData() {
343: return JS_EXPRESSION_VARIABLE_ARRAY;
344: }
345:
346: public String[] getJSDHTMLVariablesData() {
347: return JS_DHTML_VARIABLE_ARRAY;
348: }
349:
350: public String[] getJSURLFunctionParamsData() {
351: return JS_SIMPLE_FUNCTION_ARRAY;
352: }
353:
354: public String[] getJSExpressionFunctionParamsData() {
355: return JS_EXPRESSION_FUNCTION_ARRAY;
356: }
357:
358: public String[] getJSDHTMLFunctionParamsData() {
359: return JS_DHTML_FUNCTION_ARRAY;
360: }
361:
362: public String[] getJSSystemVariablesData() {
363: return JS_SYSTEM_VARIABLE_ARRAY;
364: }
365:
366: public String[] getJSDJSVariablesData() {
367: return JS_DJS_VARIABLE_ARRAY;
368:
369: }
370:
371: public String[] getJSDJSFunctionParamsData() {
372: return JS_DJS_FUNCTION_ARRAY;
373: }
374:
375: public static void main(String args[]) {
376:
377: /*try{
378: init("outGateway.xml");
379: }catch(Exception e){
380: e.printStackTrace();
381: System.out.println("Could not read file....???");
382: }*/
383: }
384: }
|