KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > transport > tcp > StubSSLSocket


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.activemq.transport.tcp;
20
21 import java.io.IOException JavaDoc;
22
23 import javax.net.ssl.HandshakeCompletedListener;
24 import javax.net.ssl.SSLSession;
25 import javax.net.ssl.SSLSocket;
26
27 public class StubSSLSocket extends SSLSocket {
28     
29     public static final int UNTOUCHED = -1;
30     public static final int FALSE = 0;
31     public static final int TRUE = 1;
32     
33     private int wantClientAuthStatus = UNTOUCHED;
34     private int needClientAuthStatus = UNTOUCHED;
35     private int useClientModeStatus = UNTOUCHED;
36     
37     final StubSSLSession session;
38         
39     public StubSSLSocket(StubSSLSession ses) {
40         this.session = ses;
41     }
42     
43     public void setWantClientAuth(boolean arg0) {
44         this.wantClientAuthStatus = (arg0 ? TRUE : FALSE);
45     }
46     
47     public void setNeedClientAuth(boolean arg0) {
48         this.needClientAuthStatus = (arg0 ? TRUE : FALSE);
49         if ( session != null ) {
50             this.session.setIsVerified(arg0);
51         }
52     }
53     
54     public void setUseClientMode(boolean arg0) {
55         useClientModeStatus = (arg0 ? TRUE : FALSE);
56     }
57     
58     public boolean getWantClientAuth() {
59         return (wantClientAuthStatus == TRUE);
60     }
61
62     public boolean getNeedClientAuth() {
63         return (needClientAuthStatus == TRUE);
64     }
65     
66     public boolean getUseClientMode() {
67         return (useClientModeStatus == TRUE );
68     }
69     
70     public int getWantClientAuthStatus() {
71         return wantClientAuthStatus;
72     }
73     
74     public int getNeedClientAuthStatus() {
75         return needClientAuthStatus;
76     }
77     
78     public int getUseClientModeStatus() {
79         return useClientModeStatus;
80     }
81     
82     public SSLSession getSession() {
83         return this.session;
84     }
85     
86     
87     // --- Stubbed methods ---
88

89     public String JavaDoc[] getSupportedCipherSuites() {
90         return null;
91     }
92
93     public String JavaDoc[] getEnabledCipherSuites() {
94         return null;
95     }
96
97     public void setEnabledCipherSuites(String JavaDoc[] arg0) {
98     }
99
100     public String JavaDoc[] getSupportedProtocols() {
101         return null;
102     }
103
104     public String JavaDoc[] getEnabledProtocols() {
105         return null;
106     }
107
108     public void setEnabledProtocols(String JavaDoc[] arg0) {
109     }
110
111     public void addHandshakeCompletedListener(HandshakeCompletedListener arg0) {
112     }
113
114     public void removeHandshakeCompletedListener(HandshakeCompletedListener arg0) {
115     }
116
117     public void startHandshake() throws IOException JavaDoc {
118     }
119
120     public void setEnableSessionCreation(boolean arg0) {
121     }
122
123     public boolean getEnableSessionCreation() {
124         return false;
125     }
126
127 }
128
Popular Tags