01: /*
02: * $Id: Evidence.java,v 1.3 2007/01/08 16:06:00 shyam_rao Exp $
03: */
04:
05: /*
06: * The contents of this file are subject to the terms
07: * of the Common Development and Distribution License
08: * (the License). You may not use this file except in
09: * compliance with the License.
10: *
11: * You can obtain a copy of the license at
12: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
13: * See the License for the specific language governing
14: * permissions and limitations under the License.
15: *
16: * When distributing Covered Code, include this CDDL
17: * Header Notice in each file and include the License file
18: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
19: * If applicable, add the following below the CDDL Header,
20: * with the fields enclosed by brackets [] replaced by
21: * you own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
25: */
26:
27: package com.sun.xml.wss.saml.assertion.saml20.jaxb20;
28:
29: import com.sun.xml.wss.saml.SAMLException;
30:
31: import com.sun.xml.wss.logging.LogDomainConstants;
32: import com.sun.xml.wss.saml.internal.saml20.jaxb20.EvidenceType;
33: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
34: import java.util.List;
35: import java.util.logging.Logger;
36:
37: import javax.xml.bind.JAXBContext;
38:
39: /**
40: * The <code>Evidence</code> element specifies an assertion either by
41: * reference or by value. An assertion is specified by reference to the value of
42: * the assertion's <code>AssertionIDReference</code> element.
43: * An assertion is specified by value by including the entire
44: * <code>Assertion</code> object
45: */
46: public class Evidence extends EvidenceType implements
47: com.sun.xml.wss.saml.Evidence {
48:
49: protected static final Logger log = Logger.getLogger(
50: LogDomainConstants.WSS_API_DOMAIN,
51: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
52:
53: /**
54: * Constructs an <code>Evidence</code> object from a block of existing XML
55: * that has already been built into a DOM.
56: *
57: * @param assertionSpecifierElement A <code>org.w3c.dom.Element</code>
58: * representing DOM tree for <code>Evidence</code> object.
59: * @exception SAMLException if it could not process the Element properly,
60: * implying that there is an error in the sender or in the
61: * element definition.
62: */
63: public static EvidenceType fromElement(org.w3c.dom.Element element)
64: throws SAMLException {
65: try {
66: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
67:
68: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
69: return (EvidenceType) u.unmarshal(element);
70: } catch (Exception ex) {
71: throw new SAMLException(ex.getMessage());
72: }
73: }
74:
75: private void setAssertionIDReferenceOrAssertion(List evidence) {
76: this .assertionIDRefOrAssertionURIRefOrAssertion = evidence;
77: }
78:
79: /**
80: * Constructs an Evidence from a Set of <code>Assertion</code> and
81: * <code>AssertionIDReference</code> objects.
82: *
83: * @param assertionIDRef Set of <code>AssertionIDReference</code> objects.
84: * @param assertion Set of <code>Assertion</code> objects.
85: * @exception SAMLException if either Set is empty or has invalid object.
86: */
87: public Evidence(List assertionIDRef, List assertion) {
88:
89: if (assertionIDRef != null)
90: setAssertionIDReferenceOrAssertion(assertionIDRef);
91: else if (assertion != null)
92: setAssertionIDReferenceOrAssertion(assertion);
93: }
94: }
|