/** * If the state supports this, it will save the current cert to a file. The complete filename must be supplied, * including any path. * * @param inputLine * @throws Exception */ public void savecert(InputLine inputLine) throws Exception { if (showHelp(inputLine)) { saveCertHelp(); return; } if (assetResponse == null) { say("Sorry, but there is no cert to save. Please do a successful getcert call first."); return; } String cert = CertUtil.toPEM(assetResponse.getX509Certificates()); if (!inputLine.hasArgs()) { say("Sorry. You did not specify a file so the cert cannot be saved."); return; } String fileName = inputLine.getArg(1); FileWriter fileWriter = new FileWriter(fileName); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); bufferedWriter.write(cert + "\n"); bufferedWriter.flush(); bufferedWriter.close(); say("File \"" + fileName + "\" saved successfully."); }