private KeyStore createKeystore ( ParsedKeystoreEntry parsedKeystoreEntry , String keystorePasswordURL , File policyFile ) throws Exception { if ( parsedKeystoreEntry == null ) { return null ; } KeyStore toReturn ; String keystoreURL = expandStringWithProperty ( parsedKeystoreEntry . getKeystoreURL ( ) ) ; String keystoreType = expandStringWithProperty ( parsedKeystoreEntry . getKeystoreType ( ) ) ; String keystoreProvider = expandStringWithProperty ( parsedKeystoreEntry . getKeystoreProvider ( ) ) ; if ( keystoreURL == null ) { throw new Exception ( "ER003: Null keystore url!" ) ; } if ( keystoreType == null ) { keystoreType = KeyStore . getDefaultType ( ) ; } if ( keystoreProvider == null ) { toReturn = KeyStore . getInstance ( keystoreType ) ; } else { toReturn = KeyStore . getInstance ( keystoreType , keystoreProvider ) ; } char [ ] keystorePassword = null ; if ( keystorePasswordURL != null ) { keystorePassword = readKeystorePassword ( expandStringWithProperty ( keystorePasswordURL ) , policyFile ) ; } // try relative path to policy file String path = getPolicyFileHome ( policyFile ) ; File f = null ; if ( path != null ) { f = new File ( path , keystoreURL ) ; } if ( f == null || ! f . exists ( ) ) { // try absoluth path f = new File ( keystoreURL ) ; if ( ! f . exists ( ) ) { throw new Exception ( "ER004: KeyStore doesn't exists!" ) ; } } FileInputStream fis = null ; try { fis = new FileInputStream ( f ) ; toReturn . load ( fis , keystorePassword ) ; } finally { if ( fis != null ) { fis . close ( ) ; } } return toReturn ; }
Private method for creating KeyStore object from ParsedKeystoreEntry and other information from policy file .