Source Code Cross Referenced for SlowSSLSocket.java in  » Testing » jakarta-jmeter » org » apache » jmeter » util » 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.util 
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.util;
020:
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:        import java.io.OutputStream;
024:        import java.net.InetAddress;
025:        import java.net.SocketAddress;
026:        import java.net.SocketException;
027:        import java.nio.channels.SocketChannel;
028:
029:        import javax.net.ssl.HandshakeCompletedListener;
030:        import javax.net.ssl.SSLSession;
031:        import javax.net.ssl.SSLSocket;
032:
033:        /**
034:         * "Slow" SSLsocket implementation to emulate dial-up modems etc
035:         * 
036:         * WARNING: the class relies on overriding all superclass methods in order to apply them to the input socket.
037:         * Any missing methods will access the superclass socket, which will probably be in the wrong state.
038:         * 
039:         */
040:        public class SlowSSLSocket extends SSLSocket {
041:
042:            private final int CPS; // Characters per second to emulate
043:
044:            private final SSLSocket sslSock; // Save the actual socket
045:
046:            // Ensure we can't be called without suitable parameters
047:            private SlowSSLSocket() {
048:                CPS = 0;
049:                throw new IllegalArgumentException("No such constructor");
050:            }
051:
052:            /**
053:             * Wrap an SSLSocket with slow input and output streams
054:             * @param sock SSLSocket to be wrapped
055:             * @param cps characters per second to emulate
056:             */
057:            public SlowSSLSocket(final SSLSocket sock, final int cps) {
058:                if (cps <= 0) {
059:                    throw new IllegalArgumentException("Speed (cps) <= 0");
060:                }
061:                sslSock = sock;
062:                CPS = cps;
063:            }
064:
065:            // Override so we can intercept the stream
066:            public OutputStream getOutputStream() throws IOException {
067:                return new SlowOutputStream(sslSock.getOutputStream(), CPS);
068:            }
069:
070:            // Override so we can intercept the stream
071:            public InputStream getInputStream() throws IOException {
072:                return new SlowInputStream(sslSock.getInputStream(), CPS);
073:            }
074:
075:            // Forward all the SSLSocket methods to the input socket
076:
077:            public void addHandshakeCompletedListener(
078:                    HandshakeCompletedListener arg0) {
079:                sslSock.addHandshakeCompletedListener(arg0);
080:            }
081:
082:            public boolean getEnableSessionCreation() {
083:                return sslSock.getEnableSessionCreation();
084:            }
085:
086:            public String[] getEnabledCipherSuites() {
087:                return sslSock.getEnabledCipherSuites();
088:            }
089:
090:            public String[] getEnabledProtocols() {
091:                return sslSock.getEnabledProtocols();
092:            }
093:
094:            public boolean getNeedClientAuth() {
095:                return sslSock.getNeedClientAuth();
096:            }
097:
098:            public SSLSession getSession() {
099:                return sslSock.getSession();
100:            }
101:
102:            public String[] getSupportedCipherSuites() {
103:                return sslSock.getSupportedCipherSuites();
104:            }
105:
106:            public String[] getSupportedProtocols() {
107:                return sslSock.getSupportedProtocols();
108:            }
109:
110:            public boolean getUseClientMode() {
111:                return sslSock.getUseClientMode();
112:            }
113:
114:            public boolean getWantClientAuth() {
115:                return sslSock.getWantClientAuth();
116:            }
117:
118:            public void removeHandshakeCompletedListener(
119:                    HandshakeCompletedListener arg0) {
120:                sslSock.removeHandshakeCompletedListener(arg0);
121:            }
122:
123:            public void setEnableSessionCreation(boolean arg0) {
124:                sslSock.setEnableSessionCreation(arg0);
125:            }
126:
127:            public void setEnabledCipherSuites(String[] arg0) {
128:                sslSock.setEnabledCipherSuites(arg0);
129:            }
130:
131:            public void setEnabledProtocols(String[] arg0) {
132:                sslSock.setEnabledProtocols(arg0);
133:            }
134:
135:            public void setNeedClientAuth(boolean arg0) {
136:                sslSock.setNeedClientAuth(arg0);
137:            }
138:
139:            public void setUseClientMode(boolean arg0) {
140:                sslSock.setUseClientMode(arg0);
141:            }
142:
143:            public void setWantClientAuth(boolean arg0) {
144:                sslSock.setWantClientAuth(arg0);
145:            }
146:
147:            public void startHandshake() throws IOException {
148:                sslSock.startHandshake();
149:            }
150:
151:            // Also forward all the Socket methods.
152:
153:            public void bind(SocketAddress bindpoint) throws IOException {
154:                sslSock.bind(bindpoint);
155:            }
156:
157:            public synchronized void close() throws IOException {
158:                sslSock.close();
159:            }
160:
161:            public void connect(SocketAddress endpoint, int timeout)
162:                    throws IOException {
163:                sslSock.connect(endpoint, timeout);
164:            }
165:
166:            public void connect(SocketAddress endpoint) throws IOException {
167:                sslSock.connect(endpoint);
168:            }
169:
170:            public SocketChannel getChannel() {
171:                return sslSock.getChannel();
172:            }
173:
174:            public InetAddress getInetAddress() {
175:                return sslSock.getInetAddress();
176:            }
177:
178:            public boolean getKeepAlive() throws SocketException {
179:                return sslSock.getKeepAlive();
180:            }
181:
182:            public InetAddress getLocalAddress() {
183:                return sslSock.getLocalAddress();
184:            }
185:
186:            public int getLocalPort() {
187:                return sslSock.getLocalPort();
188:            }
189:
190:            public SocketAddress getLocalSocketAddress() {
191:                return sslSock.getLocalSocketAddress();
192:            }
193:
194:            public boolean getOOBInline() throws SocketException {
195:                return sslSock.getOOBInline();
196:            }
197:
198:            public int getPort() {
199:                return sslSock.getPort();
200:            }
201:
202:            public synchronized int getReceiveBufferSize()
203:                    throws SocketException {
204:                return sslSock.getReceiveBufferSize();
205:            }
206:
207:            public SocketAddress getRemoteSocketAddress() {
208:                return sslSock.getRemoteSocketAddress();
209:            }
210:
211:            public boolean getReuseAddress() throws SocketException {
212:                return sslSock.getReuseAddress();
213:            }
214:
215:            public synchronized int getSendBufferSize() throws SocketException {
216:                return sslSock.getSendBufferSize();
217:            }
218:
219:            public int getSoLinger() throws SocketException {
220:                return sslSock.getSoLinger();
221:            }
222:
223:            public synchronized int getSoTimeout() throws SocketException {
224:                return sslSock.getSoTimeout();
225:            }
226:
227:            public boolean getTcpNoDelay() throws SocketException {
228:                return sslSock.getTcpNoDelay();
229:            }
230:
231:            public int getTrafficClass() throws SocketException {
232:                return sslSock.getTrafficClass();
233:            }
234:
235:            public boolean isBound() {
236:                return sslSock.isBound();
237:            }
238:
239:            public boolean isClosed() {
240:                return sslSock.isClosed();
241:            }
242:
243:            public boolean isConnected() {
244:                return sslSock.isConnected();
245:            }
246:
247:            public boolean isInputShutdown() {
248:                return sslSock.isInputShutdown();
249:            }
250:
251:            public boolean isOutputShutdown() {
252:                return sslSock.isOutputShutdown();
253:            }
254:
255:            public void sendUrgentData(int data) throws IOException {
256:                sslSock.sendUrgentData(data);
257:            }
258:
259:            public void setKeepAlive(boolean on) throws SocketException {
260:                sslSock.setKeepAlive(on);
261:            }
262:
263:            public void setOOBInline(boolean on) throws SocketException {
264:                sslSock.setOOBInline(on);
265:            }
266:
267:            public synchronized void setReceiveBufferSize(int size)
268:                    throws SocketException {
269:                sslSock.setReceiveBufferSize(size);
270:            }
271:
272:            public void setReuseAddress(boolean on) throws SocketException {
273:                sslSock.setReuseAddress(on);
274:            }
275:
276:            public synchronized void setSendBufferSize(int size)
277:                    throws SocketException {
278:                sslSock.setSendBufferSize(size);
279:            }
280:
281:            public void setSoLinger(boolean on, int linger)
282:                    throws SocketException {
283:                sslSock.setSoLinger(on, linger);
284:            }
285:
286:            public synchronized void setSoTimeout(int timeout)
287:                    throws SocketException {
288:                sslSock.setSoTimeout(timeout);
289:            }
290:
291:            public void setTcpNoDelay(boolean on) throws SocketException {
292:                sslSock.setTcpNoDelay(on);
293:            }
294:
295:            public void setTrafficClass(int tc) throws SocketException {
296:                sslSock.setTrafficClass(tc);
297:            }
298:
299:            public void shutdownInput() throws IOException {
300:                sslSock.shutdownInput();
301:            }
302:
303:            public void shutdownOutput() throws IOException {
304:                sslSock.shutdownOutput();
305:            }
306:
307:            public String toString() {
308:                return sslSock.toString();
309:            }
310:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.