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 org.opensaml.xml.encryption.CipherData;
20 import org.opensaml.xml.validation.ValidationException;
21 import org.opensaml.xml.validation.Validator;
22
23
24
25
26 public class CipherDataSchemaValidator implements Validator<CipherData> {
27
28
29 public void validate(CipherData xmlObject) throws ValidationException {
30 validateChildrenPresence(xmlObject);
31 }
32
33
34
35
36
37
38
39 protected void validateChildrenPresence(CipherData xmlObject) throws ValidationException {
40 if (xmlObject.getCipherValue() == null && xmlObject.getCipherReference() == null) {
41 throw new ValidationException("CipherData did not contain either a CipherValue or CipherReference child");
42 }
43 if (xmlObject.getCipherValue() != null && xmlObject.getCipherReference() != null) {
44 throw new ValidationException("CipherData contained both a CipherValue and a CipherReference child");
45 }
46 }
47 }