Source Code Cross Referenced for ReissueResponseGenerator.java in  » Authentication-Authorization » ejbca » org » ejbca » core » protocol » xkms » generators » 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 » Authentication Authorization » ejbca » org.ejbca.core.protocol.xkms.generators 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*************************************************************************
002:         *                                                                       *
003:         *  EJBCA: The OpenSource Certificate Authority                          *
004:         *                                                                       *
005:         *  This software is free software; you can redistribute it and/or       *
006:         *  modify it under the terms of the GNU Lesser General Public           *
007:         *  License as published by the Free Software Foundation; either         *
008:         *  version 2.1 of the License, or any later version.                    *
009:         *                                                                       *
010:         *  See terms of license at gnu.org.                                     *
011:         *                                                                       *
012:         *************************************************************************/package org.ejbca.core.protocol.xkms.generators;
013:
014:        import java.security.cert.X509Certificate;
015:
016:        import org.apache.log4j.Logger;
017:        import org.ejbca.core.model.InternalResources;
018:        import org.ejbca.core.model.ra.UserDataConstants;
019:        import org.ejbca.core.model.ra.UserDataVO;
020:        import org.ejbca.core.protocol.xkms.common.XKMSConstants;
021:        import org.ejbca.util.passgen.IPasswordGenerator;
022:        import org.ejbca.util.passgen.PasswordGeneratorFactory;
023:        import org.w3._2002._03.xkms_.KeyBindingAbstractType;
024:        import org.w3._2002._03.xkms_.KeyBindingType;
025:        import org.w3._2002._03.xkms_.ReissueRequestType;
026:        import org.w3._2002._03.xkms_.ReissueResultType;
027:        import org.w3c.dom.Document;
028:
029:        /**
030:         * Class generating a response for a reissue call
031:         * 
032:         * 
033:         * @author Philip Vendil 
034:         *
035:         * @version $Id: ReissueResponseGenerator.java,v 1.2 2007/01/07 19:44:14 herrvendil Exp $
036:         */
037:
038:        public class ReissueResponseGenerator extends KRSSResponseGenerator {
039:            private static Logger log = Logger
040:                    .getLogger(ReissueResponseGenerator.class);
041:
042:            private static final InternalResources intres = InternalResources
043:                    .getInstance();
044:
045:            public ReissueResponseGenerator(String remoteIP,
046:                    ReissueRequestType req, Document requestDoc) {
047:                super (remoteIP, req, requestDoc);
048:            }
049:
050:            /**
051:             * Returns a reissue response
052:             */
053:            public ReissueResultType getResponse(boolean requestVerifies) {
054:                ReissueResultType result = xkmsFactory
055:                        .createReissueResultType();
056:                super .populateResponse(result, requestVerifies);
057:                ReissueRequestType req = (ReissueRequestType) this .req;
058:
059:                if (resultMajor == null) {
060:                    if (!checkValidRespondWithRequest(req.getRespondWith(),
061:                            false)) {
062:                        resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
063:                        resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED;
064:                    }
065:
066:                    if (resultMajor == null) {
067:                        if (resultMajor == null) {
068:                            X509Certificate cert = (X509Certificate) getPublicKeyInfo(
069:                                    req, false);
070:                            boolean isCertValid = certIsValid(cert);
071:                            if (isCertValid && confirmPOP(cert.getPublicKey())) {
072:                                UserDataVO userData = findUserData(cert);
073:                                if (userData != null) {
074:                                    String password = "";
075:                                    boolean encryptedPassword = isPasswordEncrypted(req);
076:                                    if (isCertValid
077:                                            && XKMSConfig
078:                                                    .isAutomaticReissueAllowed()) {
079:                                        password = setUserStatusToNew(userData);
080:                                    } else {
081:                                        if (encryptedPassword) {
082:                                            password = getEncryptedPassword(
083:                                                    requestDoc, userData
084:                                                            .getPassword());
085:                                        } else {
086:                                            password = getClearPassword(req,
087:                                                    userData.getPassword());
088:                                        }
089:                                    }
090:
091:                                    if (password != null) {
092:                                        X509Certificate newCert = registerReissueOrRecover(
093:                                                false, true, result, userData,
094:                                                password, cert.getPublicKey(),
095:                                                null);
096:                                        if (newCert != null) {
097:                                            KeyBindingAbstractType keyBinding = getResponseValues(
098:                                                    req.getReissueKeyBinding(),
099:                                                    newCert, false, true);
100:                                            result
101:                                                    .getKeyBinding()
102:                                                    .add(
103:                                                            (KeyBindingType) keyBinding);
104:                                        }
105:                                    }
106:                                }
107:                            }
108:                        }
109:                    }
110:                }
111:
112:                if (resultMajor == null) {
113:                    resultMajor = XKMSConstants.RESULTMAJOR_SUCCESS;
114:                }
115:
116:                setResult(result);
117:
118:                return result;
119:            }
120:
121:            /**
122:             * Method that sets the users status to 'new' and a 
123:             * default password
124:             * @param the userdata of the user
125:             * @return the new password or null of operation failed.
126:             */
127:            private String setUserStatusToNew(UserDataVO userdata) {
128:                String retval = null;
129:                try {
130:                    IPasswordGenerator passwordGenerator = PasswordGeneratorFactory
131:                            .getInstance(PasswordGeneratorFactory.PASSWORDTYPE_LETTERSANDDIGITS);
132:                    String password = passwordGenerator.getNewPassword(8, 8);
133:
134:                    userdata.setStatus(UserDataConstants.STATUS_NEW);
135:                    userdata.setPassword(password);
136:
137:                    getUserAdminSession().changeUser(raAdmin, userdata, true);
138:                    retval = password;
139:                } catch (Exception e) {
140:                    log.error(intres.getLocalizedMessage(
141:                            "xkms.errorsettinguserstatus", userdata
142:                                    .getUsername()), e);
143:                }
144:
145:                return retval;
146:            }
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.