001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the "License"). You may not use this file except
005: * in compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://jwsdp.dev.java.net/CDDLv1.0.html
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * HEADER in each file and include the License file at
014: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
015: * add the following below this CDDL HEADER, with the
016: * fields enclosed by brackets "[]" replaced with your
017: * own identifying information: Portions Copyright [yyyy]
018: * [name of copyright owner]
019: */
020: /*
021: * $Id: Attribute.java,v 1.5 2007/01/08 16:05:57 shyam_rao Exp $
022: */
023:
024: /*
025: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
026: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
027: */
028:
029: package com.sun.xml.wss.saml.assertion.saml11.jaxb10;
030:
031: import com.sun.xml.wss.saml.SAMLException;
032: import com.sun.xml.bind.util.ListImpl;
033:
034: import com.sun.xml.wss.logging.LogDomainConstants;
035: import com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.AttributeTypeImpl;
036: import com.sun.xml.wss.saml.util.SAMLJAXBUtil;
037: import java.util.LinkedList;
038: import org.w3c.dom.Element;
039:
040: import java.util.List;
041: import java.util.Iterator;
042: import java.util.logging.Logger;
043:
044: import javax.xml.bind.JAXBContext;
045:
046: /**
047: * The <code>Attribute</code> element specifies an attribute of the assertion subject.
048: * The <code>Attribute</code> element is an extension of the <code>AttributeDesignator</code> element
049: * that allows the attribute value to be specified.
050: */
051: public class Attribute extends
052: com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.AttributeImpl
053: implements com.sun.xml.wss.saml.Attribute {
054:
055: protected static final Logger log = Logger.getLogger(
056: LogDomainConstants.WSS_API_DOMAIN,
057: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
058:
059: /**
060: * Constructs an attribute element from an existing XML block.
061: *
062: * @param element representing a DOM tree element.
063: * @exception SAMLException if there is an error in the sender or in the
064: * element definition.
065: */
066: public static AttributeTypeImpl fromElement(Element element)
067: throws SAMLException {
068: try {
069: JAXBContext jc = SAMLJAXBUtil.getJAXBContext();
070: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
071: return (AttributeTypeImpl) u.unmarshal(element);
072: } catch (Exception ex) {
073: throw new SAMLException(ex.getMessage());
074: }
075: }
076:
077: private void setAttributeValue(List values) {
078: Iterator it = values.iterator();
079: List typeList = new LinkedList();
080: while (it.hasNext()) {
081: List tmpList = new LinkedList();
082: tmpList.add(it.next());
083: AnyType type = new AnyType();
084: type.setContent(tmpList);
085: typeList.add(type);
086: }
087: this ._AttributeValue = new ListImpl(typeList);
088: }
089:
090: /**
091: * Constructs an instance of <code>Attribute</code>.
092: *
093: * @param name A String representing <code>AttributeName</code> (the name
094: * of the attribute).
095: * @param nameSpace A String representing the namespace in which
096: * <code>AttributeName</code> elements are interpreted.
097: * @param values A List of DOM element representing the
098: * <code>AttributeValue</code> object.
099: * @exception SAMLException if there is an error in the sender or in the
100: * element definition.
101: */
102: public Attribute(String name, String nameSpace, List values) {
103: setAttributeName(name);
104: setAttributeNamespace(nameSpace);
105: setAttributeValue(values);
106: /*List attValues = new LinkedList();
107: List typeList = new LinkedList();
108:
109: Iterator it = values.iterator();
110: while ( it.hasNext()) {
111: AnyType type = new AnyType();
112: typeList.clear();
113: typeList.add(it.next());
114: type.setContent(typeList);
115: attValues.add(type);
116: }
117: setAttributeValue(attValues);*/
118:
119: }
120: }
|