01: /*
02: * $Id: Attribute.java,v 1.3 2007/01/08 16:05:58 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.AttributeType;
32: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
33: import org.w3c.dom.Element;
34:
35: import java.util.List;
36: import java.util.logging.Logger;
37:
38: import javax.xml.bind.JAXBContext;
39:
40: /**
41: * The <code>Attribute</code> element specifies an attribute of the assertion subject.
42: * The <code>Attribute</code> element is an extension of the <code>AttributeDesignator</code> element
43: * that allows the attribute value to be specified.
44: */
45: public class Attribute extends AttributeType implements
46: com.sun.xml.wss.saml.Attribute {
47:
48: protected static final Logger log = Logger.getLogger(
49: LogDomainConstants.WSS_API_DOMAIN,
50: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
51:
52: /**
53: * Constructs an attribute element from an existing XML block.
54: *
55: * @param element representing a DOM tree element.
56: * @exception SAMLException if there is an error in the sender or in the
57: * element definition.
58: */
59: public static AttributeType fromElement(Element element)
60: throws SAMLException {
61: try {
62: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
63:
64: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
65: return (AttributeType) u.unmarshal(element);
66: } catch (Exception ex) {
67: throw new SAMLException(ex.getMessage());
68: }
69: }
70:
71: private void setAttributeValue(List values) {
72: this .attributeValue = values;
73: }
74:
75: /**
76: * Constructs an instance of <code>Attribute</code>.
77: *
78: * @param name A String representing <code>AttributeName</code> (the name
79: * of the attribute).
80: * @param nameSpace A String representing the namespace in which
81: * <code>AttributeName</code> elements are interpreted.
82: * @param values A List of DOM element representing the
83: * <code>AttributeValue</code> object.
84: * @exception SAMLException if there is an error in the sender or in the
85: * element definition.
86: */
87: public Attribute(String name, List values) {
88: setName(name);
89: setAttributeValue(values);
90: }
91: }
|