<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%><%
%><%-- @(#)declare.jsp --%>
<%@ page import="com.iplanet.sso.SSOTokenManager,
                 com.iplanet.sso.SSOToken,
                 com.iplanet.am.sdk.AMStoreConnection,
                 com.iplanet.sso.SSOException,
                 com.iplanet.am.sdk.AMUser" %>
<%@ taglib uri="/tld/jx.tld" prefix="jx" %>

<%-- declare all UI related variables --%>
<jx:declare id="tFontColor" type="java.lang.String"/>
<jx:declare id="tFontFace" type="java.lang.String"/>
<jx:declare id="tBgColor" type="java.lang.String"/>
<jx:declare id="tTitleBarColor" type="java.lang.String" />
<jx:declare id="tTabColor" type="java.lang.String" />
<jx:declare id="tTabFontColor" type="java.lang.String" />
<jx:declare id="tTitleFontColor" type="java.lang.String" />
<jx:declare id="tBorderColor" type="java.lang.String"/>

<%-- images are stored relative to the desktopUrl --%>
<jx:declare id="channelName" type="java.lang.String"/>
<jx:declare id="gn" type="java.lang.String"/>
<jx:declare id="authorId" type="java.lang.String"/>
<jx:declare id="hitNumber" type="java.lang.Integer"/>
<jx:declare id="vdw" type="java.lang.Boolean"/>
<jx:declare id="showDesc" type="java.lang.Boolean"/>
<jx:declare id="ddd" type="java.lang.String"/>
<jx:declare id="df" type="java.lang.String"/>
<jx:declare id="det" type="java.lang.String"/>
<jx:declare id="dbname" type="java.lang.String"/>
<jx:declare id="desktopUrl" type="java.lang.String"/>
<jx:declare id="dpurl" type="java.lang.String"/>
<jx:declare id="desktopPathInfo" type="java.lang.String"/>
<jx:declare id="locale" type="java.util.Locale"/>

<%
try {
		SSOTokenManager mgr = SSOTokenManager.getInstance(); 
		SSOToken token = mgr.createSSOToken(request);
		if (token !=null) {
				AMStoreConnection amstore = new AMStoreConnection(token);
				AMUser user = amstore.getUser(token.getPrincipal().getName() );
				boolean subscriptionsService = user.getAssignedServices().contains("SunPortalSubscriptionsService");
				if ((user != null) && (subscriptionsService != false)) {
					pageContext.setAttribute("displaySubscription", "true", PageContext.REQUEST_SCOPE);
				} else {
					pageContext.setAttribute("displaySubscription", "false", PageContext.REQUEST_SCOPE);
				}
		} else {
			pageContext.setAttribute("displaySubscription", "false", PageContext.REQUEST_SCOPE);
		}
	} catch (Exception e) {
		// failed to get token or AMUser, anayway means not subscription allowed
		pageContext.setAttribute("displaySubscription", "false", PageContext.REQUEST_SCOPE);
	}
%>
