Source Code Cross Referenced for SetupCAHandler.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » console » ca » 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 » EJB Server geronimo » plugins » org.apache.geronimo.console.ca 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *
003:         *  Licensed to the Apache Software Foundation (ASF) under one or more
004:         *  contributor license agreements.  See the NOTICE file distributed with
005:         *  this work for additional information regarding copyright ownership.
006:         *  The ASF licenses this file to You under the Apache License, Version 2.0
007:         *  (the "License"); you may not use this file except in compliance with
008:         *  the License.  You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing, software
013:         *  distributed under the License is distributed on an "AS IS" BASIS,
014:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */package org.apache.geronimo.console.ca;
018:
019:        import java.io.IOException;
020:        import java.math.BigInteger;
021:        import java.text.DateFormat;
022:        import java.text.SimpleDateFormat;
023:        import java.util.Calendar;
024:        import java.util.Date;
025:        import java.util.GregorianCalendar;
026:
027:        import javax.portlet.ActionRequest;
028:        import javax.portlet.ActionResponse;
029:        import javax.portlet.PortletException;
030:        import javax.portlet.RenderRequest;
031:        import javax.portlet.RenderResponse;
032:
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:        import org.apache.geronimo.console.MultiPageModel;
036:
037:        /**
038:         * Handler for Setup CA screen to get CA details from user.
039:         *
040:         * @version $Rev: 514091 $ $Date: 2007-03-02 22:26:39 -0800 (Fri, 02 Mar 2007) $
041:         */
042:        public class SetupCAHandler extends BaseCAHandler {
043:            private final static Log log = LogFactory
044:                    .getLog(SetupCAHandler.class);
045:
046:            public SetupCAHandler() {
047:                super (SETUPCA_MODE, "/WEB-INF/view/ca/setupCA.jsp");
048:            }
049:
050:            public String actionBeforeView(ActionRequest request,
051:                    ActionResponse response, MultiPageModel model)
052:                    throws PortletException, IOException {
053:                String[] params = { ERROR_MSG, INFO_MSG, "caCN", "caOU", "caO",
054:                        "caL", "caST", "caC", "alias", "keyAlgorithm",
055:                        "keySize", "algorithm", "validFrom", "validTo", "sNo",
056:                        "password" };
057:                for (int i = 0; i < params.length; ++i) {
058:                    String value = request.getParameter(params[i]);
059:                    if (value != null)
060:                        response.setRenderParameter(params[i], value);
061:                }
062:                return getMode();
063:            }
064:
065:            public void renderView(RenderRequest request,
066:                    RenderResponse response, MultiPageModel model)
067:                    throws PortletException, IOException {
068:                String[] params = { ERROR_MSG, INFO_MSG, "caCN", "caOU", "caO",
069:                        "caL", "caST", "caC", "alias", "keyAlgorithm",
070:                        "keySize", "algorithm", "validFrom", "validTo", "sNo",
071:                        "password" };
072:                for (int i = 0; i < params.length; ++i) {
073:                    Object value = request.getParameter(params[i]);
074:                    if (value != null)
075:                        request.setAttribute(params[i], value);
076:                }
077:            }
078:
079:            public String actionAfterView(ActionRequest request,
080:                    ActionResponse response, MultiPageModel model)
081:                    throws PortletException, IOException {
082:                String errorMsg = null;
083:                try {
084:                    // Validate the Serial Number
085:                    String sNo = request.getParameter("sNo");
086:                    new BigInteger(sNo.trim());
087:
088:                    // Validate the from and to dates
089:                    String validFrom = request.getParameter("validFrom");
090:                    String validTo = request.getParameter("validTo");
091:                    // Check if the from date format is MM/DD/YYYY
092:                    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
093:                    Date validFromDate = df.parse(validFrom);
094:                    Calendar calendar = new GregorianCalendar();
095:                    calendar.setTime(validFromDate);
096:                    String mmddyyyy = (calendar.get(Calendar.MONTH) < 9 ? "0"
097:                            : "")
098:                            + (calendar.get(Calendar.MONTH) + 1);
099:                    mmddyyyy += "/"
100:                            + (calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0"
101:                                    : "")
102:                            + (calendar.get(Calendar.DAY_OF_MONTH));
103:                    mmddyyyy += "/" + calendar.get(Calendar.YEAR);
104:                    if (!mmddyyyy.equals(validFrom)) {
105:                        throw new Exception(
106:                                "validFrom must be a date in MM/DD/YYYY format.");
107:                    }
108:                    // Check if the to date format is MM/DD/YYYY
109:                    Date validToDate = df.parse(validTo);
110:                    calendar.setTime(validToDate);
111:                    mmddyyyy = (calendar.get(Calendar.MONTH) < 9 ? "0" : "")
112:                            + (calendar.get(Calendar.MONTH) + 1);
113:                    mmddyyyy += "/"
114:                            + (calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0"
115:                                    : "")
116:                            + (calendar.get(Calendar.DAY_OF_MONTH));
117:                    mmddyyyy += "/" + calendar.get(Calendar.YEAR);
118:                    if (!mmddyyyy.equals(validTo)) {
119:                        throw new Exception(
120:                                "validTo must be a date in MM/DD/YYYY format.");
121:                    }
122:                    // Check if the from date is before the to date
123:                    if (validFromDate.after(validToDate)) {
124:                        throw new Exception("Validity: From date '" + validFrom
125:                                + "' is before the To date '" + validTo + "'.");
126:                    }
127:
128:                    // Load page to confirm CA details
129:                    return CONFIRM_CA_MODE + BEFORE_ACTION;
130:                } catch (Exception e) {
131:                    errorMsg = e.toString();
132:                    log.error("Error in user input during CA Setup.", e);
133:                }
134:                if (errorMsg != null)
135:                    response.setRenderParameter(ERROR_MSG, errorMsg);
136:                return getMode() + BEFORE_ACTION;
137:            }
138:
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.