001: /*
002: * Please read the License Agreement and other supplemental license terms, if
003: * any, accompanying this software package before using any of the software
004: * provided. If you do not agree to the terms of the License Agreement or any
005: * other supplemental terms, please promptly destroy or return the software to
006: * Sun Microsystems, Inc.
007: *
008: * "CONFIDENTIAL AND PROPRIETARY" Copyright ? 2003 Sun Microsystems, Inc.
009: * All rights reserved.
010: */
011:
012: package com.sun.portal.providers.login;
013:
014: import javax.servlet.http.HttpServletRequest;
015: import javax.servlet.http.HttpServletResponse;
016: import javax.servlet.http.Cookie;
017: import java.util.Hashtable;
018: import java.net.URL;
019: import java.net.MalformedURLException;
020: import java.util.Enumeration;
021: import java.util.ResourceBundle;
022: import java.util.logging.Logger;
023: import java.util.logging.Level;
024:
025: import com.sun.portal.providers.context.ProviderContext;
026: import com.sun.portal.providers.ProfileProviderAdapter;
027: import com.sun.portal.providers.ProviderException;
028: import com.sun.portal.providers.context.ProviderContextException;
029: import com.sun.portal.log.common.PortalLogger;
030:
031: public class LoginProvider extends ProfileProviderAdapter {
032: private static Logger logger = PortalLogger
033: .getLogger(LoginProvider.class);
034:
035: private ResourceBundle bundle = null;
036:
037: public StringBuffer getContent(HttpServletRequest request,
038: HttpServletResponse response) throws ProviderException {
039: if (bundle == null) {
040: bundle = getResourceBundle();
041: }
042: logger.finest("PSDT_CSPPL0001");
043:
044: StringBuffer content = new StringBuffer();
045: Hashtable tagTable = new Hashtable();
046:
047: String fontFace = "";
048: URL loginHelpUrl = null;
049: fontFace = getStringProperty("fontFace1", "sans-serif");
050: tagTable.put("fontFace1", fontFace);
051: loginHelpUrl = getHelp(request, "loginHelpUrl");
052: if (loginHelpUrl != null) {
053: tagTable.put("loginHelpUrl", loginHelpUrl.toString());
054: }
055:
056: // are persistent cookies enabled?
057: // note: if the property returns true, it
058: // must also be the case the the authentication
059: // service is set to accept persistent cookies
060: StringBuffer persistent = new StringBuffer();
061: boolean pc = getBooleanProperty("persistentCookie");
062: if (pc) {
063: logger.finest("PSDT_CSPPL0002");
064: persistent = getTemplate("persistentCookie.template",
065: tagTable);
066: } else {
067: persistent.append("");
068: }
069:
070: tagTable.put("persistentCookie", persistent.toString());
071:
072: StringBuffer libertyLogin = new StringBuffer();
073: boolean federationEnabled = false;
074: try {
075: if (getProviderContext().getProviderVersion(getName()) >= 2) {
076: federationEnabled = getBooleanProperty("federationEnabled");
077: }
078: } catch (ProviderContextException pce) {
079: logger.log(Level.FINE, "PSDT_CSPPL0003", pce);
080: throw new ProviderException(
081: "LoginProvider.getContent():Exception getting login provider version",
082: pce);
083: }
084:
085: if (federationEnabled) {
086: String preLoginURL = getStringProperty("preLoginURL",
087: "/portal/dt");
088: tagTable.put("preLoginURL", preLoginURL);
089: logger.finest("PSDT_CSPPL0004");
090: libertyLogin = getTemplate("libertyLogin.template",
091: tagTable);
092: } else {
093: libertyLogin.append("");
094: }
095:
096: tagTable.put("libertyLogin", libertyLogin.toString());
097:
098: //get the login url from provider context
099: String loginUrl = getProviderContext().getLoginURL();
100: tagTable.put("loginURL", loginUrl);
101: tagTable.put("channelName", getName());
102: content = getTemplate("display.template", tagTable);
103: return content;
104: }
105:
106: /**
107: * isPresentable() returns true if the template for the front page
108: * of the provider exists and returns false if it doesn't exist
109: */
110: public boolean isPresentable(HttpServletRequest request) {
111: boolean isPresentable = false;
112:
113: ProviderContext pc = getProviderContext();
114: try {
115: if ((getTemplatePath("display.template") != null)) {
116: isPresentable = true;
117: }
118: } catch (Exception pe) {
119: logger.log(Level.INFO, "PSDT_CSPPL0005", pe);
120: }
121:
122: return isPresentable;
123: }
124: }
|