Source Code Cross Referenced for CMWAdvGenerateKey.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » ui » ide » security » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.ui.ide.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:
025:        package com.bostechcorp.cbesb.ui.ide.security;
026:
027:        import java.io.File;
028:        import java.util.Date;
029:
030:        import org.eclipse.jface.wizard.IWizardPage;
031:
032:        import org.eclipse.swt.SWT;
033:        import org.eclipse.swt.events.FocusAdapter;
034:        import org.eclipse.swt.events.FocusEvent;
035:        import org.eclipse.swt.events.ModifyEvent;
036:        import org.eclipse.swt.events.ModifyListener;
037:        import org.eclipse.swt.events.SelectionAdapter;
038:        import org.eclipse.swt.events.SelectionEvent;
039:
040:        import org.eclipse.swt.layout.GridData;
041:        import org.eclipse.swt.layout.GridLayout;
042:        import org.eclipse.swt.widgets.Button;
043:        import org.eclipse.swt.widgets.Composite;
044:        import org.eclipse.swt.widgets.Label;
045:
046:        import org.eclipse.swt.widgets.Text;
047:
048:        import com.bostechcorp.cbesb.common.i18n.I18N;
049:        import com.bostechcorp.cbesb.common.i18n.Messages;
050:        import com.bostechcorp.cbesb.ui.util.AuthenticationUtil;
051:
052:        public class CMWAdvGenerateKey extends CMWContextAwarePage {
053:
054:            private Text text_2;
055:            private Text text_1;
056:            private Text text_8;
057:            private Text text_7;
058:            private Text text_6;
059:            private Text text_5;
060:            private Text text_4;
061:            private Text text_3;
062:            private Text text;
063:            private Button generateButton;
064:            private long time;
065:
066:            protected CMWAdvGenerateKey(String pageName) {
067:                super (pageName);
068:                setTitle(I18N.getString(Messages.CMW_ADVANCED_GENERATE_TITLE));
069:                setDescription(I18N
070:                        .getString(Messages.CMW_ADVANCED_GENERATE_DESCRIPTION));
071:
072:            }
073:
074:            public void createControl(Composite parent) {
075:
076:                Composite shell = new Composite(parent, SWT.NONE);
077:                final GridLayout gridLayout = new GridLayout();
078:                gridLayout.marginHeight = 0;
079:                gridLayout.marginWidth = 0;
080:                gridLayout.numColumns = 3;
081:                shell.setLayout(gridLayout);
082:
083:                final Label commonNameLabel = new Label(shell, SWT.NONE);
084:                commonNameLabel.setLayoutData(new GridData(SWT.FILL,
085:                        SWT.CENTER, false, false));
086:                commonNameLabel.setText(I18N
087:                        .getString(Messages.CMW_ADVANCED_GENERATE_LABEL_CN));
088:
089:                text = new Text(shell, SWT.BORDER);
090:                text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
091:                        false, 2, 1));
092:
093:                final Label organizationalUnitLabel = new Label(shell, SWT.NONE);
094:                organizationalUnitLabel.setLayoutData(new GridData(SWT.FILL,
095:                        SWT.CENTER, false, false));
096:                organizationalUnitLabel.setText(I18N
097:                        .getString(Messages.CMW_ADVANCED_GENERATE_LABEL_ON));
098:
099:                text_3 = new Text(shell, SWT.BORDER);
100:                text_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
101:                        false, 2, 1));
102:
103:                final Label organizationLabel = new Label(shell, SWT.NONE);
104:                organizationLabel.setLayoutData(new GridData(SWT.FILL,
105:                        SWT.CENTER, false, false));
106:                organizationLabel.setText(I18N
107:                        .getString(Messages.CMW_ADVANCED_GENERATE_LABEL_O));
108:
109:                text_4 = new Text(shell, SWT.BORDER);
110:                text_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
111:                        false, 2, 1));
112:
113:                final Label localtyLabel = new Label(shell, SWT.NONE);
114:                localtyLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
115:                        false, false));
116:                localtyLabel.setText(I18N
117:                        .getString(Messages.CMW_ADVANCED_GENERATE_LABEL_L));
118:
119:                text_5 = new Text(shell, SWT.BORDER);
120:                text_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
121:                        false, 2, 1));
122:
123:                final Label stateLabel = new Label(shell, SWT.NONE);
124:                stateLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
125:                        false, false));
126:                stateLabel.setText(I18N
127:                        .getString(Messages.CMW_ADVANCED_GENERATE_LABEL_S));
128:
129:                text_6 = new Text(shell, SWT.BORDER);
130:                text_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
131:                        false, 2, 1));
132:
133:                final Label countryLabel = new Label(shell, SWT.NONE);
134:                countryLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
135:                        false, false));
136:                countryLabel.setText(I18N
137:                        .getString(Messages.CMW_ADVANCED_GENERATE_LABEL_C));
138:
139:                text_7 = new Text(shell, SWT.BORDER);
140:                text_7.setTextLimit(2);
141:                final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
142:                        true, false, 2, 1);
143:                gridData.widthHint = 128;
144:                text_7.setLayoutData(gridData);
145:
146:                final Label keyFileLabel = new Label(shell, SWT.NONE);
147:                keyFileLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
148:                        false, false));
149:                keyFileLabel.setText(I18N
150:                        .getString(Messages.CMW_ADVANCED_LABEL_KEYSTORE));
151:
152:                text_8 = new Text(shell, SWT.BORDER);
153:                text_8.addFocusListener(new FocusAdapter() {
154:                    public void focusLost(final FocusEvent e) {
155:                        /*				if(!text_8.getText().endsWith(getFilterKeys()))
156:                         {
157:                         text_8.setText(text_8.getText()+getFilterKeys());
158:                         }
159:                         */
160:                        autoSuggestFileName();
161:                    }
162:                });
163:                text_8.addModifyListener(new ModifyListener() {
164:                    public void modifyText(final ModifyEvent e) {
165:
166:                    }
167:                });
168:                text_8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
169:                        false));
170:                text_8.setText("");
171:
172:                final Button browseButton = new Button(shell, SWT.NONE);
173:                browseButton.addSelectionListener(new SelectionAdapter() {
174:                    public void widgetSelected(final SelectionEvent e) {
175:
176:                        //systemFileBrowse(text_8,getPro_path()+"/src/"+getAuthKeys(),getCurr_pro_name()+"_"+time%1000000+".jks");
177:                        systemFileBrowse(text_8, getPro_path() + "/src/"
178:                                + getAuthKeys(), text_8.getText()
179:                                .substring(
180:                                        text_8.getText().lastIndexOf(
181:                                                "/src/auth/keys/") + 15));
182:                    }
183:                });
184:                browseButton.setText(I18N
185:                        .getString(Messages.CMW_ADVANCED_LABEL_BROWSE));
186:                //
187:                setControl(shell);
188:
189:                final Label label = new Label(shell, SWT.NONE);
190:                label
191:                        .setText(I18N
192:                                .getString(Messages.CMW_ADVANCED_LABEL_PASSWORD_KEY_STORE));
193:
194:                text_1 = new Text(shell, SWT.PASSWORD | SWT.BORDER);
195:                text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
196:                        false, 2, 1));
197:
198:                final Label label_1 = new Label(shell, SWT.NONE);
199:                label_1
200:                        .setText(I18N
201:                                .getString(Messages.CMW_ADVANCED_LABEL_PASSWORD_CONFIRM));
202:
203:                text_2 = new Text(shell, SWT.PASSWORD | SWT.BORDER);
204:                text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
205:                        false, 2, 1));
206:                setPageComplete(true);//by default
207:
208:                // listener
209:
210:                ModifyListener mody = new ModifyListener() {
211:                    public void modifyText(ModifyEvent e) {
212:                        updatePageComplete();
213:                    }
214:                };
215:                text.addModifyListener(mody);
216:                text_1.addModifyListener(mody);//pwd
217:                text_2.addModifyListener(mody);//pwd
218:
219:                text_3.addModifyListener(mody);
220:                text_4.addModifyListener(mody);
221:                text_5.addModifyListener(mody);
222:                text_6.addModifyListener(mody);
223:                text_7.addModifyListener(mody);
224:                text_8.addModifyListener(mody);
225:
226:                final Label label_2 = new Label(shell, SWT.SEPARATOR
227:                        | SWT.HORIZONTAL);
228:                label_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
229:                        false, 3, 1));
230:
231:                generateButton = new Button(shell, SWT.NONE);
232:                generateButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP,
233:                        false, true));
234:                generateButton.addSelectionListener(new SelectionAdapter() {
235:                    public void widgetSelected(final SelectionEvent e) {
236:                        performAction();
237:                    }
238:                });
239:                generateButton
240:                        .setText(I18N
241:                                .getString(Messages.CMW_ADVANCED_LABEL_GENERATE_BUTTON));
242:                new Label(shell, SWT.NONE);
243:                new Label(shell, SWT.NONE);
244:                //
245:                updatePageComplete();
246:                autoSuggestFileName();
247:            }
248:
249:            @Override
250:            public IWizardPage getNextPage() {
251:                CertificateManagerWizard parent = (CertificateManagerWizard) getWizard();
252:                return parent.getNextPage(this );
253:            }
254:
255:            @Override
256:            public IWizardPage getPreviousPage() {
257:                CertificateManagerWizard parent = (CertificateManagerWizard) getWizard();
258:                return parent.getPreviousPage(this );
259:            }
260:
261:            @Override
262:            protected void updatePageComplete() {
263:                setPageComplete(verify());
264:                if (generateButton != null)
265:                    generateButton.setEnabled(verify());
266:            }
267:
268:            private boolean verify() {
269:                if (text == null) {
270:                    return false;
271:                }
272:                //autoSuggestFileName();
273:                if (text.getText().equals("")) {
274:                    showError(I18N
275:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_CN));
276:                    return false;
277:                } else if (text_3.getText().equals("")) {
278:                    showError(I18N
279:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_OU));
280:                    return false;
281:                } else if (text_4.getText().equals("")) {
282:                    showError(I18N
283:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_O));
284:                    return false;
285:                }
286:                /*else if (text_5.getText().equals(""))
287:                {
288:                	showError(I18N.getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_L));
289:                	return false;
290:                }
291:                else if (text_6.getText().equals(""))
292:                {
293:                	showError(I18N.getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_S));
294:                	return false;
295:                }*/
296:                else if (text_7.getText().equals("")) {
297:                    showError(I18N
298:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_C));
299:                    return false;
300:                } else if (text_8.getText().equals("")) {
301:                    autoSuggestFileName();
302:                    return false;
303:                } else if (text_8.getText().replace("\\", "").replace("/", "")
304:                        .indexOf(
305:                                getPro_path().replace("\\", "")
306:                                        .replace("/", "")) != 0) {
307:                    autoSuggestFileName();
308:                    return false;
309:                } else if (text_8.getText().indexOf("/src/auth/keys/") == -1) {
310:                    autoSuggestFileName();
311:                    return false;
312:                } else if (text_8.getText().substring(
313:                        text_8.getText().indexOf("/src/auth/keys/") + 15)
314:                        .indexOf("/") > -1) {
315:                    autoSuggestFileName();
316:                    return false;
317:                } else if (!text_8.getText().endsWith(getFilterKeys())) {
318:                    //text_8.setText(text_8.getText()+getFilterKeys());
319:                    autoSuggestFileName();
320:                    return false;
321:                } else if (text_1.getText().equals("")) {
322:                    showError(I18N
323:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_PASSWORD_MISSING));
324:                    return false;
325:                } else if (text_2.getText().equals("")) {
326:                    showError(I18N
327:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_PASSWORD_CONFIRM_FILL));
328:                    return false;
329:                } else if (!text_1.getText().equals(text_2.getText())) {
330:                    showError(I18N
331:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_PASSWORD_CONFIRM_IDENTICAL));
332:                    return false;
333:                } else if (text_1.getText().length() < 6) {
334:                    showError(I18N
335:                            .getString(Messages.CMW_ADVANCED_MESSAGE_ERROR_PASSWORD_SHORT));
336:                    return false;
337:                }
338:                showClean();
339:                return true;
340:            }
341:
342:            private void autoSuggestFileName() {
343:                time = (new Date()).getTime();
344:                //if (text_8.getText().length())
345:                String fileName = "";
346:                if (text_8.getText().lastIndexOf("/") == -1) {
347:                    fileName = getCurr_pro_name() + "_" + time % 1000000
348:                            + ".jks";
349:                } else {
350:                    if (text_8.getText().indexOf("/src/auth/keys/") != -1) {
351:                        fileName = text_8.getText().substring(
352:                                text_8.getText().indexOf("/src/auth/keys/"));
353:                        fileName = fileName.replace("/src/auth/keys/", "");
354:                        fileName = fileName.replace("/", "");
355:
356:                    } else {
357:                        fileName = text_8.getText().substring(
358:                                text_8.getText().lastIndexOf("/"));
359:                    }
360:                    if (fileName.length() > 15) {
361:                        fileName = fileName.substring(0, 15);
362:                    }
363:                }
364:
365:                if (!fileName.endsWith(getFilterKeys())) {
366:                    if (fileName.indexOf(".") != -1) {
367:                        fileName = fileName.substring(0, fileName.indexOf("."));
368:                    }
369:                    fileName += getFilterKeys();
370:                }
371:
372:                text_8.setText(getPro_path() + "/src/auth/keys/" + fileName);
373:            }
374:
375:            public boolean performFinish() {
376:                //return performAction();
377:                return false;
378:            }
379:
380:            protected boolean performAction() {
381:                String fileName = text_8.getText();
382:                /*if (text.getText().trim().length()<6)
383:                {fileName=(getPro_path()+"/src/auth/keys/"+text.getText().trim()+"_"+time+".jks");
384:                }else
385:                {fileName=(getPro_path()+"/src/auth/keys/"+text.getText().trim().substring(0,6)+"_"+time+".jks");
386:                }*/
387:                File file = new File(fileName);
388:                String dName = "CN=" + text.getText() + ", OU="
389:                        + text_3.getText() + ", O=" + text_4.getText() + ", L="
390:                        + text_5.getText() + ", S=" + text_6.getText() + ", C="
391:                        + text_7.getText();
392:                showWarning(I18N
393:                        .getString(Messages.CMW_ADVANCED_MESSAGE_OPERATION_PRGRESS));
394:                try {
395:                    AuthenticationUtil.generateKey(file, dName, text_2
396:                            .getText());
397:                    showInfo(I18N
398:                            .getString(Messages.CMW_ADVANCED_MESSAGE_OPERATION_SUCCES));
399:                } catch (Exception e) {
400:                    setPageComplete(false);
401:                    showError(I18N
402:                            .getString(Messages.CMW_ADVANCED_MESSAGE_OPERATION_EXCEPTION));
403:                    e.printStackTrace();
404:                    currentExceptionMessage = e.getMessage();
405:                    return true;
406:                }
407:                return true;
408:            }
409:
410:            @Override
411:            public boolean canFinish() {
412:                //if ( getWizard().getNextPage(this)==null && verify()) return true;
413:                return false;
414:            }
415:
416:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.