Source Code Cross Referenced for CryptographyCallbackHandler.java in  » Web-Services » spring-ws-1.0.0 » org » springframework » ws » soap » security » xwss » callback » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » spring ws 1.0.0 » org.springframework.ws.soap.security.xwss.callback 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.ws.soap.security.xwss.callback;
018:
019:        import java.io.IOException;
020:
021:        import javax.security.auth.callback.Callback;
022:        import javax.security.auth.callback.UnsupportedCallbackException;
023:
024:        import com.sun.xml.wss.impl.callback.CertificateValidationCallback;
025:        import com.sun.xml.wss.impl.callback.DecryptionKeyCallback;
026:        import com.sun.xml.wss.impl.callback.EncryptionKeyCallback;
027:        import com.sun.xml.wss.impl.callback.SignatureKeyCallback;
028:        import com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback;
029:
030:        /**
031:         * Default callback handler that handles cryptographic callback. This handler determines the exact callback passed, and
032:         * calls a template method for it. By default, all template methods throw an <code>UnsupportedCallbackException</code>,
033:         * so you only need to override those you need.
034:         *
035:         * @author Arjen Poutsma
036:         */
037:        public class CryptographyCallbackHandler extends
038:                AbstractCallbackHandler {
039:
040:            protected final void handleInternal(Callback callback)
041:                    throws IOException, UnsupportedCallbackException {
042:                if (callback instanceof  CertificateValidationCallback) {
043:                    handleCertificateValidationCallback((CertificateValidationCallback) callback);
044:                } else if (callback instanceof  DecryptionKeyCallback) {
045:                    handleDecryptionKeyCallback((DecryptionKeyCallback) callback);
046:                } else if (callback instanceof  EncryptionKeyCallback) {
047:                    handleEncryptionKeyCallback((EncryptionKeyCallback) callback);
048:                } else if (callback instanceof  SignatureKeyCallback) {
049:                    handleSignatureKeyCallback((SignatureKeyCallback) callback);
050:                } else if (callback instanceof  SignatureVerificationKeyCallback) {
051:                    handleSignatureVerificationKeyCallback((SignatureVerificationKeyCallback) callback);
052:                } else {
053:                    throw new UnsupportedCallbackException(callback);
054:                }
055:
056:            }
057:
058:            //
059:            // Certificate validation
060:            //
061:
062:            /**
063:             * Template method that handles <code>CertificateValidationCallback</code>s. Called from
064:             * <code>handleInternal()</code>. Default implementation throws an <code>UnsupportedCallbackException</code>.
065:             */
066:            protected void handleCertificateValidationCallback(
067:                    CertificateValidationCallback callback) throws IOException,
068:                    UnsupportedCallbackException {
069:                throw new UnsupportedCallbackException(callback);
070:            }
071:
072:            //
073:            // Decryption
074:            //
075:
076:            /**
077:             * Method that handles <code>DecryptionKeyCallback</code>s. Called from <code>handleInternal()</code>. Default
078:             * implementation delegates to specific handling methods.
079:             *
080:             * @see #handlePrivateKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback,
081:             *      com.sun.xml.wss.impl.callback.DecryptionKeyCallback.PrivateKeyRequest)
082:             * @see #handleSymmetricKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback,
083:             *      com.sun.xml.wss.impl.callback.DecryptionKeyCallback.SymmetricKeyRequest)
084:             */
085:            protected final void handleDecryptionKeyCallback(
086:                    DecryptionKeyCallback callback) throws IOException,
087:                    UnsupportedCallbackException {
088:                if (callback.getRequest() instanceof  DecryptionKeyCallback.PrivateKeyRequest) {
089:                    handlePrivateKeyRequest(callback,
090:                            (DecryptionKeyCallback.PrivateKeyRequest) callback
091:                                    .getRequest());
092:                } else if (callback.getRequest() instanceof  DecryptionKeyCallback.SymmetricKeyRequest) {
093:                    handleSymmetricKeyRequest(
094:                            callback,
095:                            (DecryptionKeyCallback.SymmetricKeyRequest) callback
096:                                    .getRequest());
097:                } else {
098:                    throw new UnsupportedCallbackException(callback);
099:                }
100:            }
101:
102:            /**
103:             * Method that handles <code>DecryptionKeyCallback</code>s with <code>PrivateKeyRequest</code> . Called from
104:             * <code>handleDecryptionKeyCallback()</code>. Default implementation delegates to specific handling methods.
105:             *
106:             * @see #handlePublicKeyBasedPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback,
107:             *      com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest)
108:             * @see #handleX509CertificateBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback,
109:             *      com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509CertificateBasedRequest)
110:             * @see #handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback,
111:             *      com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509IssuerSerialBasedRequest)
112:             * @see #handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback,
113:             *      com.sun.xml.wss.impl.callback.DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest)
114:             */
115:            protected final void handlePrivateKeyRequest(
116:                    DecryptionKeyCallback callback,
117:                    DecryptionKeyCallback.PrivateKeyRequest request)
118:                    throws IOException, UnsupportedCallbackException {
119:                if (request instanceof  DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest) {
120:                    handlePublicKeyBasedPrivKeyRequest(
121:                            callback,
122:                            (DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest) request);
123:                } else if (request instanceof  DecryptionKeyCallback.X509CertificateBasedRequest) {
124:                    handleX509CertificateBasedRequest(
125:                            callback,
126:                            (DecryptionKeyCallback.X509CertificateBasedRequest) request);
127:                } else if (request instanceof  DecryptionKeyCallback.X509IssuerSerialBasedRequest) {
128:                    handleX509IssuerSerialBasedRequest(
129:                            callback,
130:                            (DecryptionKeyCallback.X509IssuerSerialBasedRequest) request);
131:                } else if (request instanceof  DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) {
132:                    handleX509SubjectKeyIdentifierBasedRequest(
133:                            callback,
134:                            (DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest) request);
135:                } else {
136:                    throw new UnsupportedCallbackException(callback);
137:                }
138:            }
139:
140:            /**
141:             * Template method that handles <code>DecryptionKeyCallback</code>s with <code>PublicKeyBasedPrivKeyRequest</code>s.
142:             * Called from <code>handlePrivateKeyRequest()</code>. Default implementation throws an
143:             * <code>UnsupportedCallbackException</code>.
144:             */
145:            protected void handlePublicKeyBasedPrivKeyRequest(
146:                    DecryptionKeyCallback callback,
147:                    DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request)
148:                    throws IOException, UnsupportedCallbackException {
149:                throw new UnsupportedCallbackException(callback);
150:            }
151:
152:            /**
153:             * Template method that handles <code>DecryptionKeyCallback</code>s with <code>X509CertificateBasedRequest</code>s.
154:             * Called from <code>handlePrivateKeyRequest()</code>. Default implementation throws an
155:             * <code>UnsupportedCallbackException</code>.
156:             */
157:            protected void handleX509CertificateBasedRequest(
158:                    DecryptionKeyCallback callback,
159:                    DecryptionKeyCallback.X509CertificateBasedRequest request)
160:                    throws IOException, UnsupportedCallbackException {
161:                throw new UnsupportedCallbackException(callback);
162:            }
163:
164:            /**
165:             * Template method that handles <code>DecryptionKeyCallback</code>s with <code>X509IssuerSerialBasedRequest</code>s.
166:             * Called from <code>handlePrivateKeyRequest()</code>. Default implementation throws an
167:             * <code>UnsupportedCallbackException</code>.
168:             */
169:            protected void handleX509IssuerSerialBasedRequest(
170:                    DecryptionKeyCallback callback,
171:                    DecryptionKeyCallback.X509IssuerSerialBasedRequest request)
172:                    throws IOException, UnsupportedCallbackException {
173:                throw new UnsupportedCallbackException(callback);
174:            }
175:
176:            /**
177:             * Template method that handles <code>DecryptionKeyCallback</code>s with <code>X509SubjectKeyIdentifierBasedRequest</code>s.
178:             * Called from <code>handlePrivateKeyRequest()</code>. Default implementation throws an
179:             * <code>UnsupportedCallbackException</code>.
180:             */
181:            protected void handleX509SubjectKeyIdentifierBasedRequest(
182:                    DecryptionKeyCallback callback,
183:                    DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request)
184:                    throws IOException, UnsupportedCallbackException {
185:                throw new UnsupportedCallbackException(callback);
186:            }
187:
188:            /**
189:             * Method that handles <code>DecryptionKeyCallback</code>s with <code>SymmetricKeyRequest</code> . Called from
190:             * <code>handleDecryptionKeyCallback()</code>. Default implementation delegates to specific handling methods.
191:             *
192:             * @see #handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.DecryptionKeyCallback,
193:             *      com.sun.xml.wss.impl.callback.DecryptionKeyCallback.AliasSymmetricKeyRequest)
194:             */
195:            protected final void handleSymmetricKeyRequest(
196:                    DecryptionKeyCallback callback,
197:                    DecryptionKeyCallback.SymmetricKeyRequest request)
198:                    throws IOException, UnsupportedCallbackException {
199:                if (request instanceof  DecryptionKeyCallback.AliasSymmetricKeyRequest) {
200:                    DecryptionKeyCallback.AliasSymmetricKeyRequest aliasSymmetricKeyRequest = (DecryptionKeyCallback.AliasSymmetricKeyRequest) request;
201:                    handleAliasSymmetricKeyRequest(callback,
202:                            aliasSymmetricKeyRequest);
203:                } else {
204:                    throw new UnsupportedCallbackException(callback);
205:                }
206:            }
207:
208:            /**
209:             * Template method that handles <code>DecryptionKeyCallback</code>s with <code>AliasSymmetricKeyRequest</code>s.
210:             * Called from <code>handleSymmetricKeyRequest()</code>. Default implementation throws an
211:             * <code>UnsupportedCallbackException</code>.
212:             */
213:            protected void handleAliasSymmetricKeyRequest(
214:                    DecryptionKeyCallback callback,
215:                    DecryptionKeyCallback.AliasSymmetricKeyRequest request)
216:                    throws IOException, UnsupportedCallbackException {
217:                throw new UnsupportedCallbackException(callback);
218:            }
219:
220:            //
221:            // Encryption
222:            //
223:
224:            /**
225:             * Method that handles <code>EncryptionKeyCallback</code>s. Called from <code>handleInternal()</code>. Default
226:             * implementation delegates to specific handling methods.
227:             *
228:             * @see #handleSymmetricKeyRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback,
229:             *      com.sun.xml.wss.impl.callback.EncryptionKeyCallback.SymmetricKeyRequest)
230:             * @see #handleX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback,
231:             *      com.sun.xml.wss.impl.callback.EncryptionKeyCallback.X509CertificateRequest)
232:             */
233:            protected final void handleEncryptionKeyCallback(
234:                    EncryptionKeyCallback callback) throws IOException,
235:                    UnsupportedCallbackException {
236:                if (callback.getRequest() instanceof  EncryptionKeyCallback.SymmetricKeyRequest) {
237:                    handleSymmetricKeyRequest(
238:                            callback,
239:                            (EncryptionKeyCallback.SymmetricKeyRequest) callback
240:                                    .getRequest());
241:                } else if (callback.getRequest() instanceof  EncryptionKeyCallback.X509CertificateRequest) {
242:                    handleX509CertificateRequest(
243:                            callback,
244:                            (EncryptionKeyCallback.X509CertificateRequest) callback
245:                                    .getRequest());
246:                } else {
247:                    throw new UnsupportedCallbackException(callback);
248:
249:                }
250:            }
251:
252:            /**
253:             * Method that handles <code>EncryptionKeyCallback</code>s with <code>SymmetricKeyRequest</code> . Called from
254:             * <code>handleEncryptionKeyCallback()</code>. Default implementation delegates to specific handling methods.
255:             *
256:             * @see #handleAliasSymmetricKeyRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback,
257:             *      com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasSymmetricKeyRequest)
258:             */
259:            protected final void handleSymmetricKeyRequest(
260:                    EncryptionKeyCallback callback,
261:                    EncryptionKeyCallback.SymmetricKeyRequest request)
262:                    throws IOException, UnsupportedCallbackException {
263:                if (request instanceof  EncryptionKeyCallback.AliasSymmetricKeyRequest) {
264:                    handleAliasSymmetricKeyRequest(
265:                            callback,
266:                            (EncryptionKeyCallback.AliasSymmetricKeyRequest) request);
267:                }
268:            }
269:
270:            /**
271:             * Template method that handles <code>EncryptionKeyCallback</code>s with <code>AliasSymmetricKeyRequest</code>s.
272:             * Called from <code>handleSymmetricKeyRequest()</code>. Default implementation throws an
273:             * <code>UnsupportedCallbackException</code>.
274:             */
275:            protected void handleAliasSymmetricKeyRequest(
276:                    EncryptionKeyCallback callback,
277:                    EncryptionKeyCallback.AliasSymmetricKeyRequest request)
278:                    throws IOException, UnsupportedCallbackException {
279:                throw new UnsupportedCallbackException(callback);
280:            }
281:
282:            /**
283:             * Method that handles <code>EncryptionKeyCallback</code>s with <code>X509CertificateRequest</code> . Called from
284:             * <code>handleEncryptionKeyCallback()</code>. Default implementation delegates to specific handling methods.
285:             *
286:             * @see #handleAliasX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback,
287:             *      com.sun.xml.wss.impl.callback.EncryptionKeyCallback.AliasX509CertificateRequest)
288:             * @see #handleDefaultX509CertificateRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback,
289:             *      com.sun.xml.wss.impl.callback.EncryptionKeyCallback.DefaultX509CertificateRequest)
290:             * @see #handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.EncryptionKeyCallback,
291:             *      com.sun.xml.wss.impl.callback.EncryptionKeyCallback.PublicKeyBasedRequest)
292:             */
293:            protected final void handleX509CertificateRequest(
294:                    EncryptionKeyCallback callback,
295:                    EncryptionKeyCallback.X509CertificateRequest request)
296:                    throws IOException, UnsupportedCallbackException {
297:                if (request instanceof  EncryptionKeyCallback.AliasX509CertificateRequest) {
298:                    handleAliasX509CertificateRequest(
299:                            callback,
300:                            (EncryptionKeyCallback.AliasX509CertificateRequest) request);
301:                } else if (request instanceof  EncryptionKeyCallback.DefaultX509CertificateRequest) {
302:                    handleDefaultX509CertificateRequest(
303:                            callback,
304:                            (EncryptionKeyCallback.DefaultX509CertificateRequest) request);
305:                } else if (request instanceof  EncryptionKeyCallback.PublicKeyBasedRequest) {
306:                    handlePublicKeyBasedRequest(
307:                            callback,
308:                            (EncryptionKeyCallback.PublicKeyBasedRequest) request);
309:                } else {
310:                    throw new UnsupportedCallbackException(callback);
311:                }
312:            }
313:
314:            /**
315:             * Template method that handles <code>EncryptionKeyCallback</code>s with <code>AliasX509CertificateRequest</code>s.
316:             * Called from <code>handleX509CertificateRequest()</code>. Default implementation throws an
317:             * <code>UnsupportedCallbackException</code>.
318:             */
319:            protected void handleAliasX509CertificateRequest(
320:                    EncryptionKeyCallback callback,
321:                    EncryptionKeyCallback.AliasX509CertificateRequest request)
322:                    throws IOException, UnsupportedCallbackException {
323:                throw new UnsupportedCallbackException(callback);
324:            }
325:
326:            /**
327:             * Template method that handles <code>EncryptionKeyCallback</code>s with <code>DefaultX509CertificateRequest</code>s.
328:             * Called from <code>handleX509CertificateRequest()</code>. Default implementation throws an
329:             * <code>UnsupportedCallbackException</code>.
330:             */
331:            protected void handleDefaultX509CertificateRequest(
332:                    EncryptionKeyCallback callback,
333:                    EncryptionKeyCallback.DefaultX509CertificateRequest request)
334:                    throws IOException, UnsupportedCallbackException {
335:                throw new UnsupportedCallbackException(callback);
336:            }
337:
338:            /**
339:             * Template method that handles <code>EncryptionKeyCallback</code>s with <code>PublicKeyBasedRequest</code>s. Called
340:             * from <code>handleX509CertificateRequest()</code>. Default implementation throws an
341:             * <code>UnsupportedCallbackException</code>.
342:             */
343:            protected void handlePublicKeyBasedRequest(
344:                    EncryptionKeyCallback callback,
345:                    EncryptionKeyCallback.PublicKeyBasedRequest request)
346:                    throws IOException, UnsupportedCallbackException {
347:                throw new UnsupportedCallbackException(callback);
348:            }
349:
350:            //
351:            // Signing
352:            //
353:
354:            /**
355:             * Method that handles <code>SignatureKeyCallback</code>s. Called from <code>handleInternal()</code>. Default
356:             * implementation delegates to specific handling methods.
357:             *
358:             * @see #handlePrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback,
359:             *      com.sun.xml.wss.impl.callback.SignatureKeyCallback.PrivKeyCertRequest)
360:             */
361:            protected final void handleSignatureKeyCallback(
362:                    SignatureKeyCallback callback) throws IOException,
363:                    UnsupportedCallbackException {
364:                if (callback.getRequest() instanceof  SignatureKeyCallback.PrivKeyCertRequest) {
365:                    handlePrivKeyCertRequest(callback,
366:                            (SignatureKeyCallback.PrivKeyCertRequest) callback
367:                                    .getRequest());
368:                } else {
369:                    throw new UnsupportedCallbackException(callback);
370:                }
371:            }
372:
373:            /**
374:             * Method that handles <code>SignatureKeyCallback</code>s with <code>PrivKeyCertRequest</code>s. Called from
375:             * <code>handleSignatureKeyCallback()</code>. Default implementation delegates to specific handling methods.
376:             *
377:             * @see #handleDefaultPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback,
378:             *      com.sun.xml.wss.impl.callback.SignatureKeyCallback.DefaultPrivKeyCertRequest)
379:             * @see #handleAliasPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback,
380:             *      com.sun.xml.wss.impl.callback.SignatureKeyCallback.AliasPrivKeyCertRequest)
381:             * @see #handlePublicKeyBasedPrivKeyCertRequest(com.sun.xml.wss.impl.callback.SignatureKeyCallback,
382:             *      com.sun.xml.wss.impl.callback.SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest)
383:             */
384:            protected final void handlePrivKeyCertRequest(
385:                    SignatureKeyCallback cb,
386:                    SignatureKeyCallback.PrivKeyCertRequest request)
387:                    throws IOException, UnsupportedCallbackException {
388:                if (request instanceof  SignatureKeyCallback.DefaultPrivKeyCertRequest) {
389:                    handleDefaultPrivKeyCertRequest(
390:                            cb,
391:                            (SignatureKeyCallback.DefaultPrivKeyCertRequest) request);
392:                } else if (cb.getRequest() instanceof  SignatureKeyCallback.AliasPrivKeyCertRequest) {
393:                    handleAliasPrivKeyCertRequest(
394:                            cb,
395:                            (SignatureKeyCallback.AliasPrivKeyCertRequest) request);
396:                } else if (cb.getRequest() instanceof  SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) {
397:                    handlePublicKeyBasedPrivKeyCertRequest(
398:                            cb,
399:                            (SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest) request);
400:                } else {
401:                    throw new UnsupportedCallbackException(cb);
402:                }
403:            }
404:
405:            /**
406:             * Template method that handles <code>SignatureKeyCallback</code>s with <code>DefaultPrivKeyCertRequest</code>s.
407:             * Called from <code>handlePrivKeyCertRequest()</code>. Default implementation throws an
408:             * <code>UnsupportedCallbackException</code>.
409:             */
410:            protected void handleDefaultPrivKeyCertRequest(
411:                    SignatureKeyCallback callback,
412:                    SignatureKeyCallback.DefaultPrivKeyCertRequest request)
413:                    throws IOException, UnsupportedCallbackException {
414:                throw new UnsupportedCallbackException(callback);
415:            }
416:
417:            /**
418:             * Template method that handles <code>SignatureKeyCallback</code>s with <code>AliasPrivKeyCertRequest</code>s.
419:             * Called from <code>handlePrivKeyCertRequest()</code>. Default implementation throws an
420:             * <code>UnsupportedCallbackException</code>.
421:             */
422:            protected void handleAliasPrivKeyCertRequest(
423:                    SignatureKeyCallback callback,
424:                    SignatureKeyCallback.AliasPrivKeyCertRequest request)
425:                    throws IOException, UnsupportedCallbackException {
426:                throw new UnsupportedCallbackException(callback);
427:            }
428:
429:            /**
430:             * Template method that handles <code>SignatureKeyCallback</code>s with <code>PublicKeyBasedPrivKeyCertRequest</code>s.
431:             * Called from <code>handlePrivKeyCertRequest()</code>. Default implementation throws an
432:             * <code>UnsupportedCallbackException</code>.
433:             */
434:            protected void handlePublicKeyBasedPrivKeyCertRequest(
435:                    SignatureKeyCallback callback,
436:                    SignatureKeyCallback.PublicKeyBasedPrivKeyCertRequest request)
437:                    throws IOException, UnsupportedCallbackException {
438:                throw new UnsupportedCallbackException(callback);
439:            }
440:
441:            //
442:            // Signature verification
443:            //
444:
445:            /**
446:             * Method that handles <code>SignatureVerificationKeyCallback</code>s. Called from <code>handleInternal()</code>.
447:             * Default implementation delegates to specific handling methods.
448:             *
449:             * @see #handleX509CertificateRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback,
450:             *      com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509CertificateRequest)
451:             */
452:            protected final void handleSignatureVerificationKeyCallback(
453:                    SignatureVerificationKeyCallback callback)
454:                    throws UnsupportedCallbackException, IOException {
455:                if (callback.getRequest() instanceof  SignatureVerificationKeyCallback.X509CertificateRequest) {
456:                    handleX509CertificateRequest(
457:                            callback,
458:                            (SignatureVerificationKeyCallback.X509CertificateRequest) callback
459:                                    .getRequest());
460:                } else {
461:                    throw new UnsupportedCallbackException(callback);
462:                }
463:            }
464:
465:            /**
466:             * Method that handles <code>SignatureVerificationKeyCallback</code>s with <code>X509CertificateRequest</code>s.
467:             * Called from <code>handleSignatureVerificationKeyCallback()</code>. Default implementation delegates to specific
468:             * handling methods.
469:             *
470:             * @see #handlePublicKeyBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback,
471:             *      com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.PublicKeyBasedRequest)
472:             * @see #handleX509IssuerSerialBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback,
473:             *      com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest)
474:             * @see #handleX509SubjectKeyIdentifierBasedRequest(com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback,
475:             *      com.sun.xml.wss.impl.callback.SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest)
476:             */
477:            protected final void handleX509CertificateRequest(
478:                    SignatureVerificationKeyCallback callback,
479:                    SignatureVerificationKeyCallback.X509CertificateRequest request)
480:                    throws UnsupportedCallbackException, IOException {
481:                if (request instanceof  SignatureVerificationKeyCallback.PublicKeyBasedRequest) {
482:                    handlePublicKeyBasedRequest(
483:                            callback,
484:                            (SignatureVerificationKeyCallback.PublicKeyBasedRequest) request);
485:                } else if (request instanceof  SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) {
486:                    handleX509IssuerSerialBasedRequest(
487:                            callback,
488:                            (SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest) request);
489:                } else if (request instanceof  SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) {
490:                    handleX509SubjectKeyIdentifierBasedRequest(
491:                            callback,
492:                            (SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest) request);
493:                } else {
494:                    throw new UnsupportedCallbackException(callback);
495:                }
496:            }
497:
498:            /**
499:             * Template method that handles <code>SignatureKeyCallback</code>s with <code>PublicKeyBasedPrivKeyCertRequest</code>s.
500:             * Called from <code>handlePrivKeyCertRequest()</code>. Default implementation throws an
501:             * <code>UnsupportedCallbackException</code>.
502:             */
503:            protected void handleX509SubjectKeyIdentifierBasedRequest(
504:                    SignatureVerificationKeyCallback callback,
505:                    SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request)
506:                    throws IOException, UnsupportedCallbackException {
507:                throw new UnsupportedCallbackException(callback);
508:            }
509:
510:            /**
511:             * Template method that handles <code>SignatureKeyCallback</code>s with <code>X509IssuerSerialBasedRequest</code>s.
512:             * Called from <code>handlePrivKeyCertRequest()</code>. Default implementation throws an
513:             * <code>UnsupportedCallbackException</code>.
514:             */
515:            protected void handleX509IssuerSerialBasedRequest(
516:                    SignatureVerificationKeyCallback callback,
517:                    SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request)
518:                    throws IOException, UnsupportedCallbackException {
519:                throw new UnsupportedCallbackException(callback);
520:            }
521:
522:            /**
523:             * Template method that handles <code>SignatureKeyCallback</code>s with <code>PublicKeyBasedRequest</code>s. Called
524:             * from <code>handlePrivKeyCertRequest()</code>. Default implementation throws an
525:             * <code>UnsupportedCallbackException</code>.
526:             */
527:            protected void handlePublicKeyBasedRequest(
528:                    SignatureVerificationKeyCallback callback,
529:                    SignatureVerificationKeyCallback.PublicKeyBasedRequest request)
530:                    throws IOException, UnsupportedCallbackException {
531:                throw new UnsupportedCallbackException(callback);
532:            }
533:        }
w_w_w.j__av___a___2___s_._co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.