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: Subject.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:
033: import com.sun.xml.wss.logging.LogDomainConstants;
034: import com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.SubjectTypeImpl;
035: import com.sun.xml.wss.saml.util.SAMLJAXBUtil;
036: import java.util.logging.Logger;
037:
038: import javax.xml.bind.JAXBContext;
039:
040: /**
041: * The <code>Subject</code> element specifies one or more subjects. It contains either or
042: both of the following elements:<code>NameIdentifier</code>;
043: An identification of a subject by its name and security domain.
044: <code>SubjectConfirmation</code>;
045: Information that allows the subject to be authenticated.
046:
047: If a <code>Subject</code> element contains more than one subject specification,
048: the issuer is asserting that the surrounding statement is true for
049: all of the subjects specified. For example, if both a
050: <code>NameIdentifier</code> and a <code>SubjectConfirmation</code> element are
051: present, the issuer is asserting that the statement is true of both subjects
052: being identified. A <Subject> element SHOULD NOT identify more than one
053: principal.
054: */
055: public class Subject extends
056: com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.SubjectImpl
057: implements com.sun.xml.wss.saml.Subject {
058:
059: protected static final Logger log = Logger.getLogger(
060: LogDomainConstants.WSS_API_DOMAIN,
061: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
062:
063: /**
064: * Constructs a Subject object from a <code>NameIdentifier</code>
065: * object and a <code>SubjectConfirmation</code> object.
066: *
067: * @param nameIdentifier <code>NameIdentifier</code> object.
068: * @param subjectConfirmation <code>SubjectConfirmation</code> object.
069: * @exception SAMLException if it could not process the
070: * Element properly, implying that there is an error in the
071: * sender or in the element definition.
072: */
073: public Subject(NameIdentifier nameIdentifier,
074: SubjectConfirmation subjectConfirmation) {
075:
076: if (nameIdentifier != null)
077: setNameIdentifier(nameIdentifier);
078:
079: if (subjectConfirmation != null)
080: setSubjectConfirmation(subjectConfirmation);
081: }
082:
083: /**
084: * This constructor builds a subject element from an existing XML block
085: * which has already been built into a DOM.
086: *
087: * @param subjectElement An Element representing DOM tree for Subject object
088: * @exception SAMLException if it could not process the Element properly,
089: * implying that there is an error in the sender or in the
090: * element definition.
091: */
092: public static SubjectTypeImpl fromElement(
093: org.w3c.dom.Element element) throws SAMLException {
094: try {
095: JAXBContext jc = SAMLJAXBUtil.getJAXBContext();
096: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
097: return (SubjectTypeImpl) u.unmarshal(element);
098: } catch (Exception ex) {
099: throw new SAMLException(ex.getMessage());
100: }
101: }
102:
103: }
|