001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * for use in the design, construction, operation or maintenance of
035: * any nuclear facility.
036: */
037: package com.sun.portal.siebelportlet.util;
038:
039: import java.util.Enumeration;
040: import java.util.Vector;
041: import java.util.Hashtable;
042: import java.util.ResourceBundle;
043: import java.util.Properties;
044: import java.io.IOException;
045: import java.io.Writer;
046: import java.util.logging.*;
047:
048: import javax.portlet.*;
049: import javax.servlet.http.HttpServletRequest;
050: import com.sun.portal.iwayutil.config.*;
051: import com.sun.portal.iwayutil.connection.*;
052:
053: /**
054: *
055: * This class provided the utility methods to get the Account related
056: * information from Siebel Server.
057: *
058: * @version 1.0
059: * @author Deepak H P
060: * @date 30 Jun 2005
061: *
062: **/
063: public class SiebelIwayUtils implements SiebelConstants {
064:
065: static IWAYConnection conn = null;
066: static Logger logger = SiebelLogger.getLogger();
067: static Properties iWayProps = null;
068:
069: public static String setiWayProperties(String userName,
070: String password, HttpServletRequest httpReq,
071: String configName, String channleName) {
072: String status = NO_SSOA_STATUS;
073: try {
074: debug("setiWayProperties()", "Getting iWayProps : ");
075: iWayProps = getiWayProperties(httpReq, configName,
076: channleName);
077:
078: if (iWayProps != null) {
079: debug("setiWayProperties()", "iWayProps Are not null ");
080: status = NO_SSOA_CONFIG_STATUS;
081: iWayProps.put(IWAY_USER, userName);
082: iWayProps.put(IWAY_PASSWORD, password);
083: status = VALID_SSOA_CONFIG_STATUS;
084: } else {
085: debug("setiWayProperties()", "iWayProps Are Null ");
086: }
087: } catch (Exception ex) {
088: debug("setiWayProperties()", "ex : " + ex);
089: }
090: return status;
091: }
092:
093: private static Properties getiWayProperties(
094: HttpServletRequest httpReq, String configName,
095: String channleName) {
096: Properties props = null;
097: try {
098: debug("getiWayProperties", "Getting iWayProps");
099: SiebelSSOAdapterUtils ssoaUtils = new SiebelSSOAdapterUtils(
100: httpReq, configName, channleName);
101: props = ssoaUtils.getSiebelProperties();
102: debug("getiWayProperties", "Got iWayProps : ");
103: } catch (Exception ex) {
104: debug("getiWayProperties",
105: "Exception in Getting iWayProps : " + ex);
106: }
107: return props;
108: }
109:
110: private static void initializeiWayConnetcion() {
111:
112: if (conn == null) {
113: try {
114: debug("initializeiWayConnetcion()",
115: "Getting iWay Connection!!!");
116: conn = IWAYConnectionFactory
117: .getIWAYConnection(iWayProps);
118: debug("initializeiWayConnetcion()",
119: "Got iWay Connection " + conn);
120: } catch (Exception ex) {
121: debug("initializeiWayConnetcion()",
122: "Exception in Getting iWay Connection " + ex);
123: }
124: }
125: }
126:
127: public static void resetiWayConnetcion() {
128:
129: conn = null;
130: }
131:
132: public static String getResponseString(String reqStr) {
133:
134: String xmlOutput = null;
135: try {
136: initializeiWayConnetcion();
137: IWAYRequest iWayRequest = new IWAYRequest(reqStr);
138: debug("doView()", "Getting iWay Response");
139: IWAYResponse iWayResponse = conn.getResponse(iWayRequest);
140: debug("doView()", "Got Response ");
141: xmlOutput = iWayResponse.getResponseString();
142: } catch (Exception ex) {
143: debug("getResponseString()",
144: "Exception in Getting iWay Connection " + ex);
145: }
146: return xmlOutput;
147: }
148:
149: /**
150: * This method will print the log the messages.
151: **/
152: private static void debug(String methodName, String msg) {
153: logger.log(Level.INFO,
154: "com.sun.portal.siebelportlet.util.SiebelIwayUtils:"
155: + methodName + ":" + msg);
156: }
157: }
|