class CredentialManagerImpl implements CredentialManager,
		Observable<KeystoreChangedEvent> {

	@Override
	public String addTrustedCertificate(X509Certificate cert)
			throws CMException {
		// Need to make sure we are initialized before we do anything else
		// as Credential Manager can be created but not initialized
		initialize();

		String alias = null;

		synchronized (truststore) {
			// Create an alias for the new trusted certificate entry in the
			// Truststore as
			// "trustedcert#"<CERT_SUBJECT_COMMON_NAME>"#"<CERT_ISSUER_COMMON_NAME>"#"<CERT_SERIAL_NUMBER>
			alias = createTrustedCertificateAlias(cert);
			try {
				truststore.setCertificateEntry(alias, cert);
				saveKeystore(TRUSTSTORE);
				multiCaster.notify(new KeystoreChangedEvent(TRUSTSTORE));

				/*
				 * This is now done from the KeystoresChangedObserver's notify
				 * method. Update the default SSLSocketFactory used by the
				 * HttpsURLConnectionS
				 */
				// HttpsURLConnection.setDefaultSSLSocketFactory(createTavernaSSLSocketFactory());

				logger.debug("Updating SSLSocketFactory after inserting a trusted certificate");
			} catch (Exception ex) {
				throw new CMException(
						"failed to insert trusted certificate entry in the Truststore",
						ex);
			}
		}

		return alias;
	}

	public  CredentialManagerImpl();

}