/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: SessionContext.java,v 1.2 2008/06/25 05:47:21 qcheng Exp $
*
*/
/**
* The <code>SessionContext</code> class represents session status of an entity
* to another system entity. It is supplied to a relying party to support policy
* enforcement.
*
* @supported.all.api
*/
public class SessionContext {
/**
* Default constructor
*/
protected SessionContext() {
}
/**
* Constructs a <code>SessionContext</code> object from a
* <code>SessionSubject</code> object, a <code>AuthnContext</code>
* object and a <code>String</code>.
*
* @param sessionSubject <code>SessionSubject</code> object.
* @param authnContext authentication context object.
* @param providerID provider ID.
* @throws SAMLException if <code>sessionSubject</code> is null or
* <code>providerID</code> is null.
*/
throw new SAMLRequesterException(
}
_issueInstant = new Date();
_authenticationInstant = new Date();
}
/**
* Returns the <code>SessionSubject</code> within the
* <code>SessionContext</code> object.
*
* @return <code>SessionSubject</code> object.
*/
return _sessionSubject;
}
/**
* Sets the <code>SessionSubject</code> object.
*
* @param sub <code>SessionSubject</code> object.
*/
}
/**
* Returns the <code>AuthnContext</code> within the
* <code>SessionContext</code> object.
*
* @return <code>AuthnContext</code> object.
*/
return _authnContext;
}
/**
* Returns the <code>ProviderID</code> in the <code>SessionContext</code>
* object.
*
* @return <code>ProviderID</code> object
*/
return _providerID;
}
/**
* Sets the <code>AuthnContext</code> in the <code>SessionContext</code>.
*
* @param authnContext <code>AuthnContext</code> to be set.
* @return true if <code>AuthnContext</code> was set.
*/
if (authnContext == null) {
"setAuthnContext: Input is null.");
}
return false;
}
return true;
}
/**
* Constructs an <code>SessionContext</code> object from a DOM Element.
*
* @param element representing a DOM tree element.
* @throws SAMLException if there is an error in the sender or in the
* element definition.
*/
// make sure input is not null
throw new SAMLRequesterException(
}
// check if it's an ResourceAccessStatement
if (!valid) {
throw new SAMLRequesterException(
}
"or AssertionIssueInstant is missing!");
throw new SAMLRequesterException(
}
try {
} catch (ParseException e) {
//TODO: handle exception
}
//Handle the children elements of SessionContext
if (nodeCount > 0) {
for (int i = 0; i < nodeCount; i++) {
" or tag namespace of child element is" +
" either null or empty.");
}
throw new SAMLRequesterException(
}
if (_sessionSubject != null) {
" should only contain one SessionSubject");
}
throw new SAMLRequesterException(
} else {
try {
} catch (Exception e) {
"could not new SessionSubject" +
" object.");
}
throw new SAMLRequesterException(
"SessionSubject"));
}
}
if (_providerID != null) {
" should at most contain one" +
" ProviderID.");
}
throw new SAMLRequesterException(
} else {
.getNodeValue();
}
if (_authnContext != null) {
"should at most contain one " +
"AuthnContext");
}
throw new SAMLRequesterException(
} else {
try {
} catch (Exception e) {
"could not new AuthnContext" +
" object.", e);
}
throw new SAMLRequesterException(
"AuthnContext"));
}
}
} else {
}
throw new SAMLRequesterException(
}
} // end of if (currentNode.getNodeType() == Node.ELEMENT_NODE)
} // end of for loop
} // end of if (nodeCount > 0)
// check if the subject is null
"one SessionSubject and one " +
" one AuthnContext.");
}
throw new SAMLRequesterException(
}
}
/**
* Returns a String representation of the <code>SessionContext</code>
* element.
*
* @return A string containing the valid XML for this element.
* By default name space name is prepended to the element name
* example <code><saml:Subject></code>.
* @throws ParseException if could not convert String Date
* expression to Date object.
* @throws FSMsgException if could not get <code>AuthnContext</code> XML
* String representation.
*/
return toXMLString(true, false);
}
/**
* Returns a String representation of the <code><SessionContext></code>
* element.
*
* @param includeNS if true prepends all elements by their Namespace
* name <code><saml:Subject></code>.
* @param declareNS if true includes the namespace within the
* generated XML.
* @return A string containing the valid XML for this element. Return null
* if error happened.
* @throws ParseException if could not convert String Date
* expression to Date object.
* @throws FSMsgException if could not get <code>AuthnContext</code> XML
* String representation.
**/
throws ParseException, FSMsgException {
if (includeNS) {
}
if (declareNS) {
"\"";
}
append("\"").
append(">");
if (_authnContext != null) {
}
}
}