Package org.opensaml.xml.validation

Examples of org.opensaml.xml.validation.ValidationException


     * @param assertion
     * @throws ValidationException
     */
    protected void validateIssuer(Assertion assertion) throws ValidationException {
        if (DatatypeHelper.isEmpty(assertion.getIssuer())) {
             throw new ValidationException("Issuer not present");
         }
    }
View Full Code Here


     * @param assertion
     * @throws ValidationException
     */
    protected void validateIssueInstant(Assertion assertion) throws ValidationException {
         if (assertion.getIssueInstant() == null) {
             throw new ValidationException("IssueInstant not present");
         }
    }
View Full Code Here

     * @throws ValidationException
     */
    protected void validateStatements(Assertion assertion) throws ValidationException {
        List <Statement> list = assertion.getStatements();
         if (list == null || list.size() == 0) {
             throw new ValidationException("No Statements present");
         }
    }
View Full Code Here

     *
     * @throws ValidationException thrown if the statement does not have a subject
     */
    protected void validateSubject(SubjectStatementType subjectStatement) throws ValidationException {
        if (subjectStatement.getSubject() == null) {
            throw new ValidationException("No Subject present");
        }
    }
View Full Code Here

         validateURIPresent(audience);
    }
   
    protected void validateURIPresent(Audience audience) throws ValidationException {
        if (DatatypeHelper.isEmpty(audience.getUri())) {
            throw new ValidationException("AudienceURI Required");
        }
    }
View Full Code Here

     * @throws ValidationException
     */
    protected void validateVersion(Assertion assertion) throws ValidationException {
         if ((assertion.getMajorVersion() != 1) &&
             (assertion.getMinorVersion() != 0 || assertion.getMinorVersion() != 1)) {
             throw new ValidationException("Invalid Version");
         }
    }   
View Full Code Here

     * @param assertion
     * @throws ValidationException
     */
    protected void validateId(Assertion assertion) throws ValidationException {
         if (DatatypeHelper.isEmpty(assertion.getID())) {
             throw new ValidationException("ID not present");
         }
    }
View Full Code Here

     */
    protected void validateSignatureImpl(SignatureImpl sigImpl) throws ValidationException {

        if (sigImpl.getXMLSignature() == null) {
            log.error("SignatureImpl did not contain the an Apache XMLSignature child");
            throw new ValidationException("Apache XMLSignature does not exist on SignatureImpl");
        }
        XMLSignature apacheSig = sigImpl.getXMLSignature();

        if (!(sigImpl.getParent() instanceof SignableSAMLObject)) {
            log.error("Signature is not an immedidate child of a SignableSAMLObject");
            throw new ValidationException("Signature is not an immediate child of a SignableSAMLObject.");
        }
        SignableSAMLObject signableObject = (SignableSAMLObject) sigImpl.getParent();

        Reference ref = validateReference(apacheSig);

View Full Code Here

     */
    protected Reference validateReference(XMLSignature apacheSig) throws ValidationException {
        int numReferences = apacheSig.getSignedInfo().getLength();
        if (numReferences != 1) {
            log.error("Signature SignedInfo had invalid number of References: " + numReferences);
            throw new ValidationException("Signature SignedInfo must have exactly 1 Reference element");
        }

        Reference ref = null;
        try {
            ref = apacheSig.getSignedInfo().item(0);
        } catch (XMLSecurityException e) {
            log.error("Apache XML Security exception obtaining Reference", e);
            throw new ValidationException("Could not obtain Reference from Signature/SignedInfo", e);
        }
        if (ref == null) {
            log.error("Signature Reference was null");
            throw new ValidationException("Signature Reference was null");
        }
        return ref;
    }
View Full Code Here

        String uriID = uri.substring(1);
       
        Element expected = signableObject.getDOM();
        if (expected == null) {
            log.error("SignableSAMLObject does not have a cached DOM Element.");
            throw new ValidationException("SignableSAMLObject does not have a cached DOM Element.");
        }
        Document doc = expected.getOwnerDocument();
       
        Element resolved = IdResolver.getElementById(doc, uriID);
        if (resolved == null) {
            log.error("Apache xmlsec IdResolver could not resolve the Element for id reference: {}", uriID);
            throw new ValidationException("Apache xmlsec IdResolver could not resolve the Element for id reference: "
                    +  uriID);
        }
       
        if (!expected.isSameNode(resolved)) {
            log.error("Signature Reference URI '{}' did not resolve to the expected parent Element", uri);
            throw new ValidationException("Signature Reference URI did not resolve to the expected parent Element");
        }
    }
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.