01: /*
02: * $Id: AttributeStatement.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.AttributeStatementType;
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>AttributeStatement</code> element supplies a statement by the issuer that the
42: *specified subject is associated with the specified attributes.
43: */
44: public class AttributeStatement extends AttributeStatementType
45: implements com.sun.xml.wss.saml.AttributeStatement {
46:
47: protected static final Logger log = Logger.getLogger(
48: LogDomainConstants.WSS_API_DOMAIN,
49: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
50:
51: private void setAttributes(List attr) {
52: this .attributeOrEncryptedAttribute = attr;
53: }
54:
55: /**
56: *Dafault constructor
57: */
58: public AttributeStatement(List attr) {
59: setAttributes(attr);
60: }
61:
62: /**
63: * Constructs an <code>AttributStatement</code> element from an existing
64: * XML block
65: * @param element representing a DOM tree element
66: * @exception SAMLException if there is an error in the sender or in the
67: * element definition.
68: */
69: public static AttributeStatementType fromElement(Element element)
70: throws SAMLException {
71: try {
72: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
73:
74: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
75: return (AttributeStatementType) u.unmarshal(element);
76: } catch (Exception ex) {
77: throw new SAMLException(ex.getMessage());
78: }
79: }
80: }
|