EvidenceBase.java revision a688bcbb4bcff5398fdd29b86f83450257dc0df4
/**
* 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: EvidenceBase.java,v 1.2 2008/06/25 05:47:32 qcheng Exp $
*
*/
/**
*The <code>Evidence</code> element specifies an assertion either by
*reference or by value. An assertion is specified by reference to the value of
*the assertion's <code>AssertionIDReference</code> element.
*An assertion is specified by value by including the entire
*<code>Assertion</code> object
*
* This class is an abstract base class for all Evidence implementations and
* encapsulates common functionality.
*@supported.all.api
*/
public abstract class EvidenceBase {
static SAMLConstants sc;
/**
* Constructs an <code>Evidence</code> object from a block of existing XML
* that has already been built into a DOM.
*
* @param assertionSpecifierElement A <code>org.w3c.dom.Element</code>
* representing DOM tree for <code>Evidence</code> object.
* @exception SAMLException if it could not process the Element properly,
* implying that there is an error in the sender or in the
* element definition.
*/
throws SAMLException
{
if (elementName == null) {
+ "missing");
}
("nullInput")) ;
}
"Evidence: invalid root element");
}
}
if (length <= 0 ) {
+"no sub elements found in this Element");
}
"noElement")) ;
}
for (int n=0; n < length; n++) {
continue;
}
} else {
+ "invalid sub element");
}
throw new SAMLRequesterException(
}
}
}
/**
* Constructs a new <code>Evidence></code> element containing a
* set of <code>Assertion</code> objects.
*
* @param evidenceContent A set of <code>Assertion</code> and
* <code>AssertionIDReference</code> objects to be put within the
* <code>Evidence</code> element. The same Set contains both type
* of elements.
* @exception SAMLException if the Set is empty or has invalid object.
*/
if (evidenceContent.isEmpty()) {
+ "specified");
}
"nullInput")) ;
}
if (obj instanceof AssertionBase) {
} else if (obj instanceof AssertionIDReference) {
} else {
"Evidence: Invalid input Element");
throw new SAMLRequesterException(
}
}
}
/**
* Constructs an Evidence from a Set of <code>Assertion</code> and
* <code>AssertionIDReference</code> objects.
*
* @param assertionIDRef Set of <code>AssertionIDReference</code> objects.
* @param assertion Set of <code>Assertion</code> objects.
* @exception SAMLException if either Set is empty or has invalid object.
*/
throws SAMLException {
+ "specified");
}
"nullInput")) ;
}
if (assID instanceof AssertionIDReference) {
}
else {
"Evidence: Invalid input Element");
throw new SAMLRequesterException(
}
}
if (ass instanceof AssertionBase) {
}
else {
"Evidence: Invalid input Element");
throw new SAMLRequesterException(
}
}
}
/**
* Adds an <code>Assertion</code> object into the Evidence object.
* @param assertion <code>Assertion</code> to be added
* @return true if operation succeeds.
*/
+ "specified");
}
return false;
} else {
return true;
}
}
/**
* Adds an <code>AssertionIDReference</code> object into the
* <code>Evidence</code> object.
*
* @param assertionIDRef <code>AssertionIDReference</code> to be added.
* @return true if operation succeeds.
*/
{
if (assertionIDRef == null) {
+ "specified");
}
return false;
} else {
return true;
}
}
/**
* Removes an <code>Assertion</code> object from the <code>Evidence</code>
* object.
*
* @param assertion <code>Assertion</code> to be removed.
* @return true if the operation succeeds, Returns failure of the
* <code>Assertion</code> is the only element inside the
* <code>Evidence</code>.
*/
{
return true;
}
} else {
+ "specified");
}
}
return false;
}
/**
* Removes an <code>AssertionIDReference</code> object from the
* <code>Evidence</code> object.
*
* @param assertionIDRef <code>AssertionIDReference</code> to be removed
* @return true if the operation succeeds, Returns false if the
* <code>AssertionIDReference</code> is the only element
* inside the <code>Evidence</code>.
*/
public boolean removeAssertionIDReference(AssertionIDReference
{
if (assertionIDRef != null) {
return true;
}
} else {
+ "specified");
}
}
return false;
}
/**
*Get <code>java.util.Set</code> of <code>AssertionIDReference</code>
*objects in the <code>Evidence</code>
*@return <code>java.util.Set</code> of <code>AssertionIDReference</code>
*objects within this Evidence.
*/
public Set getAssertionIDReference() {
return _assertionIDRef;
}
/**
*Get <code>java.util.Set</code> of <code>Assertion</code>
*objects in the <code>Evidence</code>
*@return <code>java.util.Set</code> of <code>Assertion</code>
*objects within this Evidence.
*/
public Set getAssertion() {
return _assertion;
}
/**
* Returns a String representation of the 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:Evidence></code>.
*/
// call toString() with includeNS true by default and declareNS false
return xml;
}
/**
* Returns a String representation of the <code><Evidence></code>
* element (or of the <code><Evidence></code> element).
*
* @param includeNS Determines whether or not the namespace qualifier is
* prepended to the <code>Element</code> when converted.
* @param declareNS Determines whether or not the namespace is declared
* within the Element.
* @return The string containing the valid XML for this element .The top
* level element is <code>Evidence</code>.
*/
}
}
}
/**
* Creates appropriate Assertion Instance
* @param assertionElement the assertion Element
* @return the assertion instance
*/
protected abstract AssertionBase
throws SAMLException;
/**
* Creates appropriate AssertionIDReference Instance
* @param assertionID the assertion ID String
* @return the AssertionIDReference instance
*/
protected abstract AssertionIDReference
throws SAMLException;
}