1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.wss4j.common.saml.bean;
21
22 import java.security.PublicKey;
23 import java.security.cert.X509Certificate;
24
25 import org.w3c.dom.Element;
26
27
28
29
30
31 public class KeyInfoBean {
32
33 public enum CERT_IDENTIFIER {
34 X509_CERT, X509_ISSUER_SERIAL, KEY_VALUE
35 }
36
37 private X509Certificate cert;
38 private CERT_IDENTIFIER certIdentifier = CERT_IDENTIFIER.X509_CERT;
39 private PublicKey publicKey;
40 private byte[] ephemeralKey;
41 private Element keyInfoElement;
42
43
44
45
46 public KeyInfoBean() {
47 }
48
49
50
51
52
53
54 public X509Certificate getCertificate() {
55 return cert;
56 }
57
58
59
60
61
62
63 public void setCertificate(X509Certificate cert) {
64 this.cert = cert;
65 }
66
67
68
69
70
71
72 public PublicKey getPublicKey() {
73 return publicKey;
74 }
75
76
77
78
79
80
81 public void setPublicKey(PublicKey publicKey) {
82 this.publicKey = publicKey;
83 }
84
85
86
87
88
89
90 public CERT_IDENTIFIER getCertIdentifer() {
91 return certIdentifier;
92 }
93
94
95
96
97
98
99 public void setCertIdentifer(CERT_IDENTIFIER certIdentifier) {
100 this.certIdentifier = certIdentifier;
101 }
102
103 public byte[] getEphemeralKey() {
104 return ephemeralKey;
105 }
106
107 public void setEphemeralKey(byte[] ephemeralKey) {
108 this.ephemeralKey = ephemeralKey;
109 }
110
111
112
113
114
115
116 public Element getElement() {
117 return keyInfoElement;
118 }
119
120
121
122
123
124
125 public void setElement(Element keyInfoElement) {
126 this.keyInfoElement = keyInfoElement;
127 }
128
129
130
131
132
133
134
135 @Override
136 public boolean equals(Object o) {
137 if (this == o) {
138 return true;
139 }
140 if (!(o instanceof KeyInfoBean)) {
141 return false;
142 }
143
144 KeyInfoBean that = (KeyInfoBean) o;
145
146 if (certIdentifier != that.certIdentifier) {
147 return false;
148 }
149 if (cert == null && that.cert != null) {
150 return false;
151 } else if (cert != null && !cert.equals(that.cert)) {
152 return false;
153 }
154
155 if (publicKey == null && that.publicKey != null) {
156 return false;
157 } else if (publicKey != null && !publicKey.equals(that.publicKey)) {
158 return false;
159 }
160
161 if (keyInfoElement == null && that.keyInfoElement != null) {
162 return false;
163 } else if (keyInfoElement != null && !keyInfoElement.equals(that.keyInfoElement)) {
164 return false;
165 }
166
167 return true;
168 }
169
170
171
172
173 @Override
174 public int hashCode() {
175 int result = certIdentifier.hashCode();
176 if (cert != null) {
177 result = 31 * result + cert.hashCode();
178 }
179 if (publicKey != null) {
180 result = 31 * result + publicKey.hashCode();
181 }
182 if (keyInfoElement != null) {
183 result = 31 * result + keyInfoElement.hashCode();
184 }
185 return result;
186 }
187 }