01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: * @version $Revision$
21: */package javax.net.ssl;
22:
23: import java.security.InvalidAlgorithmParameterException;
24: import java.security.KeyStore;
25: import java.security.KeyStoreException;
26:
27: /**
28: * Class for vertifying TrustManagerFactorySpi and TrustManagerFactory
29: * functionality
30: *
31: */
32:
33: public class MyTrustManagerFactorySpi extends TrustManagerFactorySpi {
34: protected void engineInit(KeyStore ks) throws KeyStoreException {
35: if (ks == null) {
36: throw new KeyStoreException(
37: "Not supported operation for null KeyStore");
38: }
39: }
40:
41: protected void engineInit(ManagerFactoryParameters spec)
42: throws InvalidAlgorithmParameterException {
43: if (spec == null) {
44: throw new InvalidAlgorithmParameterException(
45: "Null parameter");
46: }
47: if (spec instanceof Parameters) {
48: try {
49: engineInit(((Parameters) spec).getKeyStore());
50: } catch (KeyStoreException e) {
51: throw new RuntimeException(e);
52: }
53: } else {
54: throw new InvalidAlgorithmParameterException(
55: "Invalid parameter");
56: }
57: }
58:
59: protected TrustManager[] engineGetTrustManagers() {
60: return null;
61: }
62:
63: public static class Parameters implements ManagerFactoryParameters {
64: private KeyStore keyStore;
65:
66: public Parameters(KeyStore ks) {
67: this .keyStore = ks;
68: }
69:
70: public KeyStore getKeyStore() {
71: return keyStore;
72: }
73: }
74: }
|