/** * Test that the version is SAML1.1 or 1.0 * @param assertion what to test * @throws ValidationException */ protected void validateVersion(Assertion assertion) throws ValidationException { if ((assertion.getMajorVersion() != 1) && (assertion.getMinorVersion() != 0 || assertion.getMinorVersion() != 1)) { throw new ValidationException("Invalid Version"); } }
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { Assertion assertion = (Assertion) samlElement; if (assertion.getID() != null) { domElement.setAttributeNS(null, Assertion.ID_ATTRIB_NAME, assertion.getID()); if (assertion.getMinorVersion() != 0) { domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true); } } if (assertion.getIssuer() != null) { domElement.setAttributeNS(null, Assertion.ISSUER_ATTRIB_NAME, assertion.getIssuer()); } if (assertion.getIssueInstant() != null) { String date = ISODateTimeFormat.dateTime().print(assertion.getIssueInstant()); domElement.setAttributeNS(null, Assertion.ISSUEINSTANT_ATTRIB_NAME, date); } domElement.setAttributeNS(null, Assertion.MAJORVERSION_ATTRIB_NAME, "1"); if (assertion.getMinorVersion() == 0) { domElement.setAttributeNS(null, Assertion.MINORVERSION_ATTRIB_NAME, "0"); } else { domElement.setAttributeNS(null, Assertion.MINORVERSION_ATTRIB_NAME, "1"); } } }
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"); } } } } } }
/** {@inheritDoc} */ public XMLObject unmarshall(Element domElement) throws UnmarshallingException { // After regular unmarshalling, check the minor version and set ID-ness if not SAML 1.0 Assertion assertion = (Assertion) super.unmarshall(domElement); if (assertion.getMinorVersion() != 0 && !DatatypeHelper.isEmpty(assertion.getID())) { domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true); } return assertion; }