Package org.opensaml.xml.validation

Examples of org.opensaml.xml.validation.ValidationException


     */
    protected void validateReferenceURI(String uri, String id) throws ValidationException {
        if (!DatatypeHelper.isEmpty(uri)) {
            if (!uri.startsWith("#")) {
                log.error("Signature Reference URI was not a document fragment reference: " + uri);
                throw new ValidationException("Signature Reference URI was not a document fragment reference");
            } else if (DatatypeHelper.isEmpty(id)) {
                log.error("SignableSAMLObject did not contain an ID attribute");
                throw new ValidationException("SignableSAMLObject did not contain an ID attribute");
            } else if (uri.length() < 2 || !id.equals(uri.substring(1))) {
                log.error("Reference URI '{}' did not point to SignableSAMLObject with ID '{}'", uri, id);
                throw new ValidationException("Reference URI did not point to parent ID");
            }
        }
    }
View Full Code Here


        Transforms transforms = null;
        try {
            transforms = reference.getTransforms();
        } catch (XMLSecurityException e) {
            log.error("Apache XML Security error obtaining Transforms instance", e);
            throw new ValidationException("Apache XML Security error obtaining Transforms instance", e);
        }

        if (transforms == null) {
            log.error("Error obtaining Transforms instance, null was returned");
            throw new ValidationException("Transforms instance was null");
        }

        int numTransforms = transforms.getLength();
        if (numTransforms > 2) {
            log.error("Invalid number of Transforms was present: " + numTransforms);
            throw new ValidationException("Invalid number of transforms");
        }

        boolean sawEnveloped = false;
        for (int i = 0; i < numTransforms; i++) {
            Transform transform = null;
            try {
                transform = transforms.item(i);
            } catch (TransformationException e) {
                log.error("Error obtaining transform instance", e);
                throw new ValidationException("Error obtaining transform instance", e);
            }
            String uri = transform.getURI();
            if (Transforms.TRANSFORM_ENVELOPED_SIGNATURE.equals(uri)) {
                log.debug("Saw Enveloped signature transform");
                sawEnveloped = true;
            } else if (Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS.equals(uri)
                    || Transforms.TRANSFORM_C14N_EXCL_WITH_COMMENTS.equals(uri)) {
                log.debug("Saw Exclusive C14N signature transform");
            } else {
                log.error("Saw invalid signature transform: " + uri);
                throw new ValidationException("Signature contained an invalid transform");
            }
        }

        if (!sawEnveloped) {
            log.error("Signature was missing the required Enveloped signature transform");
            throw new ValidationException("Transforms did not contain the required enveloped transform");
        }
    }
View Full Code Here

     * @throws ValidationException if the signature contains ds:Object children
     */
    protected void validateObjectChildren(XMLSignature apacheSig) throws ValidationException {
        if (apacheSig.getObjectLength() > 0) {
            log.error("Signature contained {} ds:Object child element(s)", apacheSig.getObjectLength());
            throw new ValidationException("Signature contained illegal ds:Object children");
        }
    }
View Full Code Here

     * @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");
        }
    }
View Full Code Here

     * @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 (!DatatypeHelper.safeEquals(request.getVersion().toString(), SAMLVersion.VERSION_20.toString())) {
            throw new ValidationException("Wrong SAML Version");
        }
    }
View Full Code Here

     * @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");
        }
    }
View Full Code Here

     * @param response
     * @throws ValidationException
     */
    protected void validateStatus(StatusResponse response) throws ValidationException {
        if (response.getStatus() == null)
            throw new ValidationException("Status is required");
       
    }
View Full Code Here

     * @param response
     * @throws ValidationException
     */
    protected void validateID(StatusResponse response) throws ValidationException {
        if (DatatypeHelper.isEmpty(response.getID()))
            throw new ValidationException("ID attribute must not be empty");
    }
View Full Code Here

     * @param response
     * @throws ValidationException
     */
    protected void validateVersion(StatusResponse response) throws ValidationException {
        if (response.getVersion() == null)
            throw new ValidationException("Version attribute must not be null");
        if (!DatatypeHelper.safeEquals(response.getVersion().toString(), SAMLVersion.VERSION_20.toString()))
            throw new ValidationException("Wrong SAML Version");
    }
View Full Code Here

     * @param response
     * @throws ValidationException
     */
    protected void validateIssueInstant(StatusResponse response) throws ValidationException {
        if (response.getIssueInstant() == null)
            throw new ValidationException ("IssueInstant attribute must not be null");
    }
View Full Code Here

TOP

Related Classes of org.opensaml.xml.validation.ValidationException

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.