Source Code Cross Referenced for CMWContextAwarePage.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.Iterator;
029:
030:        import org.eclipse.core.resources.IFile;
031:        import org.eclipse.core.resources.IFolder;
032:        import org.eclipse.core.resources.IProject;
033:        import org.eclipse.core.resources.ResourcesPlugin;
034:        import org.eclipse.core.runtime.IPath;
035:        import org.eclipse.core.runtime.Path;
036:        import org.eclipse.jface.resource.ImageDescriptor;
037:        import org.eclipse.jface.viewers.IStructuredSelection;
038:        import org.eclipse.jface.wizard.WizardPage;
039:        import org.eclipse.swt.SWT;
040:        import org.eclipse.swt.widgets.FileDialog;
041:        import org.eclipse.swt.widgets.Text;
042:
043:        import com.bostechcorp.cbesb.common.i18n.I18N;
044:        import com.bostechcorp.cbesb.common.i18n.Messages;
045:        import com.bostechcorp.cbesb.ui.ide.Activator;
046:        import com.bostechcorp.cbesb.ui.util.AuthenticationUtil;
047:        import com.bostechcorp.cbesb.ui.util.browser.BaseFileBrowser;
048:
049:        public abstract class CMWContextAwarePage extends WizardPage {
050:            //
051:            private IPath initialSourcePath;
052:            private static String separator = "/";
053:            private static String curr_pro_name = "";
054:            private static String pro_path = "";
055:            private static String authCerts = "auth/certs";
056:            private static String authKeys = "auth/keys";
057:            private static String filterKeys = ".jks";
058:            private static String filterCerts = ".jks";
059:            private static String lastSystemLocation = null;
060:
061:            //
062:            /** 
063:             * indicate wether to skip immediate next page
064:             * */
065:            public boolean skip = false;
066:            protected CMWTextComposite composite = null;
067:            //
068:            protected String currentExceptionMessage = null;
069:
070:            protected CMWContextAwarePage(String pageName) {
071:                super (pageName);
072:
073:                //initContents();	//setting up the paths
074:                //init(getWizard().selection);
075:            }
076:
077:            public CMWContextAwarePage(String string, String title,
078:                    ImageDescriptor titleImage) {
079:                super (string, title, titleImage);
080:                //if (getControl()!=null) getControl().setSize(100, 100);
081:            }
082:
083:            @Override
084:            public CertificateManagerWizard getWizard() {
085:                if (super .getWizard() instanceof  CertificateManagerWizard) {
086:                    return (CertificateManagerWizard) super .getWizard();
087:                }
088:                return null;
089:            }
090:
091:            /**
092:             * Called by the wizard to initialize the receiver's cached selection.
093:             * @param selection the selection or <code>null</code> if none
094:             */
095:            public void init(IStructuredSelection selection) {
096:                //	if CertificateManagerWizard(String projectWorkSpace,String projectName) 
097:                //constructor was used then 		
098:                if (CertificateManagerWizard.projectName != null
099:                        && CertificateManagerWizard.projectWorkSpace != null) {
100:                    initContents();
101:                    return;
102:                }
103:                //else if CertificateManagerWizard(IWorkbench workbench, IStructuredSelection selection)
104:                // constructor was used
105:                if (!(selection instanceof  IStructuredSelection))
106:                    return;
107:                Iterator iter = ((IStructuredSelection) selection).iterator();
108:                while (iter.hasNext()) {
109:                    Object item = (Object) iter.next();
110:                    if (item instanceof  IFolder) {
111:                        IFolder file = (IFolder) item;
112:                        initialSourcePath = file.getLocation();
113:                        break;
114:                    }
115:                    if (item instanceof  IFile) {
116:                        IFile file = (IFile) item;
117:                        initialSourcePath = file.getLocation();
118:                        break;
119:                    }
120:                    if (item instanceof  IProject) {
121:                        IProject file = (IProject) item;
122:                        initialSourcePath = file.getLocation();
123:                        break;
124:                    }
125:                }
126:                initContents();
127:            }
128:
129:            /**
130:             * Called by <code>createControl</code> to initialize the receiver's
131:             * content based upon the cached selection provided by the wizard.
132:             */
133:            private void initContents() {
134:                //	if CertificateManagerWizard(String projectWorkSpace,String projectName) 
135:                //constructor was used then
136:                if (CertificateManagerWizard.projectName != null
137:                        && CertificateManagerWizard.projectWorkSpace != null) {
138:                    curr_pro_name = CertificateManagerWizard.projectName;
139:                    pro_path = CertificateManagerWizard.projectWorkSpace;
140:                } else
141:                //	else if CertificateManagerWizard(IWorkbench workbench, IStructuredSelection selection)
142:                // constructor was used
143:                {
144:                    if (initialSourcePath == null)
145:                        return;
146:                    IPath rootLoc = ResourcesPlugin.getWorkspace().getRoot()
147:                            .getLocation();
148:                    IPath path = initialSourcePath;
149:                    if (rootLoc.isPrefixOf(path))
150:                        path = path.setDevice(null).removeFirstSegments(
151:                                rootLoc.segmentCount());
152:                    if (path.toString().contains(separator)) {
153:                        int index = path.toString().indexOf(separator);
154:                        curr_pro_name = path.toString().substring(0, index);
155:                    } else
156:                        curr_pro_name = path.toString();
157:                    pro_path = rootLoc.toString() + separator + curr_pro_name;
158:                    CertificateManagerWizard.projectName = curr_pro_name;
159:                }//end else 
160:                updatePageComplete();
161:                setMessage(null);
162:                setErrorMessage(null);
163:            }
164:
165:            protected abstract void updatePageComplete();
166:
167:            protected void systemFileBrowse(Text destination) {
168:                if (destination == null)
169:                    return;
170:                FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
171:                if (lastSystemLocation != null) {
172:                    dialog.setFilterPath(lastSystemLocation);
173:                } else {
174:                    dialog.setFilterPath(getPro_path());
175:                }
176:                dialog.setFilterNames(new String[] { "All Files (*.*)",
177:                        "Store Files (*.jks)", "Certificate Files (*.cer)" });
178:                dialog.setFilterExtensions(new String[] { "*.*", "*.jks",
179:                        "*.cer" });
180:                String result = dialog.open();
181:                if (result == null) {
182:                    //destination.setText("");
183:                    result = "";
184:                }
185:                destination.setText(result.replace("\\", "/"));
186:                if (result.lastIndexOf("\\") != -1) {
187:                    lastSystemLocation = result.substring(0, result
188:                            .lastIndexOf("\\"));
189:                } else {
190:                    lastSystemLocation = null;
191:                }
192:            }
193:
194:            protected void systemMultipleFileBrowse(Text destination) {
195:                if (destination == null)
196:                    return;
197:                FileDialog dialog = new FileDialog(getShell(), SWT.MULTI);
198:                if (lastSystemLocation != null) {
199:                    dialog.setFilterPath(lastSystemLocation);
200:                } else {
201:                    dialog.setFilterPath(getPro_path());
202:                }
203:                dialog.setFilterNames(new String[] { "All Files (*.*)" });
204:                dialog.setFilterExtensions(new String[] { "*.*" });
205:
206:                String result = dialog.open();
207:                if (result == null) {
208:                    result = "";
209:                } else {
210:                    //File file = new File(result);
211:                    Path path = new Path(result);
212:                    path = (Path) path.removeFileExtension();
213:                    path = (Path) path.removeLastSegments(1);
214:
215:                    String[] fileNames = dialog.getFileNames();
216:                    String tempResult = " ";
217:                    if (fileNames != null)//just another extra caution
218:                    {
219:                        for (int i = 0; i < fileNames.length; i++) {
220:                            tempResult += path.toString()
221:                                    + "/"
222:                                    + fileNames[i]
223:                                    + AuthenticationUtil.MULTIPLE_FILE_SEPARATOR
224:                                    + "\n ";
225:                        }
226:                    }
227:                    result = tempResult;
228:                }
229:
230:                destination.setText(result.replace("\\", "/"));
231:
232:                if (result.lastIndexOf("\\") != -1) {
233:                    lastSystemLocation = result.substring(0, result
234:                            .lastIndexOf("\\"));
235:                } else {
236:                    lastSystemLocation = null;
237:                }
238:            }
239:
240:            protected void systemFileBrowse(Text destination, String p,
241:                    String fileName) {
242:                if (destination == null)
243:                    return;
244:                FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
245:                if (lastSystemLocation != null) {
246:                    dialog.setFilterPath(lastSystemLocation);
247:                } else {
248:                    dialog.setFilterPath(p);
249:                }
250:                dialog.setFileName(fileName);
251:                dialog.setFilterNames(new String[] { "All Files (*.*)",
252:                        "Store Files (*.jks)", "Certificate Files (*.cer)" });
253:                dialog.setFilterExtensions(new String[] { "*.*", "*.jks",
254:                        "*.cer" });
255:                String result = dialog.open();
256:
257:                if (result == null) {
258:                    //destination.setText("");
259:                    result = "";
260:                }
261:                destination.setText(result.replace("\\", "/"));
262:                if (result.lastIndexOf("\\") != -1) {
263:                    lastSystemLocation = result.substring(0, result
264:                            .lastIndexOf("\\"));
265:                } else {
266:                    lastSystemLocation = null;
267:                }
268:
269:            }
270:
271:            protected void projectKeysBrowse(Text destination) {
272:                BaseFileBrowser browser = new BaseFileBrowser(Activator
273:                        .getDefault(), this .getShell(), destination,
274:                        getCurr_pro_name(), getFilterKeys(), getAuthKeys(),
275:                        I18N.getString(Messages.SELECT_KEY_FILE));
276:                browser.open();
277:            }
278:
279:            protected void projectCersBrowse(Text destination) {
280:                BaseFileBrowser browser = new BaseFileBrowser(Activator
281:                        .getDefault(), this .getShell(), destination,
282:                        getCurr_pro_name(), getFilterCerts(), getAuthCerts(),
283:                        I18N.getString(Messages.SELECT_TRUST_STORE_FILE));
284:                browser.open();
285:            }
286:
287:            //Getters
288:            /**
289:             * @return the authCerts
290:             */
291:            public String getAuthCerts() {
292:                return authCerts;
293:            }
294:
295:            /**
296:             * @return the authKeys
297:             */
298:            public String getAuthKeys() {
299:                return authKeys;
300:            }
301:
302:            /**
303:             * @return the curr_pro_name
304:             */
305:            public String getCurr_pro_name() {
306:                return curr_pro_name;
307:            }
308:
309:            /**
310:             * @return the filterCerts
311:             */
312:            public String getFilterCerts() {
313:                return filterCerts;
314:            }
315:
316:            /**
317:             * @return the filterKeys
318:             */
319:            public String getFilterKeys() {
320:                return filterKeys;
321:            }
322:
323:            /**
324:             * @return the initialSourcePath
325:             */
326:            public IPath getInitialSourcePath() {
327:                return initialSourcePath;
328:            }
329:
330:            /**
331:             * @return the pro_path
332:             */
333:            public String getPro_path() {
334:                return pro_path;
335:            }
336:
337:            /**
338:             * @return the separator
339:             */
340:            public String getSeparator() {
341:                return separator;
342:            }
343:
344:            public void showError(String error) {
345:                setMessage(error, WizardPage.ERROR);
346:            }
347:
348:            public void showWarning(String warning) {
349:                setMessage(warning, WizardPage.WARNING);
350:            }
351:
352:            public void showInfo(String info) {
353:                setMessage(info, WizardPage.INFORMATION);
354:            }
355:
356:            public void showClean() {
357:                setMessage(null);
358:            }
359:
360:            /***
361:             * This method should be called by the wizard if there are 
362:             * different finish operation in this page
363:             */
364:            public boolean performFinish() {
365:                return true;
366:            }
367:
368:            /***
369:             * This method should be called by the wizard if there are 
370:             * different cancel operation in this page
371:             */
372:            public boolean performCancel() {
373:                return true;
374:            }
375:
376:            public boolean canFinish() {
377:                return false;
378:            }
379:
380:            /**
381:             * Owerwrite this method and return true, to create a page finish/cancel operation, 
382:             * other than the wizards's finish/cance 	 
383:             * @return false by default
384:             */
385:            public boolean askPageToFinish() {
386:                return false;
387:            }
388:
389:            /**
390:             * return the Text composite selection if it is a TextComposite page
391:             */
392:            public boolean isYes() {
393:                if (composite == null)
394:                    return true;
395:                return composite.isYes();
396:            }
397:
398:            @Override
399:            public void performHelp() {
400:                if (currentExceptionMessage != null) {
401:                    currentExceptionMessage = currentExceptionMessage
402:                            .replaceAll("keytool error:", "");
403:                    currentExceptionMessage = currentExceptionMessage
404:                            .replaceAll(" java.lang.Exception:", "");
405:                    currentExceptionMessage = currentExceptionMessage
406:                            .replaceAll(" java.io.IOException:", "");
407:                    currentExceptionMessage = currentExceptionMessage
408:                            .replaceAll(" java.io.FileNotFoundException:", "");
409:
410:                    //currentExceptionMessage=currentExceptionMessage.replaceAll(":","");
411:
412:                    showError(I18N
413:                            .getString(Messages.CMW_ADVANCED_MESSAGE_OPERATION_EXCEPTION_CONTENT)
414:                            + " " + currentExceptionMessage);
415:                    //MsgUtil.confirmDialog(I18N.getString(Messages.CMW_ADVANCED_MESSAGE_OPERATION_EXCEPTION_CONTENT)+" "+currentExceptionMessage);
416:                    currentExceptionMessage = null;
417:                } else
418:                    showClean();
419:            }
420:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.