Package org.opensaml.saml1.core

Examples of org.opensaml.saml1.core.Conditions


        if (conditionsV1Builder == null) {
            conditionsV1Builder = (SAMLObjectBuilder<Conditions>)
                builderFactory.getBuilder(Conditions.DEFAULT_ELEMENT_NAME);
           
        }
        Conditions conditions = conditionsV1Builder.buildObject();
       
        if (conditionsBean == null) {
            DateTime newNotBefore = new DateTime();
            conditions.setNotBefore(newNotBefore);
            conditions.setNotOnOrAfter(newNotBefore.plusMinutes(5));
            return conditions;
        }
       
        int tokenPeriodMinutes = conditionsBean.getTokenPeriodMinutes();
        DateTime notBefore = conditionsBean.getNotBefore();
        DateTime notAfter = conditionsBean.getNotAfter();
       
        if (notBefore != null && notAfter != null) {
            if (notBefore.isAfter(notAfter)) {
                throw new IllegalStateException(
                    "The value of notBefore may not be after the value of notAfter"
                );
            }
            conditions.setNotBefore(notBefore);
            conditions.setNotOnOrAfter(notAfter);
        } else {
            DateTime newNotBefore = new DateTime();
            conditions.setNotBefore(newNotBefore);
            conditions.setNotOnOrAfter(newNotBefore.plusMinutes(tokenPeriodMinutes));
        }
       
        if (conditionsBean.getAudienceURI() != null) {
            AudienceRestrictionCondition audienceRestriction =
                createSamlv1AudienceRestriction(conditionsBean.getAudienceURI());
            conditions.getAudienceRestrictionConditions().add(audienceRestriction);
        }
       
        return conditions;
    }
View Full Code Here


public class ConditionsUnmarshaller extends AbstractSAMLObjectUnmarshaller {

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
            throws UnmarshallingException {
        Conditions conditions = (Conditions) parentSAMLObject;

        if (childSAMLObject instanceof Condition) {
            conditions.getConditions().add((Condition) childSAMLObject);
        } else {
            super.processChildElement(parentSAMLObject, childSAMLObject);
        }
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {

        Conditions conditions = (Conditions) samlObject;

        if (Conditions.NOTBEFORE_ATTRIB_NAME.equals(attribute.getLocalName())
                && !DatatypeHelper.isEmpty(attribute.getValue())) {
            conditions.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
        } else if (Conditions.NOTONORAFTER_ATTRIB_NAME.equals(attribute.getLocalName())
                && !DatatypeHelper.isEmpty(attribute.getValue())) {
            conditions.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
        } else {
            processAttribute(samlObject, attribute);
        }
    }
View Full Code Here

public class ConditionsMarshaller extends AbstractSAMLObjectMarshaller {

    /** {@inheritDoc} */
    protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {

        Conditions conditions = (Conditions) samlElement;

        if (conditions.getNotBefore() != null) {
            String date = Configuration.getSAMLDateFormatter().print(conditions.getNotBefore());
            domElement.setAttributeNS(null, Conditions.NOTBEFORE_ATTRIB_NAME, date);
        }

        if (conditions.getNotOnOrAfter() != null) {
            String date = Configuration.getSAMLDateFormatter().print(conditions.getNotOnOrAfter());
            domElement.setAttributeNS(null, Conditions.NOTONORAFTER_ATTRIB_NAME, date);
        }
    }
View Full Code Here

    }
   
    protected void validateDoNotCache(Assertion assertion) throws ValidationException {
       
        if (assertion.getMinorVersion() == 0) {
            Conditions conditions = assertion.getConditions();
            if (conditions != null) {
                for (Condition condition : conditions.getConditions()) {
                    if (condition instanceof DoNotCacheCondition) {
                        throw new ValidationException("DoNotCacheCondition not valid in SAML1.0");
                    }
                }
            }
View Full Code Here

        this.setAssertionId(assertion.getID());

        //Read the validity period from the 'Conditions' element, else read it from SC Data
        if (assertion.getConditions() != null) {
            Conditions conditions = assertion.getConditions();
            if (conditions.getNotBefore() != null) {
                this.setDateNotBefore(conditions.getNotBefore().toDate());
            }
            if (conditions.getNotOnOrAfter() != null) {
                this.setDateNotOnOrAfter(conditions.getNotOnOrAfter().toDate());
            }
        }
    }
View Full Code Here

        if (conditionsV1Builder == null) {
            conditionsV1Builder = (SAMLObjectBuilder<Conditions>)
                builderFactory.getBuilder(Conditions.DEFAULT_ELEMENT_NAME);
           
        }
        Conditions conditions = conditionsV1Builder.buildObject();
       
        if (conditionsBean == null) {
            DateTime newNotBefore = new DateTime();
            conditions.setNotBefore(newNotBefore);
            conditions.setNotOnOrAfter(newNotBefore.plusMinutes(5));
            return conditions;
        }
       
        long tokenPeriodSeconds = conditionsBean.getTokenPeriodSeconds();
        DateTime notBefore = conditionsBean.getNotBefore();
        DateTime notAfter = conditionsBean.getNotAfter();
       
        if (notBefore != null && notAfter != null) {
            if (notBefore.isAfter(notAfter)) {
                throw new IllegalStateException(
                    "The value of notBefore may not be after the value of notAfter"
                );
            }
            conditions.setNotBefore(notBefore);
            conditions.setNotOnOrAfter(notAfter);
        } else {
            DateTime newNotBefore = new DateTime();
            conditions.setNotBefore(newNotBefore);
            if (tokenPeriodSeconds <= 0) {
                tokenPeriodSeconds = 5L * 60L;
            }
            DateTime notOnOrAfter =
                new DateTime(newNotBefore.getMillis() + tokenPeriodSeconds * 1000L);
           
            conditions.setNotOnOrAfter(notOnOrAfter);
        }
       
        if (conditionsBean.getAudienceURI() != null) {
            AudienceRestrictionCondition audienceRestriction =
                createSamlv1AudienceRestriction(conditionsBean.getAudienceURI());
            conditions.getAudienceRestrictionConditions().add(audienceRestriction);
        }
       
        return conditions;
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
            throws UnmarshallingException {
        Conditions conditions = (Conditions) parentSAMLObject;

        if (childSAMLObject instanceof Condition) {
            conditions.getConditions().add((Condition) childSAMLObject);
        } else {
            super.processChildElement(parentSAMLObject, childSAMLObject);
        }
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {

        Conditions conditions = (Conditions) samlObject;

        if (Conditions.NOTBEFORE_ATTRIB_NAME.equals(attribute.getLocalName())
                && !DatatypeHelper.isEmpty(attribute.getValue())) {
            conditions.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
        } else if (Conditions.NOTONORAFTER_ATTRIB_NAME.equals(attribute.getLocalName())
                && !DatatypeHelper.isEmpty(attribute.getValue())) {
            conditions.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
        } else {
            processAttribute(samlObject, attribute);
        }
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {

        Conditions conditions = (Conditions) samlElement;

        if (conditions.getNotBefore() != null) {
            String date = Configuration.getSAMLDateFormatter().print(conditions.getNotBefore());
            domElement.setAttributeNS(null, Conditions.NOTBEFORE_ATTRIB_NAME, date);
        }

        if (conditions.getNotOnOrAfter() != null) {
            String date = Configuration.getSAMLDateFormatter().print(conditions.getNotOnOrAfter());
            domElement.setAttributeNS(null, Conditions.NOTONORAFTER_ATTRIB_NAME, date);
        }
    }
View Full Code Here

TOP

Related Classes of org.opensaml.saml1.core.Conditions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.