0001: /*
0002: * $Id: SrapAttrs.java,v 1.24 2003/08/15 17:48:06 ru111118 Exp $
0003: * $Source: /m/portal/ps/srap/src/migration/modules/srap/ldap/Attic/SrapAttrs.java,v $
0004: * $Log: SrapAttrs.java,v $
0005: * Revision 1.24 2003/08/15 17:48:06 ru111118
0006: * Fix for bug#4899275 migrating from AMPasswordUtil to DecryptAction and EncryptAction
0007: *
0008: * Revision 1.23 2003/07/04 09:20:59 mm132998
0009: * 3.0 -> 6.2 migration changes
0010: *
0011: * Revision 1.22 2003/06/26 12:43:25 mm132998
0012: * 3.0 -> 6.2 migration changes
0013: *
0014: * Revision 1.21 2003/06/20 11:39:57 mm132998
0015: * Initial changes for 6.2
0016: *
0017: * Revision 1.19.2.1 2002/09/30 10:48:26 bv131302
0018: * LihueRtm_branch changes
0019: *
0020: * Revision 1.13.2.4 2002/09/23 19:46:13 mm132998
0021: * CRT #1987
0022: *
0023: * Revision 1.20 2002/09/23 19:44:00 mm132998
0024: * CRT #1987
0025: *
0026: * Revision 1.19 2002/09/20 18:33:32 mm132998
0027: * CRT 1987 - Not mentioned in the CRT submision though
0028: *
0029: * Revision 1.18 2002/09/13 15:33:58 mm132998
0030: * CRT #1963
0031: *
0032: * Revision 1.17 2002/09/10 14:39:14 mm132998
0033: * CRT 1954
0034: *
0035: * Revision 1.16 2002/09/10 10:19:25 mm132998
0036: * CRT 1953
0037: *
0038: * Revision 1.15 2002/09/06 16:22:09 mm132998
0039: * CRT 1950
0040: *
0041: * Revision 1.14 2002/09/04 14:30:06 mm132998
0042: * CRT #1940
0043: *
0044: * Revision 1.13 2002/08/27 16:42:08 mm132998
0045: * CRT : 1921
0046: *
0047: * Revision 1.12 2002/08/26 13:25:53 bv131302
0048: * Hana CRT#1913 - netfile host
0049: *
0050: * Revision 1.11 2002/08/20 14:52:43 bv131302
0051: * Commonhost data migration, gateway MaxSockets removed
0052: *
0053: * Revision 1.10 2002/08/19 15:04:04 bv131302
0054: * commonhost data migration
0055: *
0056: * Revision 1.9 2002/08/13 18:25:53 mm132998
0057: * CRT : 1868 , Bugs : 4730677 ,4730681 , 4730685
0058: *
0059: * Revision 1.8 2002/08/12 15:13:14 mm132998
0060: * Bug 4719627 , 4728392
0061: *
0062: * Revision 1.7 2002/08/07 15:50:55 mm132998
0063: * 4724258,4719647,4724284,4719627,4723564,4715826
0064: *
0065: * Revision 1.6 2002/07/22 20:43:38 mm132998
0066: * Bug ID - 4718198 , Desc - Initial code changes
0067: *
0068: * Revision 1.5 2002/07/22 20:20:29 mm132998
0069: * Bug ID - 4718198 , Desc - Initial code changes
0070: *
0071: * Revision 1.4 2002/07/22 12:00:37 mm132998
0072: * Bug ID - 4718198 , Desc - Initial code changes
0073: *
0074: * Revision 1.3 2002/07/22 10:53:56 mm132998
0075: * Bug ID - 4718198 , Desc - Initial code changes
0076: *
0077: * Revision 1.2 2002/07/22 08:47:30 mm132998
0078: * Bug ID - 4718198 , Desc - Initial code changes
0079: *
0080: *
0081: */
0082: /**
0083: * $Id: SrapAttrs.java,v 1.24 2003/08/15 17:48:06 ru111118 Exp $
0084: * Copyright 2002 Sun Microsystems, Inc. All
0085: * rights reserved. Use of this product is subject
0086: * to license terms. Federal Acquisitions:
0087: * Commercial Software -- Government Users
0088: * Subject to Standard License Terms and
0089: * Conditions.
0090: *
0091: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0092: * are trademarks or registered trademarks of Sun Microsystems,
0093: * Inc. in the United States and other countries.
0094: */package migration.modules.srap.ldap;
0095:
0096: import netscape.ldap.util.*;
0097:
0098: import netscape.ldap.LDAPAttribute;
0099: import netscape.ldap.LDAPAttributeSet;
0100:
0101: import com.iplanet.portalserver.util.Password;
0102:
0103: import com.sun.identity.security.EncryptAction;
0104:
0105: import java.security.AccessController;
0106: import java.util.*;
0107: import java.io.*;
0108:
0109: public class SrapAttrs {
0110:
0111: static Map ATTRIBUTES = new HashMap();
0112: static HashMap LIHUE_ATTRIBUTES = new HashMap();
0113:
0114: static final int USER_WWW_AUTHORIZATION = 1;
0115: static final int NETFILE_HOSTDATA = 2;
0116: static final int NETFILE_NTDOMAIN = 3;
0117:
0118: static final int ROLE_AT = 4;
0119: static final int PARENT = 5;
0120:
0121: static final int NETLET_LOOPBACK_PORT = 6;
0122: static final int NETLET_PORT_WARN = 7;
0123: static final int NETLET_RULES = 8;
0124: static final int NETLET_RULESACCESS = 9;
0125: static final int NETLET_RULESDENY = 10;
0126: //static final int NETLET_HOSTACCESS = 11;
0127:
0128: static final int NETFILE_ALLOW_CHGDOMAIN = 12;
0129: static final int NETFILE_ALLOWCHGUSER = 13;
0130: static final int NETFILE_ALLOWDELETE = 14;
0131: static final int NETFILE_CHGHOSTLIST = 15;
0132: static final int NETFILE_ACCESSWIN = 16;
0133: static final int NETFILE_ACCESSFTP = 17;
0134: static final int NETFILE_ACCESSNFS = 18;
0135: static final int NETFILE_ACCESSNETWARE = 19;
0136: static final int NETFILE_WINSIZE = 20;
0137: static final int NETFILE_WINLOC = 21;
0138: static final int NETFILE_MAXSEARCHDIR = 22;
0139:
0140: static final int GATEWAY_ALLOWLIST = 23;
0141: static final int GATEWAY_DENYLIST = 24;
0142:
0143: static final int NETLET_DOMAINACCESSALLOW = 25;
0144: static final int NETLET_DOMAINACCESSDENY = 26;
0145:
0146: static final int NETLET_HOSTACCESSALLOW = 27;
0147: static final int NETLET_HOSTACCESSDENY = 28;
0148:
0149: static final int NETFILE_COMMONHOSTDATA = 29;
0150:
0151: static final int NETLET_DENIED = 30;
0152: static final int NETFILE_DENIED = 31;
0153: static final int NETFILE_CHGHOSTLIST_ALLOW = 32;
0154:
0155: //static final int NETFILE_TEMPDIR = 33;
0156:
0157: static String rootsuffix = new String("o=isp");
0158:
0159: static boolean addGatewayAccessList = true;
0160: static boolean addNetletSupport = true;
0161: static boolean addNetfileSupport = true;
0162:
0163: static String isFlat = new String("n");
0164: static String currOrgName = new String();
0165: static String RoleValue = new String();
0166:
0167: static boolean userNetfileDenied = false;
0168: static boolean userNetletDenied = false;
0169:
0170: static String currentUserOrgName = "";
0171:
0172: public static void main(String args[]) {
0173:
0174: String outputfile, ldiffile;
0175:
0176: ldiffile = new String();// Input file, the LDIF file to be converted....
0177: outputfile = new String();
0178: if (System.getProperty("FLAT") != null)
0179: isFlat = System.getProperty("FLAT");
0180:
0181: String localeString = null;
0182: if (System.getProperty("LOCALE_STRING") != null)
0183: localeString = System.getProperty("LOCALE_STRING");
0184: Locale locale = Locale.getDefault();
0185: if (localeString == null)
0186: locale = Locale.getDefault();
0187: else
0188: locale = getLocale(localeString);
0189:
0190: ResourceBundle ambundle;
0191: ambundle = ResourceBundle.getBundle("AMConfig", locale);
0192: if (ambundle.getObject("com.iplanet.am.rootsuffix") != null)
0193: rootsuffix = (String) (ambundle
0194: .getObject("com.iplanet.am.rootsuffix"));
0195: if (args.length == 3) {
0196: outputfile = args[1];
0197: ldiffile = args[0];
0198: System.out.println("Outputfile : " + outputfile
0199: + " Inputfile : " + ldiffile + "doConvert : "
0200: + args[2]);
0201: try {
0202: int tmp = Integer.parseInt(args[2]);
0203: addGatewayAccessList = false;
0204: addNetletSupport = false;
0205: addNetfileSupport = false;
0206: if ((tmp & 1) == 1) {
0207: // Gateway Support
0208: addGatewayAccessList = true;
0209: }
0210: if ((tmp & 2) == 2) {
0211: addNetletSupport = true;
0212: }
0213: if ((tmp & 4) == 4) {
0214: addNetfileSupport = true;
0215: }
0216: } catch (NumberFormatException nfex) {
0217: nfex.printStackTrace();
0218:
0219: }
0220: } else if (args.length == 3) {
0221: outputfile = args[1];
0222: ldiffile = args[0];
0223: } else if (args.length == 1) {
0224: outputfile = new String("default.ldif");
0225: ldiffile = args[0];
0226: } else if (args.length == 0) {
0227: System.out
0228: .println("Input file to be converted not specified!");
0229: System.out
0230: .println("Invokation Format is:java UsersConvert infile outfile");
0231: System.exit(1);
0232: }
0233:
0234: doConvert(ldiffile, outputfile);
0235: System.exit(0);
0236: }
0237:
0238: public static void doConvert(String ldiffile, String outputfile) {
0239: LDIFRecord out;
0240: FileWriter outFile;
0241: int count = 0;
0242: LDIF l1;
0243: //LDIFWriter convertedFile;
0244:
0245: InitHashMap(); // Populate the hash map.
0246:
0247: try {
0248: l1 = new LDIF(ldiffile);
0249: // convertedFile=new LDIFWriter(new PrintWriter(new FileOutputStream(outputfile)));
0250:
0251: outFile = new FileWriter(outputfile);
0252:
0253: System.out
0254: .println("Converting LDIF entries corr. to users from file:"
0255: + ldiffile + ".....\n");
0256:
0257: LDIFRecord tmp = l1.nextRecord();
0258:
0259: while (tmp != null) {
0260: // System.out.println("\n # Entry id:"+count);
0261: //OutputRecord(tmp);
0262:
0263: outFile.write("\n# Entry id:" + count + "\n");
0264: out = ConvertRecord(tmp, count++);
0265: try {
0266: OutputRecord(outFile, out);
0267: } catch (Exception e) {
0268: System.out.println("Error writing to output file:"
0269: + outputfile);
0270: e.printStackTrace();
0271: }
0272: tmp = l1.nextRecord();
0273: }
0274: outFile.close();
0275: System.out.println("Processed " + count + " entries");
0276: System.out
0277: .println("Output available in file " + outputfile);
0278: } catch (IOException e) {
0279: System.out.println("Error:" + e.toString());
0280: e.printStackTrace();
0281: }
0282: }
0283:
0284: static void InitHashMap() {
0285: /* Populate hash map to have the list of attributest that need to be processed....
0286: Attributes in the display profile stored in LDAP are not put in Hash Table.
0287: They are handled differently....*/
0288:
0289: //ATTRIBUTES.put((new String("uid")).toLowerCase(), new Integer(UID));
0290: ATTRIBUTES.put((new String("iwtUser-WWW-Authorization-at"))
0291: .toLowerCase(), new Integer(USER_WWW_AUTHORIZATION));
0292: ATTRIBUTES.put((new String("iwtNetFile-hostdata-at"))
0293: .toLowerCase(), new Integer(NETFILE_HOSTDATA));
0294: ATTRIBUTES.put((new String("iwtNetFile-ntdomain-at"))
0295: .toLowerCase(), new Integer(NETFILE_NTDOMAIN));
0296: ATTRIBUTES.put((new String("parent")).toLowerCase(),
0297: new Integer(PARENT));
0298: ATTRIBUTES.put((new String("iwtUser-role-at")).toLowerCase(),
0299: new Integer(ROLE_AT));
0300: // Netlet
0301: ATTRIBUTES.put((new String("iwtNetlet-clientLoopbackPort-at"))
0302: .toLowerCase(), new Integer(NETLET_LOOPBACK_PORT));
0303: ATTRIBUTES.put((new String("iwtNetlet-portWarn-at"))
0304: .toLowerCase(), new Integer(NETLET_PORT_WARN));
0305: ATTRIBUTES.put(
0306: (new String("iwtNetlet-Rules-at")).toLowerCase(),
0307: new Integer(NETLET_RULES));
0308: ATTRIBUTES.put((new String("iwtNetlet-access-pv-al-"))
0309: .toLowerCase(), new Integer(NETLET_RULESACCESS));
0310: ATTRIBUTES.put((new String("iwtNetlet-access-pv-de-"))
0311: .toLowerCase(), new Integer(NETLET_RULESDENY));
0312: ATTRIBUTES.put((new String("iwtNetlet-hostAccess-pv-al-"))
0313: .toLowerCase(), new Integer(NETLET_HOSTACCESSALLOW));
0314: ATTRIBUTES.put((new String("iwtNetlet-hostAccess-pv-de-"))
0315: .toLowerCase(), new Integer(NETLET_HOSTACCESSDENY));
0316: ATTRIBUTES.put((new String("iwtNetlet-domainAccess-pv-al-"))
0317: .toLowerCase(), new Integer(NETLET_DOMAINACCESSALLOW));
0318: ATTRIBUTES.put((new String("iwtNetlet-domainAccess-pv-de-"))
0319: .toLowerCase(), new Integer(NETLET_DOMAINACCESSDENY));
0320: // Netfile
0321: ATTRIBUTES.put((new String("iwtNetFile-allowchgdomain-pv-ac-"))
0322: .toLowerCase(), new Integer(NETFILE_ALLOW_CHGDOMAIN));
0323: ATTRIBUTES.put((new String("iwtNetFile-allowchguserid-pv-ac-"))
0324: .toLowerCase(), new Integer(NETFILE_ALLOWCHGUSER));
0325: ATTRIBUTES.put((new String("iwtNetFile-allowdelete-pv-ac-"))
0326: .toLowerCase(), new Integer(NETFILE_ALLOWDELETE));
0327: ATTRIBUTES.put((new String("iwtNetFile-chghostlist-pv-de-"))
0328: .toLowerCase(), new Integer(NETFILE_CHGHOSTLIST));
0329: ATTRIBUTES.put((new String("iwtNetFile-chghostlist-pv-al-"))
0330: .toLowerCase(), new Integer(NETFILE_CHGHOSTLIST_ALLOW));
0331: ATTRIBUTES.put((new String("iwtNetFile-accesswin-at"))
0332: .toLowerCase(), new Integer(NETFILE_ACCESSWIN));
0333: ATTRIBUTES.put((new String("iwtNetFile-accessftp-at"))
0334: .toLowerCase(), new Integer(NETFILE_ACCESSFTP));
0335: ATTRIBUTES.put((new String("iwtNetFile-accessnfs-at"))
0336: .toLowerCase(), new Integer(NETFILE_ACCESSNFS));
0337: ATTRIBUTES.put((new String("iwtNetFile-accessnetware-at"))
0338: .toLowerCase(), new Integer(NETFILE_ACCESSNETWARE));
0339: ATTRIBUTES.put((new String("iwtNetFile-winsize-at"))
0340: .toLowerCase(), new Integer(NETFILE_WINSIZE));
0341: ATTRIBUTES.put((new String("iwtNetFile-winloc-at"))
0342: .toLowerCase(), new Integer(NETFILE_WINLOC));
0343: ATTRIBUTES.put((new String("iwtNetFile-maxsearchdir-at"))
0344: .toLowerCase(), new Integer(NETFILE_MAXSEARCHDIR));
0345: ATTRIBUTES.put((new String("iwtNetFile-commonhostdata-at"))
0346: .toLowerCase(), new Integer(NETFILE_COMMONHOSTDATA));
0347:
0348: ATTRIBUTES.put((new String("iwtUser-URLPrivList-pv-al-"))
0349: .toLowerCase(), new Integer(GATEWAY_ALLOWLIST));
0350: ATTRIBUTES.put((new String("iwtUser-URLPrivList-pv-de-"))
0351: .toLowerCase(), new Integer(GATEWAY_DENYLIST));
0352:
0353: ATTRIBUTES.put((new String("iwtNetFile-execute-pv-ac-"))
0354: .toLowerCase(), new Integer(NETFILE_DENIED));
0355: ATTRIBUTES.put((new String("iwtNetlet-execute-pv-ac-"))
0356: .toLowerCase(), new Integer(NETLET_DENIED));
0357: //ATTRIBUTES.put((new String("iwtNetFile-tempdir-at")).toLowerCase(), new Integer(NETFILE_TEMPDIR));
0358:
0359: // LIHUE_ATTRIBUTES
0360: LIHUE_ATTRIBUTES.put("sunPortalNetFileHostTypePassShare"
0361: .toLowerCase(), "sunPortalNetFileHostTypePassShare");
0362: LIHUE_ATTRIBUTES.put("sunPortalNetFileNTDomain".toLowerCase(),
0363: "sunPortalNetFileNTDomain");
0364: LIHUE_ATTRIBUTES.put("sunPortalGatewayWWWAuthorization"
0365: .toLowerCase(), "sunPortalGatewayWWWAuthorization");
0366: LIHUE_ATTRIBUTES.put("sunPortalNetletClientLoopbackPort"
0367: .toLowerCase(), "sunPortalNetletClientLoopbackPort");
0368: LIHUE_ATTRIBUTES.put("sunPortalNetletPortWarn".toLowerCase(),
0369: "sunPortalNetletPortWarn");
0370: LIHUE_ATTRIBUTES.put("sunPortalNetletRules".toLowerCase(),
0371: "sunPortalNetletRules");
0372: LIHUE_ATTRIBUTES.put(
0373: "sunPortalNetletAccessRules".toLowerCase(),
0374: "sunPortalNetletAccessRules");
0375: LIHUE_ATTRIBUTES.put("sunPortalNetletDenyRules".toLowerCase(),
0376: "sunPortalNetletDenyRules");
0377: LIHUE_ATTRIBUTES.put("sunPortalNetFileAllowChangeDomain"
0378: .toLowerCase(), "sunPortalNetFileAllowChangeDomain");
0379: LIHUE_ATTRIBUTES.put("sunPortalNetFileAllowChangeUserId"
0380: .toLowerCase(), "sunPortalNetFileAllowChangeUserId");
0381: LIHUE_ATTRIBUTES.put("sunPortalNetFileAllowDelete"
0382: .toLowerCase(), "sunPortalNetFileAllowDelete");
0383: LIHUE_ATTRIBUTES.put("sunPortalNetFileDeniedHostList"
0384: .toLowerCase(), "sunPortalNetFileDeniedHostList");
0385: LIHUE_ATTRIBUTES.put("sunPortalNetFileAllowedHostList"
0386: .toLowerCase(), "sunPortalNetFileAllowedHostList");
0387:
0388: LIHUE_ATTRIBUTES.put("sunPortalNetFileAccessWin".toLowerCase(),
0389: "sunPortalNetFileAccessWin");
0390: LIHUE_ATTRIBUTES.put("sunPortalNetFileAccessFTP".toLowerCase(),
0391: "sunPortalNetFileAccessFTP");
0392: LIHUE_ATTRIBUTES.put("sunPortalNetFileAccessNFS".toLowerCase(),
0393: "sunPortalNetFileAccessNFS");
0394: LIHUE_ATTRIBUTES.put("sunPortalNetFileAccessNetware"
0395: .toLowerCase(), "sunPortalNetFileAccessNetware");
0396: LIHUE_ATTRIBUTES.put(
0397: "sunPortalNetFileWindowSize".toLowerCase(),
0398: "sunPortalNetFileWindowSize");
0399: LIHUE_ATTRIBUTES.put("sunPortalNetFileWindowLocation"
0400: .toLowerCase(), "sunPortalNetFileWindowLocation");
0401: LIHUE_ATTRIBUTES.put("sunPortalNetFileMaxSearchDir"
0402: .toLowerCase(), "sunPortalNetFileMaxSearchDir");
0403: LIHUE_ATTRIBUTES.put("sunPortalGatewayAccessAllowList"
0404: .toLowerCase(), "sunPortalGatewayAccessAllowList");
0405: LIHUE_ATTRIBUTES.put("sunPortalGatewayAccessDenyList"
0406: .toLowerCase(), "sunPortalGatewayAccessDenyList");
0407: LIHUE_ATTRIBUTES.put(
0408: "sunPortalNetletAccessHosts".toLowerCase(),
0409: "sunPortalNetletAccessHosts");
0410: LIHUE_ATTRIBUTES.put("sunPortalNetletDenyHosts".toLowerCase(),
0411: "sunPortalNetletDenyHosts");
0412: LIHUE_ATTRIBUTES.put("sunPortalNetFileCommonHostData"
0413: .toLowerCase(), "sunPortalNetFileCommonHostData");
0414: //LIHUE_ATTRIBUTES.put("sunPortalNetFileTempDir".toLowerCase(),"sunPortalNetFileTempDir");
0415: }
0416:
0417: static LDIFRecord ConvertRecord(LDIFRecord toConvert, int count) {
0418: LDIFAttributeContent con, converted;
0419: LDAPAttribute tmp;
0420: LDAPAttributeSet theAttrSet;
0421: String attrVal, firstname;
0422: String[] allAttrs;
0423: String[] listAllAttrs;
0424: Vector dispProf = new Vector();
0425: String lastname = new String();
0426: boolean cnValuetobeSet = false;
0427: String[] allAttrsConv;
0428: int tmpcount;
0429:
0430: String[] netletHostAccessAllow = null;
0431: String[] netletHostAccessDeny = null;
0432: String[] netletDomainAccessAllow = null;
0433: String[] netletDomainAccessDeny = null;
0434:
0435: userNetfileDenied = false;
0436: userNetletDenied = false;
0437:
0438: firstname = new String();
0439:
0440: LDAPAttribute[] attrList;
0441: int i, typeAttr;
0442:
0443: con = (LDIFAttributeContent) toConvert.getContent();
0444: converted = new LDIFAttributeContent();
0445: attrList = con.getAttributes();
0446: theAttrSet = new LDAPAttributeSet(attrList);
0447:
0448: converted.setControls(con.getControls());
0449:
0450: for (i = 0; i < attrList.length; ++i) {
0451: typeAttr = attrType(attrList[i].getName());
0452: allAttrs = (((LDAPAttribute) (theAttrSet
0453: .getAttribute(attrList[i].getName())))
0454: .getStringValueArray());
0455: switch (typeAttr) {
0456:
0457: case -1:
0458: /* Populate the list of attributes that correspond to the Display profile....*/
0459:
0460: break;
0461:
0462: case PARENT:
0463: currOrgName = (allAttrs[0].trim()).substring(1);
0464: break;
0465:
0466: case ROLE_AT:
0467: RoleValue = allAttrs[1];
0468: if (isFlat.equalsIgnoreCase("y")) {
0469: allAttrsConv = getnsRoleDN(allAttrs[1]);
0470: converted.addElement(new LDAPAttribute("nsRoleDN",
0471: allAttrsConv));
0472: }
0473: break;
0474:
0475: case NETFILE_HOSTDATA:
0476:
0477: if (allAttrs.length > 1) {
0478: Object array[] = new Object[allAttrs.length - 1];
0479: int length = 0;
0480: for (int jk = 1; jk < allAttrs.length; ++jk) {
0481: String plainData = Password
0482: .decrypt(allAttrs[jk]);
0483: if (plainData.length() != 0) {
0484: listAllAttrs = (String[]) NetfileUtil
0485: .getHostTypePassShareAttrb(
0486: plainData,
0487: NetfileUtil.STRING_ARRAY);
0488: length += listAllAttrs.length;
0489: array[jk - 1] = listAllAttrs;
0490: } else {
0491: array[jk - 1] = null;
0492: }
0493: }
0494: listAllAttrs = new String[length];
0495: String tmpArray[];
0496: int indx = 0;
0497: int resultIndex = 0;
0498: while (indx < array.length) {
0499: if (array[indx] != null) {
0500: tmpArray = (String[]) array[indx];
0501: int indx1 = 0;
0502: while (indx1 < tmpArray.length) {
0503: listAllAttrs[resultIndex] = Base64
0504: .encode((String) AccessController
0505: .doPrivileged(new EncryptAction(
0506: tmpArray[indx1])));
0507: //listAllAttrs[resultIndex] = tmpArray[indx1];
0508: indx1++;
0509: resultIndex++;
0510: }
0511: }
0512: indx++;
0513: }
0514: converted.addElement(new LDAPAttribute(
0515: "sunPortalNetFileHostTypePassShare",
0516: listAllAttrs));
0517: }
0518: break;
0519:
0520: case NETFILE_NTDOMAIN:
0521:
0522: if (allAttrs.length > 1) {
0523: listAllAttrs = new String[allAttrs.length - 1];
0524: for (int jk = 1; jk < allAttrs.length; ++jk)
0525: listAllAttrs[jk - 1] = allAttrs[jk];
0526: converted.addElement(new LDAPAttribute(
0527: "sunPortalNetFileNTDomain", listAllAttrs));
0528: }
0529: break;
0530:
0531: case USER_WWW_AUTHORIZATION:
0532:
0533: if (allAttrs.length > 1) {
0534: listAllAttrs = new String[allAttrs.length - 1];
0535: for (int jk = 1; jk < allAttrs.length; ++jk)
0536: listAllAttrs[jk - 1] = allAttrs[jk];
0537: converted.addElement(new LDAPAttribute(
0538: "sunPortalGatewayWWWAuthorization",
0539: listAllAttrs));
0540: }
0541: break;
0542:
0543: case NETLET_LOOPBACK_PORT:
0544: if (allAttrs.length > 1) {
0545: listAllAttrs = new String[1];
0546: listAllAttrs[0] = allAttrs[1];
0547: converted.addElement(new LDAPAttribute(
0548: "sunPortalNetletClientLoopbackPort",
0549: listAllAttrs));
0550: }
0551: break;
0552:
0553: case NETLET_PORT_WARN:
0554: converted.addElement(new LDAPAttribute(
0555: "sunPortalNetletPortWarn", allAttrs[1]));
0556: break;
0557:
0558: case NETLET_RULES:
0559:
0560: if (allAttrs.length > 1) {
0561: listAllAttrs = new String[allAttrs.length - 1];
0562: tmpcount = 1;
0563: while (tmpcount < allAttrs.length) {
0564: listAllAttrs[tmpcount - 1] = allAttrs[tmpcount];
0565: tmpcount++;
0566: }
0567: converted.addElement(new LDAPAttribute(
0568: "sunPortalNetletRules", listAllAttrs));
0569: }
0570: break;
0571:
0572: case NETLET_RULESACCESS:
0573: if (allAttrs.length > 0) {
0574: listAllAttrs = new String[allAttrs.length];
0575: tmpcount = 0;
0576: while (tmpcount < allAttrs.length) {
0577: listAllAttrs[tmpcount] = allAttrs[tmpcount];
0578: tmpcount++;
0579: }
0580: converted
0581: .addElement(new LDAPAttribute(
0582: "sunPortalNetletAccessRules",
0583: listAllAttrs));
0584: tmpcount++;
0585: }
0586: break;
0587:
0588: case NETLET_RULESDENY:
0589: if (allAttrs.length > 0) {
0590: listAllAttrs = new String[allAttrs.length];
0591: tmpcount = 0;
0592: while (tmpcount < allAttrs.length) {
0593: listAllAttrs[tmpcount] = allAttrs[tmpcount];
0594: tmpcount++;
0595: }
0596: converted.addElement(new LDAPAttribute(
0597: "sunPortalNetletDenyRules", listAllAttrs));
0598: tmpcount++;
0599: }
0600: break;
0601:
0602: case NETLET_HOSTACCESSALLOW:
0603: netletHostAccessAllow = allAttrs;
0604: break;
0605:
0606: case NETLET_HOSTACCESSDENY:
0607: netletHostAccessDeny = allAttrs;
0608: break;
0609:
0610: case NETLET_DOMAINACCESSALLOW:
0611: netletDomainAccessAllow = allAttrs;
0612: break;
0613:
0614: case NETLET_DOMAINACCESSDENY:
0615: netletDomainAccessDeny = allAttrs;
0616: break;
0617:
0618: case NETFILE_ALLOW_CHGDOMAIN:
0619: if (allAttrs.length > 0) {
0620: listAllAttrs = new String[1];
0621: listAllAttrs[0] = allAttrs[0];
0622: converted.addElement(new LDAPAttribute(
0623: "sunPortalNetFileAllowChangeDomain",
0624: listAllAttrs));
0625: }
0626: break;
0627: /*
0628: case NETFILE_TEMPDIR:
0629: if (allAttrs.length > 0){
0630: listAllAttrs = new String[1];
0631: listAllAttrs[0] = allAttrs[0];
0632: converted.addElement(new LDAPAttribute("sunPortalNetFileTempDir",listAllAttrs));
0633: }
0634: break;
0635: */
0636: case NETFILE_ALLOWCHGUSER:
0637: if (allAttrs.length > 0) {
0638: listAllAttrs = new String[1];
0639: listAllAttrs[0] = allAttrs[0];
0640: converted.addElement(new LDAPAttribute(
0641: "sunPortalNetFileAllowChangeUserId",
0642: listAllAttrs));
0643: }
0644: break;
0645: case NETFILE_ALLOWDELETE:
0646: if (allAttrs.length > 0) {
0647: listAllAttrs = new String[1];
0648: listAllAttrs[0] = allAttrs[0];
0649: converted
0650: .addElement(new LDAPAttribute(
0651: "sunPortalNetFileAllowDelete",
0652: listAllAttrs));
0653: }
0654: break;
0655: case NETFILE_CHGHOSTLIST:
0656: if (allAttrs.length > 0) {
0657: listAllAttrs = new String[allAttrs.length];
0658: tmpcount = 0;
0659: while (tmpcount < allAttrs.length) {
0660: listAllAttrs[tmpcount] = allAttrs[tmpcount];
0661: tmpcount++;
0662: }
0663: converted.addElement(new LDAPAttribute(
0664: "sunPortalNetFileDeniedHostList",
0665: listAllAttrs));
0666: tmpcount++;
0667: }
0668: break;
0669: case NETFILE_CHGHOSTLIST_ALLOW:
0670: if (allAttrs.length > 0) {
0671: listAllAttrs = new String[allAttrs.length];
0672: tmpcount = 0;
0673: while (tmpcount < allAttrs.length) {
0674: listAllAttrs[tmpcount] = allAttrs[tmpcount];
0675: tmpcount++;
0676: }
0677: converted.addElement(new LDAPAttribute(
0678: "sunPortalNetFileAllowedHostList",
0679: listAllAttrs));
0680: tmpcount++;
0681: }
0682: break;
0683: case NETFILE_ACCESSWIN:
0684: if (allAttrs.length > 1) {
0685: listAllAttrs = new String[1];
0686: listAllAttrs[0] = allAttrs[1];
0687: converted.addElement(new LDAPAttribute(
0688: "sunPortalNetFileAccessWin", listAllAttrs));
0689: }
0690: break;
0691: case NETFILE_ACCESSFTP:
0692: if (allAttrs.length > 1) {
0693: listAllAttrs = new String[1];
0694: listAllAttrs[0] = allAttrs[1];
0695: converted.addElement(new LDAPAttribute(
0696: "sunPortalNetFileAccessFTP", listAllAttrs));
0697: }
0698: break;
0699: case NETFILE_ACCESSNFS:
0700: if (allAttrs.length > 1) {
0701: listAllAttrs = new String[1];
0702: listAllAttrs[0] = allAttrs[1];
0703: converted.addElement(new LDAPAttribute(
0704: "sunPortalNetFileAccessNFS", listAllAttrs));
0705: }
0706: break;
0707: case NETFILE_ACCESSNETWARE:
0708: if (allAttrs.length > 1) {
0709: listAllAttrs = new String[1];
0710: listAllAttrs[0] = allAttrs[1];
0711: converted.addElement(new LDAPAttribute(
0712: "sunPortalNetFileAccessNetware",
0713: listAllAttrs));
0714: }
0715: break;
0716: case NETFILE_WINSIZE:
0717: if (allAttrs.length > 1) {
0718: listAllAttrs = new String[1];
0719: listAllAttrs[0] = allAttrs[1];
0720: converted
0721: .addElement(new LDAPAttribute(
0722: "sunPortalNetFileWindowSize",
0723: listAllAttrs));
0724: }
0725: break;
0726: case NETFILE_WINLOC:
0727: if (allAttrs.length > 1) {
0728: listAllAttrs = new String[1];
0729: listAllAttrs[0] = allAttrs[1];
0730: converted.addElement(new LDAPAttribute(
0731: "sunPortalNetFileWindowLocation",
0732: listAllAttrs));
0733: }
0734: break;
0735: case NETFILE_MAXSEARCHDIR:
0736: if (allAttrs.length > 1) {
0737: listAllAttrs = new String[1];
0738: listAllAttrs[0] = allAttrs[1];
0739: converted.addElement(new LDAPAttribute(
0740: "sunPortalNetFileMaxSearchDir",
0741: listAllAttrs));
0742: }
0743: break;
0744: case GATEWAY_ALLOWLIST:
0745: if (allAttrs.length > 0) {
0746: listAllAttrs = new String[allAttrs.length];
0747: tmpcount = 0;
0748: while (tmpcount < allAttrs.length) {
0749: listAllAttrs[tmpcount] = allAttrs[tmpcount];
0750: tmpcount++;
0751: }
0752: converted.addElement(new LDAPAttribute(
0753: "sunPortalGatewayAccessAllowList",
0754: listAllAttrs));
0755: tmpcount++;
0756: }
0757: break;
0758: case GATEWAY_DENYLIST:
0759: if (allAttrs.length > 0) {
0760: listAllAttrs = new String[allAttrs.length];
0761: tmpcount = 0;
0762: while (tmpcount < allAttrs.length) {
0763: listAllAttrs[tmpcount] = allAttrs[tmpcount];
0764: tmpcount++;
0765: }
0766: converted.addElement(new LDAPAttribute(
0767: "sunPortalGatewayAccessDenyList",
0768: listAllAttrs));
0769: tmpcount++;
0770: }
0771: break;
0772: case NETFILE_COMMONHOSTDATA:
0773: if (allAttrs.length > 1) {
0774: /*
0775: * Looks like -
0776: * 1) There can be multiple entries for common host data in 3.0
0777: * 2) 6.0 multiple entries have to be seperated by '\n'
0778: */
0779: Object array[] = new Object[allAttrs.length - 1];
0780: int length = 0;
0781: for (int jk = 1; jk < allAttrs.length; ++jk) {
0782: String plainData = allAttrs[jk].toString();
0783: if (plainData.length() != 0) {
0784: listAllAttrs = (String[]) NetfileUtil
0785: .getHostTypePassShareAttrb(
0786: plainData,
0787: NetfileUtil.STRING_ARRAY);
0788: length += listAllAttrs.length;
0789: array[jk - 1] = listAllAttrs;
0790: } else {
0791: array[jk - 1] = null;
0792: }
0793: }
0794: listAllAttrs = new String[1];
0795: StringBuffer outBuff = new StringBuffer();
0796: boolean firstEntryDone = false;
0797: String tmpArray[];
0798: int indx = 0;
0799: int resultIndex = 0;
0800: while (indx < array.length) {
0801: if (array[indx] != null) {
0802: tmpArray = (String[]) array[indx];
0803: int indx1 = 0;
0804: while (indx1 < tmpArray.length) {
0805: //listAllAttrs[resultIndex] = Base64.encode(tmpArray[indx1]);
0806: //listAllAttrs[resultIndex] = tmpArray[indx1];
0807: if (!firstEntryDone) {
0808: firstEntryDone = true;
0809: } else {
0810: outBuff.append('\n');
0811: }
0812: outBuff.append(tmpArray[indx1]);
0813: indx1++;
0814: resultIndex++;
0815: }
0816: }
0817: indx++;
0818: }
0819: listAllAttrs[0] = Base64.encode(outBuff.toString());
0820: converted.addElement(new LDAPAttribute(
0821: "sunPortalNetFileCommonHostData",
0822: listAllAttrs));
0823: }
0824: break;
0825: case NETLET_DENIED:
0826: userNetletDenied = allAttrs[0]
0827: .equalsIgnoreCase("false");
0828: break;
0829:
0830: case NETFILE_DENIED:
0831: userNetfileDenied = allAttrs[0]
0832: .equalsIgnoreCase("false");
0833: break;
0834: }
0835: }
0836:
0837: if (netletDomainAccessAllow != null
0838: || netletHostAccessAllow != null) {
0839: if (netletHostAccessAllow != null
0840: && netletDomainAccessAllow != null) {
0841: listAllAttrs = new String[netletDomainAccessAllow.length
0842: + netletHostAccessAllow.length];
0843: } else if (netletDomainAccessAllow != null) {
0844: listAllAttrs = new String[netletDomainAccessAllow.length];
0845: } else {
0846: listAllAttrs = new String[netletHostAccessAllow.length];
0847: }
0848: tmpcount = 0;
0849: if (netletHostAccessAllow != null) {
0850: int tmpitercount = 0;
0851:
0852: while (tmpitercount < netletHostAccessAllow.length) {
0853: listAllAttrs[tmpcount] = netletHostAccessAllow[tmpitercount];
0854: tmpcount++;
0855: tmpitercount++;
0856: }
0857: }
0858: if (netletDomainAccessAllow != null) {
0859: int tmpitercount = 0;
0860:
0861: while (tmpitercount < netletDomainAccessAllow.length) {
0862: listAllAttrs[tmpcount] = "*."
0863: + netletDomainAccessAllow[tmpitercount];
0864: tmpcount++;
0865: tmpitercount++;
0866: }
0867: }
0868: converted.addElement(new LDAPAttribute(
0869: "sunPortalNetletAccessHosts", listAllAttrs));
0870: }
0871: if (netletDomainAccessDeny != null
0872: || netletHostAccessDeny != null) {
0873: if (netletHostAccessDeny != null
0874: && netletDomainAccessDeny != null) {
0875: listAllAttrs = new String[netletDomainAccessDeny.length
0876: + netletHostAccessDeny.length];
0877: } else if (netletDomainAccessDeny != null) {
0878: listAllAttrs = new String[netletDomainAccessDeny.length];
0879: } else {
0880: listAllAttrs = new String[netletHostAccessDeny.length];
0881: }
0882: tmpcount = 0;
0883: if (netletHostAccessDeny != null) {
0884: int tmpitercount = 0;
0885:
0886: while (tmpitercount < netletHostAccessDeny.length) {
0887: listAllAttrs[tmpcount] = netletHostAccessDeny[tmpitercount];
0888: tmpcount++;
0889: tmpitercount++;
0890: }
0891: }
0892: if (netletDomainAccessDeny != null) {
0893: int tmpitercount = 0;
0894:
0895: while (tmpitercount < netletDomainAccessDeny.length) {
0896: listAllAttrs[tmpcount] = "*."
0897: + netletDomainAccessDeny[tmpitercount];
0898: tmpcount++;
0899: tmpitercount++;
0900: }
0901: }
0902: converted.addElement(new LDAPAttribute(
0903: "sunPortalNetletDenyHosts", listAllAttrs));
0904: }
0905:
0906: return new LDIFRecord(toConvert.getDN(), converted);
0907: }
0908:
0909: static int attrType(String attrName) {
0910: /* Returns the type of attribute that is being handled currently....*/
0911:
0912: try {
0913: return ((Integer) ATTRIBUTES.get(attrName.toLowerCase()))
0914: .intValue();
0915: } catch (Exception e) {
0916: return -1;
0917: }
0918: }
0919:
0920: static boolean isValidLihueEntry(String attr) {
0921:
0922: return LIHUE_ATTRIBUTES.get(attr.toLowerCase()) != null ? true
0923: : false;
0924: }
0925:
0926: static void OutputRecord(FileWriter fw, LDIFRecord toOutput)
0927: throws Exception {
0928: LDIFAttributeContent con;
0929: LDAPAttribute[] list;
0930: LDAPAttributeSet theAttrSet;
0931: String[] values;
0932: String dnVal = new String();
0933: StringBuffer sb = new StringBuffer();
0934:
0935: boolean paramSet = false;
0936:
0937: con = (LDIFAttributeContent) toOutput.getContent();
0938: list = con.getAttributes();
0939: theAttrSet = new LDAPAttributeSet(list);
0940: //dnVal=processDN(toOutput.getDN());
0941: if (isFlat.equalsIgnoreCase("y"))
0942: dnVal = getDN(toOutput.getDN());
0943: else
0944: dnVal = processDN(toOutput.getDN());
0945:
0946: // Workaround for setting dynamic attribute
0947: if (addGatewayAccessList || addNetfileSupport
0948: || addNetletSupport) {
0949: paramSet = true;
0950: sb.append("\ndn:").append(dnVal);
0951: sb.append("\nchangetype:modify");
0952: sb.append("\nadd: objectclass");
0953: // Which all object classes to add.
0954: if (addGatewayAccessList) {
0955: sb
0956: .append("\nobjectclass:sunPortalGatewayAccessService");
0957: }
0958: if (addNetletSupport) {
0959: sb.append("\nobjectclass:sunPortalNetletService");
0960: }
0961: /*
0962: // From 6.2 , we dont need this !
0963: if (addNetfileSupport){
0964: // TODO :: Add the "NetFile User Role" role to this user.
0965: sb
0966: .append("\nobjectclass:sunPortalNetFileService")
0967: .append("\n\ndn:").append(dnVal)
0968: .append("\nchangetype:modify")
0969: .append("\nadd: nsRoleDN")
0970: .append("\nnsRoleDN: cn=NetFile User Role")
0971: .append(currentUserOrgName)
0972: .append("\n");
0973: }
0974: */
0975: }
0976: if (userNetfileDenied) {
0977: sb.append("\ndn:").append(dnVal).append(
0978: "\nchangetype:modify").append("\nadd: nsRoleDN")
0979: .append("\nnsRoleDN: cn=NetFile Denied User Role")
0980: .append(currentUserOrgName).append("\n");
0981: }
0982: if (userNetletDenied) {
0983: sb.append("\ndn:").append(dnVal).append(
0984: "\nchangetype:modify").append("\nadd: nsRoleDN")
0985: .append("\nnsRoleDN: cn=Netlet Denied User Role")
0986: .append(currentUserOrgName).append("\n");
0987: }
0988: System.out.println("Processing dn : " + dnVal + " , org - "
0989: + currentUserOrgName);
0990: sb.append("\n");
0991: if (theAttrSet.size() > 0) {
0992: for (int i = 0; i < theAttrSet.size(); ++i) {
0993: values = (String[]) (theAttrSet.elementAt(i))
0994: .getStringValueArray();
0995:
0996: if (isValidLihueEntry((theAttrSet.elementAt(i))
0997: .getName().trim())) {
0998: paramSet = true;
0999: sb.append("\ndn:" + dnVal);
1000: sb.append("\nchangetype:modify");
1001: sb.append("\nadd:"
1002: + (theAttrSet.elementAt(i)).getName());
1003: for (int j = 0; j < values.length; ++j) {
1004: sb.append("\n"
1005: + (theAttrSet.elementAt(i)).getName());
1006: if ((theAttrSet.elementAt(i)).getName().equals(
1007: "sunPortalNetFileHostTypePassShare")
1008: || (theAttrSet.elementAt(i))
1009: .getName()
1010: .equals(
1011: "sunPortalNetFileCommonHostData"))
1012: sb.append("::" + values[j]);
1013: else
1014: sb.append(":" + values[j]);
1015: }
1016: sb.append("\n");
1017: }
1018: }
1019: }
1020: if (paramSet == true)
1021: fw.write(sb.toString());
1022: return;
1023: }
1024:
1025: static String processDN(String inDN) {
1026: String toRet = new String("uid=");
1027: String tmp;
1028:
1029: inDN = inDN.trim();
1030: toRet = toRet
1031: + inDN.substring(inDN.indexOf("=") + 1, inDN
1032: .indexOf(",")) + ",ou=People";
1033: currentUserOrgName = "";
1034: if (RoleValue.equals("")) {
1035: //System.out.println("Returning DN:"+toRet);
1036: } else {
1037: //System.out.println("RoleValue.."+RoleValue);
1038: tmp = RoleValue;
1039: while (tmp.indexOf("/") >= 0) {
1040: String tmpStr = ",o="
1041: + tmp.substring(tmp.lastIndexOf("/") + 1);
1042: currentUserOrgName += tmpStr;
1043: toRet += tmpStr;
1044: tmp = tmp.substring(0, tmp.lastIndexOf("/"));
1045: }
1046: }
1047: toRet = toRet + "," + rootsuffix;
1048: currentUserOrgName = currentUserOrgName + "," + rootsuffix;
1049: return toRet;
1050: }
1051:
1052: static java.util.Locale getLocale(String stringformat) {
1053: if (stringformat == null)
1054: return java.util.Locale.getDefault();
1055:
1056: StringTokenizer tk = new StringTokenizer(stringformat, "_");
1057: String lang = "";
1058: String country = "";
1059: String variant = "";
1060:
1061: if (tk.hasMoreTokens())
1062: lang = tk.nextToken();
1063: if (tk.hasMoreTokens())
1064: country = tk.nextToken();
1065: if (tk.hasMoreTokens())
1066: variant = tk.nextToken();
1067:
1068: return new java.util.Locale(lang, country, variant);
1069: }
1070:
1071: static String getDN(String inDN) {
1072: String toRet = new String("uid=");
1073:
1074: toRet = toRet
1075: + inDN.substring(inDN.indexOf("=") + 1, inDN
1076: .indexOf(",")) + ",ou=People,o=" + currOrgName;
1077: currentUserOrgName = currOrgName + "," + rootsuffix;
1078: toRet = toRet + "," + rootsuffix;
1079:
1080: return toRet;
1081: }
1082:
1083: static String[] getnsRoleDN(String role) {
1084:
1085: String[] rolesList = null;
1086:
1087: String orgName = new String();
1088: String roleTemp = new String();
1089: String temp;
1090: int j = 0;
1091: int count = 0;
1092:
1093: orgName = role.substring(1, role.indexOf("/", 1));
1094:
1095: if (role.indexOf("/", 1) >= 0)
1096: role = role.substring(role.indexOf("/", 1));
1097: StringTokenizer strTok = new StringTokenizer(role, "/");
1098:
1099: rolesList = new String[strTok.countTokens()];
1100:
1101: while (strTok.hasMoreTokens()) {
1102: temp = "cn=" + strTok.nextToken() + ",o=" + orgName + ","
1103: + rootsuffix;
1104: rolesList[j] = new String(temp);
1105: //System.out.println("RolesList.."+rolesList[j]);
1106: j++;
1107: }
1108: return rolesList;
1109: }
1110: }
|