1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.ws.security.validate;
21
22 import java.security.Principal;
23 import java.security.PublicKey;
24 import java.security.cert.X509Certificate;
25 import javax.security.auth.Subject;
26
27 import org.apache.ws.security.message.token.BinarySecurity;
28 import org.apache.ws.security.message.token.SecurityContextToken;
29 import org.apache.ws.security.message.token.Timestamp;
30 import org.apache.ws.security.message.token.UsernameToken;
31 import org.apache.ws.security.saml.ext.AssertionWrapper;
32
33 /**
34 * This class stores various Credential types that can be validated and/or returned by a
35 * Validator implementation. It also stores an optional Principal object which can provide
36 * context information to the validators.
37 */
38 public class Credential {
39
40 private PublicKey publicKey;
41 private X509Certificate[] certs;
42 private Timestamp timestamp;
43 private UsernameToken usernametoken;
44 private BinarySecurity binarySecurityToken;
45 private AssertionWrapper assertion;
46 private AssertionWrapper transformedToken;
47 private SecurityContextToken securityContextToken;
48 private Principal principal;
49 private byte[] secretKey;
50 private Subject subject;
51
52 /**
53 * Set a SecurityContextToken to be validated
54 * @param securityContextToken a SecurityContextToken to be validated
55 */
56 public void setSecurityContextToken(SecurityContextToken securityContextToken) {
57 this.securityContextToken = securityContextToken;
58 }
59
60 /**
61 * Get a SecurityContextToken to be validated
62 * @return a SecurityContextToken to be validated
63 */
64 public SecurityContextToken getSecurityContextToken() {
65 return securityContextToken;
66 }
67
68 /**
69 * Set a SecretKey (byte[]) to be validated
70 * @param secretKey a SecretKey (byte) to be validated
71 */
72 public void setSecretKey(byte[] secretKey) {
73 this.secretKey = secretKey;
74 }
75
76 /**
77 * Get a SecretKey (byte[]) to be validated
78 * @return a SecretKey (byte[]) to be validated
79 */
80 public byte[] getSecretKey() {
81 return secretKey;
82 }
83
84
85 /**
86 * Set a PublicKey to be validated
87 * @param publicKey a PublicKey to be validated
88 */
89 public void setPublicKey(PublicKey publicKey) {
90 this.publicKey = publicKey;
91 }
92
93 /**
94 * Get a PublicKey to be validated
95 * @return a PublicKey to be validated
96 */
97 public PublicKey getPublicKey() {
98 return publicKey;
99 }
100
101 /**
102 * Set an X509Certificate chain to be validated
103 * @param certs an X509Certificate chain to be validated
104 */
105 public void setCertificates(X509Certificate[] certs) {
106 this.certs = certs;
107 }
108
109 /**
110 * Get an X509Certificate chain to be validated
111 * @return an X509Certificate chain to be validated
112 */
113 public X509Certificate[] getCertificates() {
114 return certs;
115 }
116
117 /**
118 * Set a Timestamp to be validated
119 * @param timestamp a Timestamp to be validated
120 */
121 public void setTimestamp(Timestamp timestamp) {
122 this.timestamp = timestamp;
123 }
124
125 /**
126 * Get a Timestamp to be validated
127 * @return a Timestamp to be validated
128 */
129 public Timestamp getTimestamp() {
130 return timestamp;
131 }
132
133 /**
134 * Set a UsernameToken to be validated
135 * @param usernametoken a UsernameToken to be validated
136 */
137 public void setUsernametoken(UsernameToken usernametoken) {
138 this.usernametoken = usernametoken;
139 }
140
141 /**
142 * Get a UsernameToken to be validated
143 * @return a UsernameToken to be validated
144 */
145 public UsernameToken getUsernametoken() {
146 return usernametoken;
147 }
148
149 /**
150 * Set the BinarySecurityToken to be validated
151 * @param binarySecurityToken the BinarySecurityToken to be validated
152 */
153 public void setBinarySecurityToken(BinarySecurity binarySecurityToken) {
154 this.binarySecurityToken = binarySecurityToken;
155 }
156
157 /**
158 * Get the BinarySecurityToken to be validated
159 * @return the BinarySecurityToken to be validated
160 */
161 public BinarySecurity getBinarySecurityToken() {
162 return binarySecurityToken;
163 }
164
165 /**
166 * Set an AssertionWrapper to be validated
167 * @param assertion an AssertionWrapper to be validated
168 */
169 public void setAssertion(AssertionWrapper assertion) {
170 this.assertion = assertion;
171 }
172
173 /**
174 * Get an AssertionWrapper to be validated
175 * @return an AssertionWrapper to be validated
176 */
177 public AssertionWrapper getAssertion() {
178 return assertion;
179 }
180
181 /**
182 * Set an AssertionWrapper instance which corresponds to a Transformed Token.
183 * @param transformedToken a transformed AssertionWrapper instance
184 */
185 public void setTransformedToken(AssertionWrapper transformedToken) {
186 this.transformedToken = transformedToken;
187 }
188
189 /**
190 * Get an AssertionWrapper instance which corresponds to a Transformed Token.
191 * @return a transformed AssertionWrapper instance
192 */
193 public AssertionWrapper getTransformedToken() {
194 return transformedToken;
195 }
196
197 /**
198 * Set the principal that supplies context information to the validators.
199 * @param principal the principal that supplies context information to the validators
200 */
201 public void setPrincipal(Principal principal) {
202 this.principal = principal;
203 }
204
205 /**
206 * Get the principal
207 * @return the principal
208 */
209 public Principal getPrincipal() {
210 return principal;
211 }
212
213 /**
214 * Set the subject that may result from the Validation process
215 * @param subject the subject that may result from the Validation process
216 */
217 public void setSubject(Subject subject) {
218 this.subject = subject;
219 }
220
221 /**
222 * Get the subject that may result from the Validation process
223 * @return the subject that may result from the Validation process
224 */
225 public Subject getSubject() {
226 return subject;
227 }
228
229 }