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.oracleportlet.util;
038:
039: import java.util.Properties;
040: import java.util.Enumeration;
041: import java.util.logging.*;
042: import javax.servlet.http.HttpServletRequest;
043: import com.sun.portal.iwayutil.ssoadapterutils.*;
044:
045: /**
046: * This is a utility class that contains method to obtain values related to Oracle connection
047: * This class uses EAISSOAdapterConfigUtils object to obtain these values from an SSO adapter
048: *
049: * @author Zahid Syed
050: */
051:
052: public class OracleSSOAdapterUtils implements OraclePortletConstants {
053:
054: Properties oracleSSOProps = null;
055: EAISSOAdapterConfigUtils ssoUtils = null;
056: Logger logger = null;
057:
058: public OracleSSOAdapterUtils(HttpServletRequest httpReq,
059: String oraSSOConfigName) {
060: logger = OraclePortletLogger.getLogger();
061:
062: //Create a dummy string for channel name, which would be passed as an argument
063: String oraSSOChannelName = "OracleSSOAChannelName";
064: ssoUtils = new EAISSOAdapterConfigUtils(oraSSOConfigName,
065: oraSSOChannelName);
066: if (ssoUtils == null) {
067: logMessage(Level.SEVERE,
068: "OracleSSOAdapterUtils :Could not get EAISSOAdapterConfigUtils object :");
069: } else {
070: oracleSSOProps = ssoUtils.getSSOAdapterAttributes(httpReq);
071: }
072: }
073:
074: /**
075: * This method reads the config parameter values from the SSO adapter template and returns them
076: **/
077: public Properties getOracleProperties() {
078: Properties props = null;
079:
080: if (oracleSSOProps == null)
081: {
082: logMessage(Level.SEVERE, "getOracleProperties: oracleSSOProps is null :");
083: }
084: else {
085: props = new Properties();
086: Enumeration enum = oracleSSOProps.propertyNames();
087: String name = null;
088: String value = null;
089: while (enum.hasMoreElements()) {
090: name = (String) enum.nextElement();
091: value = (String) oracleSSOProps.get(name);
092: props.put(name, value);
093: }
094: }
095: return props;
096: }
097:
098: /**
099: * This method logs the debug messages
100: **/
101: private void logMessage(Object debugLevel, String msg) {
102:
103: logger.log((Level) debugLevel, msg);
104: }
105:
106: }
|