Source Code Cross Referenced for SSLManagerCommand.java in  » Testing » jakarta-jmeter » org » apache » jmeter » gui » action » 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 » Testing » jakarta jmeter » org.apache.jmeter.gui.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         * 
017:         */
018:
019:        package org.apache.jmeter.gui.action;
020:
021:        import java.awt.event.ActionEvent;
022:        import java.io.File;
023:        import java.io.IOException;
024:        import java.util.Collections;
025:        import java.util.HashSet;
026:        import java.util.Set;
027:
028:        import javax.swing.JFileChooser;
029:        import javax.swing.filechooser.FileFilter;
030:
031:        import org.apache.jmeter.gui.GuiPackage;
032:        import org.apache.jmeter.util.JMeterUtils;
033:        import org.apache.jmeter.util.SSLManager;
034:
035:        // 
036:        /**
037:         * SSL Manager Command. The SSL Manager provides a mechanism to change your
038:         * client authentication if required by the server. If you have JSSE 1.0.2
039:         * installed, you can select your client identity from a list of installed keys.
040:         * You can also change your keystore. JSSE 1.0.2 allows you to export a PKCS#12
041:         * key from Netscape 4.04 or higher and use it in a read only format. You must
042:         * supply a password that is greater than six characters due to limitations in
043:         * the keytool program--and possibly the rest of the system.
044:         * <p>
045:         * By selecting a *.p12 file as your keystore (your PKCS#12) format file, you
046:         * can have a whopping one key keystore. The advantage is that you can test a
047:         * connection using the assigned Certificate from a Certificate Authority.
048:         * </p>
049:         * TODO ? 
050:         * N.B. The present implementation does not seem to allow selection of keys,
051:         * it only allows a change of keystore at run-time, or to provide one if not
052:         * already defined via the property.
053:         * 
054:         * @author <a href="bloritsch@apache.org">Berin Loritsch</a>
055:         */
056:        public class SSLManagerCommand implements  Command {
057:            private static Set commandSet;
058:            static {
059:                HashSet commands = new HashSet();
060:                commands.add(ActionNames.SSL_MANAGER);
061:                SSLManagerCommand.commandSet = Collections
062:                        .unmodifiableSet(commands);
063:            }
064:
065:            private JFileChooser keyStoreChooser;
066:
067:            /**
068:             * Handle the "sslmanager" action by displaying the "SSL CLient Manager"
069:             * dialog box. The Dialog Box is NOT modal, because those should be avoided
070:             * if at all possible.
071:             */
072:            public void doAction(ActionEvent e) {
073:                if (e.getActionCommand().equals(ActionNames.SSL_MANAGER)) {
074:                    this .sslManager();
075:                }
076:            }
077:
078:            /**
079:             * Provide the list of Action names that are available in this command.
080:             */
081:            public Set getActionNames() {
082:                return SSLManagerCommand.commandSet;
083:            }
084:
085:            /**
086:             * Called by sslManager button. Raises sslManager dialog.
087:             * I.e. a FileChooser for PCSI12 (.p12|.P12) files.
088:             */
089:            private void sslManager() {
090:                SSLManager.reset();
091:
092:                keyStoreChooser = new JFileChooser(JMeterUtils
093:                        .getJMeterProperties().getProperty("user.dir")); //$NON-NLS-1$
094:                keyStoreChooser
095:                        .addChoosableFileFilter(new AcceptPKCS12FileFilter());
096:                keyStoreChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
097:                int retVal = keyStoreChooser.showOpenDialog(GuiPackage
098:                        .getInstance().getMainFrame());
099:
100:                if (JFileChooser.APPROVE_OPTION == retVal) {
101:                    File selectedFile = keyStoreChooser.getSelectedFile();
102:                    try {
103:                        System.setProperty(SSLManager.JAVAX_NET_SSL_KEY_STORE,
104:                                selectedFile.getCanonicalPath());
105:                    } catch (IOException e) {
106:                        //Ignored
107:                    }
108:                }
109:
110:                keyStoreChooser = null;
111:                SSLManager.getInstance();
112:            }
113:
114:            /**
115:             * Internal class to add a PKCS12 file format filter for JFileChooser.
116:             */
117:            static private class AcceptPKCS12FileFilter extends FileFilter {
118:                /**
119:                 * Get the description that shows up in JFileChooser filter menu.
120:                 * 
121:                 * @return description
122:                 */
123:                public String getDescription() {
124:                    return JMeterUtils.getResString("pkcs12_desc"); //$NON-NLS-1$
125:                }
126:
127:                /**
128:                 * Tests to see if the file ends with "*.p12" or "*.P12".
129:                 * 
130:                 * @param testFile
131:                 *            file to test
132:                 * @return true if file is accepted, false otherwise
133:                 */
134:                public boolean accept(File testFile) {
135:                    return testFile.isDirectory()
136:                            || testFile.getName().endsWith(".p12") //$NON-NLS-1$
137:                            || testFile.getName().endsWith(".P12"); //$NON-NLS-1$
138:                }
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.