SessionInfo.java revision 8af80418ba1ec431c8027fa9668e5678658d3611
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: SessionInfo.java,v 1.3 2008/06/25 05:41:31 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted [2011] [ForgeRock AS]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.iplanet.dpro.session.share;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Enumeration;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Hashtable;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.xml.XMLUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>SessionInfo</code> class holds all the information about the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>Session</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class SessionInfo {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** <code>Session</code> id */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String sid;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** <code>Session</code> type */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String stype;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** <code>Cookie</code> id */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String cid;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** <code> Cookie</code> domain */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String cdomain;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** Max <code>Session</code> Time */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String maxtime;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** Max <code>Session</code> Idle time */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String maxidle;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** Max <code>Session</code> Cache */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String maxcaching;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** <code>Session</code> idle time */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String timeidle;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** Time left for <code>Session</code> to become inactive */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String timeleft;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** <code>Session</code> state */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String state;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Hashtable properties = new Hashtable();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String QUOTE = "\"";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String NL = "\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs <code> SessionInfo </code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public SessionInfo() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * translates the <code>Session</code> Information to an XML document
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * String based
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return An XML String representing the information
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toXMLString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster StringBuilder xml = new StringBuilder(200);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster xml.append("<Session sid=").append(QUOTE).append(sid).append(QUOTE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(" stype=").append(QUOTE).append(stype).append(QUOTE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(" cid=").append(QUOTE).append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster XMLUtils.escapeSpecialCharacters(cid)).append(QUOTE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(" cdomain=").append(QUOTE).append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster XMLUtils.escapeSpecialCharacters(cdomain))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(QUOTE).append(" maxtime=").append(QUOTE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(maxtime).append(QUOTE).append(" maxidle=")
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(QUOTE).append(maxidle).append(QUOTE).append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster " maxcaching=").append(QUOTE).append(maxcaching)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(QUOTE).append(" timeidle=").append(QUOTE).append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster timeidle).append(QUOTE).append(" timeleft=").append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster QUOTE).append(timeleft).append(QUOTE).append(" state=")
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(QUOTE).append(state).append(QUOTE).append(">").append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster NL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (properties != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Enumeration enumerator = properties.keys();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while (enumerator.hasMoreElements()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String name = (String) enumerator.nextElement();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String value = (String) properties.get(name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster xml.append("<Property name=").append(QUOTE).append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster XMLUtils.escapeSpecialCharacters(name)).append(QUOTE)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(" value=").append(QUOTE).append(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster XMLUtils.escapeSpecialCharacters(value))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(QUOTE).append(">").append("</Property>")
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(NL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster xml.append("</Session>");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return xml.toString();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}