1 /* |
1 /* |
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package sun.security.ssl; |
26 package sun.security.ssl; |
27 |
27 |
28 import java.util.*; |
|
29 import java.io.*; |
28 import java.io.*; |
30 import java.security.*; |
29 import java.security.*; |
31 import java.security.cert.*; |
30 import java.security.cert.*; |
|
31 import java.util.*; |
32 import javax.net.ssl.*; |
32 import javax.net.ssl.*; |
33 |
33 import sun.security.validator.TrustStoreUtil; |
34 import sun.security.validator.Validator; |
34 import sun.security.validator.Validator; |
35 import sun.security.validator.TrustStoreUtil; |
|
36 |
35 |
37 abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi { |
36 abstract class TrustManagerFactoryImpl extends TrustManagerFactorySpi { |
38 |
37 |
39 private static final Debug debug = Debug.getInstance("ssl"); |
|
40 private X509TrustManager trustManager = null; |
38 private X509TrustManager trustManager = null; |
41 private boolean isInitialized = false; |
39 private boolean isInitialized = false; |
42 |
40 |
43 TrustManagerFactoryImpl() { |
41 TrustManagerFactoryImpl() { |
44 // empty |
42 // empty |
49 if (ks == null) { |
47 if (ks == null) { |
50 try { |
48 try { |
51 trustManager = getInstance(TrustStoreManager.getTrustedCerts()); |
49 trustManager = getInstance(TrustStoreManager.getTrustedCerts()); |
52 } catch (SecurityException se) { |
50 } catch (SecurityException se) { |
53 // eat security exceptions but report other throwables |
51 // eat security exceptions but report other throwables |
54 if (debug != null && Debug.isOn("trustmanager")) { |
52 if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) { |
55 System.out.println( |
53 SSLLogger.fine( |
56 "SunX509: skip default keystore: " + se); |
54 "SunX509: skip default keystore", se); |
57 } |
55 } |
58 } catch (Error err) { |
56 } catch (Error err) { |
59 if (debug != null && Debug.isOn("trustmanager")) { |
57 if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) { |
60 System.out.println( |
58 SSLLogger.fine( |
61 "SunX509: skip default keystore: " + err); |
59 "SunX509: skip default keystore", err); |
62 } |
60 } |
63 throw err; |
61 throw err; |
64 } catch (RuntimeException re) { |
62 } catch (RuntimeException re) { |
65 if (debug != null && Debug.isOn("trustmanager")) { |
63 if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) { |
66 System.out.println( |
64 SSLLogger.fine( |
67 "SunX509: skip default keystore: " + re); |
65 "SunX509: skip default keystor", re); |
68 } |
66 } |
69 throw re; |
67 throw re; |
70 } catch (Exception e) { |
68 } catch (Exception e) { |
71 if (debug != null && Debug.isOn("trustmanager")) { |
69 if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) { |
72 System.out.println( |
70 SSLLogger.fine( |
73 "SunX509: skip default keystore: " + e); |
71 "SunX509: skip default keystore", e); |
74 } |
72 } |
75 throw new KeyStoreException( |
73 throw new KeyStoreException( |
76 "problem accessing trust store", e); |
74 "problem accessing trust store", e); |
77 } |
75 } |
78 } else { |
76 } else { |