001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.rproxy.rewriter.yahoo;
006:
007: import java.util.Map;
008:
009: import com.sun.portal.rewriter.util.ConfigManager;
010: import com.sun.portal.rewriter.util.Debug;
011: import com.sun.portal.rproxy.configservlet.Request;
012: import com.sun.portal.rproxy.configservlet.Response;
013: import com.sun.portal.rproxy.configservlet.client.AttributeExtractor;
014: import com.sun.portal.rproxy.configservlet.client.SrapClient;
015:
016: /**
017: * Fetches the Yahoo Service Attributes for the Gateway to rewrite and recompute
018: * the MD5 authentication digest.
019: *
020: * @author Rajesh T, Raja Nagendra Kumar
021: */
022: public final class YahooConfigManager {
023: public static final String PROPERTY_IS_YAHOO_INTEGRATION_ENABLED = "IS_YAHOO_INTEGRATION_ENABLED";
024:
025: private static final String ATTRIBUTE_PREFIX = "sunPortalYahoo";
026:
027: private static final String SERVICE_NAME = "SunPortalYahooService";
028:
029: private static final String GET_REQUEST = "GET_GLOBALS";
030:
031: private static final String PROPERTY_USER_NAME = ATTRIBUTE_PREFIX
032: + "CorporateID"; // BugNo:4889146
033:
034: private static final String PROPERTY_USER_PASSWORD = ATTRIBUTE_PREFIX
035: + "CorporatePassword"; // BugNo:4889146
036:
037: private static final String PROPERTY_EDIT_SERVER = ATTRIBUTE_PREFIX
038: + "EditServer";
039:
040: private static boolean yahooInstalled = true;
041:
042: private static String corporateID = "rajan001";
043:
044: private static String corporatePassword = "GePDKPhEzv4t";
045:
046: private static String editServerURI;
047:
048: public static void init() {
049: // BugNo:4889146
050: try {
051: if (ConfigManager
052: .getBoolean(PROPERTY_IS_YAHOO_INTEGRATION_ENABLED) == false) {
053: throw new Exception(
054: "Yahoo Integation disabled using SRAPRewriterModule.properties file");
055: }
056:
057: Request bRequest = new Request("this-should-be-sid",
058: SERVICE_NAME, GET_REQUEST);
059: Response bResponse = SrapClient.bootupExecute(bRequest);
060: Map bYahooData = (Map) bResponse.getReturnedObject();
061: if (bYahooData.isEmpty()) {
062: throw new Exception(
063: "Yahoo may not be installed with the portal");
064: }
065:
066: corporateID = AttributeExtractor.getString(bYahooData,
067: PROPERTY_USER_NAME, "NoCorporateID");
068: corporatePassword = AttributeExtractor.getString(
069: bYahooData, PROPERTY_USER_PASSWORD,
070: "NoCorporatePassword");
071: editServerURI = AttributeExtractor.getString(bYahooData,
072: PROPERTY_EDIT_SERVER, "NoEditServerURI");
073:
074: Debug
075: .message("Yahoo Integration Eanbled with Corporate ID: "
076: + corporateID);
077: } catch (Throwable e) {
078: yahooInstalled = false;
079: Debug.warning(
080: "Unable to Initialize Yahoo Rewriting Module", e);
081: }
082: }// init()
083:
084: public static String getCorporateID() {
085: return corporateID;
086: }// getUserName()
087:
088: public static String getCorporatePassword() {
089: return corporatePassword;
090: }// getUserPassword()
091:
092: public static String getEditServer() {
093: return editServerURI;
094: }// getEditServer()
095:
096: public static boolean isYahooEnabled() {
097: return yahooInstalled;
098: }// isYahooEnabled()
099:
100: }// class YahooConfigManager
|