Source Code Cross Referenced for NoInputCallbackHandler.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » security » auth » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.security.auth.callback 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: Florent Benoit
022:         * --------------------------------------------------------------------------
023:         * $Id: NoInputCallbackHandler.java 4804 2004-05-25 15:13:29Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.security.auth.callback;
026:
027:        import java.io.IOException;
028:        import javax.security.auth.callback.CallbackHandler;
029:        import javax.security.auth.callback.UnsupportedCallbackException;
030:        import javax.security.auth.callback.NameCallback;
031:        import javax.security.auth.callback.PasswordCallback;
032:        import javax.security.auth.callback.Callback;
033:        import java.security.cert.Certificate;
034:
035:        /**
036:         * The username and password are given by the constructor No JNDI, datasource or
037:         * file checks.
038:         * @author Florent Benoit (initial developer)
039:         * @author Alexandre Thaveau (add the use of certificates)
040:         * @author Marc-Antoine Bourgeot (add the use of certificates)
041:         */
042:        public class NoInputCallbackHandler implements  CallbackHandler {
043:
044:            /**
045:             * Username to use
046:             */
047:            private String username = null;
048:
049:            /**
050:             * Password to use
051:             */
052:            private String password = null;
053:
054:            /**
055:             * Certificate to use, optionnal
056:             */
057:            private Certificate cert = null;
058:
059:            /**
060:             * No default Constructor : must use the one with username and password
061:             * @throws Exception if someone try to use it
062:             */
063:            public NoInputCallbackHandler() throws Exception {
064:                throw new Exception(
065:                        "This class could only be used with the constructor NoInputCallbackHandler(String username, String password)");
066:            }
067:
068:            /**
069:             * Constructor
070:             * @param username username to store for the authentication
071:             * @param password password to store for the authentication
072:             */
073:            public NoInputCallbackHandler(String username, String password) {
074:                this .username = username;
075:                this .password = password;
076:            }
077:
078:            /**
079:             * Constructor
080:             * @param username username to store for the authentication
081:             * @param password password to store for the authentication
082:             * @param cert the certificate for the authentication
083:             */
084:            public NoInputCallbackHandler(String username, String password,
085:                    Certificate cert) {
086:                this (username, password);
087:                this .cert = cert;
088:            }
089:
090:            /**
091:             * Invoke an array of Callbacks.
092:             * @param callbacks an array of <code>Callback</code> objects which
093:             *        contain the information requested by an underlying security
094:             *        service to be retrieved or displayed.
095:             * @throws IOException if an input or output error occurs. <p>
096:             * @throws UnsupportedCallbackException if the implementation of this method
097:             *         does not support one or more of the Callbacks specified in the
098:             *         <code>callbacks</code> parameter.
099:             */
100:            public void handle(Callback[] callbacks) throws IOException,
101:                    UnsupportedCallbackException {
102:
103:                for (int i = 0; i < callbacks.length; i++) {
104:                    if (callbacks[i] instanceof  NameCallback) {
105:                        // set the username to the username given in the constructor
106:                        NameCallback nc = (NameCallback) callbacks[i];
107:                        nc.setName(username);
108:                    } else if (callbacks[i] instanceof  PasswordCallback) {
109:                        // set the password to the password given in the constructor
110:                        PasswordCallback pc = (PasswordCallback) callbacks[i];
111:                        pc.setPassword(password.toCharArray());
112:                    } else if (callbacks[i] instanceof  CertificateCallback) {
113:                        CertificateCallback cc = (CertificateCallback) callbacks[i];
114:                        cc.setUserCertificate(cert);
115:                    } else {
116:                        throw new UnsupportedCallbackException(callbacks[i],
117:                                "Unrecognized Callback");
118:                    }
119:                }
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.