package uk.ac.sdss.extractcert;

import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;

/**
 * This class gives access to a set of test client credentials for
 * the UK federation, in the form of a Java KeyStore.
 *
 * @author iay
 */
abstract class TestCredentialKeyStore {

	public static KeyStore getInstance() throws CryptoException {
		try {
			KeyStore ks = KeyStore.getInstance("PKCS12");
			char[] pass = new char[]{'p', 'a', 's', 's'};
			InputStream is = TestCredentialKeyStore.class.getResourceAsStream("ssl_test.p12");
			ks.load(is, pass);
			return ks;
		} catch (IOException e) {
			throw new CryptoException("can't access PKCS#12 credentials", e);
		} catch (KeyStoreException e) {
			throw new CryptoException(e);
		} catch (NoSuchAlgorithmException e) {
			throw new CryptoException(e);
		} catch (CertificateException e) {
			throw new CryptoException(e);
		}
	}
	
}

@@ -692,16 +692,106 @@
 .p12%22);%0A
+%09%09%09if (is == null)%0A%09%09%09%09throw new CryptoException(%22could not access credential resource%22);%0A
 %09%09%09ks.lo

Throw an exception if we can't get hold of the PKCS#12 keystore holding the test credential.