Code example for KeyStore

Methods: getCertificate, getKey

0
    	X509Certificate retVal = null;
    	Certificate cert = null;
    	 
    	try 
    	{ 
    		cert = ks.getCertificate(alias);
			if (cert != null && cert instanceof X509Certificate)
			{ 
				 
				// check if there is private key 
				Key key = ks.getKey(alias, privateKeyPassword == null ? null : privateKeyPassword.toCharArray());
				if (key != null && key instanceof PrivateKey)
					retVal = X509CertificateEx.fromX509Certificate((X509Certificate)cert, (PrivateKey)key);
				else 
					retVal = (X509Certificate)cert;				
			}    		    		 
    	} 
    	catch (Exception e)
    	{ 
    		throw new NHINDException(e);
    	}