public PublicKey get ( KeyStoreChooser keyStoreChooser , PublicKeyChooserByAlias publicKeyChooserByAlias ) { CacheKey cacheKey = new CacheKey ( keyStoreChooser . getKeyStoreName ( ) , publicKeyChooserByAlias . getAlias ( ) ) ; PublicKey retrievedPublicKey = cache . get ( cacheKey ) ; if ( retrievedPublicKey != null ) { return retrievedPublicKey ; } KeyStore keyStore = keyStoreRegistry . get ( keyStoreChooser ) ; if ( keyStore != null ) { PublicKeyFactoryBean factory = new PublicKeyFactoryBean ( ) ; factory . setKeystore ( keyStore ) ; factory . setAlias ( publicKeyChooserByAlias . getAlias ( ) ) ; try { factory . afterPropertiesSet ( ) ; PublicKey publicKey = ( PublicKey ) factory . getObject ( ) ; if ( publicKey != null ) { cache . put ( cacheKey , publicKey ) ; } return publicKey ; } catch ( Exception e ) { throw new PublicKeyException ( "error initializing the public key factory bean" , e ) ; } } return null ; }
Returns the selected public key or null if not found .