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: Conditions.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.ConditionsTypeImpl;
036: import com.sun.xml.wss.saml.util.SAMLJAXBUtil;
037: import java.util.Calendar;
038: import java.util.List;
039: import java.util.logging.Logger;
040:
041: import javax.xml.bind.JAXBContext;
042:
043: /**
044: * The validity of an <code>Assertion</code> MAY be subject to a set of
045: * <code>Conditions</code>. Each <code>Condition</code> evaluates to a value that
046: * is Valid, Invalid or Indeterminate.
047: */
048: public class Conditions extends
049: com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.ConditionsImpl
050: implements com.sun.xml.wss.saml.Conditions {
051:
052: protected static final Logger log = Logger.getLogger(
053: LogDomainConstants.WSS_API_DOMAIN,
054: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
055:
056: /**
057: Constructor taking in nothing (SAML spec allows it)
058: */
059: public Conditions() {
060: super ();
061: }
062:
063: private void setaudienceRestrictionConditionOrDoNotCacheConditionOrCondition(
064: List condition) {
065: this ._AudienceRestrictionConditionOrDoNotCacheConditionOrCondition = new ListImpl(
066: condition);
067: }
068:
069: /**
070: * Constructs an instance of <code>Conditions</code>.
071: *
072: * @param notBefore specifies the earliest time instant at which the
073: * assertion is valid.
074: * @param notOnOrAfter specifies the time instant at which the assertion
075: * has expired.
076: * @param condition
077: * @param arc the <code>AudienceRestrictionCondition</code> to be
078: * added. Can be null, if no audience restriction.
079: * @param doNotCacheCnd
080: * @exception SAMLException if there is a problem in input data and it
081: * cannot be processed correctly.
082: */
083: public Conditions(Calendar notBefore, Calendar notOnOrAfter,
084: List condition, List arc, List doNotCacheCnd) {
085:
086: setNotBefore(notBefore);
087: setNotOnOrAfter(notOnOrAfter);
088:
089: if (condition != null) {
090: setaudienceRestrictionConditionOrDoNotCacheConditionOrCondition(condition);
091: } else if (arc != null) {
092: setaudienceRestrictionConditionOrDoNotCacheConditionOrCondition(arc);
093: } else if (doNotCacheCnd != null) {
094: setaudienceRestrictionConditionOrDoNotCacheConditionOrCondition(doNotCacheCnd);
095: }
096: }
097:
098: /**
099: * Constructs a <code>Conditions</code> element from an existing XML block.
100: *
101: * @param conditionsElement A <code>org.w3c.dom.Element</code> representing
102: * DOM tree for <code>Conditions</code> object
103: * @exception SAMLException if it could not process the Element properly,
104: * implying that there is an error in the sender or in the
105: * element definition.
106: */
107: public static ConditionsTypeImpl fromElement(
108: org.w3c.dom.Element element) throws SAMLException {
109: try {
110: JAXBContext jc = SAMLJAXBUtil.getJAXBContext();
111: javax.xml.bind.Unmarshaller u = jc.createUnmarshaller();
112: return (ConditionsTypeImpl) u.unmarshal(element);
113: } catch (Exception ex) {
114: throw new SAMLException(ex.getMessage());
115: }
116: }
117: }
|