1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.xml.signature.validator;
18
19 import org.opensaml.xml.signature.DSAKeyValue;
20 import org.opensaml.xml.validation.ValidationException;
21 import org.opensaml.xml.validation.Validator;
22
23
24
25
26 public class DSAKeyValueSchemaValidator implements Validator<DSAKeyValue> {
27
28
29 public void validate(DSAKeyValue xmlObject) throws ValidationException {
30 validateChildrenPresence(xmlObject);
31 }
32
33
34
35
36
37
38
39 protected void validateChildrenPresence(DSAKeyValue xmlObject) throws ValidationException {
40 if (xmlObject.getY() == null) {
41 throw new ValidationException("DSAKeyValue did not contain a required Y value");
42 }
43
44 if (xmlObject.getP() != null && xmlObject.getQ() == null) {
45 throw new ValidationException("RSAKeyValue did contained a P value without a Q value");
46 } else if (xmlObject.getQ() != null && xmlObject.getP() == null) {
47 throw new ValidationException("RSAKeyValue did contained a Q value without a P value");
48 }
49
50 if (xmlObject.getPgenCounter() != null && xmlObject.getSeed() == null) {
51 throw new ValidationException("RSAKeyValue did contained a PgenCounter value without a Seed value");
52 } else if (xmlObject.getSeed() != null && xmlObject.getPgenCounter() == null) {
53 throw new ValidationException("RSAKeyValue did contained a Seed value without a PgenCounter value");
54 }
55
56 }
57 }