question: private boolean installReply ( String alias , InputStream in ) throws Exception { if ( alias == null ) { alias = keyAlias ; } Pair < Key , char [ ] > objs = recoverKey ( alias , storePass , keyPass ) ; PrivateKey privKey = ( PrivateKey ) objs . fst ; if ( keyPass == null ) { keyPass = objs . snd ; } Certificate userCert = keyStore . getCertificate ( alias ) ; if ( userCert == null ) { MessageFormat form = new MessageFormat ( rb . getString ( "alias.has.no.public.key.certificate." ) ) ; Object [ ] source = { alias } ; throw new Exception ( form . format ( source ) ) ; } Collection < ? extends Certificate > c = cf . generateCertificates ( in ) ; if ( c . isEmpty ( ) ) { throw new Exception ( rb . getString ( "Reply.has.no.certificates" ) ) ; } Certificate [ ] replyCerts = c . toArray ( new Certificate [ c . size ( ) ] ) ; Certificate [ ] newChain ; if ( replyCerts . length == 1 ) { newChain = establishCertChain ( userCert , replyCerts [ 0 ] ) ; } else { newChain = validateReply ( alias , userCert , replyCerts ) ; } if ( newChain != null ) { keyStore . setKeyEntry ( alias , privKey , ( keyPass != null ) ? keyPass : storePass , newChain ) ; return true ; } else { return false ; } }
target:  Processes a certificate reply from a certificate authority. <p>Builds a certificate chain on top of the certificate reply, using trusted certificates from the keystore. The chain is complete after a self-signed certificate has been encountered. The self-signed certificate is considered a root certificate authority, and is stored at the end of the chain. <p>The newly generated chain replaces the old chain associated with the key entry.