01: /*
02: * $Id: NameID.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:
31: import com.sun.xml.wss.logging.LogDomainConstants;
32: import com.sun.xml.wss.saml.internal.saml20.jaxb20.NameIDType;
33: import com.sun.xml.wss.saml.util.SAML20JAXBUtil;
34: import java.util.logging.Logger;
35:
36: import javax.xml.bind.JAXBContext;
37:
38: /**
39: *The NameID element specifies a <code>Subject</code> by a combination
40: * of a name and a security domain governing the name of the <code>Subject</code>.
41: */
42: public class NameID extends NameIDType implements
43: com.sun.xml.wss.saml.NameID {
44:
45: protected static final Logger log = Logger.getLogger(
46: LogDomainConstants.WSS_API_DOMAIN,
47: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
48:
49: /**
50: * Constructs a <code>NameIdentifer</code> element from an existing XML
51: * block.
52: *
53: * @param NameIDElement A <code>org.w3c.dom.Element</code>
54: * representing DOM tree for <code>NameID</code> object
55: * @exception SAMLException if it could not process the
56: * <code>org.w3c.dom.Element</code> properly, implying that there
57: * is an error in the sender or in the element definition.
58: */
59: public static NameIDType fromElement(org.w3c.dom.Element element)
60: throws SAMLException {
61: try {
62: JAXBContext jc = SAML20JAXBUtil.getJAXBContext();
63:
64: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
65: return (NameIDType) u.unmarshal(element);
66: } catch (Exception ex) {
67: throw new SAMLException(ex.getMessage());
68: }
69: }
70:
71: /**
72: * Constructs a <code>NameQualifier</code> instance.
73: *
74: * @param name The string representing the name of the Subject
75: * @param nameQualifier The security or administrative domain that qualifies
76: * the name of the <code>Subject</code>. This is optional could be
77: * null or "".
78: * @param format The syntax used to describe the name of the
79: * <code>Subject</code>. This optional, could be null or "".
80: * @exception SAMLException if the input has an error.
81: */
82: public NameID(String name, String nameQualifier, String format) {
83: if (name != null)
84: setValue(name);
85:
86: if (nameQualifier != null)
87: setNameQualifier(nameQualifier);
88:
89: if (format != null)
90: setFormat(format);
91: }
92: }
|