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: * @author Vera Y. Petrashkova
020: * @version $Revision$
021: */package javax.net.ssl;
022:
023: import java.nio.ByteBuffer;
024: import java.security.KeyManagementException;
025: import java.security.SecureRandom;
026:
027: /**
028: * Additional class for verification of SSLContextSpi and SSLContext
029: * functionality
030: *
031: */
032:
033: public class MySSLContextSpi extends SSLContextSpi {
034: private boolean init = false;
035:
036: protected void engineInit(KeyManager[] km, TrustManager[] tm,
037: SecureRandom sr) throws KeyManagementException {
038: if (sr == null) {
039: throw new KeyManagementException("secureRandom is null");
040: }
041: init = true;
042: }
043:
044: protected SSLSocketFactory engineGetSocketFactory() {
045: if (!init) {
046: throw new RuntimeException("Not initialiazed");
047: }
048: return null;
049: }
050:
051: protected SSLServerSocketFactory engineGetServerSocketFactory() {
052: if (!init) {
053: throw new RuntimeException("Not initialiazed");
054: }
055: return null;
056: }
057:
058: protected SSLSessionContext engineGetServerSessionContext() {
059: if (!init) {
060: throw new RuntimeException("Not initialiazed");
061: }
062: return null;
063: }
064:
065: protected SSLSessionContext engineGetClientSessionContext() {
066: if (!init) {
067: throw new RuntimeException("Not initialiazed");
068: }
069: return null;
070: }
071:
072: /*
073: * FIXME: add these methods
074: */
075: protected SSLEngine engineCreateSSLEngine(String host, int port) {
076: if (!init) {
077: throw new RuntimeException("Not initialiazed");
078: }
079: return new tmpSSLEngine(host, port);
080: }
081:
082: protected SSLEngine engineCreateSSLEngine() {
083: if (!init) {
084: throw new RuntimeException("Not initialiazed");
085: }
086: return new tmpSSLEngine();
087: }
088:
089: public class tmpSSLEngine extends SSLEngine {
090: String tmpHost;
091: int tmpPort;
092:
093: public tmpSSLEngine() {
094: tmpHost = null;
095: tmpPort = 0;
096: }
097:
098: public tmpSSLEngine(String host, int port) {
099: tmpHost = host;
100: tmpPort = port;
101: }
102:
103: public String getPeerHost() {
104: return tmpHost;
105: }
106:
107: public int getPeerPort() {
108: return tmpPort;
109: }
110:
111: public void beginHandshake() throws SSLException {
112: }
113:
114: public void closeInbound() throws SSLException {
115: }
116:
117: public void closeOutbound() {
118: }
119:
120: public Runnable getDelegatedTask() {
121: return null;
122: }
123:
124: public String[] getEnabledCipherSuites() {
125: return null;
126: }
127:
128: public String[] getEnabledProtocols() {
129: return null;
130: }
131:
132: public boolean getEnableSessionCreation() {
133: return true;
134: }
135:
136: public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
137: return null;
138: }
139:
140: public boolean getNeedClientAuth() {
141: return true;
142: }
143:
144: public SSLSession getSession() {
145: return null;
146: }
147:
148: public String[] getSupportedCipherSuites() {
149: return null;
150: }
151:
152: public String[] getSupportedProtocols() {
153: return null;
154: }
155:
156: public boolean getUseClientMode() {
157: return true;
158: }
159:
160: public boolean getWantClientAuth() {
161: return true;
162: }
163:
164: public boolean isInboundDone() {
165: return true;
166: }
167:
168: public boolean isOutboundDone() {
169: return true;
170: }
171:
172: public void setEnabledCipherSuites(String[] suites) {
173: }
174:
175: public void setEnabledProtocols(String[] protocols) {
176: }
177:
178: public void setEnableSessionCreation(boolean flag) {
179: }
180:
181: public void setNeedClientAuth(boolean need) {
182: }
183:
184: public void setUseClientMode(boolean mode) {
185: }
186:
187: public void setWantClientAuth(boolean want) {
188: }
189:
190: public SSLEngineResult unwrap(ByteBuffer src,
191: ByteBuffer[] dsts, int offset, int length)
192: throws SSLException {
193: return null;
194: }
195:
196: public SSLEngineResult wrap(ByteBuffer[] srcs, int offset,
197: int length, ByteBuffer dst) throws SSLException {
198: return null;
199: }
200: }
201: }
|