1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.xml.encryption.validator;
18
19 import javax.xml.namespace.QName;
20
21 import org.opensaml.xml.XMLObject;
22 import org.opensaml.xml.encryption.ReferenceType;
23 import org.opensaml.xml.util.DatatypeHelper;
24 import org.opensaml.xml.util.XMLConstants;
25 import org.opensaml.xml.validation.ValidationException;
26 import org.opensaml.xml.validation.Validator;
27
28
29
30
31 public class ReferenceTypeSchemaValidator implements Validator<ReferenceType> {
32
33
34 public void validate(ReferenceType xmlObject) throws ValidationException {
35 validateURI(xmlObject);
36 validateChildrenNamespaces(xmlObject);
37 }
38
39
40
41
42
43
44
45 protected void validateURI(ReferenceType xmlObject) throws ValidationException {
46 if (DatatypeHelper.isEmpty(xmlObject.getURI())) {
47 throw new ValidationException("ReferenceType URI was empty");
48 }
49 }
50
51
52
53
54
55
56
57 protected void validateChildrenNamespaces(ReferenceType xmlObject) throws ValidationException {
58
59 for (XMLObject child : xmlObject.getUnknownXMLObjects()) {
60 QName childName = child.getElementQName();
61 if (XMLConstants.XMLENC_NS.equals(childName.getNamespaceURI())) {
62 throw new ValidationException("ReferenceType contains an illegal child extension element: " + childName);
63 }
64 }
65 }
66
67 }