/** * Validates the Version attribute. * * @param request request to validate * @throws ValidationException if invalid */ protected void validateVersion(RequestAbstractType request) throws ValidationException { if (request.getVersion() == null) { throw new ValidationException("Version attribute must not be null"); } if (request.getVersion().toString() != SAMLVersion.VERSION_20.toString()) { throw new ValidationException("Wrong SAML Version"); } }
@Override public boolean validateXMLSignature( RequestAbstractType request, X509Credential cred, String alias) throws IdentityException { boolean isSignatureValid = false; if (request.getSignature() != null) { try { SignatureValidator validator = new SignatureValidator(cred); validator.validate(request.getSignature()); isSignatureValid = true; } catch (ValidationException e) { throw IdentityException.error( "Signature Validation Failed for the SAML Assertion : Signature is " + "invalid.", e); } } return isSignatureValid; }
/** * Validates the IsssueInstant attribute. * * @param request request to validate * @throws ValidationException if invalid */ protected void validateIssueInstant(RequestAbstractType request) throws ValidationException { if (request.getIssueInstant() == null) { throw new ValidationException("IssueInstant attribute must not be null"); } }
/** * Validates the ID attribute. * * @param request request to validate * @throws ValidationException if invalid */ protected void validateID(RequestAbstractType request) throws ValidationException { if (DatatypeHelper.isEmpty(request.getID())) { throw new ValidationException("ID attribute must not be empty"); } }
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { RequestAbstractType req = (RequestAbstractType) samlObject; if (req.getVersion() != null) { domElement.setAttributeNS( null, RequestAbstractType.VERSION_ATTRIB_NAME, req.getVersion().toString()); } if (req.getID() != null) { domElement.setAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, req.getID()); domElement.setIdAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, true); } if (req.getVersion() != null) { domElement.setAttributeNS( null, RequestAbstractType.VERSION_ATTRIB_NAME, req.getVersion().toString()); } if (req.getIssueInstant() != null) { String iiStr = Configuration.getSAMLDateFormatter().print(req.getIssueInstant()); domElement.setAttributeNS(null, RequestAbstractType.ISSUE_INSTANT_ATTRIB_NAME, iiStr); } if (req.getDestination() != null) { domElement.setAttributeNS( null, RequestAbstractType.DESTINATION_ATTRIB_NAME, req.getDestination()); } if (req.getConsent() != null) { domElement.setAttributeNS(null, RequestAbstractType.CONSENT_ATTRIB_NAME, req.getConsent()); } }