List of usage examples for org.apache.shiro.crypto CryptoException CryptoException
public CryptoException(String message, Throwable cause)
From source file:org.qi4j.library.shiro.tests.x509.X509FixturesData.java
License:Open Source License
private static KeyStore loadKeyStore(String type, String resource, char[] password) { try {/* w w w . j av a 2 s. c om*/ KeyStore ks = KeyStore.getInstance(type); ks.load(X509FixturesData.class.getResourceAsStream(resource), password); return ks; } catch (GeneralSecurityException ex) { throw new CryptoException("Unable to create client SSLContext", ex); } catch (IOException ex) { throw new CryptoException("Unable to create client SSLContext", ex); } }
From source file:org.qi4j.library.shiro.tests.x509.X509FixturesData.java
License:Open Source License
public static SSLContext createSSLContext(KeyStore ks, char[] password, KeyStore ts) { try {/* w ww.ja v a 2s . co m*/ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, password); TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ts); KeyManager[] keyManagers = kmf.getKeyManagers(); TrustManager[] trustManagers = tmf.getTrustManagers(); SSLContext sslCtx = SSLContext.getInstance("TLS"); sslCtx.init(keyManagers, trustManagers, null); return sslCtx; } catch (GeneralSecurityException ex) { throw new CryptoException("Unable to create client SSLContext", ex); } }
From source file:org.qi4j.library.shiro.tests.x509.X509FixturesData.java
License:Open Source License
private static X509Certificate readPem(String resource) { try {/*from ww w .j av a 2 s. com*/ return (X509Certificate) new PEMReader( new InputStreamReader(X509Fixtures.class.getResourceAsStream(resource))).readObject(); } catch (IOException ex) { throw new CryptoException("Unable to read the test user X509Certificate PEM", ex); } }