01: /*
02: * $Id: Advice.java,v 1.3 2007/01/08 16:05:59 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: import com.sun.xml.wss.logging.LogDomainConstants;
31: import com.sun.xml.wss.saml.internal.saml20.jaxb20.AdviceType;
32: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
33: import javax.xml.bind.JAXBContext;
34: import org.w3c.dom.Element;
35:
36: import java.util.List;
37: import java.util.logging.Logger;
38:
39: /**
40: *The <code>Advice</code> element contains additional information that the issuer wishes to
41: *provide. This information MAY be ignored by applications without affecting
42: *either the semantics or validity. Advice elements MAY be specified in
43: *an extension schema.
44: */
45: public class Advice extends AdviceType implements
46: com.sun.xml.wss.saml.Advice {
47: protected static final Logger log = Logger.getLogger(
48: LogDomainConstants.WSS_API_DOMAIN,
49: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
50:
51: public static AdviceType fromElement(Element element)
52: throws SAMLException {
53: try {
54: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
55: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
56: return (AdviceType) u.unmarshal(element);
57: } catch (Exception ex) {
58: throw new SAMLException(ex.getMessage());
59: }
60: }
61:
62: private void setAssertionIDRefOrAssertionURIRefOrAssertion(
63: List assertionIDRefOrAssertionURIRefOrAssertion) {
64: this .assertionIDRefOrAssertionURIRefOrAssertion = assertionIDRefOrAssertionURIRefOrAssertion;
65: }
66:
67: /**
68: * Constructor
69: *
70: * @param assertionidreference A List of <code>AssertionIDReference</code>.
71: * @param assertion A List of Assertion
72: * @param otherelement A List of any element defined as
73: * <code><any namespace="##other" processContents="lax"></code>;
74: */
75: public Advice(List assertionidreference, List assertion,
76: List otherelement) {
77: if (null != assertionidreference) {
78: setAssertionIDRefOrAssertionURIRefOrAssertion(assertionidreference);
79: } else if (null != assertion) {
80: setAssertionIDRefOrAssertionURIRefOrAssertion(assertion);
81: } else if (null != otherelement) {
82: setAssertionIDRefOrAssertionURIRefOrAssertion(otherelement);
83: }
84: }
85: }
|