01: /*
02: * $Id: AudienceRestriction.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: import com.sun.xml.wss.logging.LogDomainConstants;
31: import com.sun.xml.wss.saml.internal.saml20.jaxb20.AudienceRestrictionType;
32: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
33:
34: import java.util.List;
35: import java.util.logging.Logger;
36:
37: import javax.xml.bind.JAXBContext;
38:
39: /**
40: * This is an implementation of the abstract <code>Condition</code> class, which
41: * specifes that the assertion this AuthenticationCondition is part of, is
42: *addressed to one or more specific audience.
43: */
44: public class AudienceRestriction extends AudienceRestrictionType
45: implements com.sun.xml.wss.saml.AudienceRestriction {
46:
47: protected static final Logger log = Logger.getLogger(
48: LogDomainConstants.WSS_API_DOMAIN,
49: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
50:
51: private void setAudience(List audience) {
52: this .audience = audience;
53: }
54:
55: /**
56: This constructor takes in a <code>List</code> of audience for this
57: condition, each of them being a String.
58: @param audience A List of audience to be included within this condition
59: @exception SAMLException if the <code>List</code> is empty or if there is
60: some error in processing the contents of the <code>List</code>
61: */
62: public AudienceRestriction(List audience) {
63: setAudience(audience);
64: }
65:
66: /**
67: * Constructs an <code>AudienceRestriction</code> element from an
68: * existing XML block.
69: *
70: * @param AudienceRestrictionElement A
71: * <code>org.w3c.dom.Element</code> representing DOM tree for
72: * <code>AudienceRestriction</code> object.
73: * @exception SAMLException if it could not process the
74: * <code>org.w3c.dom.Element</code> properly, implying that there
75: * is an error in the sender or in the element definition.
76: */
77: public static AudienceRestrictionType fromElement(
78: org.w3c.dom.Element element) throws SAMLException {
79: try {
80: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
81:
82: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
83: return (AudienceRestrictionType) u.unmarshal(element);
84: } catch (Exception ex) {
85: throw new SAMLException(ex.getMessage());
86: }
87: }
88: }
|