1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.xml.signature.impl;
18
19 import java.math.BigInteger;
20
21 import org.opensaml.xml.schema.impl.XSBase64BinaryImpl;
22 import org.opensaml.xml.security.keyinfo.KeyInfoHelper;
23 import org.opensaml.xml.signature.CryptoBinary;
24 import org.opensaml.xml.util.DatatypeHelper;
25
26
27
28
29 public class CryptoBinaryImpl extends XSBase64BinaryImpl implements CryptoBinary {
30
31
32 private BigInteger bigIntValue;
33
34
35
36
37
38
39
40
41 protected CryptoBinaryImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
42 super(namespaceURI, elementLocalName, namespacePrefix);
43 }
44
45
46 public BigInteger getValueBigInt() {
47 if (bigIntValue == null && !DatatypeHelper.isEmpty(getValue())) {
48 bigIntValue = KeyInfoHelper.decodeBigIntegerFromCryptoBinary(getValue());
49 }
50 return bigIntValue;
51 }
52
53
54 public void setValueBigInt(BigInteger bigInt) {
55 if (bigInt == null) {
56 setValue(null);
57 } else {
58 setValue(KeyInfoHelper.encodeCryptoBinaryFromBigInteger(bigInt));
59 }
60 bigIntValue = bigInt;
61 }
62
63
64 public void setValue(String newValue) {
65 if (bigIntValue != null
66 && (!DatatypeHelper.safeEquals(getValue(), newValue) || newValue == null)) {
67
68
69 bigIntValue = null;
70 }
71 super.setValue(newValue);
72 }
73
74 }