1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/** 19 * @author Vera Y. Petrashkova 20 */ 21 22package javax.net.ssl; 23 24import java.nio.ByteBuffer; 25import java.security.KeyManagementException; 26import java.security.SecureRandom; 27 28/** 29 * Additional class for verification of SSLContextSpi and SSLContext 30 * functionality 31 */ 32 33public class MySSLContextSpi extends SSLContextSpi { 34 private boolean init = false; 35 36 @Override 37 protected void engineInit(KeyManager[] km, TrustManager[] tm, 38 SecureRandom sr) throws KeyManagementException { 39 if (sr == null) { 40 throw new KeyManagementException( 41 "secureRandom is null"); 42 } 43 init = true; 44 } 45 46 @Override 47 protected SSLSocketFactory engineGetSocketFactory() { 48 if (!init) { 49 throw new RuntimeException("Not initialiazed"); 50 } 51 return null; 52 } 53 54 @Override 55 protected SSLServerSocketFactory engineGetServerSocketFactory() { 56 if (!init) { 57 throw new RuntimeException("Not initialiazed"); 58 } 59 return null; 60 } 61 62 @Override 63 protected SSLSessionContext engineGetServerSessionContext() { 64 if (!init) { 65 throw new RuntimeException("Not initialiazed"); 66 } 67 return null; 68 } 69 70 @Override 71 protected SSLSessionContext engineGetClientSessionContext() { 72 if (!init) { 73 throw new RuntimeException("Not initialiazed"); 74 } 75 return null; 76 } 77 78 /* 79 * FIXME: add these methods 80 */ 81 @Override 82 protected SSLEngine engineCreateSSLEngine(String host, int port) { 83 if (!init) { 84 throw new RuntimeException("Not initialiazed"); 85 } 86 return new tmpSSLEngine(host, port); 87 } 88 89 @Override 90 protected SSLEngine engineCreateSSLEngine() { 91 if (!init) { 92 throw new RuntimeException("Not initialiazed"); 93 } 94 return new tmpSSLEngine(); 95 } 96 97 public class tmpSSLEngine extends SSLEngine { 98 String tmpHost; 99 int tmpPort; 100 101 public tmpSSLEngine() { 102 tmpHost = null; 103 tmpPort = 0; 104 } 105 106 public tmpSSLEngine(String host, int port) { 107 tmpHost = host; 108 tmpPort = port; 109 } 110 111 @Override 112 public String getPeerHost() { 113 return tmpHost; 114 } 115 116 @Override 117 public int getPeerPort() { 118 return tmpPort; 119 } 120 121 @Override 122 public void beginHandshake() throws SSLException { 123 } 124 125 @Override 126 public void closeInbound() throws SSLException { 127 } 128 129 @Override 130 public void closeOutbound() { 131 } 132 133 @Override 134 public Runnable getDelegatedTask() { 135 return null; 136 } 137 138 @Override 139 public String[] getEnabledCipherSuites() { 140 return null; 141 } 142 143 @Override 144 public String[] getEnabledProtocols() { 145 return null; 146 } 147 148 @Override 149 public boolean getEnableSessionCreation() { 150 return true; 151 } 152 153 @Override 154 public SSLEngineResult.HandshakeStatus getHandshakeStatus() { 155 return null; 156 } 157 158 @Override 159 public boolean getNeedClientAuth() { 160 return true; 161 } 162 163 @Override 164 public SSLSession getSession() { 165 return null; 166 } 167 168 @Override 169 public String[] getSupportedCipherSuites() { 170 return null; 171 } 172 173 @Override 174 public String[] getSupportedProtocols() { 175 return null; 176 } 177 178 @Override 179 public boolean getUseClientMode() { 180 return true; 181 } 182 183 @Override 184 public boolean getWantClientAuth() { 185 return true; 186 } 187 188 @Override 189 public boolean isInboundDone() { 190 return true; 191 } 192 193 @Override 194 public boolean isOutboundDone() { 195 return true; 196 } 197 198 @Override 199 public void setEnabledCipherSuites(String[] suites) { 200 } 201 202 @Override 203 public void setEnabledProtocols(String[] protocols) { 204 } 205 206 @Override 207 public void setEnableSessionCreation(boolean flag) { 208 } 209 210 @Override 211 public void setNeedClientAuth(boolean need) { 212 } 213 214 @Override 215 public void setUseClientMode(boolean mode) { 216 } 217 218 @Override 219 public void setWantClientAuth(boolean want) { 220 } 221 222 @Override 223 public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, 224 int offset, int length) throws SSLException { 225 return null; 226 } 227 228 @Override 229 public SSLEngineResult wrap(ByteBuffer[] srcs, int offset, 230 int length, ByteBuffer dst) throws SSLException { 231 return null; 232 } 233 234 @Override 235 public SSLParameters getSSLParameters() { 236 // TODO Auto-generated method stub 237 return null; 238 } 239 240 @Override 241 public void setSSLParameters(SSLParameters sslP) { 242 // TODO Auto-generated method stub 243 244 } 245 } 246}