1 11 package org.eclipse.osgi.internal.verifier; 12 13 import java.security.cert.Certificate ; 14 import java.security.cert.CertificateException ; 15 import org.eclipse.osgi.internal.provisional.verifier.CertificateTrustAuthority; 16 import org.eclipse.osgi.util.NLS; 17 18 public class DefaultTrustAuthority implements CertificateTrustAuthority { 19 private KeyStores keyStores; 22 private int supportFlags; 24 public DefaultTrustAuthority(int supportFlags) { 25 this.supportFlags = supportFlags; 26 } 27 public void checkTrust(Certificate [] certChain) throws CertificateException { 28 if (certChain == null || certChain.length == 0) { 29 throw new IllegalArgumentException (JarVerifierMessages.Cert_Verifier_Illegal_Args); 30 } 31 KeyStores stores = getKeyStores(); 32 if (stores != null && !stores.isTrusted(certChain[certChain.length - 1])) { 34 throw new CertificateException (NLS.bind(JarVerifierMessages.Cert_Verifier_Not_Trusted, new String [] {certChain[0].toString()})); 35 } 36 } 37 38 private synchronized KeyStores getKeyStores() { 39 if (((supportFlags & SignedBundleHook.VERIFY_TRUST) == 0) || keyStores != null) 40 return keyStores; 41 keyStores = new KeyStores(); 42 return keyStores; 43 } 44 public void addTrusted(Certificate [] certs) throws CertificateException { 45 } 47 48 } 49 | Popular Tags |