001: /**
002: * $Id: ValidatePortalInputData.java,v 1.52.2.2 2007/04/17 08:35:44 pr150268 Exp $
003: * Copyright 2004 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.fabric.config;
014:
015: import com.sun.portal.fabric.util.FileUtil;
016: import java.io.File;
017: import java.net.MalformedURLException;
018: import java.net.URL;
019: import java.util.ArrayList;
020: import java.util.HashMap;
021: import java.util.HashSet;
022: import java.util.Iterator;
023: import java.util.List;
024: import java.util.Map;
025: import java.util.Properties;
026: import java.util.Set;
027: import java.util.logging.Level;
028: import java.util.logging.LogRecord;
029: import java.util.logging.Logger;
030:
031: import com.iplanet.sso.SSOException;
032: import com.iplanet.sso.SSOToken;
033: import com.iplanet.sso.SSOTokenManager;
034: import com.sun.portal.admin.common.context.PSConfigContext;
035: import com.sun.portal.fabric.tasks.ConfigurationException;
036: import com.sun.portal.fabric.tasks.WebContainerFactory;
037: import com.sun.portal.fabric.tasks.WebContainer;
038: import com.sun.portal.fabric.util.AMUtil;
039: import com.sun.portal.fabric.util.NetworkUtil;
040: import com.sun.portal.log.common.PortalLogger;
041: import com.sun.portal.util.LDAPUtil;
042: import com.sun.portal.util.Platform;
043:
044: import netscape.ldap.LDAPConnection;
045: import netscape.ldap.LDAPException;
046:
047: public class ValidatePortalInputData {
048:
049: protected static final String COMP_PORTAL_SERVER = "portalserver";
050: protected static final String COMP_NETLET_PROXY = "netletproxy";
051: protected static final String COMP_REWRITER_PROXY = "rewriterproxy";
052: protected static final String COMP_GATEWAY = "gateway";
053:
054: protected String message = null;
055: protected static final String FS = Platform.fs;
056: private static Logger configLogger;
057: protected static LDAPConnection connection;
058: protected static PSConfigContext pcc;
059: protected static PortalConfigurator pc;
060: protected static Map sharedComponentsCheckData;
061: protected static Map sharedComponentsCheckData2;
062: protected static List allComponentsList;
063:
064: static {
065: configLogger = PortalLogger
066: .getLogger(ValidatePortalInputData.class);
067: pc = new PortalConfigurator();
068: try {
069: // Get the PSConfigContext
070: pcc = pc.getPSConfigContext();
071: } catch (ConfigurationException ex) {
072: configLogger.log(Level.SEVERE, "PSFB_CSPFC0244");
073: }
074:
075: Platform.psConfDir = pcc.getPSConfigDir();
076:
077: connection = LDAPUtil.getLDAPConnection(pcc
078: .getDirectoryServerHost(),
079: pcc.getDirectoryServerPort(), pcc
080: .getUserDataStoreManager(), pcc
081: .getUserDataStoreManagerCredentials(), pcc
082: .isDomainDataSecure());
083:
084: sharedComponentsCheckData = new HashMap();
085: sharedComponentsCheckData.put("CacaoConfigDir",
086: new String[] { "cacao.properties" });
087: sharedComponentsCheckData.put("CacaoProdDir", new String[] {
088: Platform.getCommand("cacaoadm"),
089: Platform.getCommand("cacao_cacao.jar") });
090: sharedComponentsCheckData.put("JDMKLibDir",
091: new String[] { "jmxremote_optional.jar" });
092: sharedComponentsCheckData.put("JSSJarDir",
093: new String[] { "jss4.jar" });
094: sharedComponentsCheckData.put("JavaHome", new String[] {
095: Platform.getCommand("java"),
096: Platform.getCommand("jar"), "/lib/tools.jar" });
097: sharedComponentsCheckData.put("NSSLibDir",
098: new String[] { null });
099: sharedComponentsCheckData.put("SharedLibDir",
100: new String[] { "ldapjdk.jar" });
101: sharedComponentsCheckData.put("DerbyLibDir",
102: new String[] { "derby.jar" });
103: sharedComponentsCheckData.put("AntLibDir",
104: new String[] { "ant.jar" });
105: sharedComponentsCheckData.put("AntHomeDir",
106: new String[] { Platform.getCommand("ant") });
107: sharedComponentsCheckData.put("RegistryLibDir",
108: new String[] { "omar-common.jar" });
109: sharedComponentsCheckData.put("MFWKLibDir",
110: new String[] { "mfwk_instrum_tk.jar" });
111: sharedComponentsCheckData.put("MFWKBinDir",
112: new String[] { Platform.getCommand("mfwksetup") });
113: sharedComponentsCheckData.put("JAXLibDir",
114: new String[] { "xws-security.jar" });
115: sharedComponentsCheckData.put("WebNFSLibDir",
116: new String[] { "webnfs.zip" });
117:
118: // Support data for SharedComponents
119: sharedComponentsCheckData2 = new HashMap();
120: sharedComponentsCheckData2.put("DerbyLibDir", new String[] {
121: COMP_PORTAL_SERVER, "true" });
122: sharedComponentsCheckData2.put("AntLibDir", new String[] {
123: COMP_PORTAL_SERVER, "true" });
124: sharedComponentsCheckData2.put("AntHomeDir", new String[] {
125: COMP_PORTAL_SERVER, "true" });
126: sharedComponentsCheckData2.put("RegistryLibDir", new String[] {
127: COMP_PORTAL_SERVER, "true" });
128: sharedComponentsCheckData2.put("MFWKLibDir", new String[] {
129: COMP_PORTAL_SERVER, "true" });
130: sharedComponentsCheckData2.put("MFWKBinDir", new String[] {
131: COMP_PORTAL_SERVER, "true" });
132: //sharedComponentsCheckData2.put("JAXLibDir", new String[] {COMP_PORTAL_SERVER, "true"});
133: sharedComponentsCheckData2.put("WebNFSLibDir", new String[] {
134: COMP_PORTAL_SERVER, "true" });
135:
136: // components list
137: allComponentsList = new ArrayList();
138: allComponentsList.add(COMP_PORTAL_SERVER);
139: allComponentsList.add(COMP_NETLET_PROXY);
140: allComponentsList.add(COMP_REWRITER_PROXY);
141: allComponentsList.add(COMP_GATEWAY);
142: }
143:
144: public ValidatePortalInputData(PSConfigContext pcc,
145: PortalConfigData pci) throws ConfigurationException {
146:
147: message = "please refer the fabric log file for more information";
148: // Validate amLdapUser Password Credentials, Directory Manager Credentials, AccessManager Cedentials
149: String amLDAPUserDN = pcc.getAMSpecialUsersDN().replaceFirst(
150: "dsameuser", pci.getLDAPUserId());
151: if (!validateCredentials(amLDAPUserDN, pci
152: .getLDAPUserPassword())) {
153: message = "Invalid LDAP Password.";
154: throw new ConfigurationException(message);
155: }
156: if (!validateCredentials(pcc.getUserDataStoreManager(), pci
157: .getDirectoryManagerPassword())) {
158: message = "Invalid Directory Manager Password.";
159: throw new ConfigurationException(message);
160: }
161: if (!validateCredentials(pcc.getAdminUserDN(), pci
162: .getAMAdminPassword())) {
163: message = "Invalid Administrator User Password.";
164: throw new ConfigurationException(message);
165: }
166:
167: try {
168: //Close the LDAP Connection
169: connection.disconnect();
170: configLogger.log(Level.INFO, "PSFB_CSPFC0165");
171: } catch (LDAPException e1) {
172: configLogger.log(Level.SEVERE, "PSFB_CSPFC0063", e1);
173: throw new ConfigurationException(message);
174: }
175:
176: configLogger.log(Level.INFO, "PSFB_CSPFC0049");
177: if (!validateAMSDK(pci.getAMAdmin(), pci.getAMAdminPassword(),
178: pcc.getDefaultOrganization())) {
179: throw new ConfigurationException(message);
180: }
181: }
182:
183: public ValidatePortalInputData(PortalConfigData pci)
184: throws ConfigurationException {
185:
186: // Validate comoponets to configure list
187: List componentsToConfigure = pci.getPSComponentsToConfigure();
188: if (!validateComponentsToConfigure(componentsToConfigure)) {
189: throw new ConfigurationException(message);
190: }
191:
192: String host = pcc.getDirectoryServerHost();
193: int port = Integer.parseInt(pcc.getDirectoryServerPort());
194: message = "please refer the log file "
195: + pci.getPSDataDir()
196: + FS
197: + "logs/config/portal.fabric.0.0.log for more information";
198:
199: // Check if the Host is a LocalHost
200: if (!NetworkUtil.isLocalHost(pci.getConfigHostName())) {
201: configLogger.log(Level.SEVERE, "PSFB_CSPFC0172", pci
202: .getConfigHostName());
203: throw new ConfigurationException(message);
204: }
205:
206: //null connection indicates could not connect to Directory
207: if (connection == null) {
208: configLogger.log(Level.SEVERE, "PSFB_CSPFC0046",
209: new String[] { host, String.valueOf(port) });
210: throw new ConfigurationException(message);
211: }
212:
213: //Dont Validate credentials if only GW/RWP/NLP being installed and directory is not on the
214: //local host
215: if (!pci.isOnlySRAComponentInstalled()
216: || pci.getConfigHostName().equals(
217: pcc.getDirectoryServerHost())) {
218:
219: // Validate DirectoryManager Credentials
220: if (!validateCredentials(pcc.getUserDataStoreManager(), pcc
221: .getUserDataStoreManagerCredentials())) {
222: if (!pci.isOnlySRAComponentInstalled()) {
223: throw new ConfigurationException(message);
224: }
225: }
226:
227: // Validate AccessManager Credentials
228: if (!validateCredentials(pcc.getAdminUserDN(), pci
229: .getAMAdminPassword())) {
230: if (!pci.isOnlySRAComponentInstalled()) {
231: throw new ConfigurationException(message);
232: }
233: }
234:
235: // Validate amLdapUser Password Credentials, Directory Manager Credentials, AccessManager Cedentials
236: String amLDAPUserDN = pcc.getAMSpecialUsersDN()
237: .replaceFirst("dsameuser", pci.getLDAPUserId());
238: if (!validateCredentials(amLDAPUserDN, pci
239: .getLDAPUserPassword())
240: || !validateCredentials(pcc
241: .getUserDataStoreManager(), pcc
242: .getUserDataStoreManagerCredentials())
243: || !validateCredentials(pcc.getAdminUserDN(), pci
244: .getAMAdminPassword())) {
245: if (!pci.isOnlySRAComponentInstalled()) {
246: throw new ConfigurationException(message);
247: }
248: }
249:
250: }
251:
252: try {
253: //Close the LDAP Connection
254: connection.disconnect();
255: configLogger.log(Level.INFO, "PSFB_CSPFC0165");
256: } catch (LDAPException e1) {
257: configLogger.log(Level.SEVERE, "PSFB_CSPFC0063", e1);
258: throw new ConfigurationException(message);
259: }
260:
261: configLogger.log(Level.INFO, "PSFB_CSPFC0049");
262: if (!validateAMSDK(pci.getAMAdmin(), pci.getAMAdminPassword(),
263: pcc.getDefaultOrganization())) {
264: if (!pci.isOnlySRAComponentInstalled()) {
265: throw new ConfigurationException(message);
266: }
267: }
268:
269: if (validateSharedComponents(pci.getsharedCompDetails(),
270: componentsToConfigure)
271: && checkPSAMInstallData(pci)) {
272: configLogger.log(Level.INFO, "PSFB_CSPFC0075");
273: } else {
274: throw new ConfigurationException(message);
275: }
276:
277: if (componentsToConfigure.contains(COMP_PORTAL_SERVER)) {
278:
279: if (validatePortalServerData(pci.getSamplePortalData())
280: && validateSearchServerData(pci
281: .getSearchServerDetails())) {
282: configLogger.log(Level.INFO, "PSFB_CSPFC0076");
283: } else
284: throw new ConfigurationException(message);
285: }
286:
287: int iComponentsListSize = (componentsToConfigure != null) ? componentsToConfigure
288: .size()
289: : 0;
290: String sDSHostName = componentsToConfigure
291: .contains(COMP_PORTAL_SERVER) ? null : host;
292: for (int z = 0; z < iComponentsListSize; z++) {
293:
294: String sComponent = (String) componentsToConfigure.get(z);
295: if ((sComponent != null)
296: && (sComponent.equalsIgnoreCase(COMP_NETLET_PROXY)
297: || sComponent
298: .equalsIgnoreCase(COMP_REWRITER_PROXY) || sComponent
299: .equalsIgnoreCase(COMP_GATEWAY))) {
300: configLogger.log(Level.INFO, "PSFB_CSPFC0180",
301: new String[] { sComponent });
302: if (validateSRAComponentData(pci, sComponent,
303: sDSHostName, port)) {
304: sDSHostName = null;
305: configLogger.log(Level.INFO, "PSFB_CSPFC0183",
306: new String[] { sComponent });
307: try {
308: configLogger.log(Level.INFO, "PSFB_CSPFC0186");
309: pci.getcertificateOrganization();
310: configLogger.log(Level.INFO, "PSFB_CSPFC0187");
311: } catch (Exception e) {
312: configLogger.log(Level.SEVERE,
313: "PSFB_CSPFC0188", e);
314: throw new ConfigurationException(message);
315: }
316: } else {
317: configLogger.log(Level.SEVERE, "PSFB_CSPFC0189",
318: new String[] { sComponent });
319: throw new ConfigurationException(message);
320: }
321: }
322: }
323: }
324:
325: public boolean validateCredentials(String userName,
326: String credentials) {
327:
328: boolean bRet = true;
329:
330: try {
331: configLogger.log(Level.INFO, "PSFB_CSPFC0164", userName);
332: connection.authenticate(userName, credentials);
333: configLogger.log(Level.INFO, "PSFB_CSPFC0047", userName);
334: } catch (LDAPException e) {
335: if (configLogger.isLoggable(Level.SEVERE)) {
336: LogRecord record = new LogRecord(Level.SEVERE,
337: "PSFB_CSPFC0087");
338: record.setLoggerName(configLogger.getName());
339: record.setParameters(new String[] { userName });
340: record.setThrown(e);
341: configLogger.log(record);
342: }
343: bRet = false;
344: }
345:
346: return bRet;
347: }
348:
349: public boolean validateAMSDK(String amAdminDN,
350: String amAdminPassword, String orgName) {
351:
352: boolean bRet = true;
353:
354: try {
355:
356: SSOToken amSSOToken = AMUtil.createSSOToken(amAdminDN,
357: amAdminPassword, orgName);
358:
359: if (SSOTokenManager.getInstance().isValidToken(amSSOToken)) {
360: configLogger.log(Level.INFO, "PSFB_CSPFC0055");
361: SSOTokenManager.getInstance().destroyToken(amSSOToken);
362: }
363: } catch (SSOException e1) {
364: configLogger.log(Level.SEVERE, "PSFB_CSPFC0056", e1);
365: bRet = false;
366: } catch (Exception e) {
367: configLogger.log(Level.SEVERE, "PSFB_CSPFC0054", e);
368: bRet = false;
369: }
370:
371: return bRet;
372: }
373:
374: private boolean validateComponentsToConfigure(List components)
375: throws ConfigurationException {
376:
377: boolean bRet = true;
378: String msg = "";
379: String pslibdir = pcc.getPSBaseDir() + "/lib";
380: configLogger.log(Level.INFO, pslibdir);
381:
382: if ((components == null) || components.isEmpty()) {
383: configLogger.log(Level.SEVERE, "PSFB_CSPFC0238");
384: //??} else if (!allComponentsList.containsAll(components)) {
385: //?? configLogger.log(Level.SEVERE, "PSFB_CSPFC0239", new String[] { components.toString() });
386: //?? bRet = false;
387: } else {
388: Iterator it = components.listIterator();
389: while (it.hasNext()) {
390: String component = (String) it.next();
391: if (component.equals("portalserver")) {
392: if (!FileUtil.fileExists(pslibdir + "/desktop.jar")) {
393: bRet = false;
394: configLogger.log(Level.INFO, "PSFB_CSPFC0308",
395: pslibdir + "/desktop.jar");
396: msg = msg + " " + component + ",";
397: }
398: } else if (component.equals("gateway")) {
399: if (!(FileUtil
400: .fileExists(pcc.getPSBaseDir()
401: + "/template/sra/GWConfig.properties.template"))) {
402: bRet = false;
403: configLogger
404: .log(
405: Level.INFO,
406: "PSFB_CSPFC0309",
407: pcc.getPSBaseDir()
408: + "/template/sra/GWConfig.properties.template");
409: msg = msg + " " + component + ",";
410: }
411: } else if (component.equals("netletproxy")) {
412: if (!(FileUtil.fileExists(pslibdir
413: + "/netletproxy.jar"))) {
414: bRet = false;
415: configLogger.log(Level.INFO, "PSFB_CSPFC0310",
416: pslibdir + "/netletproxy.jar");
417: msg = msg + " " + component + ",";
418: }
419: } else if (component.equals("rewriterproxy")) {
420: if (!(FileUtil
421: .fileExists(pslibdir + "/rwproxy.jar"))) {
422: bRet = false;
423: configLogger.log(Level.INFO, "PSFB_CSPFC0311",
424: pslibdir + "/rwproxy.jar");
425: msg = msg + " " + component + ",";
426: }
427: }
428:
429: }
430: if (!bRet) {
431: throw new ConfigurationException(
432: "Please check if the packages related to"
433: + msg.substring(0, msg.length() - 1)
434: + " are installed. For details on the example xml files please refer to "
435: + pcc.getPSBaseDir()
436: + "/samples/psconfig/ReadMe.txt");
437: }
438: configLogger.log(Level.INFO, "PSFB_CSPFC0241",
439: new String[] { components.toString() });
440: }
441:
442: return bRet;
443: }
444:
445: private boolean validateSharedComponents(Map sharedComponents,
446: List components) {
447:
448: boolean bRet = true;
449: Iterator iter = sharedComponents.keySet().iterator();
450:
451: while (iter.hasNext()) {
452:
453: String element = (String) iter.next();
454:
455: if ("CacaoConfigDir".equals(element)) {
456: continue;
457: }
458:
459: String shareComponentDir = (String) sharedComponents
460: .get(element);
461:
462: String[] filesList = (String[]) sharedComponentsCheckData
463: .get(element);
464: if (filesList == null) {
465: configLogger.log(Level.WARNING, "PSFB_CSPFC0301",
466: element);
467: continue;
468: }
469:
470: String[] privList = (String[]) sharedComponentsCheckData2
471: .get(element);
472:
473: if (((privList == null) || privList[1].equals("true"))
474: && ((shareComponentDir == null) || shareComponentDir
475: .trim().equals(""))) {
476: configLogger.log(Level.SEVERE, "PSFB_CSPFC0060",
477: element);
478: bRet = false;
479: break;
480: }
481:
482: if ((privList == null) || components.contains(privList[0])) {
483: if ((filesList != null) && (filesList[0] != null)) {
484: bRet = checkFileExists(element, shareComponentDir,
485: filesList);
486: } else if (!checkDirExists(element, shareComponentDir)) {
487: bRet = false;
488: }
489: }
490:
491: if (!bRet) {
492: if ((privList != null) && privList[1].equals("false")) {
493: configLogger.log(Level.INFO, "PSFB_CSPFC0085",
494: element);
495: } else {
496: configLogger.log(Level.INFO, "PSFB_CSPFC0168",
497: element);
498: break;
499: }
500: }
501: }
502:
503: return bRet;
504: }
505:
506: private boolean checkDirExists(String token, String value) {
507:
508: File dir = new File(value);
509: boolean bIsDir = dir.isDirectory();
510: configLogger.log(Level.INFO, bIsDir ? "PSFB_CSPFC0058"
511: : "PSFB_CSPFC0059", new String[] { token, value });
512: return bIsDir;
513: }
514:
515: private boolean checkFileExists(String sharedComponent,
516: String sharedComponentLocation, String[] files) {
517:
518: boolean bIsFile = true;
519:
520: for (int i = 0; i < files.length; i++) {
521:
522: File shareComponentFile = new File(sharedComponentLocation,
523: files[i]);
524: if (shareComponentFile.isFile()) {
525: configLogger.log(Level.INFO, "PSFB_CSPFC0166",
526: shareComponentFile.toString());
527: } else if ((new File(files[i])).isFile()) {
528: configLogger.log(Level.INFO, "PSFB_CSPFC0166",
529: (new File(files[i])).toString());
530: } else {
531: configLogger.log(Level.SEVERE, "PSFB_CSPFC0167",
532: shareComponentFile.toString());
533: checkDirExists(sharedComponent, sharedComponentLocation);
534: bIsFile = false;
535: break;
536: }
537: }
538:
539: return bIsFile;
540: }
541:
542: private boolean checkPSAMInstallData(PortalConfigData pci) {
543:
544: boolean bRet = true;
545: bRet = checkFileExists("AccessManagerProdDir", pci
546: .getAMProdDir(), new String[] { "lib/am_sdk.jar" });
547: bRet &= checkFileExists("PortalServerProdDir", pci
548: .getPSProdDir(), new String[] { "lib/config.jar",
549: "lib/fabric.jar" });
550: if (!bRet) {
551: return bRet;
552: }
553:
554: String sAMConfigDir = pci.getAMConfigDir();
555: if (checkDirExists("AccessManagerDataDir", pci.getAMDataDir())
556: && checkDirExists("AccessManagerConfigDir",
557: sAMConfigDir)
558: && checkDirExists("PortalServerConfigDir", pci
559: .getPSConfigDir())
560: && checkDirExists("PortalServerDataDir", pci
561: .getPSDataDir())) {
562:
563: String sAMConfigFile = pci.getAMConfigFile();
564: if ((sAMConfigFile == null)
565: || sAMConfigFile.trim().equals("")) {
566: configLogger.log(Level.SEVERE, "PSFB_CSPFC0086",
567: sAMConfigFile);
568: return false;
569: }
570:
571: File amAccessFile = new File(sAMConfigDir + FS
572: + sAMConfigFile);
573: if (!(amAccessFile.exists() && amAccessFile.canRead() && amAccessFile
574: .canWrite())) {
575: return false;
576: }
577:
578: configLogger.log(Level.SEVERE, "PSFB_CSPFC0061",
579: amAccessFile.getAbsolutePath());
580:
581: } else {
582: bRet = false;
583: }
584:
585: return bRet;
586: }
587:
588: private boolean validateSearchServerData(Map searchServerData) {
589:
590: if ((searchServerData == null) || searchServerData.isEmpty()) {
591: configLogger.log(Level.SEVERE, "PSFB_CSPFC0077");
592: return true;
593: }
594:
595: Set portNos = new HashSet();
596: Iterator iter = searchServerData.keySet().iterator();
597: while (iter.hasNext()) {
598: String searchServerID = (String) iter.next();
599: Properties SearchServerWCDetails = (Properties) searchServerData
600: .get(searchServerID);
601: if (!portNos.add(SearchServerWCDetails.getProperty("Port"))) {
602: configLogger.log(Level.SEVERE, "PSFB_CSPFC0072");
603: return false;
604: }
605:
606: try {
607: Map searchServerWCDetailsMap = (Map) SearchServerWCDetails;
608: WebContainer wc = WebContainerFactory.getWebContainer(
609: searchServerWCDetailsMap, true);
610: } catch (Exception e) {
611: configLogger.log(Level.SEVERE, e.getMessage());
612: if (configLogger.isLoggable(Level.SEVERE)) {
613: LogRecord record = new LogRecord(Level.SEVERE,
614: "PSFB_CSPFC0071");
615: record.setLoggerName(configLogger.getName());
616: record.setThrown(e);
617: configLogger.log(record);
618: }
619: return false;
620: }
621: }
622: return true;
623: }
624:
625: private boolean validateSRAComponentData(PortalConfigData pci,
626: String component, String dsHost, int dsPort) {
627:
628: Map sraComponentData = null;
629: if ((component != null) && (pci != null)) {
630: if (component.equalsIgnoreCase(COMP_NETLET_PROXY)) {
631: sraComponentData = (Map) pci.getNetletProxyDetails();
632: } else if (component.equalsIgnoreCase(COMP_REWRITER_PROXY)) {
633: sraComponentData = (Map) pci.getRewriterProxyDetails();
634: } else if (component.equalsIgnoreCase(COMP_GATEWAY)) {
635: sraComponentData = (Map) pci.getGatewayDetails();
636: }
637: }
638:
639: if ((sraComponentData == null) || sraComponentData.isEmpty()) {
640: configLogger.log(Level.SEVERE, "PSFB_CSPFC0177");
641: return false;
642: }
643:
644: Iterator iter = sraComponentData.keySet().iterator();
645:
646: while (iter.hasNext()) {
647:
648: String instanceID = (String) iter.next();
649: configLogger.log(Level.INFO, "PSFB_CSPFC0179", instanceID);
650:
651: Properties sraInstanceProp = (Properties) sraComponentData
652: .get(instanceID);
653:
654: if (dsHost != null) {
655: //srapGatewayUserDN=pcc.getUserNamingAttribute() +"=amService-srapGateway," + "ou" + "=agents," + pcc.getDefaultOrganization();
656: //validateCredentials(srapGatewayUserDN,pci.getSRALogUserPassword());
657: try {
658: connection.connect(dsHost, dsPort);
659: if (!validateCredentials(
660: "uid=amService-srapGateway,ou=agents,"
661: + pcc.getDefaultOrganization(),
662: sraInstanceProp
663: .getProperty("LogUserPassword"))) {
664: configLogger
665: .log(Level.SEVERE, "PSFB_CSPFC0312");
666: return false;
667: }
668: connection.disconnect();
669: } catch (LDAPException e) {
670: configLogger.log(Level.SEVERE, "PSFB_CSPFC0313");
671: return false;
672: }
673: }
674:
675: String host = sraInstanceProp.getProperty("Host");
676: String ipAddress = sraInstanceProp.getProperty("IPAddress");
677: String port = sraInstanceProp.getProperty("Port");
678:
679: try {
680: Integer.parseInt(port);
681: } catch (NumberFormatException e) {
682: configLogger.log(Level.SEVERE, "PSFB_CSPFC0192",
683: new String[] { port, instanceID });
684: return false;
685: }
686:
687: if (!NetworkUtil.isHostValid(host)) {
688: configLogger.log(Level.SEVERE, "PSFB_CSPFC0170", host);
689: return false;
690: }
691:
692: if (!NetworkUtil.validateIPAddressAndHost(host, ipAddress)) {
693: configLogger.log(Level.SEVERE, "PSFB_CSPFC0171",
694: new String[] { host, ipAddress });
695: return false;
696: }
697:
698: if (NetworkUtil.isPortValid(host, port)) {
699: configLogger.log(Level.SEVERE, "PSFB_CSPFC0207",
700: new String[] { host, port });
701: return false;
702: }
703: configLogger.log(Level.INFO, "PSFB_CSPFC0195",
704: new String[] { instanceID, host, port, ipAddress });
705: }
706: configLogger.log(Level.INFO, "PSFB_CSPFC0197");
707: return true;
708: }
709:
710: private boolean validatePortalServerData(Map portalServerData) {
711:
712: Set portNos = new HashSet();
713: Set instanceIDs = new HashSet();
714:
715: Iterator iter = portalServerData.keySet().iterator();
716:
717: try {
718:
719: while (iter.hasNext()) {
720:
721: configLogger.log(Level.INFO, "PSFB_CSPFC0064");
722: String portalID = (String) iter.next();
723:
724: if ((portalID == null)
725: || (portalID.trim().length() == 0)) {
726: configLogger.log(Level.SEVERE, "PSFB_CSPFC0028");
727: return false;
728: }
729:
730: List psData = (ArrayList) portalServerData
731: .get(portalID);
732: Iterator e = psData.iterator();
733:
734: String portalwebappURI = e.hasNext() ? (String) e
735: .next() : "";
736: String portalAccessURL = e.hasNext() ? (String) e
737: .next() : "";
738: String searchServerID = e.hasNext() ? (String) e.next()
739: : "";
740: String configureDevSample = e.hasNext() ? (String) e
741: .next() : null;
742: String configureEntSample = e.hasNext() ? (String) e
743: .next() : null;
744: String configureCommunitySample = e.hasNext() ? (String) e
745: .next()
746: : null;
747: List profiler = e.hasNext() ? (List) e.next()
748: : new ArrayList();
749: List mail = e.hasNext() ? (List) e.next()
750: : new ArrayList();
751: List calendar = e.hasNext() ? (List) e.next()
752: : new ArrayList();
753: List addressBook = e.hasNext() ? (List) e.next()
754: : new ArrayList();
755: List instantMessenger = e.hasNext() ? (List) e.next()
756: : new ArrayList();
757: Map portalInstances = e.hasNext() ? (Map) e.next()
758: : null;
759:
760: if (!portalwebappURI.startsWith("/")) {
761: configLogger.log(Level.SEVERE, "PSFB_CSPFC0088",
762: portalwebappURI);
763: return false;
764: }
765:
766: try {
767: new URL(portalAccessURL);
768: } catch (MalformedURLException me) {
769: configLogger.log(Level.SEVERE, "PSFB_CSPFC0065",
770: portalAccessURL);
771: return false;
772: }
773:
774: if ((configureDevSample != null)
775: || (configureEntSample != null)
776: || (configureCommunitySample != null)) {
777:
778: if ((searchServerID == null)
779: || searchServerID.trim().equals("")) {
780: configLogger
781: .log(Level.SEVERE, "PSFB_CSPFC0066");
782: }
783: }
784:
785: if (portalInstances != null) {
786:
787: Iterator itr = portalInstances.keySet().iterator();
788:
789: while (itr.hasNext()) {
790: String instanceID = (String) itr.next();
791: Properties webconfigprop = (Properties) portalInstances
792: .get(instanceID);
793: if (!portNos.add(webconfigprop
794: .getProperty("Port"))) {
795: configLogger.log(Level.SEVERE,
796: "PSFB_CSPFC0072");
797: return false;
798: }
799:
800: if (!instanceIDs.add(instanceID)) {
801: configLogger.log(Level.SEVERE,
802: "PSFB_CSPFC0072");
803: return false;
804: }
805:
806: try {
807: Map wcAttribs = (Map) webconfigprop;
808: WebContainer wc = WebContainerFactory
809: .getWebContainer(wcAttribs, true);
810: } catch (Exception e0) {
811: configLogger.log(Level.SEVERE, e0
812: .getMessage());
813: if (configLogger.isLoggable(Level.SEVERE)) {
814: LogRecord record = new LogRecord(
815: Level.SEVERE, "PSFB_CSPFC0070");
816: record.setLoggerName(configLogger
817: .getName());
818: record.setThrown(e0);
819: configLogger.log(record);
820: }
821: return false;
822: }
823: }
824: }
825: }
826: } catch (Exception e) {
827: configLogger.log(Level.SEVERE, "PSFB_CSPFC0070", e);
828: return false;
829: }
830:
831: return true;
832: }
833: }
|