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: AuthenticationStatement.java,v 1.5 2007/01/08 16:05:58 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.AuthenticationStatementTypeImpl;
036: import com.sun.xml.wss.saml.util.SAMLJAXBUtil;
037: import java.util.Calendar;
038: import org.w3c.dom.Element;
039: import java.util.List;
040: import java.util.logging.Logger;
041:
042: import javax.xml.bind.JAXBContext;
043:
044: /**
045: * The <code>AuthenticationStatement</code> element supplies a
046: * statement by the issuer that its subject was authenticated by a
047: * particular means at a particular time. The
048: * <code>AuthenticationStatement</code> element is of type
049: * <code>AuthenticationStatementType</code>, which extends the
050: * <code>SubjectStatementAbstractType</code> with the additional element and
051: * attributes.
052: */
053: public class AuthenticationStatement
054: extends
055: com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.AuthenticationStatementImpl
056: implements com.sun.xml.wss.saml.AuthenticationStatement {
057:
058: protected static final Logger log = Logger.getLogger(
059: LogDomainConstants.WSS_API_DOMAIN,
060: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
061:
062: /**
063: *Default constructor
064: */
065: protected AuthenticationStatement() {
066: super ();
067: }
068:
069: /**
070: * This constructor builds an authentication statement element from an
071: * existing XML block.
072: *
073: * @param element representing a DOM tree element.
074: * @exception SAMLException if there is an error in the sender or in the
075: * element definition.
076: */
077: public static AuthenticationStatementTypeImpl fromElement(
078: Element element) throws SAMLException {
079: try {
080: JAXBContext jc = SAMLJAXBUtil.getJAXBContext();
081: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
082: return (AuthenticationStatementTypeImpl) u
083: .unmarshal(element);
084: } catch (Exception ex) {
085: throw new SAMLException(ex.getMessage());
086: }
087: }
088:
089: private void setAuthorityBinding(List authorityBinding) {
090: _AuthorityBinding = new ListImpl(authorityBinding);
091: }
092:
093: /**
094: * Constructor for authentication statement
095: *
096: * @param authMethod (optional) A String specifies the type of authentication
097: * that took place.
098: * @param authInstant (optional) A String specifies the time at which the
099: * authentication that took place.
100: * @param subject (required) A Subject object
101: * @param subjectLocality (optional) A <code>SubjectLocality</code> object.
102: * @param authorityBinding (optional) A List of <code>AuthorityBinding</code>
103: * objects.
104: * @exception SAMLException if there is an error in the sender.
105: */
106: public AuthenticationStatement(String authMethod,
107: Calendar authInstant, Subject subject,
108: SubjectLocality subjectLocality, List authorityBinding) {
109:
110: if (authMethod != null)
111: setAuthenticationMethod(authMethod);
112:
113: if (authInstant != null)
114: setAuthenticationInstant(authInstant);
115:
116: if (subject != null)
117: setSubject(subject);
118:
119: if (subjectLocality != null)
120: setSubjectLocality(subjectLocality);
121:
122: if (authorityBinding != null)
123: setAuthorityBinding(authorityBinding);
124: }
125: }
|